Code Coverage Support - 2023.2 English

Vivado Design Suite User Guide: Logic Simulation (UG900)

Document ID
UG900
Release Date
2023-10-18
Version
2023.2 English

Code coverage is a measure of how well the RTL code has been exercised by the test bench. Code coverage is automatically extracted by the simulator when enabled. AMD Vivado™ simulator currently supports four types of code coverage, line, branch, condition, and toggle. When you enable code coverage for any of the code coverage types, the tool automatically generates a code coverage database. To view the coverage of design, AMD Vivado™ simulator provides a standalone executable named as xcrg (Xilinx Coverage Report Generator), which can be used to generate coverage reports by reading the coverage database.

The code coverage functionality supported by the simulator is :

  • Line/Statement coverage with exact execution count of statements
  • Branch Coverage for if-else, if-elseif-else, switch case, tenary operators
  • Detection and highlighting of missing else and missing default in code coverage report
  • Condition Coverage with exact count of the number of times a condition has been checked and evaluated to TRUE/FALSE
  • packed/unpacked reg, bit, logic, wire data types
  • int, shorting, integer, byte datatypes, and non-dynamic struct members
  • Generation of code coverage HTML report by using xcrg
  • Dashboard view of code coverage of design
  • List of the file, module, and hierarchical instances for the whole design
  • File-specific code coverage view, module, and instance-specific views
  • Merging of Line/Statement, Branch, Condition, and Toggle coverage from different runs using xcrg
Note: Currently, Vivado simulator only supports these features for SystemVerilog and Verilog code. VHDL is not supported yet.
Table 1. xcrg Command Options and Description
xcrg Option Description
-db_name arg Name of the database inside xsim.covdb. If unspecified all databases present in the directory are used.
-dir arg Path where the xsim.covdb database directory is located. Default is ./xsim.covdb.
-file arg Specify file with location of the coverage databases to be restored.
-h Print help message and exit.
-help Print help message and exit.
-merge_db_name arg Name of the merged database. Default is xcrg_mdb.
-merge_dir arg Directory where the merged database is saved. Default is ./xsim.covdb.
-nolog Suppresses the log file generation.
-report_dir arg Directory where the coverage database and the report are saved. This option is mandatory.
-report_format arg Specify the desired format of the coverage report HTML or text or all. Default is HTML.
-log arg Specify the file name which has the log saved. Default is xcrg.log.
-version Print the version of XCRG and exit.
-cc_db <arg> Specify the DB Name (Snapshot Name), which is used to save the code coverage database. The code coverage database can be restored from <cc_dir_argvalue>/xsim.codeCov/<cc_db_argvalue>.
-cc_dir <arg> Specify the directory where the code coverage information database is saved. Code coverage database can be restored from <cc_dir_argvalue>/xsim.codeCov/<cc_db_argvalue>. Default is ./xsim.CodeCov/.
-cc_fullfile Show the entire file in the code coverage report. By default, this is OFF for files more than 50000 lines and only the file's module contents are shown.
-cc_report <arg> Directory where the code coverage HTML report is saved. Default is xcrg_code_cov_report.
-merge_cc Merge the code coverage databases specified and create a output merged code coverage database.
-cc_instancescount <arg> Specify the maximum number of instances shown in the code coverage report. Default is 100.

xcrg Examples


# Functional Coverage with one DUT and one TB generating html and text reports
xelab -svlog DUT1.v -svlog TB1.v -cov_db_dir ./fRun1 -cov_db_name DB1 -R 
xcrg -dir ./fRun1/ -db_name DB1 -report_dir ./fReport1 -report_format html
firefox ./fReport1/dashboard.html &
xcrg -dir ./fRun1/ -db_name DB1 -report_dir ./fReport1 -report_format text
gvim ./fReport1/xcrg_report.txt

# Merging Functional Coverage runs of one DUT and 2 TBs generating merged html report (using TB from previous example)
xelab -svlog DUT1.v -svlog TB2.v -cov_db_dir ./fRun2 -cov_db_name DB2 -R
xcrg -dir ./fRun1 -db_name DB1 -dir ./fRun2 -db_name DB2 -merge_dir ./fMerge1 -merge_db_name mDB1 -report_dir ./mfReport1
firefox ./mfReport1/dashboard.html &

# Code Coverage run and html report generation
xelab -svlog ccDUT.v -svlog ccTB.v -cc_type sbct -cc_db DB1 -cc_dir ./cRun1 -R
xcrg -cc_db DB1 -cc_dir ./cRun1 -cc_report ./cReport1
firefox ./cReport1/dashboard.html &

# Other examples
xcrg -h
xcrg -file /path/to/file
xcrg -file /path/to/file -db_name work.top
xcrg -dir /path/to/abc
xcrg -dir ./abc -report_dir def -report_format html
xcrg -dir ./abc -db_name work.top -report_dir def -report_format html
xcrg -dir /path/to/abc -db_name work.top -report_dir def -report_format text
xcrg -merge_dir m
xcrg -merge_db_name xyz -report_dir def
xcrg -report_format html -nolog
xcrg -report_format html -log xcrgOutput.log
xcrg -cc_db a1 -cc_dir ./ 
xcrg -cc_report abc -cc_db work.testbench -cc_dir ./xsim.codeCov/