-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncurried BiSignalIn params lead to faulty Verilog #2168
Comments
Note that |
The curried version looks OK:
|
I'm using Clash 1.6.1, and for boring reasons can't try out 1.6.3 right now; do let me know if there's been relevant changes in between. |
No changes related to that. Thanks for the report! |
Seems clash is supposed to report an error when arguments are of composite types containing clash-compiler/clash-lib/src/Clash/Netlist/Util.hs Lines 970 to 978 in acf574a
But somehow this error isn't being triggered. |
That function is only called for non-topentities. If you add a NOINLINE pragma for |
We could try to make BiSignalIn non-representable and see if the testsuite still passes:
that’s the easiest way to force Clash to inline the things we want inlined. |
A similar issue arises when packing the BiSignalIn into some structure. topEntityComparisonIoBuffer ::
Clock XilinxSystem ->
Reset XilinxSystem ->
Enable XilinxSystem ->
Signal XilinxSystem (BitVector 8) -> -- Input from FSM
Signal XilinxSystem (BitVector 8) -> -- Input Direction
Vec 8 (BiSignalIn 'Floating XilinxSystem 1) -> -- Input from Outside
(Signal XilinxSystem (BitVector 8), Vec 8 (BiSignalOut 'Floating XilinxSystem 1)) -- (Output to FSM, Output to Outside)
topEntityComparisonIoBuffer clk rst en = withClockResetEnable clk rst en ioBuffer
ioBuffer ::
forall dom regSize.
(HiddenClockResetEnable dom, KnownNat regSize) =>
Signal dom (BitVector regSize) -> -- Input from FSM
Signal dom (BitVector regSize) -> -- Input Direction
Vec regSize (BiSignalIn 'Floating dom 1) -> -- Input from Outside
(Signal dom (BitVector regSize), Vec regSize (BiSignalOut 'Floating dom 1)) -- (Output to FSM, Output to Outside)
ioBuffer inp inpD inpO = (outFsm, outO)
where
-- Change Signal BitVector to Vec (Signal Bit)
vecEnableBits = unbundle $ bv2v <$> inpD
-- Read Bit i only if inpD[i] is high
readIfBit :: Signal dom Bit -> BiSignalIn 'Floating dom 1 -> Signal dom Bit
readIfBit rd i = mux (bitToBool <$> rd) (readFromBiSignal i) undefined-- shoud generate "-" in vhdl when Bit should not be read
readEnabledBits = zipWith readIfBit vecEnableBits inpO
-- Bundle the read bits from Vec (Signal Bit) to Signal BitVector
outFsm = v2bv <$> bundle readEnabledBits
-- Write Bit i only if inpD[i] is low
-- writeToBiSignal will only write on a Just value
-- Enable, valuetoWrite, bisignal -> bisignalout
writeIfBit :: Signal dom Bit -> Signal dom Bit -> BiSignalIn 'Floating dom 1 -> BiSignalOut 'Floating dom 1
writeIfBit wr dat i = writeToBiSignal i (bitsToMaybe <$> wr <*> dat)
bitsToMaybe :: Bit -> Bit -> Maybe Bit
bitsToMaybe b1 b2 = if bitToBool b1 then Just b2 else Nothing
vecInputBits = unbundle $ bv2v <$> inp
outO = zipWith3 writeIfBit vecEnableBits vecInputBits inpO |
The text was updated successfully, but these errors were encountered: