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
| Option | Description |
|---|---|
-coveropt 3 | Sets optimization level to 3 |
+cover | Enables all coverage types (s,b,c,e,f,t) |
+cover=sbf | Enable specific types only |
-coverage | Collect coverage during simulation |
-do "..." | Execute tcl commands inline |
Coverage Types
| Flag | Type |
|---|---|
s | Statement |
b | Branch |
c | Condition |
e | Expression |
f | FSM |
t | Toggle (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
Comments (0)
Leave a Comment