-
Notifications
You must be signed in to change notification settings - Fork 902
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
verific: Add bottom and top bound properties to wire #4538
Conversation
45c09bd
to
1af9fa6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make your formatting conform to the surrounding code/the yosys coding style.
The tests do not seem to test anything, what is their intent?
Formatting done. The tests were meant to exercise the |
849a092
to
d4de358
Compare
Coverted to draft because most likely we want this PR to be merged first so that |
d4de358
to
7eff1a0
Compare
Requested changes are done, but no way to resolve the conversation
for signed attributes Co-authored-by: N. Engelhardt <[email protected]> Co-authored-by: Roland Coeurjoly <[email protected]>
4bde830
to
bdc43c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't speak to how the Verific interface is used, but otherwise it looks good to me
What are the reasons/motivation for this change?
Having bound properties for wires would help detect underflow and overflow in cases where the user is more restrictive than the RTLIL representation.
For example, the following VHDL
signal a : INTEGER range 0 to 6;
is represented in RTLIL as:
wire width 3 input 1 \a
because to represent decimal 6 you need at least 3 bits.However, decimal 7 can also be represented, which would be an overflow as per the user specified range, and that user constraint would get lost without this attribute.
This patch helps ensure that those user constraints are maintained and accessible in the RTLIL representation.
Explain how this is achieved.
With the Verific API, we get the bounds information and create attributes (named
bottom_bound
andtop_bound
).Those attributes are of the same bit width as the wire they belong to.
If at least one the bound is negative, both constants are flagged as signed.
Supporting changes
printattrs.cc: Updated the logic to print attributes for signed constants.
RTLIL::Const: The constructor was modified to use
long long
instead ofint
. This is necessary because to support VHDL 2019 integers with bit widths up to 64, the Verific API’sTypeRange::GetScalarRangeLeftBound()
method returns along long
.Discarded options
We decided that bound attributes for enumeration types will not be added in this PR.