Verilator freezes with AvalonSTMonitor on multiple tests after await
See original GitHub issueHi,
I am playing with Verilator and cocotb.
I have made this minimal repro: https://gist.github.com/bluecmd/fe70d5279bfcaca470c6556ccd502933.
Log:
make results.xml
make[1]: Entering directory '/home/blue/cocotb-freeze'
MODULE=test TESTCASE= TOPLEVEL=thing TOPLEVEL_LANG=verilog \
sim_build/thing
-.--ns INFO cocotb.gpi ..mbed/gpi_embed.cpp:74 in set_program_name_in_venv Did not detect Python virtual environment. Using system-wide Python interpreter
-.--ns INFO cocotb.gpi ../gpi/GpiCommon.cpp:105 in gpi_print_registered_impl VPI registered
-.--ns INFO cocotb.gpi ..mbed/gpi_embed.cpp:244 in embed_sim_init Python interpreter initialized and cocotb loaded!
0.00ns INFO cocotb __init__.py:202 in _initialise_testbench Running on Verilator version 4.100 2020-09-07
0.00ns INFO cocotb __init__.py:209 in _initialise_testbench Running tests with cocotb v1.4.0 from /usr/local/lib/python3.7/dist-packages/cocotb
0.00ns INFO cocotb __init__.py:229 in _initialise_testbench Seeding Python random module with 1599498748
0.00ns INFO cocotb.regression regression.py:127 in __init__ Found test test.test_a
0.00ns INFO cocotb.regression regression.py:127 in __init__ Found test test.test_b
0.00ns INFO cocotb.regression regression.py:463 in _start_test Running test 1/2: test_a
0.00ns INFO cocotb.test.test_a.0x7b12a02146d8 decorators.py:256 in _advance Starting test: "test_a"
Description: None
52000.00ns INFO cocotb.regression regression.py:361 in _score_test Test Passed: test_a
52000.00ns INFO cocotb.regression regression.py:463 in _start_test Running test 2/2: test_b
52000.00ns INFO cocotb.test.test_b.0x7b12a0228b00 decorators.py:256 in _advance Starting test: "test_b"
Description: None
[Freeze]
- I am using Verilator 4.100
- I set up two identical tests creating two clocks and one AvalonSTMonitor
- If I run a single test using
make TESTCASE=test_a
either test works. - If I make the test only use a single clock, running both tests works.
- If I initialize the AvalonSTMonitor before calling await on anything both tests work.
- Using
make SIM=icarus
works fine.
I would prefer to be able to initialize AvalonSTMonitor after doing reset to ensure the previous test state has been cleared.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had to remove the
timescale
directive for the timing to match up with Icarus’s. Icarus doesn’t supporttimescale
. Still hangs at the same place regardless.Anyway, the main difference I can see is that Verilator schedules the clock’s Timers before the Timer in the
run
Task. This means the clocks are updated before the AvalonMonitor starts. On Icarus, therun
task’s Timer is scheduled first, so the AvalonMonitor starts before the clocks are updated.The first thing the AvalonMonitor does is synchronize with the clock using RisingEdge(clk). On Verilator, because the clocks update first, this RisingEdge(clk) won’t trigger until the next clock cycle. On Icarus, because the clocks are updated after Monitor, this causes the RisingEdge(clk) to trigger immediately.
This implies if I add something (say, ReadOnly) to push the Monitor task to run after the clocks are updated, then Icarus should fail as well. However, it does not.
I don’t know why this scheduling difference is leading to issues. It’s almost definitely a Verilator issue. I really can’t make head or tails of it.
EDIT: uploaded log files. icarus.log verilator.log
Let’s assume it is.