-
Notifications
You must be signed in to change notification settings - Fork 860
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
Enforce RTLIL Wire/Const limit size of 2^24 #3460
base: main
Are you sure you want to change the base?
Conversation
c035071
to
c541158
Compare
I think the correct thing to use here is |
Possibly, I'll see how it feels with |
c541158
to
cbe9366
Compare
Looking at the surrounding code, +1 on |
cbe9366
to
5830b31
Compare
cdb59c0
to
42e4610
Compare
We need to test where large consts may be created:
|
@@ -187,7 +187,11 @@ wire_stmt: | |||
|
|||
wire_options: | |||
wire_options TOK_WIDTH TOK_INT { | |||
current_wire->width = $3; | |||
if ($3 > 0x1000000) { |
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.
it maybe better to use a constexpr defined in rtlil.h instead of repeating the magic number everywhere; my 2-cents
@@ -214,6 +217,12 @@ RTLIL::Const::Const(const std::string &str) | |||
|
|||
RTLIL::Const::Const(int val, int width) | |||
{ | |||
if (width < 0) |
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.
This should probably be a log_assert
rather than log_error
since this case isn't supposed to ever happen.
This commit adds asserts to the RTLIL parser to ensure that a wire definition is no more than 2^24 bits wide, as well as that RTLIL
Const
s can not have a negative width nor be wider than 2^24 bits.This addresses #1206 and #3317