You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Chiselsim will only terminate if the simulator exits or the commands that it is trying to run are done. However, different simulators handle things like $finish (which the Chisel stop API lowers to) differently. E.g., consider the following example code:
Compiling this with Verilator (verilator --binary Foo.sv && ./obj_dir/VFoo) will produce:
hello
- Foo.sv:5: Verilog $finish
world
- Foo.sv:7: Verilog $finish
If you run this with VCS (vcs Foo.sv && ./simv) will produce:
hello
$finish called from file "Foo.sv", line 5.
$finish at simulation time 0
The problem here is that Verilator doesn't terminate. This seems to violate the Verilog spec, based on the snippet below:
That said, we can work around this by querying the VerilatedContext.getFinish() member function when in the run_simulation function (or elsewhere) to see if Verilator is reporting that the simulation is done.
This has two major benefits:
Simulations will actually exit instead of running until they hit a timeout. For ChiselSpec, this is currently 10k half-periods. We can exit simulations way earlier without wasting cycles.
Fix a bug in how Verilator simulations work in svsim where the simulation
would _not_ terminate when a `$finish` was called. This seems to be a bug
in Verilator where it will not terminate the simulation (as mandated by
the Verilog spec) unless you are running with time delays.
Fixes#4700.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Fix a bug in how Verilator simulations work in svsim where the simulation
would _not_ terminate when a `$finish` was called. This seems to be a bug
in Verilator where it will not terminate the simulation (as mandated by
the Verilog spec) unless you are running with time delays.
Fixes#4700.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Currently, Chiselsim will only terminate if the simulator exits or the commands that it is trying to run are done. However, different simulators handle things like
$finish
(which the Chiselstop
API lowers to) differently. E.g., consider the following example code:Compiling this with Verilator (
verilator --binary Foo.sv && ./obj_dir/VFoo
) will produce:If you run this with VCS (
vcs Foo.sv && ./simv
) will produce:The problem here is that Verilator doesn't terminate. This seems to violate the Verilog spec, based on the snippet below:
That said, we can work around this by querying the
VerilatedContext.getFinish()
member function when in therun_simulation
function (or elsewhere) to see if Verilator is reporting that the simulation is done.This has two major benefits:
ChiselSpec
, this is currently 10k half-periods. We can exit simulations way earlier without wasting cycles.The text was updated successfully, but these errors were encountered: