Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

instrument

Makes the filelist a Verilator build uses: the flattened one, with a support source added, for coverage each covergroup bin written again as a cover property, and for waves a source that starts the dump. Used by TestRIG in a Verilator job. An Xcelium job has no such step. This is a function inside doris, not a command, so there are no logs.

Depends onfilelist (the sources) and flatten (the list naming them)
Outputsinstrument/filelist.f, instrument/src/, instrument/doris_support.cc, instrument/unsupported.txt
Passes whenThe filelist was read and the outputs were written

The cache key covers the sources and the flattened filelist, as outputs of the steps it reads, and what the step was asked for: the coverage scopes, or that there is no functional coverage, and the top module the waves source is bound into, or that there are no waves. So changing dut.coverage.scopes or dut.waves runs the step again. The step is the Verilator plugin’s, so its hash is in the key too, and a new plugin runs the step again.

The support source

doris_support.cc is added to every Verilator build. A TestRIG testbench runs until it is stopped, and Verilator only writes coverage when its main() is told to. So the source installs a handler for SIGTERM and SIGINT that writes the coverage collected so far to coverage.dat in the working directory and exits with code 0. It also makes standard output line buffered, so the log keeps up with the run.

The handler does the work itself rather than asking the simulation loop to stop, because the testbench can be blocked in DPI code waiting for its peer and never return to the loop. final blocks and UVM’s report summary do not run.

The waves source

With dut.waves set, the step writes instrument/src/doris_waves.sv and adds it to the filelist, after the testbench’s sources:

module doris_waves;
  initial begin
    if ($test$plusargs("doris_waves")) begin
      $dumpfile("waves.fst");
      $dumpvars;
    end
  end
endmodule

bind <dut.top> doris_waves doris_waves_i ();

The module is bound into the top module, so the testbench needs no change. A simulation built with it records waves only when it is given the +doris_waves plusarg, which the run step passes. The file is written in the run’s working directory, run/dut/waves.fst. The build needs --trace-fst, which the build step adds.

This has been built and run in a real Verilator, 5.040: the run wrote run/dut/waves.fst.

Covergroups as cover properties

Verilator parses covergroups and ignores them. It does count concurrent cover properties, with --coverage-user. So with dut.coverage.functional set, each source in the filelist that has covergroups is copied to instrument/src/ with a cover property added for each bin, and the filelist names the copy. The covergroups are left in the copy. The original’s directory is added as an include directory, for files the source includes from beside itself.

covergroup cg_itype @(posedge clk_i iff (rvfi_valid_i && rst_ni));
  cp_r_type: coverpoint {funct7, funct3} iff (opcode == 7'b0110011) {
    bins ADD = {10'b0000000_000};
  }
endgroup

becomes, before the module’s endmodule:

doris_cov__isa_coverage__cg_itype__cp_r_type__ADD: cover property (@(posedge clk_i)
    ((rvfi_valid_i && rst_ni)) && (opcode == 7'b0110011) && ((({funct7, funct3}) inside {10'b0000000_000})));

The name holds the module, covergroup, coverpoint and bin. The coverage step reads them back from it.

With dut.coverage.scopes set, only the covergroups of those modules are rewritten, as -covdut limits Xcelium.

What is not rewritten

Only what a cover property of that form can say is rewritten. Each thing left out is a line of instrument/unsupported.txt, and has no bins in the coverage report, so the totals are lower than Xcelium’s for the same testbench.

ConstructWhat happens
bins X = defaultLeft out, silently: it is not part of coverage
A crossListed
illegal_bins and ignore_binsListed. An illegal value is not an error
Bins with [], a transition (=>), with, or their own iffListed
A coverpoint with no label, or with automatic binsListed
A covergroup not sampled as @(posedge clk) or @(negedge clk), such as one sampled with sample()Listed
A covergroup in a class or a packageListed
A name with __ in itListed: __ separates the parts of the name

A cover property counts whether or not the covergroup has an instance, so a covergroup that is declared and never constructed still reports coverage here. Options such as option.weight and option.at_least are not used: a bin is covered when it is hit once.

To check by hand

instrument/unsupported.txt is empty. grep -c 'cover property' instrument/src/* gives the number of bins per source, which is the total the coverage report shows.