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
It is frequently useful to directly assign byte string constants to a Signal or otherwise use them in a context where ValueCastables are expected. This RFC proposes supporting this pattern in Amaranth by handling bytes values in Value.cast.
Implementation
These values would be "lowered" to a Const containing the entire value of the bytes packed in little-endian byte order. This would thus produce a Value of 8*len(bytes) bits. The goal here is not to use the minimal space for each value but to encode them in a useful way for debugging.
Why?
One significant use for this is for debugging, allowing values that are easily recognized in traces or in printouts to be used directly. Currently each project desiring this capability has to implement it locally; this leads to a lot of replicated code. Otherwise it is simply a feature we have encountered the desire for on multiple occasions when dealing with ASCII constants in protocols and testbenches.
Why not?
Some users could theoretically find this confusing
Not useful enough to justify
Concerns over how the bytes end up packed (ordering)
The text was updated successfully, but these errors were encountered:
We discussed this RFC at the weekly meeting. We reached a rough consensus that while potentially convenient, the alternative (using int.from_bytes(x, byteorder="little")) doesn't bother anyone and the value of this addition to the language seems insufficient to justify the added complexity of adding another implicit conversion.
Background
It is frequently useful to directly assign byte string constants to a
Signal
or otherwise use them in a context whereValueCastable
s are expected. This RFC proposes supporting this pattern in Amaranth by handlingbytes
values inValue.cast
.Implementation
These values would be "lowered" to a
Const
containing the entire value of thebytes
packed in little-endian byte order. This would thus produce aValue
of8*len(bytes)
bits. The goal here is not to use the minimal space for each value but to encode them in a useful way for debugging.Why?
One significant use for this is for debugging, allowing values that are easily recognized in traces or in printouts to be used directly. Currently each project desiring this capability has to implement it locally; this leads to a lot of replicated code. Otherwise it is simply a feature we have encountered the desire for on multiple occasions when dealing with ASCII constants in protocols and testbenches.
Why not?
The text was updated successfully, but these errors were encountered: