Structural Coverage Metrics
When Simulink® Coverage™ measures coverage for a model, it uses the same principles used in code coverage. In code coverage, you create tests to show that every line of code executes to show that there is no unexpected behavior in your program. Simulink Coverage applies the same measurement to your Simulink model. Simulink Coverage analyzes your model and reports which blocks and logical branches of the model are active during the simulation.
Structural coverage metrics analyze the structural elements of your model, such as blocks and Stateflow® charts, and report how much of the model and, if applicable, logical branches execute. The four structural coverage metrics for model coverage are block execution coverage, decision coverage, condition coverage, and modified condition decision coverage (MCDC).
For more information about these and other coverage metrics, see Types of Model Coverage.
Block Execution Coverage
Block execution coverage tells you whether each block executes during simulation. The code coverage metric that block execution coverage is most similar to is statement coverage.
Most blocks receive execution coverage, although there are some types of blocks which do not receive any coverage metrics. For more information, see Model Objects That Do Not Receive Coverage.
Decision coverage analyzes decision points in your code or model. In code coverage, a decision is a Boolean expression composed of one or more conditions and zero or more Boolean operators. In model coverage, a decision is a place in your model where the value of one or more input signals decide the output signal of a block.
In code coverage, the decision
A && B has 100% decision
coverage if the decision is
true for at least one time step, and
false for at least one time step, regardless of the outcomes of the individual
conditions inside the decision. Similarly, in model coverage, a
Switch block has 100% decision coverage if the
true case is executed for at least one time step, and the
false case is executed for at least one time step.
Condition Decision Coverage
Condition Decision coverage analyzes both decision points and the conditions that
make up the decisions. In code coverage, a condition is a Boolean expression that
does not contain Boolean operators. In other words, it is a Boolean expression that
cannot be broken down into simpler Boolean expressions. An example of a condition is
an expression like
A, where the outcome is
In model coverage, condition coverage analyzes blocks that output the logical
combination of their input. An example of a condition in a model is the
Logical Operator block. A Logical Operator block
with the operator set to
And would output
if all of its input signals are
true. This is what is meant by the logical combination of its
A has 100% coverage if the condition is
true for at least one time step, and
for at least one time step. Similarly, the Logical Operator block has
100% condition coverage if each of its input signals is
at least one time step, and
false for at least one time step. In
this example model, the signals
Boolean values in the model which represent the same conditions as the code
Modified Condition Decision Coverage (MCDC)
MCDC is condition decision coverage, except each condition must independently affect the decision outcome.
In code coverage, MCDC analyzes code to test that every entry and exit point of a program is invoked at least once, and every condition and decision has taken every possible outcome at least once. In addition, each condition must independently affect the decision outcome.
Using the same example with the decision
A && B, to
achieve 100% MCDC coverage, the conditions must show
FT. You need these three outcomes
in order to show that each condition independently
affects the outcome of the block. The
FF outcome is not needed
because this does not change the decision outcome from the
In model coverage, MCDC looks for decision reversals that occur because one
condition outcome changes from
true. An example of a block
that receives MCDC coverage is the Logical Operator block.
An And block would have 100% MCDC coverage if each input condition
outcome changes, independently affecting the
outcome of the decision. For example, an And block with two input
conditions must show three outcomes. The
true case where both
input conditions are true, and two false cases, where condition 1 is false while
condition 2 is true, and vice-versa.