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
Verilator concatenation error when passing overflowed value from C++ to verilog input port #1238
Comments
Original Redmine Comment Yes, that's true. There are several ways to debate handling this.
Preferences/thoughts? |
Original Redmine Comment 3 can be good. We should not let over-width inputs still pass to input port. If this happens, maybe throwing an exception and terminate the program? In a large test that prints tons of output, warnings just flash away and hard to catch. |
Original Redmine Comment And probably make it opt-in / opt-out so user can do the performance-safety tradeoff |
Original Redmine Comment Fixed to add assertion when VL_DEBUG is enabled. |
Original Redmine Comment Thanks Wilson! I will have a try on the new feature. |
Original Redmine Comment In 3.916. |
Original Redmine Comment I also bump into this problem, so I reply to this closed issue. Thanks. |
Original Redmine Comment Yu Sheng, I'm not sure exactly where you're suggesting the comments be put, perhaps you could attach a documentation patch? Thanks. |
Author Name: Junyi Xie
Original Redmine Issue: 1238 from https://www.veripool.org
Original Assignee: Wilson Snyder (@wsnyder)
Hi Verilator team,
I have found something related to memory accessing in Verilator.
When the value from C++ input to verilog port is larger than port width can represent,and we concatenate that port with other wires. The overflowed extra bits from C++ input will appear in the concatenated wires and overwrite what is supposed to be there.
For instance, the module has an input port A[9:0]. If in C++ code, we pass 11'd2047 (11'b111_1111_1111) to A and perform 'assign B = {2'b0, A};' on B[11:0]. Then B's value will not be 1023, but 2047. I have attached a very simple test code to reproduce the error (change the path of verilator in build_and_run.sh and execute the script should be enough).
This error can be caught by valgrind. However, users may not be aware this and get strange 'bugs' in there code. This problem troubled some of my teammates and myself when we are not aware of this.
Thus, is there any possibility that we can have some type of a warning from verilator during compile time, so that users know they are passing too large a value to a port with insufficient bits, and the potential problems of doing so.
Your help and response is much appreciated.
Thanks a lot!
Junyi
A verilator newbie
The text was updated successfully, but these errors were encountered: