aboutsummaryrefslogtreecommitdiff
path: root/src/TopSim.bs
blob: a4f19675920c94de68936599d37a87e2e095b606 (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
package TopSim where

import GetPut
import Top
import Uart

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

    uart <- mkUart 1

    rules
      when True ==> timer := timer + 1
      when True ==> uart.rxPin uart.txPin
      when True ==> do
        b <- uart.recv.get
        next := timer + 5
        saved := b
      when (timer == next) ==> do
        uart.send.put saved
      when (timer == 0x40) ==> $finish

-- vim: set ft=haskell :