| Stateflow User's Guide | ![]() |
Model Coverage for Truth Tables
Stateflow reports model coverages for the decisions made by the objects in a Stateflow diagram during model simulation. The model coverage report includes coverage for the decisions made by a truth table function. This section examines model coverage for an example truth table, check_temp, which is tested during simulation in the following Stateflow diagram:
The following shows the contents of the check_temp truth table:
You generate model coverage reports for a model during simulation. You first specify the creation of the reports in Simulink and then simulate the model. When simulation ends, a model coverage report appears in a browser window. See Making Model Coverage Reports for information on how to set up a model coverage report.
The following is the part of a model coverage report that reports on the check_temp truth table:
Coverage for the truth table function in the Coverage (this object) column shows no valid coverage values. The reason for this is that the container object for the truth table function, the chart, makes no decision on whether to execute the check_temp truth table or not.
Stateflow implements a truth table by generating a graphical function for it. The decision logic of the truth table is implemented internally in the transitions of the graphical function generated for the truth table See How Stateflow Realizes Truth Tables for a description of the generated graphical function for a truth table.
The transitions of the generated graphical function for a truth table 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, which are tested when the truth table function is called.
In the case of the check_temp truth table, the only decision covered in the model coverage report is the D1 decision. There is no model coverage for the default decision, D2.
Coverages for the D1 decision and its individual conditions in the check_temp truth table function are as follows:
Because each condition can have an outcome value of T or F, three conditions can have 6 possible values. During simulation, only 5 of 6 were tested. The D1 decision coverage column shows that the last condition received partial condition coverage by not evaluating to false (F) during simulation. The missing occurrence of the false (F) condition outcome is indicated by the appearance of a red F character.
T to F or from F to T. The D1 decision reverses when any of the conditions changes from T to F. This means that the outcomes FTT, TFT, and TTF reverse this decision by a change in the value of one condition.
The top two conditions for the D1 decision tested both true (T) and false (F) with a resulting reversal in the decision from true (T) to false (F). However, the bottom condition tested only a true (T) outcome but no false (F) outcome (appearance of red F character). Therefore, two of a possible three reversals were observed and coverage is 2/3 = 67%.
(ok) next to the ON action label indicates that its decision realized both true (T) and false (F) during simulation. Because the default decision is based on no logic of its own, it does not receive the (ok) mark.
| Defining an Underspecified Truth Table | How Stateflow Realizes Truth Tables | ![]() |
© 1994-2005 The MathWorks, Inc.