Products & Services Solutions Academia Support User Community Company

Learn more about Stateflow   

Checking Model Coverage for Truth Tables

Types of Coverage in Stateflow Truth Tables

Simulink Verification and Validation software reports model coverage for the decisions the objects make in a Stateflow chart during model 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.

Embedded MATLAB

Conditions and only those actions that have decision points.

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

Generating a Model Coverage Report

This section examines model coverage for a modified version of the truth table you created in Programming a Truth Table. Take the following steps to modify the truth table and generate model coverage data:

  1. Open the model first_truth_table.

  2. Open the truth table in the Stateflow chart for editing.

  3. Modify the truth table:

    1. In the Condition Table, add a decision column to the left of the existing D4 column.

      The new column becomes D4 and the existing column becomes D5.

    2. Enter - for conditions 1 and 2, enter T for condition 3, and specify action A4.

    3. In the Action Table, create an action 6 that executes t=5 and label it A5.

    The truth table logic now looks like the following, with the new rows highlighted.

  4. Save the truth table.

  5. In the Model Editor, select Tools > Coverage Settings.

  6. To enable model coverage during simulation, on the Coverage tab, select Coverage for this model: first_truth_table.

  7. Click OK to close the Coverage Settings dialog box.

  8. In the Model Editor, change the stop time to 10 so that the simulation stops after 10 seconds.

  9. To start the simulation, select Simulation > Start.

  10. After the simulation completes, the software creates a model coverage report.

Analyzing Coverage in Stateflow Truth Tables

In the model coverage report, scroll down to the section that shows the model coverage data for the truth table ttable.

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 graphical function. The graphical function has the decision logic that makes the transitions for the truth table. The transitions in the graphical function contain the decisions and conditions of the truth table. Coverage for the descendants in the Coverage (inc. descendants) column includes coverage for these conditions and decisions. Function calls to the truth table test the model coverage of these conditions and decisions.

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, D5

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.

13% (1/8) 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 eight decisions (D1 through D4, T or F).

Because each condition can have an outcome value of T or F, three conditions can have six possible values. However, decision D4 has only decision coverage, not condition coverage or MCDC coverage, because it represents a decision with a single predicate.

3 of the 18 (17%) condition coverage

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

No (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. MCDC 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.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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