EE 560 - Summer 2025 Digital Systems Design

Week 6 - Code Coverage

See subfolder Labs/Lab06b-Code-Coverage.

Overview

In this lab, we provide a working number lock state machine design and have you complete the testcases in the testbench and run code coverage to ensure your tests are comprehensive and cover all the statements and conditions in the design.

Procedure

Part 0

  1. Download and extract the .zip file containing the source code files:
    • src/des/number_lock.vhd (complete)
    • src/tb/number_lock_tb.vhd (to be completed by you)
    • sim/coverage.do (to be completed)
  2. Understand the design and given portion of the test bench provided.
  3. Note that to enable coverage, the compilation command must include the -cover <flags> option/argument
    • vcom -cover bcesxf <design_filename.vhd> to vcom
  4. Similarly, the simulation command must include the -coverage option:
    • vsim -coverage work.<testbench_top_entity_name>

Part 1: Running Modelsim Code Coverage

  1. Update the sim/coverage.do file in an editor to include the necessary options/flags shown aboe in Part 0.
  2. Invoke Questasim and use File..Change Directory to the sim folder of this design.
  3. Compile and run the simulation by executing: do coverage.do

Part2: Analyzing the Code Coverage result – Statement Coverage

Part3: Add TestCases

Part4: Exploring DeadCode

Once you have achieved 100% coverage, take a moment to uncomment the lines 51, 99, 100 (or potentially slightly differt) and then COMMENT line 52.

You should see full coverage except for these lines:

image image

And the final Instance percentages should be:

image

Submission

submit -user ee560 -tag code-cov number_lock_tb.vhd names.txt

NOTE:* We are NOT running automated tests. This submission is just to collect and review your work. So your submission will automatically trigger the Congratulations result. The VAST MAJORITY of your points will come form your Demo (see below).