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
Warn/Error code with X, Z values use #5115
Comments
right now we have: |
Verilator shouldn't ever consider 0 === 1'bx to be true. Note it does in a few limited cases know how to X propagate during elaboration, so if you e.g. have a parameter with a value of 1'bx, then PARAM === 1'bx will be true, even though Verilator doesn't do X in a general sense. So to summarize, we need a small test case ;) |
Was VCD dumping changed since verilator 4..? |
There were some dumping changes. Most likely there's a X=>0/1 transition at time zero causing the posedge to trigger. Thou shall use resets ;) |
Even if I define "a" as bit vector, nothing changes in waves and printing 'a' value at negedge clk . I expect that at first clk rising edge 'a' should become 2, not 1... BTW, if 'a' would have initial value of 0, "a=a<<1;" statement would never change the 'a' . |
I still suspect a time zero race between the initial and the assignment, with X's. Put a display in the always loop, and see how on Xcelium to get waves at each delta simulation point. |
BTW, to my original complain about no warnings for operations with X, Z. It's strange that the verilator 5.. started complain about # delays in the code, and does not complain about Xs ... |
Because # delay behavior changed relative to older Verilators but X/Z are handled the same. |
Oh, you said "I see some discrepancy with Xcelium" I thought you meant the wrong values from Xcelium. I'd still suggest put a display before and after the assign in the posedge. |
here $displays for Xcellium:
Here for verilator: VerilatorTB: Start of sim
its crazy - seems verilator misses 1st clk posedge (?) (I generate clk by C++ code) |
statements with T= are $display at negadge clk .. |
As mentioned above, there's probably a X->0/1 clock edge in Xcelium, but Verilator won't get it. Avoid assuming edges on time 0 events, much better to rely on an explicit reset wire. |
looks like all this because of my C++ code:
it does not evaluate design before the clock change at time 0 :( |
one more problem: Cadence/Synopsys tools could not read VCD produced by Verilator.
I had to patch it as :
Cadence tool did not show waves, Synopsys DVE complained about line 4 illegal synthax: Error: [VCD2VPD-PRINT-ERROR] VCD syntax error. I guess it was because no name in the $scope statements.. |
Perhaps you're not creating the Verilated model with a name and that gets passed through? Anyhow, can you please submit a pull request to either name empty scopes, or (not sure this works) filter them out, or if you can't get to a pull, file a new issue with a self-contained test case showing the issue. Thanks. |
|
There have been many tracing changes, if you get a bad file out of the master version, it's a bug. |
Wilson, thanks again. Now I got to our initial problem - xrun/verilator simulation difference with verilog checking for Xs: here is the problematic module:
here is TB:
C++ wrapper was provided in previous comments. xrun output :
verilator output: VerilatorTB: Start of sim
Based on that seems verilator evaluates if(a[i] == 1'bx) as TRUE and exits the for loop for a[i] ==0 . Although xrun simulates this correctly. That is why it's worth to warn compilation of RTL with Xs, at least |
There's a lot of code there, is what you intend to ask why:
In Verilator should correctly handle or warn on:
I'd argue that any |
You are right about '===' , but we got this code from a third party and warn them about it. Regardless, X,Z usage warning could save a lot of debug time in future. I asked for global warning , thinking it easier to implement, than warn about specific cases. |
Are you going to fix all these issues? |
By "all", I think we're down to general warning on By "you", I'm not personally going to get to either soon, pull requests welcome. |
I meant to add at least warnings for usage of X/Zs and fixing "empty/unnamed" $scope module statements in VCD any soon. |
As suggested above, file a separate ticket for $scope, including an example. |
Does verilator warn/error RTL code with X or Z values usage?
We use bunch of arithmetic modules and they have "if" statements with X values like
if(a==1) out = ..
else if (a === 1'bx) out = 'x
else out = ...
And because verilator is 2 state simulator it takes 'if X' branch for zero value of 'a' , producing wrong result at the end.
The text was updated successfully, but these errors were encountered: