I’m writing a testbench for the uart module provided by Retroclash to get more familiar with Shockwave. It’s as follow
{-# OPAQUE topEntity #-}
{-# ANN topEntity
(Synthesize
{ t_name = "topEntity"
, t_inputs =
[ PortName "clk"
, PortName "rst"
, PortName "uart_rxd"
]
, t_output = PortName "uart_txd"
}) #-}
topEntity :: Clock System -> Reset System -> Signal System Bit -> Signal System Bit
topEntity clk rst rxD = withClockResetEnable clk rst enableGen $
let
input = rx @8 (SNat @115200) rxD
buf = fifo input txReady
(txD, txReady) = tx @8 (SNat @115200) buf
in boolToBit <$> (not . bitToBool <$> txD)
testUART :: IO ()
testUART = do
let out = topEntity clockGen resetGen (fromList $ [high, high, high, high] <> [low, high, low, high, low, low, low, low] <> Ls.repeat high)
file <- dumpVCD (0, 10_000_000) (traceSignal "topEntity" out) []
case file of
Left msg -> error msg
Right (vcd, meta) -> do
writeFile "test.vcd" vcd
writeFileJSON "test.json" meta
With the class derived as follow
data TxState n = TxIdle | TxBusy Word32 (TxBit n)
deriving (Show, Eq, Generic, NFDataX)
data TxBit n = TxStartBit (BitVector n) | TxDataBit (BitVector n) (Index n) | TxStopBit
deriving (Show, Eq, Generic, NFDataX)
data RxState n = RxIdle | RxBusy Word32 (Maybe Bit) (RxBit n)
deriving (Show, Eq, Generic, NFDataX)
data RxBit n = RxStartBit | RxDataBit (BitVector n) (Index n) | RxStopBit (BitVector n)
deriving (Show, Eq, Generic, NFDataX)
deriving instance (KnownNat n, 1 <= n) => BitPack (TxBit n)
deriving instance (KnownNat n, 1 <= n) => BitPack (TxState n)
deriving instance (KnownNat n, 1 <= n) => Waveform (TxBit n)
deriving instance (KnownNat n, 1 <= n) => Waveform (TxState n)
deriving instance (KnownNat n, 1 <= n) => BitPack (RxBit n)
deriving instance (KnownNat n, 1 <= n) => BitPack (RxState n)
deriving instance (KnownNat n, 1 <= n) => Waveform (RxBit n)
deriving instance (KnownNat n, 1 <= n) => Waveform (RxState n)
But this will just hang until my laptop run out of memory. Did I misunderstand something and what should I do to get it to work?