aboutsummaryrefslogtreecommitdiff
path: root/fpga/src/TopSim.bs
diff options
context:
space:
mode:
Diffstat (limited to 'fpga/src/TopSim.bs')
-rw-r--r--fpga/src/TopSim.bs29
1 files changed, 26 insertions, 3 deletions
diff --git a/fpga/src/TopSim.bs b/fpga/src/TopSim.bs
index bf5d59c..add8b54 100644
--- a/fpga/src/TopSim.bs
+++ b/fpga/src/TopSim.bs
@@ -3,20 +3,43 @@ package TopSim where
import Numini
+import GetPut
+import I2C
+
mkTopSim :: Module Empty
mkTopSim = module
+ {-
ch559_uart_rx <- mkWire
inkplate_uart_rx <- mkWire
usb_uart_rx <- mkWire
hyperbus_rwds_in <- mkWire
hyperbus_dq_in <- mkWire
+ i2c_scl_in <- mkWire
i2c_sda_in <- mkWire
numini <- mkNumini ch559_uart_rx inkplate_uart_rx usb_uart_rx
- hyperbus_rwds_in hyperbus_dq_in i2c_sda_in
+ hyperbus_rwds_in hyperbus_dq_in i2c_scl_in i2c_sda_in
+ -}
+
+ i2c_scl <- mkReg 0
+ i2c_sda <- mkReg 0
+ -- i2c <- mkDividedI2C (12_000_000 / 200_000) 1 1
+ i2c <- mkDividedI2C 2 1 1
+ rules
+ when True ==> i2c_scl := i2c.txSCL
+ when True ==> i2c_sda := i2c.txSDA
- timer :: Reg (Bit 8) <- mkReg 0
+ timer :: Reg (Bit 16) <- mkReg 0
rules
+ when (timer == 0) ==> i2c.send.put (Write 0x20 0x00)
+ when (timer == 1) ==> i2c.send.put (Write 0x20 0x00)
+ when (timer == 2) ==> i2c.send.put (Write 0x20 0x00)
+ when (timer == 3) ==> i2c.send.put (Write 0x20 0x12)
+ when (timer == 4) ==> i2c.send.put (Write 0x20 0xaa)
+ when (timer == 5) ==> i2c.send.put (Write 0x20 0x55)
when True ==> timer := timer + 1
- when (timer == 0xff) ==> $finish
+ when (timer == 0x1fff) ==> $finish
+ when True ==> do
+ result <- i2c.recv.get
+ $display "recv: " (fshow result)
-- vim: set ft=haskell :