aboutsummaryrefslogtreecommitdiff
path: root/src/TopSim.bs
blob: d0d17cbb82646c2d82de493529cbf52d351d59bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package TopSim where

import App
import GetPut
import Uart

mkTopSim :: Module Empty
mkTopSim =
  module
    timer :: Reg (Bit 8) <- mkReg 0

    uart <- mkUart 1
    app <- mkApp uart.recv uart.send

    fakeUart <- mkUart 1

    rules
      when True ==> timer := timer + 1
      when True ==> uart.rxPin fakeUart.txPin
      when (timer == 0x00) ==> fakeUart.send.put 0x30
      when (timer == 0x01) ==> fakeUart.send.put 0x30
      when (timer == 0x02) ==> fakeUart.send.put 0x77
      when (timer == 0x03) ==> fakeUart.send.put 0x31
      when (timer == 0x04) ==> fakeUart.send.put 0x32
      when (timer == 0x05) ==> fakeUart.send.put 0x33
      when (timer == 0x06) ==> fakeUart.send.put 0x34
      when (timer == 0x10) ==> fakeUart.send.put 0x30
      when (timer == 0x11) ==> fakeUart.send.put 0x30
      when (timer == 0x12) ==> fakeUart.send.put 0x72
      when (timer == 0xff) ==> $finish

-- vim: set ft=haskell :