-
Notifications
You must be signed in to change notification settings - Fork 534
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
Icarus freezes when analyzing program #1171
Comments
This is invalid Verilog and the "could not find variable Next is the hang. This appears to be happening because of the following code: Also, there is no reason part select code like you are showing should be used. Whatever is generating this code is broken. Have you tried running this code on a different simulator to see what other tools report? |
FYI I killed the previous run since it was likely IO limited writing the huge debug value and just ran it normally, it eventually failed with a bad_alloc message so it ran out of memory as I was guessing it would. At best we should look into not generating billion bit vectors and reporting assignments to parameters are invalid. I do not believe this code is demonstrating any bugs in iverilog. I will mark it as an enhancement so we can generate better messages. |
I was able to simplify the code based on your comment, I have updated it in the issue. |
This is still invalid code and given that the other tools accept it with no issues implies they are not actually processing this as the standard dictates. Have you run this on other commercial simulators to see if they can process the code? It did fail on the one I tried. The first issue is you still have a non-blocking assignment to a parameter which is not valid and the second is you are trying to create a value that is billions of times larger than what a system with 32GB could represent. Maybe the other tools are able to determine the part select is 100% out of range and are creating a lazy evaluation that can then be used to verify that the part select term is !== to the parameter id_1 resulting in true without actually expanding both variables to their expected total width as mandated in the standard. Without extensive work to support lazy evaluation the most straight forward solution is to check for creating a value that is too large and then generating an error. Here is simple Verilog code that shows what you are requesting:
This produces the output |
I've looked at this a little more and have confirmed Icarus is working as expected when you do not overflow the memory. On a machine that has defined long as 32bits and then adding the -fshort-enums flag to gcc to minimize the size of the enumeration we use to represent constant numbers I was able to get something that did not run out of memory. There are still two remaining issues in the modified code you provided:
What I think needs to be done from the Icarus side is switch the verinum enumeration to a class enum that only uses a single byte per bit instead of using an old style enumeration which defaults to an int (typically 4 bytes). The class enum was added in C++ 11 which is what we are currently using as the minimum requirement to compile Icarus. We should see if there are other places we use enumerations to see if they would benefit from class enums. Next we should have a way to detect when the verinum to a long has been truncated and when this happens provide a more appropriate error message. We should also check that the bounds and size of an element can actually be represented in memory. The standard sets a suggested limit at 2^16 for the packed dimensions and 2^24 for the unpacked dimensions. I will look at what other simulators do before hard coding a limit. Whatever generator you are using is generating garbage code and needs to be constrained better. |
Icarus freezes when analyzing the program below:
The output is the following:
The text was updated successfully, but these errors were encountered: