Introduction to Model Coverage

What Is Model Coverage?

Model coverage determines the extent to which a model test case exercises simulation pathways through a model. The percentage of pathways that a test case exercises is called its model coverage. Model coverage is a measure of how thoroughly a test tests a model. Model coverage therefore helps you to validate your model tests.

How Model Coverage Works

Model coverage works by analyzing the execution of blocks that directly or indirectly determine simulation pathways through your model. If a model includes Stateflow® charts, the tool also analyzes the states and transitions of those charts. During a simulation run, the tool records the behavior of the covered blocks, states, and transitions. At the end of the simulation, the tool reports the extent to which the run exercised potential simulation pathways through each covered block.

See Understanding Model Coverage Reports for an example of a model coverage report along with descriptions of the coverages it contains. Before you do, you might need to review the types of coverages that model coverage performs in Types of Model Coverage.

Types of Model Coverage

The tool performs several types of coverage analysis, depending on the coverage options you select.

Cyclomatic Complexity

Cyclomatic complexity is a measure of the structural complexity of a model. It approximates the McCabe complexity measure for code generated from the model. In general, the McCabe complexity measure is slightly higher because of error checks that the model coverage analysis does not consider.

Model coverage uses the following formula to compute the cyclomatic complexity of an object (such as a block, chart, or state):

In this formula, N is the number of decision points that the object represents and on is the number of outcomes for the nth decision point. The tool adds 1 to the complexity number computed by this formula for atomic subsystems and Stateflow charts.

Decision Coverage (DC)

Decision coverage examines items that represent decision points in a model, such as a Switch block or Stateflow states. For each item, decision coverage determines the percentage of the total number of simulation paths through the item that the simulation actually traversed.

Condition Coverage (CC)

Condition coverage examines blocks that output the logical combination of their inputs (for example, the Logic block), and Stateflow transitions. A test case achieves full coverage if it causes each input to each instance of a logic block in the model and each condition on a transition to be true at least once during the simulation and false at least once during the simulation. Condition coverage analysis reports for each block in the model whether the test case fully covered the block.

Modified Condition/Decision Coverage (MC/DC)

Modified condition/decision coverage examines blocks that output the logical combination of their inputs (for example, the Logic block), and Stateflow transitions to determine the extent to which the test case tests the independence of logical block inputs and transition conditions. A test case achieves full coverage for a block if, for every input, there is a pair of simulation times when changing that input alone causes a change in the block's output. A test case achieves full coverage for a transition if, for each condition on the transition, there is at least one time when a change in the condition triggers the transition.

Lookup Table Coverage (LUT)

Lookup table coverage examines blocks, such as the Lookup Table block, that output the result of looking up one or more inputs in a table of inputs and outputs, interpolating between or extrapolating from table entries as necessary. Lookup table coverage records the frequency that table lookups use each interpolation interval. A test case achieves full coverage if it executes each interpolation and extrapolation interval at least once. For each lookup table block in the model, the coverage report displays a colored map of the lookup table indicating where each interpolation was performed.

Blocks That Receive Model Coverage

The following table lists the Simulink® blocks analyzed by the tool and the kind of coverage analysis performed for each block.

Block

Decision

Condition

MC/DC

LUT

1D Lookup

   

2D Lookup

   

ND Lookup

   

Interpolation Using Prelookup

   

ND Direct Lookup

   

Abs

   

Combin. Logic

  

Discrete-Time Integrator (when saturation limits are enabled)

   

Embedded MATLAB™ Function

 

Fcn (Boolean operators only)

 

  

For

   

If

   

Logic

 

 

MinMax

   

Model

Multiport Switch

   

Rate Limiter

(Relative to slew rates)

   

Relay

   

Saturation

   

Stateflow (see note below)

 

Subsystem

 

Switch

   

SwitchCase

   

While

   

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS