24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UM-334 13 - Measuring code coverage<br />

Introduction<br />

Usage flow for code coverage<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong><br />

<strong>ModelSim</strong> code coverage gives you graphical <strong>and</strong> report file feedback on which statements,<br />

branches, conditions, <strong>and</strong> expressions in your source code have been executed. It also<br />

measures bits of logic that have been toggled during execution.<br />

With coverage enabled, <strong>ModelSim</strong> counts how many times each executable statement,<br />

branch, condition, expression, <strong>and</strong> logic node in each instance is executed during<br />

simulation. Statement coverage counts the execution of each statement on a line<br />

individually, even if there are multiple statements in a line. Branch coverage counts the<br />

execution of each conditional "if/then/else" <strong>and</strong> "case" statement <strong>and</strong> indicates when a true<br />

or false condition has not executed. Condition coverage analyzes the decision made in "if"<br />

<strong>and</strong> ternary statements <strong>and</strong> is an extension to branch coverage. Expression coverage<br />

analyzes the expressions on the right h<strong>and</strong> side of assignment statements, <strong>and</strong> is similar to<br />

condition coverage. Toggle coverage counts each time a logic node transitions from one<br />

state to another.<br />

Coverage statistics are displayed in the Main, Objects, <strong>and</strong> Source windows <strong>and</strong> also can<br />

be output in different text reports (see "Reporting coverage data" (UM-350)). Raw coverage<br />

data can be saved <strong>and</strong> recalled, or merged with coverage data from the current simulation<br />

(see "Saving <strong>and</strong> reloading coverage data" (UM-354)).<br />

<strong>ModelSim</strong> code coverage offers these benefits:<br />

It is totally non-intrusive because it’s inte grated into the <strong>ModelSim</strong> engine – it doesn’t<br />

require instrumented HDL code as do third-party coverage products.<br />

It has very little impact on simulation performance (typically 5 to 10 percent).<br />

It allows you to merge sets of coverage data without requiring elaboration of the design<br />

or a simulation license.<br />

The following is an overview of the usage flow for simulating with code coverage. More<br />

detailed instructions are presented in the sections that follow.<br />

1 Compile the design using the -cover bcest argument to vcom (CR-311) or vlog (CR-358).<br />

2 Simulate the design using the -coverage argument to vsim (CR-373).<br />

3 Run the design.<br />

4 Analyze coverage statistics in the Main, Objects, <strong>and</strong> Source windows.<br />

5 Edit the source code to improve coverage.<br />

6 Re-compile, re-simulate, <strong>and</strong> re-analyze the statistics <strong>and</strong> design.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!