types of model coverage
simulink® coverage™ can perform several types of coverage analysis.
execution coverage (ec)
execution coverage is the most basic form of coverage. for each item, execution coverage determines whether the item is executed during simulation.
decision coverage (dc)
decision coverage analyzes elements 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 traversed.
for an example of decision coverage data in a model coverage report, see decisions analyzed.
condition coverage (cc)
condition coverage analyzes blocks that output the logical combination of their inputs (for example, the logical operator block) and stateflow transitions. a test case achieves full coverage when 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 whether the test case fully covered the block for each block in the model.
when you collect coverage for a model, you may not be able to achieve 100% condition coverage. for example, if you specify to short-circuit logic blocks, by selecting treat simulink logic blocks as short-circuited in the coverage pane in the configuration parameters, you might not be able to achieve 100% condition coverage for that block. see mcdc analysis for more information.
for an example of condition coverage data in a model coverage report, see conditions analyzed.
modified condition/decision coverage (mcdc)
modified condition/decision coverage analysis by the simulink coverage software extends the decision and condition coverage capabilities. it analyzes blocks that output the logical combination of their inputs 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 when a change in one input, independent of any other inputs, causes a change in the block output.
a test case achieves full coverage for a stateflow transition when there is at least one time when a change in the condition triggers the transition for each condition.
if your model contains blocks that define expressions that have different types of logical operators and more than 12 conditions, the software cannot record mcdc coverage.
because the simulink coverage mcdc coverage may not achieve full decision or condition coverage, you can achieve 100% mcdc coverage without achieving 100% decision coverage.
some simulink objects support mcdc coverage, some objects support only condition coverage, and some objects support only decision coverage. the table in lists which objects receive which types of model coverage. for example, the combinatorial logic block can receive decision coverage and condition coverage, but not mcdc coverage.
to achieve 100% mcdc coverage for your model, as defined by the do-178c/do-331 standard, in the coverage pane of the configuration parameters, select modified condition/decision coverage (mcdc) as the structural coverage level.
when you collect coverage for a model, you may not be able to achieve 100% mcdc coverage. for example, if you specify to short-circuit logic blocks, you may not be able to achieve 100% mcdc coverage for that block.
if you run the test cases independently and accumulate all the coverage results, you can determine if your model adheres to the modified condition and decision coverage standard. for more information about the do-178c/do-331 standard, see (simulink check).
for an example of mcdc coverage data in a model coverage report, see mcdc analysis. for an example of accumulated coverage results, see cumulative coverage.
cyclomatic complexity
use this metric to calculate the cyclomatic complexity of the model. cyclomatic complexity is a measure of the structural complexity of a model. the complexity measure for the model can be different than the generated code due to code features that this analysis does not consider, such as consolidated logic and error checks.
to compute the cyclomatic complexity of an object (such as a block, chart, or state), model coverage uses the following 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 calculation considers a vectorized operation or a multiport switch block as a single decision point. the tool adds 1 to the complexity number for atomic subsystems and stateflow charts.
the results provide local and aggregated cyclomatic complexity for the:
model
subsystems
charts
matlab® functions
local complexity is the cyclomatic complexity for objects at their hierarchical level. aggregated cyclomatic complexity is the cyclomatic complexity of an object and its descendants.
cyclomatic complexity:
does not run on library models.
analyzes content in masked subsystems.
does not analyze inactive variants.
if specified, analyzes the content of library-linked blocks or referenced models.
does not analyze referenced models in accelerated mode.
for an example of cyclomatic complexity data in a model coverage report, see cyclomatic complexity in the model coverage report. for more information about cyclomatic complexity for code, see .
lookup table coverage
lookup table coverage (lut) examines blocks, such as the 1-d lookup table block, that output information from inputs in a table of inputs and outputs, interpolating between or extrapolating from table entries. lookup table coverage records the frequency that table lookups use each interpolation interval. a test case achieves full coverage when 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 each interpolation. if the total number of breakpoints of an n-d lookup table block exceeds 1,500,000, the software cannot record coverage for that block.
for an example of lookup table coverage data in a model coverage report, see n-dimensional lookup table.
note
configure lookup table coverage only at the start of a simulation. if you tune a parameter that affects lookup table coverage at run time, the coverage settings for the affected block are not updated.
signal range coverage
signal range coverage records the minimum and maximum signal values at each block in the model, as measured during simulation. only blocks with output signals receive signal range coverage.
the software does not record signal range coverage for control signals, signals used by one block to initiate execution of another block. see .
if the total number of signals in your model exceeds 65535, or your model contains a signal whose width exceeds 65535, the software cannot record signal range coverage.
for an example of signal range coverage data in a model coverage report, see signal range analysis.
note
when you create cumulative coverage for reusable subsystems or stateflow constructs with single range coverage, the cumulative coverage has the largest possible range of signal values. for more information, see .
signal size coverage
signal size coverage records the minimum, maximum, and allocated size for all variable-size signals in a model. only blocks with variable-size output signals are included in the report.
if the total number of signals in your model exceeds 65535, or your model contains a signal whose width exceeds 65535, the software cannot record signal size coverage.
for an example of signal size coverage data in a model coverage report, see signal size coverage for variable-dimension signals.
for more information about variable-size signals, see .
objectives and constraints coverage
the simulink coverage software collects model coverage data for the following simulink design verifier™ blocks and matlab for code generation functions:
simulink design verifier blocks | matlab for code generation functions |
---|---|
(simulink design verifier) | (simulink design verifier) |
(simulink design verifier) | (simulink design verifier) |
(simulink design verifier) | (simulink design verifier) |
(simulink design verifier) | (simulink design verifier) |
if you do not have a simulink design verifier license, you can collect model coverage for a model that contains these blocks or functions, but you cannot analyze the model using the simulink design verifier software.
by adding one or more simulink design verifier blocks or functions into your model, you can:
check the results of a simulink design verifier analysis, run generated test cases, and use the blocks to observe the results.
define model requirements using the test objective block and verify the results with model coverage data that the software collected during simulation.
analyze the model, create a test harness, and simulate the harness with the test objective block to collect model coverage data.
analyze the model and use the proof assumption block to verify any counterexamples that the simulink design verifier identifies.
if you specify to collect simulink design verifier coverage:
the software collects coverage for the simulink design verifier blocks and functions.
the software checks the data type of the signal that links to each simulink design verifier block. if the signal data type is fixed point, the block parameter must also be fixed point. if the signal data type is not fixed point, the software tries to convert the block parameter data type. if the software cannot convert the block parameter data type, the software reports an error and you must explicitly assign the block parameter data type to match the signal.
if your model contains a verification subsystem block, the software only records coverage for simulink design verifier blocks in the (simulink design verifier) block; it does not record coverage for any other blocks in the verification subsystem.
if you do not specify to collect simulink design verifier coverage, the software does not check the data types for any simulink design verifier blocks and functions in your model and does not collect coverage.
for an example of coverage data for simulink design verifier blocks or functions in a model coverage report, see simulink design verifier coverage.
saturate on integer overflow coverage
saturate on integer overflow coverage examines blocks, such as the abs block, with the saturate on integer overflow parameter selected. only blocks with this parameter selected receive saturate on integer overflow coverage.
saturate on integer overflow coverage records the number of times the block saturates on integer overflow.
a test case achieves full coverage when the blocks saturate on integer overflow at least once and does not saturate at least once.
for an example of saturate on integer overflow coverage data in a model coverage report, see saturate on integer overflow analysis.
relational boundary coverage
relational boundary coverage examines blocks, stateflow charts, and matlab function blocks that have an explicit or implicit relational operation.
blocks such as and have an explicit relational operation.
blocks such as and have an implicit relational operation.
for these model objects, the metric records whether a simulation tests the relational operation with:
equal operand values.
this part of relational boundary coverage applies only if both operands are integers or fixed-point numbers.
operand values that differ by a certain tolerance.
this part of relational boundary coverage applies to all operands. for integer and fixed-point operands, the tolerance is fixed. for floating-point operands, you can either use a predefined tolerance or you can specify your own tolerance.
the tolerance value depends on the data type of both the operands. if both operands have the same type, the tolerance follows the following rules:
data type of operand | tolerance |
---|---|
floating point, such as single or
double |
|
fixed point | value corresponding to least significant bit. for more information, see (fixed-point designer). to find the precision value, use the (fixed-point designer) function. |
integer | 1 |
boolean | n/a |
enum | n/a |
if the two operands have different types, the tolerance follows the rules for the stricter type. if one of the operands is boolean, the tolerance follows the rules for the other operand. the strictness decreases in this order:
floating point
fixed point
integer
if both operands are fixed point but have different precision, the smaller value of precision is used as tolerance.
for relational boundaries with floating point data types, the coverage report uses
standard interval notation where square brackets, []
, indicate
inclusion and round brackets, ()
, indicate exclusion. for
example, a table that shows [-tol..0)
represents
the statement value >= -tol && value < 0
.
you specify the value of absolute and relative tolerances for relational boundary coverage of floating point inputs when you select this metric in the coverage metrics section in the of the configuration parameters dialog box.
for more information on:
how this coverage metric appears in reports, see relational boundary.
which model objects receive this coverage, see the table in .
how to obtain coverage results from the matlab command-line, see .