Main Content

Model Coverage for Stateflow Truth Tables

Types of Coverage in Stateflow Truth Tables

Simulink® Coverage™ reports model coverage for the decisions the objects make in a Stateflow® chart during simulation. The report includes coverage for the decisions the truth table functions make.

For this type of truth table...The report includes coverage data for...
Stateflow Classic

Conditions only.

MATLAB®

Conditions and only those actions that have decision points.

Note

With the MATLAB for code generation action language, you can specify decision points in actions using control flow constructs, such as loops and switch statements.

Note

To measure model coverage data for a Stateflow truth table, you must have a Stateflow license. For more information about Stateflow truth tables, see Obtain Cumulative Coverage for Reusable Subsystems and Stateflow® Constructs.

Analyze Coverage in Stateflow Truth Tables

If you have a Stateflow license, you can generate a model coverage report for a truth table.

Consider the following model.

The Stateflow chart contains the following truth table:

When you simulate the model and collect coverage, the model coverage report includes the following data:

The Coverage (this object) column shows no coverage. The reason is that the container object for the truth table function—the Stateflow chart—does not decide whether to execute the ttable truth table.

The Coverage (inc. descendants) column shows coverage for the truth table contents. Coverage for the descendants in the Coverage (inc. descendants) column includes coverage for the conditions and decisions of the logical expressions represented by the truth table.

Coverage for the decisions and their individual conditions in the ttable truth table function are as follows:

CoverageExplanation

No model coverage for the default decision, D4

All logic that leads to taking a default decision is based on a false outcome for all preceding decisions. This means that the default decision requires no logic, so there is no model coverage.

17% (1/6) decision coverage

The three constants that are inputs to the truth table (1, 0, 0) cause only decision D1 to be true. These inputs satisfy only one of the six decisions (D1 through D3, T or F).

Because each condition can have an outcome value of T or F, three conditions can have six possible values.

17% (3/18) condition coverage

Three decisions D1, D2, and D3 have condition coverage, because the set of inputs (1, 0, 0) make only decision D1 true.

0% (0/9) MCDC coverage

MCDC coverage looks for decision reversals that occur because one condition outcome changes from T to F or F to T. The simulation tests only one set of inputs, so the model reverses no decisions.

Missing coverage

The red letters T and F indicate that model coverage is missing for those conditions. For decision D1, only the T decision is satisfied. For decisions D2, D3, and D4, none of the conditions are satisfied.