You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will clearly go wrong for custom Eq classes. It just so happens I'll be using a custom Eq class soonish in the work on Xilinx floating point IP: for instance for the exponential operator, the result has an accuracy of within one unit in the last place (ULP / LSB), so a test bench will need to check whether the result is at most one ULP different from the "exact" result. With the current assert, this will lead to different behaviour of Haskell simulation and HDL simulation.
My suggestion is a structure overhaul:
Lift the machinery for the test in assertBitVector to isLike#, making isLike and isLike#not synthesisable, but generates HDL usable in HDL simulation.
Make a new assertWith with a black box and the type sig:
assertWith
:: (KnownDomaindom, ShowXa)
=>Clockdom->Resetdom->String--^ Additional message->SignaldomBool--^ 'False' when assertion fails->Signaldoma--^ Checked value, for formatting failure message->Signaldoma--^ Expected value, for formatting failure message->Signaldomb--^ Return value->Signaldomb
The checked and expected signals are only still there to format the assertion failure messages, which are the same as before. The assert itself now checks the truth value of the Bool signal.
Redefine assert and assertBitVector as:
assert clk rst msg checked expected returned = assertWith clk rst msg (checked .==. expected) checked expected returned
assertBitVector clk rst msg checked expected returned = assertWith clk rst msg (liftA2 islike# checked expected) checked expected returned
(I could have taken isLike but isLike# is faster, no pack).
While I'm in there, I can also fix another bug that I will mention here but not make a separate issue for. There is a disparity between Haskell and HDL simulation when assert is used with BitVectors with undefined bits, even without a custom Eq. The following test bench:
>>> runUntil id testBench
cycle(<Clock:System>):0, outputVerifier
expected value:0b1.0., not equal to actual value:0b1.0.cycle(<Clock:System>):1, outputVerifier
expected value:0b1.0., not equal to actual value:0b1.0.Signal sampled for 2 cycles until value True
but succeeds in HDL.
Are there any objections to or suggestions for the structure overhaul?
The text was updated successfully, but these errors were encountered:
As can already be seen from the type signature:
assert
usesEq
in Haskell simulation. However, the black boxes use a different equality test:VHDL:
Verilog/SystemVerilog:
This will clearly go wrong for custom
Eq
classes. It just so happens I'll be using a customEq
class soonish in the work on Xilinx floating point IP: for instance for the exponential operator, the result has an accuracy of within one unit in the last place (ULP / LSB), so a test bench will need to check whether the result is at most one ULP different from the "exact" result. With the currentassert
, this will lead to different behaviour of Haskell simulation and HDL simulation.My suggestion is a structure overhaul:
assertBitVector
toisLike#
, makingisLike
andisLike#
not synthesisable, but generates HDL usable in HDL simulation.assertWith
with a black box and the type sig:Bool
signal.assert
andassertBitVector
as:isLike
butisLike#
is faster, nopack
).While I'm in there, I can also fix another bug that I will mention here but not make a separate issue for. There is a disparity between Haskell and HDL simulation when
assert
is used withBitVector
s with undefined bits, even without a customEq
. The following test bench:fails in Haskell:
but succeeds in HDL.
Are there any objections to or suggestions for the structure overhaul?
The text was updated successfully, but these errors were encountered: