Monday, 8 June 2015

Generate Code Coverage Report with QuestaSim

To generate code coverage reports in questasim, there are few lines of code you need to add in tcl script .do files.

################################################################################
#Create a directory where compilation files are stored, default is 'work'
vlib work

#Compile design in that order
vlog -coveropt 3 +cover +acc mod16_counter.v mod16_tb.v

#Load the top module for simulation
vsim -coverage -vopt work.mod16_tb -c -do "coverage save -onexit -directive -codeAll mod16_cov; run -all; exit"

vcover report -html mod16_cov
#################################################################################

Explanation:-


  1. Command "-coveropt 3" sets optimization level to 3
  2. "+cover" enables code coverage, by default all types of coverage (s, b, c, e, f, t) are enabled. To enable only certain coverage types, use "+cover=sbf". Here, s = Statement, b = Branch, c = Condition, e = Expression, f = FSM, t = toggle (use "x" for extended toggle coverage,           e.g. 1->Z).
  3. It then follows files to be compiled.
  4. Option "-coverage" with vsim is used to collect coverage information.
  5. "-do" is a tcl script command used to execute multiple statements inside double quotes.
  6. It will create .ucdb (unified coverage database) file to collect coverage information
  7. "vcover report -html mod16_cov" is used to create HTML file from .UCDB file. It will create a folder named covhtmlreport which will have coverage information in an HTML file.
A typical coverage report looks like this,


Checkout below link for Coverage Example of Mod-16 Up-counter.