Coverage Statistics
Categories:
The Picker tool supports generating code line coverage reports, and the MLVP(https://github.com/XS-MLVP/mlvp)project supports generating functional coverage reports.
Code Line Coverage
Currently, the Picker tool supports generating code line coverage reports based on the Verilator simulator.
Verilator
The Verilator simulator provides coverage support.
The implementation is as follows:
- Use the
verilator_coverage
tool to process or merge coverage databases, ultimately generating acoverage.info
file for multiple DUTs. - Use the
genhtml
command of the lcov tool based oncoverage.info
and RTL code source files to generate a complete code coverage report.
The process is as follows:
- Enable the COVERAGE feature when generating the DUT with Picker (add the
-c
option). - After the simulator runs, a coverage database file
V{DUT_NAME}.dat
will be generated afterdut.finalize()
is called. - Use the write-info function of
verilator_coverage
to convert it to a.info
file. - Use the
genhtml
function oflcov
to generate an HTML report using the.info
file and the RTL source files specified in the file.
Note: The RTL source files specified in the file refer to the source file paths used when generating the
DUT
, and these paths need to be valid in the current environment. In simple terms, all.sv/.v
files used for compilation need to exist in the current environment, and the directory remains unchanged.
verilator_coverage
The verilator_coverage
tool is used to process coverage data generated by the DUT
after running .dat
files. The tool can process and merge multiple .dat
files and has two main functions:
-
Generate a
.info
file based on the.dat
file for subsequent generation of a web page report.-
-annotate <output_dir>
:Present the coverage situation in the source file in annotated form, and save the result tooutput_dir
. The format is as follows:100000 input logic a; // Begins with whitespace, because // number of hits (100000) is above the limit. %000000 input logic b; // Begins with %, because // number of hits (0) is below the limit.
-
-annotate-min <count>
:Specify the limit as count for the above.
-
-
Combine the
.dat
file with the source code file, and write the coverage data in annotated form into the specified directory.-write <merged-datafile> -read <datafiles>
:Merge several .dat (datafiles
) files into one .dat file.-write-info <merged-info> -read <datafiles>
:Merge several .dat (datafiles
) files into one .info file.
genhtml
The genhtml
provided by the lcov
package can export a more readable HTML report from the .info file. The command format is: genhtml [OPTIONS] <infofiles>
.
It is recommended to use the -o <outputdir>
option to output the results to a specified directory.
For example, in theAddr project.
Usage Example
If you enable the -c
option when using Picker, after the simulation ends, a V{DUT_NAME}.dat
file will be generated. And there will be a Makefile in the top-level directory, which contains the command to generate the coverage report.
The command is as follows:
coverage:
...
verilator_coverage -write-info coverage.info ./${TARGET}/V${PROJECT}_coverage.dat
genhtml coverage.info --output-directory coverage
...
Enter make coverage
in the shell, which will generate coverage.info based on the generated .dat file and then use genhtml
to generate an html report in the coverage directory.
VCS
Documentation for VCS is currently being finalized.