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
Patch support for --timing flag in verilator #3316
Patch support for --timing flag in verilator #3316
Conversation
e005086
to
7f8246f
Compare
hmm, CI failures seem to be unrelated to this PR |
Yeah, they seem unrelated, which is odd since #3321 is passing. |
Codecov Report
@@ Coverage Diff @@
## master #3316 +/- ##
==========================================
+ Coverage 43.89% 48.85% +4.95%
==========================================
Files 49 49
Lines 8816 8816
Branches 2446 2446
==========================================
+ Hits 3870 4307 +437
+ Misses 4388 3932 -456
- Partials 558 577 +19 |
So when not in |
I don't know enough about Verilator to say this doesn't change existing behavior. Waiting on feedback. |
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.
LGTM, thanks! Can you do the small nitpick update, @mczyz-antmicro?
So when not in --timing mode, what does top->eventsPending() and top->nextTimeSlot() return?
- eventsPending() returns false without complaining,
- nextTimeSlot() returns 0 with a fatal error
Rerunning CI against a master merge. |
Hey,
My thoughts from the testcase (I am also attaching 2 log files from a test run with master branch and with patch branch) -
Conclusions:
I've also observed "a tangent" issue, which is that Verilation command is built in the cocotb.runner. I haven't found a way to pass "--timing" to it in a clean way. It would be nice to have another argument similar to build_cmds, but for other compilation args. This is why I used a makefile to run my tests and not build/test cocotb functions |
60433dc
to
a76b296
Compare
I rebased both branches to latest master, too |
@mczyz-antmicro The test looks good but we don't really need both the Python runner and the Makefile for the test. The only issue I see is that it would be nice to timeout and kill the hung process so the rest of the regression can complete. If you wanted to open a new PR with that test, it would be appreciated. |
Thanks @mczyz-antmicro for your work on this PR! Thanks especially for the in-depth thoughts on testing your change in #3316 (comment), that's exceptional and very much appreciated. |
I will follow up with testcase in #3333 |
This PR adds a fix to error "Simulator shut down prematurely" when cocotb is used with Verilator and
--timing
parameter. The proposed fix is related to issue #3254If the HDL code contains timing statements, e.g.
#10 clk = ~clk;
, then the Verilator should be called with a--timing
flag. In current implementation Verilator shuts down prematurely, beacuse the call toVerilatedVpi::cbNextDeadline()
returns uint64 max, meaning no more scheduled events (cbNextDeadline()
is the deadline of the next registered VPI callback). If we want to support the Verilator's--timing
flag, then a check must be performed to see if there are any events pendingtop->eventsPending()
and then find the next time slottop->nextTimeSlot()
. The next time step is then the smaller of time steps returned byVerilatedVpi::cbNextDeadline()
andtop->nextTimeSlot()