$dumpfile names the VCD output, and $dumpvars with a depth and a scope selects how much hierarchy to record. Depth 0 records the scope and everything below it, while depth 1 records only the scope's own signals.
Dump scope is the largest lever on run time and disk use. Full-design dumps slow runs and flood disks, so regressions run dump-free and reruns record a window instead.
Call | Records |
|---|---|
| The scope and everything below, the expensive default |
| One suspect subtree only |
| The scope signals without the children |
Commercial flows record FSDB or vendor equivalents instead of VCD. The scoping ideas match, and the compression is far better, through tool-specific tasks.
$dumpoff and $dumpon gate recording at run time. The window edges below come from plusargs, so a failing seed reruns with waves only around the failure.
The listing names DUT hierarchy, so it is not run in this course's checks. $test$plusargs matches prefixes, so the window knobs are named +WIN_START and +WIN_STOP: WAVES is not a prefix of either, and only +WAVES turns dumping on.
// not-run: needs a testbench harness with a matching DUT hierarchy
`timescale 1ns/1ps
time dump_start = 0;
time dump_stop = 0; // 0 means run to the end
initial begin
if ($test$plusargs("WAVES")) begin
void'($value$plusargs("WIN_START=%d", dump_start));
void'($value$plusargs("WIN_STOP=%d", dump_stop));
$dumpfile("waves.vcd");
$dumpvars(0, tb_top.dut);
if (dump_start > 0) begin
$dumpoff; // armed but not recording
#(dump_start) $dumpon; // open the window
end
if (dump_stop > dump_start)
#(dump_stop - dump_start) $dumpoff; // close it
end
end
// Clean run: simv +TESTNAME=stress
// Rerun the fault: simv +TESTNAME=stress +WAVES +WIN_START=9000000 +WIN_STOP=9400000The bottom rows show the window, the fault and an 8-bit counter. The fault lands inside the open window.
Slot 0: win is 0 and data reads 10, before the window.
Slot 1: data reads 11, still outside the window.
Slot 2: win rises and data reads 12, so recording starts.
Slot 3: win stays high and data reads 13.
Slot 4: fault pulses and data reads ee, the signature inside the window.
Slot 5: win falls and data reads 14, so recording stops.
DUMP WINDOW STRATEGY
full dump ██████████████████████████████ large file, slow run
0ms 10ms
windowed dump ░░░░░░░░░░░░░░░░░░░░░░░░██░░░ small file, fast run
▲ ▲
window open failure inside
before fault window closes after
regression default: no +WAVES, so zero wave cost
failure rerun: +WAVES with a window around the failing timeThree calls end a run three ways. $finish terminates normally and runs final checks, $stop pauses into the debugger, and $fatal terminates with an error status for scripts.
Call | Meaning | Regression rule |
|---|---|---|
| Normal termination | Every passing or cleanly failing test ends here |
| Pause for interaction | Never in batch code, since the job hangs at a prompt |
| Error termination with a status | Check the tool mapping from status to exit code, and grep logs as a backstop |
Verbosity is one more run-time knob. A log helper compares each message level against it, so rerunning louder never recompiles.
Every testbench also carries a timeout guard. The guard below has a time unit, so it is a plain illustration rather than a checked block.
// snippet
`timescale 1ns/1ps
initial begin
#50ms;
$fatal(1, "TIMEOUT: test did not complete");
endThe testbench below proves the verbosity filter: with the default of 1, two of three messages show.
module tb_verbosity;
integer verbosity = 1; // 0 shows errors only, 1 is normal, 2 is debug
integer shown = 0;
integer errors = 0;
integer matched;
task automatic log_msg(input integer level);
if (level <= verbosity) shown = shown + 1;
endtask
initial begin
matched = $value$plusargs("VERBOSITY=%d", verbosity);
if (matched != 0) errors++; // no plusargs in this run, so 0 is expected
log_msg(0);
log_msg(1);
log_msg(2);
if (shown != 2) errors++; // levels 0 and 1 pass the default filter
if (errors == 0) $display("PASS: verbosity 1 showed 2 of 3 messages");
else $fatal(1, "FAIL: %0d verbosity checks did not hold", errors);
$finish;
end
endmodule$stop is the cause: it waits at an interactive prompt. Batch code uses $fatal with a message and a status instead, so the run ends and the script sees it.
At the timeout guard, which reports red. Every path out of a test ends at $finish or $fatal.
Verbosity changes per rerun, and a parameter change recompiles. A plusarg tunes the same image in seconds.