-
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
ILA ignores custom BitPack instances #2574
Comments
Isn't this just a consequence that you should never really write a custom import Clash.Annotations.BitRepresentation
data T = A | B deriving (Generic)
{-# ANN module (DataReprAnn
$(liftQ [t|T|])
1
[ ConstrRepr 'A 0b1 0b1 []
, ConstrRepr 'B 0b1 0b0 []
]) #-} If so this is not really specific to the ILA but a general Clash thing. |
Adding a It's just that I need the
It should be a solvable problem for the ILA blackbox at least, because there we can automatically add the |
You can also derive a I would really not go the route of having non-conforming |
It would be nice if we documented this better, but indeed, I also think you can't just create a topEntity :: T
topEntity = A this generates the following Verilog: assign result = 1'd0; If you want to influence the encoding of a type, you'll need So the problem is you're approaching it in reverse. |
Thanks for the feedback. I never considered the purpose of |
I think PR #2575 perhaps clarifies this well enough. |
The ILA blackboxes of
clash-cores
use a polyvariadic interface, hency any value can be dumped into an ILA. Now consider some data type with a customBitPack
instances, such asNote that this instance intentionally deviates from the default produced by deriving
BitPack
, which would assignsA
↦ 0 andB
↦ 1.Now, if we pass a value
x :: T
directly into the ILA, then the ILA still used the implicit encoding as given by the derivedBitPack
instance, e.g. it assignsA
↦ 0 andB
↦ 1. Only if we passpack x :: BitVector (BitSize T)
instead, then it assignsA
↦ 1 andB
↦ 0.This can be very confusing, especially if the custom
BitPack
instance only slightly differs against the default, making a wrongly produced ILA dump value hard to catch.As an ILA user, I just would assume that the ILA automatically uses the custom
BitPack
instance, if it exists.The same probably also applies to VIO blackboxes, but I haven't explicitly tested it.
The text was updated successfully, but these errors were encountered: