Open martijnbastiaan opened 3 years ago
+1!
Perhaps to serve your point: I believe your description of how this currently works is wrong. Bitpacking A
would rather result in 0b00..10
. The mask and value are matched bit by bit, and the bits of the value for which the corresponding mask bits are zero are ignored.
Thanks @JvWesterveld. And yeah, I think that definitely proves my point then :-)
A
ConstrRepr
uses two fields to encode a mask and a value to encode constructor bits. For example:which would mean: take the four bits indicated by the first binary value. If the value corresponds to
1010
it's constructorA
. This is confusing in multiple ways:ConstrRepr
's documentation. (This could be fixed by makingConstRepr
a record, though.)Perhaps we could fix this by leveraging the ability to set undefined bits on BitVector. For example:
The Python programmer in me says we could even use
OverloadedStrings
and do:but that's a topic for another day..
Relevant documentation: http://hackage.haskell.org/package/clash-prelude-1.4.0/docs/Clash-Annotations-BitRepresentation.html#g:1