Search code examples
vhdlcode-coveragemodelsim

Modelsim 2021.4 (Windows): How to exclude files from code coverage report


I am trying to exclude certain vhdl files from my code coverage report, but I can't get it to work. My report always shows all available files.

My workflow is as follows:

  1. in Modelsim I compile the files manually (in the GUI) with the Code Coverage option.
  2. the testbench is scripted like this
# Start simulation
vsim -coverage work.core_tb -t 1ps 
do wave/core_wave.do
view wave -undock
when -label end_of_simulation {end_of_sim == '1'} {echo "End of simulation" ; stop ;

coverage exclude -src ../../../design/hdl/FILE_1.vhd
coverage exclude -src ../../../design/hdl/FILE_2.vhd
coverage exclude -src ../../../design/hdl/FILE_3.vhd

coverage report -output ../../../design/sim/cc_reports/report.txt -srcfile=* -assert -directive -cvg -codeAll};

run -all
wave zoomfull

# Copy simulation results to local directory
file copy -force ./_Log.txt ../../../design/sim/sim_reports/safety_core_sim_results.txt

Modelsim recognizes my exclusions (in the GUI) as "pending exclusions". When I apply them manually (in the GUI), the files shown in the "Instance coverage" window are reduced as intended. But why does the report not change/adjust? What am I doing wrong?

Edit: It seems that it worked that way with an older Modelsim Version.


Solution

  • The solution is to deactivate ‘Two-Step Exclusions’ option. To deactivate it go to the Modelsim menu:

    Tools > Coverage Configuration and disable ‘Two-Step Exclusions’ menu option.

    Alternatively the following TCL command could be used:

    coverage configure -2stepexclusion off
    

    When the ‘Two-Step Exclusions’ option is active it means that any applied exclusions always go to the ‘pending exclusions’ tab first.