Open martijnbastiaan opened 5 years ago
Maybe we could use backpack to parameterize clash-prelude over the used bit representation.
How stable is that? Is it actually used in the Haskell ecosystem?
We should have a flag as to whether Clash pads with undefined bits between the constructor bits and field bits (BlueSpec), or pads LSBs with undefined bits (Current Clash behaviour)
@martijnbastiaan Can this issue be closed now that we have support for custom bit-representations?
What I'm proposing here is a flag to switch representations by default. So yeah, most (all?) if this can be mitigated by using custom repr annotations. If there's no plan to add this we can close the issue I think.
Consider the following data type:
Right now:
where the
.
s are indicatingundefined
. This behavior matches what Clash will generate in the HDL: whenever it converts the data type to astd_logic_vector
-like. While this is completely fine in terms of functionality, interoperability between tools might suffer. For example, BlueSpec uses the following:Other tooling might use "one-hot" constructors, like so:
Integrating with these tools thus requires the user to manually write these conversions. Pretty annoying!
Ideally, Clash would offer the option to configure this behavior. The easiest way would probably be a Cabal flag.