Main Content

Correct Overspecified and Underspecified Truth Tables

When programming your truth table, you might program an overspecified or underspecified truth table. An overspecified truth table contains at least one true or false combination that is specified by another decision column. When this happens, the action associated with that decision column never executes. An underspecified truth table occurs when your truth table does not have enough decision columns to account for all possible true or false combinations.

By default, Stateflow®reports an error for overspecified and underspecified truth tables. To adjust the error settings for truth tables, open your truth table. After opening the truth table, in theModelingtab, clickTable Propertiesand change the settings forUnderspecificationorOverspecification.

Truth tables are not supported in standalone Stateflow charts in MATLAB®. For more information, seeUse Truth Tables to Model Combinatorial Logic.

Example of an Overspecified Truth Table

An overspecified truth table contains at least one decision that never executes because a previous decision specifies it in theCondition Table. The following example shows theCondition Tableof an overspecified truth table.

The decision in columnD3(-TT) specifies the decisionsFTTandTTT. These decisions are duplicates of decisionsD1(FTT) andD2(TTTandTFT). Therefore, columnD3is an overspecification.

The following example shows theCondition Tableof a truth table that appears to be overspecified, but is not.

In this case, the decisionD4specifies two decisions (TTTandFTT).FTTalso appears in decisionD1, butTTT不是一个复制。因此,该Condition Tableis not overspecified.

遗漏一个真值表的例子

An underspecified truth table includes undefined behavior because it lacks decisions that cover every combination of the specified conditions.. The following example shows theCondition Tableof an underspecified truth table.

Complete coverage of the conditions in the preceding truth table requires aCondition Tablewith every possible decision:

To avoid underspecification specify an action for all other possible decisions through a default decision, namedDA:

The last decision column,D4, is the default decision for the truth table. The default decision covers any remaining decisions not tested in the preceding decision columns. SeeThe Default Decision Columnfor an example and more complete description of the default decision column for aCondition Table.

相关的话题