aboutsummaryrefslogtreecommitdiff
path: root/src/Uart.bs
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-05-06 14:48:56 -0500
committerNathan Ringo <nathan@remexre.com>2024-05-06 14:48:56 -0500
commit03d5906c48812d6c03ab0483c502e5464eaa583b (patch)
treeb34979e72c5371d344aa172be7ac5ba36e47380d /src/Uart.bs
parent60a6650618f700f720b9c424517f2be79c731771 (diff)
tweak debug, why is it always enqueueing a zero...
Diffstat (limited to 'src/Uart.bs')
-rw-r--r--src/Uart.bs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Uart.bs b/src/Uart.bs
index 2cfe14a..adf77d4 100644
--- a/src/Uart.bs
+++ b/src/Uart.bs
@@ -99,7 +99,7 @@ interface RxUart =
mkRxUart :: Clock -> Integer -> Module RxUart
mkRxUart baudClock bufferSize =
module
- fifo :: FIFOF (Bit 8) <- mkSizedFIFOF bufferSize
+ fifo :: FIFOF (Bit 8) <- mkGSizedFIFOF True False bufferSize
state :: Reg RxState <- mkReg Idle
pin :: Wire (Bit 1) <- mkWire
debugBit :: Reg (Bit 1) <- mkReg 1
@@ -108,18 +108,19 @@ mkRxUart baudClock bufferSize =
"uart_rx": when baudClock.clk
rules
"uart_rx_idle": when Idle <- state ==>
- if pin == 0 then
+ if pin == 0 then do
+ debugBit := 0
state := Data 0 0
else
state := Idle
- "uart_rx_data": when Data hi n <- state ==> do
- debugBit := pin
- let b :: Bit 8 = hi[7:1] ++ pin
+ "uart_rx_data": when Data oldBits n <- state ==> do
+ let newBits = pin ++ oldBits[6:0]
if n == 7 then do
- fifo.enq b
+ fifo.enq newBits
+ debugBit := 1
state := Idle
else
- state := Data b (n + 1)
+ state := Data newBits (n + 1)
interface RxUart
pin bit = pin := bit