Generate Code Coverage Report with QuestaSim

To generate code coverage reports in QuestaSim, add these lines to your .do tcl script:

# Create work library
vlib work

# Compile with coverage enabled
vlog -coveropt 3 +cover +acc mod16_counter.v mod16_tb.v

# Run simulation with coverage collection
vsim -coverage -vopt work.mod16_tb -c -do "coverage save -onexit -directive -codeAll mod16_cov; run -all; exit"

# Generate HTML report
vcover report -html mod16_cov

Command Reference

OptionDescription
-coveropt 3Sets optimization level to 3
+coverEnables all coverage types (s,b,c,e,f,t)
+cover=sbfEnable specific types only
-coverageCollect coverage during simulation
-do "..."Execute tcl commands inline

Coverage Types

FlagType
sStatement
bBranch
cCondition
eExpression
fFSM
tToggle (x for extended, e.g. 1→Z)

The script creates a .ucdb (unified coverage database) file. The vcover report -html command generates a covhtmlreport folder with the HTML report.

Example: Mod-16 Up-counter with Coverage

Author
Mayur Kubavat
VLSI Design and Verification Engineer sharing knowledge about SystemVerilog, UVM, and hardware verification methodologies.

Comments (0)

Leave a Comment