-
Notifications
You must be signed in to change notification settings - Fork 147
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
Improve BitPack instances with undefined bits #353
Comments
I think this touches on a deeper issue; undefined bits are generally not going to survive a x1 = undefined# :> pack 8 :: BitVector 17
x2 = unpack x1 :: Either Int16 Int16
x3 = tail (pack x2) :: BitVector 16 There's no way we can solve this correctly, even though Verilog and the hardware itself would conclude that Considering that we'd be throwing away error messages and that undefinedness is couter-intuitive and fundamentally broken in Verilog (and my guess is all other HDLs too) anyway I think we'd be best of by introducing an |
Actually, @leonschoorl kind of defeated by |
@martijnbastiaan, @cchalmers pointed out that the problem is actually:
Rather then:
The solution to this is to test whether a value is
Where the current definitions for
|
It’ll be difficult to generate HDL for that definition. We currently do not even handle isX and friends: https://github.com/clash-lang/clash-compiler/blob/master/clash-lib/prims/common/Clash_XException.json |
@christiaanb, how about:
With |
Obviously, this should be an |
Fixed by #552 |
Now that
BitVector
s contain a bitmask for which bits are defined, we should be able to improve some of theBitPack
instances (mainlyVec
).For example, we could expect these two values to pack the same way:
Which would allow us to do things like:
Similarly we could get expressions like
bv2v . v2bv
to be closer toid
even in the presence of undefined bits:@christiaanb suggested to change the following:
clash-compiler/clash-prelude/src/Clash/Sized/Internal/BitVector.hs
Lines 323 to 324 in 1d02f8f
To:
One thing to note here, even if we manage to fix
bv2v . v2bv == id
, we wouldn't be able to recover themsg
from aerrorX msg
through that expression. The errors would be represented as single bits, so all error messages would be "forgotten".The text was updated successfully, but these errors were encountered: