Stateflow Object Constraints

Stateflow Blocks

Stateflow® Block ConstraintFATAL / NonfatalCompatibility Check
Function packaging (RTWSystemCode) must be set to Inline or Nonreusable function. The subsystem must be in supported configurations for Nonreusable function. Simulink® Code Inspector™ supports the Chart (Stateflow) block for code inspection.NonfatalCheck usage of Stateflow blocks

Stateflow Charts

Chart (Stateflow) ConstraintFATAL / NonfatalCompatibility Check

The chart must not contain any of the following objects:

  • Atomic Subcharts

  • Atomic Boxes

  • MATLAB® functions

  • Simulink based states

FATALCheck usage of Stateflow charts > Check usage of Stateflow object palette
A chart that uses MATLAB action language must have unique names for the Simulink functions, graphical functions, and truth tables it contains.NonfatalCheck usage of Stateflow charts >Check name usage in a Stateflow chart that uses MATLAB action language
The MATLAB code in a chart that uses MATLAB action language must follow the same constraints as the code in MATLAB Function blocks.NonfatalCheck usage of Stateflow MATLAB action language
Chart property Create data for monitoring child activity must not be selected.NonfatalCheck usage of Stateflow charts > Check that all charts unselect ‘Create data for monitoring child activity’ option
Chart property Update method must be set to Inherited.NonfatalCheck usage of Stateflow charts > Check that all charts specify 'Inherited' as their update method
States and substates in the chart must have default transitions.NonfatalCheck usage of Stateflow charts >Check that states or substates have a default transition
Chart property Enable Super Step Semantics must not be selected.NonfatalCheck usage of Stateflow charts > Check that all charts unselect ‘Enable Super Step Semantics’ option
Chart property Execute (enter) Chart at Initialization must not be selected.Nonfatal<Check usage of Stateflow charts > Check that no charts execute at initialization
Chart property Export Chart Level Functions must not be selected.NonfatalCheck usage of Stateflow charts > Check that no charts export chart level functions
Chart property Saturate on integer overflow must not be selected.NonfatalCheck usage of Stateflow charts > Check that no charts specify saturation on overflow for integer operations
Chart property State Machine Type must not be set to Moore.NonfatalCheck usage of Stateflow charts > Check usage of State Machine Type
Chart property Support variable-size arrays must not be selected.FATALCheck usage of Stateflow charts > Check that no charts support variable-size arrays
The control flow must not have more than 1 default transition.NonfatalCheck usage of Stateflow charts > Check that all control flows have unique default transitions

Stateflow Data and Events

Data or Event ConstraintFATAL / NonfatalCompatibility Check
Stateflow data must not be of machine scope.NonfatalCheck for Stateflow machine data > All Stateflow data must be parented by a Stateflow chart
Stateflow events must not be of machine scope.NonfatalCheck for Stateflow machine events > All Stateflow events must be parented by a Stateflow chart
Chart must not define Stateflow data with Constant scope.NonfatalCheck usage of Stateflow data > Check that the chart does not define Stateflow data with Constant scope
InitializeMethod for Local or Output scope Stateflow data must not be set to Parameter. NonfatalCheck usage of Stateflow data > Check usage of Stateflow data Initialize Method

Chart data types must be builtin, enumerated, or bus.

  • If the chart data type is a bus and:

    • Chart uses C as the action language, the data must not be arrays of buses or have elements that are arrays of buses.

    • Chart uses MATLAB as the action language, the data can be arrays of buses or have elements that are arrays of buses.

  • If the chart data type is enumerated, the default value of the data must be 0.

NonfatalCheck usage of Stateflow data > Check that Stateflow data is of a supported data type
The First Index property for Stateflow data must be empty or 0.NonfatalCheck usage of Stateflow data > Check that the 'First Index' of Stateflow data are empty or 0
Size of Stateflow parameter data must be the same in Stateflow and the base workspace.NonfatalCheck usage of Stateflow data > Check that Stateflow parameter data sizes in Stateflow and the base workspace match
Chart must not use complex data.NonfatalCheck usage of Stateflow data > Check that the chart uses only non-complex data
Stateflow states and boxes must not define Stateflow data.NonfatalCheck usage of Stateflow data > Check that states and boxes do not define Stateflow data
Event scope must be Output or Local.NonfatalCheck usage of Stateflow events > Check that the chart uses only events of scope Local or Output
Event trigger must be a function-call.NonfatalCheck usage of Stateflow events > Check that the chart uses only function-call events

Stateflow Graphical Functions

Graphical Function ConstraintFATAL / NonfatalCompatibility Check
Graphical function must not contain control flow cycles.FATALCheck usage of Stateflow graphical functions > Check that control flows do not have cycles
Graphical function property Function Inline Option (InlineOption) must be Inline or Function.NonfatalCheck usage of Stateflow graphical functions > Check usage of InlineOption setting
For a graphical function with Function Inline Option (InlineOption) set to Function, the configuration parameter Code interface packaging (CodeInterfacePackaging) must be set to Nonreusable function.NonfatalCheck usage of Stateflow graphical functions > Check configuration for models with non-inlined graphical functions
Non-inlined graphical functions must have unique function names.NonfatalCheck usage of Stateflow graphical functions > Check non-inlined graphical function names
Graphical function must not be recursive.NonfatalCheck usage of Stateflow graphical functions > Check usage of recursive Stateflow function
Graphical function must not contain unstructured control flow.FATALCheck usage of Stateflow graphical functions > Check that control flows are structured
State must not have graphical function calls with different actual and expected argument data types.NonfatalCheck usage of Stateflow states > Check data type of Graphical Function arguments
State must not have graphical function calls with different actual and expected argument sizes.NonfatalCheck usage of Stateflow states > Check dimensions of Graphical Function arguments
Transition must not have graphical function calls with different actual and expected argument data types.NonfatalCheck usage of Stateflow transitions > Check data type of Graphical Function arguments
Transition must not have graphical function calls with different actual and expected argument dimensions.NonfatalCheck usage of Stateflow transitions >Check dimensions of Graphical Function arguments

Stateflow Simulink Functions

Simulink Function Constraint

FATAL / NonfatalCompatibility Check

Simulink function calls in states must have the same argument data type as the inports and outports in the defining Function-Call Subsystem.

NonfatalCheck usage of Stateflow states > Check data type of Simulink Function arguments
Simulink function calls in states must have the same argument size as the inports and outports in the defining Function-Call Subsystem.NonfatalCheck usage of Stateflow states > Check dimensions of Simulink Function arguments
Simulink function calls in transitions must have the same argument data type as the inports and outports in the defining Function-Call Subsystem. NonfatalCheck usage of Stateflow transitions > Check data type of Simulink Function arguments
Simulink function calls in transitions must have the same argument size as the inports and outports in the defining Function-Call Subsystem. NonfatalCheck usage of Stateflow transitions > Check dimensions of Simulink Function argument

Stateflow Junctions

Junction ConstraintFATAL / NonfatalCompatibility Check
Junctions must not have outgoing transitions jumping outside of a loop.NonfatalCheck usage of Stateflow junctions > Check that Stateflow junctions do not have outgoing transitions jumping outside of the loop
Non-terminating junctions must have exactly one unconditional transition exiting them.FATALCheck usage of Stateflow junctions > Check that non-terminating junctions have exactly one unconditional exiting transition
Chart must not contain a history junction.NonfatalCheck usage of Stateflow junctions > Check that the chart uses no history junctions
Header junctions must have two incoming and two outgoing transitions.NonfatalCheck usage of Stateflow junctions > Check that control flows do not have loops with unsupported header junctions
Terminating junctions must not trace back to a Stateflow state.NonfatalCheck usage of Stateflow junctions > Check usage of terminating Stateflow junctions
Unconditional transition must be last in order of execution.FATALCheck usage of Stateflow junctions > Check that unconditional transitions execute last in execution order
The chart must not contain unstructured control flow.NonfatalCheck usage of Stateflow junctions > Check that control flows are structured

Stateflow States

States (Stateflow) ConstraintFATAL / NonfatalCompatibility Check
States must not contain control flow cycles.FATALCheck usage of Stateflow states > Check that control flows do not have cycles

Action must be for one of these operations:

  • := or =

  • + , += , -, or -=

  • * , *=, / or /=

  • &, && or &=

  • |, || or |=

  • << or >>

  • cast()

  • ^ or ^=

  • %% or <

  • <= or ==

  • ~= or !=

  • <> or >

  • >= or ~

NonfatalCheck usage of Stateflow states > Check that actions do not have unsupported operations
Arrays of more than one dimension must not use indexing.NonfatalCheck usage of Stateflow states > Check for indexing in arrays that are more than one dimension
Arrays must use index of data type int32.NonfatalCheck usage of Stateflow states > Check that all arrays use index of type 'int32'
Action must not access context-sensitive constants.NonfatalCheck usage of Stateflow states > Check that no actions access context-sensitive constants
Action must not access custom data.NonfatalCheck usage of Stateflow states > Check that no actions access custom data
States and substates in the chart must have default transitions.NonfatalCheck usage of Stateflow states > Check that states or substates have a default transition

State must not use any of the following unsupported operations on enumeration type operands:

  • + or +=

  • - or -=

  • * or *=

  • / or /=

  • & or &=

  • | or |=

  • ^ or ^=

  • %%

NonfatalCheck usage of Stateflow states > Check that actions do not have unsupported operations on enumeration type operands

Math functions in actions must have:

  • Single or double type arguments for the following functions:

    • acos, asin, atan

    • ceil, cosh, cosh

    • exp, fabs, floor

    • fmod, ldexp, log

    • log10, pow, sin

    • sinh, sqrt, tan, tanh

  • Non-boolean arguments for the following functions:

    • abs, max, min

  • Integer type argument for the labs function.

NonfatalCheck usage of Stateflow states > Check that no actions contain a function whose argument is of an invalid data type
Action must not contain a binary operator with mixed data type operands.NonfatalCheck usage of Stateflow states > Check that no actions contain a binary operator whose operands are of mixed data type
Stateflow functions must not have more than 2 arguments.NonfatalCheck usage of Stateflow states > Check that no Stateflow functions have more than 2 arguments
Stateflow states must not have recursive send function calls.NonfatalCheck usage of Stateflow states > Check usage of States with recursive send function calls
State property Function Inline Option must not be Auto or Function.NonfatalCheck usage of Stateflow states > Check usage of Stateflow state InlineOption
State property Create data for monitoring must not be selected (set to on).NonfatalCheck usage of Stateflow states > Check that all states unselect ‘Create data for monitoring’ option
Actions must not access time.NonfatalCheck usage of Stateflow states > Check that no actions access time (t)
States must not contain unstructured control flow.NonfatalCheck usage of Stateflow states > Check that control flows are structured
The control flow must not have more than 1 default transition.NonfatalCheck usage of Stateflow states > Check that all control flows have unique default transitions
Paths from a state must be one of the following: inner transition to a substate, or outer transition to a sibling, direct parent, or direct substate.NonfatalCheck usage of Stateflow states > Check that all transition paths are either inner transitions to a substate, or outer transitions to siblings, direct parent, or direct substates
Actions must not contain an XOR operator with boolean operands when model parameter Casting modes is set to Standards.NonfatalCheck usage of Stateflow states > Check that no actions contain an xor operator with boolean operands
Charts must not have graphical function calls with unassigned outputs.NonfatalCheck usage of Stateflow states > Check unassigned graphical function outputs

Stateflow Transitions

Transitions (Stateflow) ConstraintFATAL / NonfatalCompatibility Check

Action must be for one of these operations:

  • := or =

  • + , += , -, or -=

  • * , *=, / or /=

  • &, && or &=

  • |, || or |=

  • << or >>

  • cast()

  • ^ or ^=

  • %% or <

  • <= or ==

  • ~= or !=

  • <> or >

  • >= or ~

NonfatalCheck usage of Stateflow transitions > Check that actions do not have unsupported operations
Arrays of more than one dimension must not use indexing.NonfatalCheck usage of Stateflow transitions > Check for indexing in arrays that are more than one dimension
Arrays must use index of data type int32.NonfatalCheck usage of Stateflow transitions > Check that all arrays use index of type 'int32'
Transition condition must be of Boolean data type.NonfatalCheck usage of Stateflow transitions > Check that all transition conditions are of boolean data type
Action must not access context-sensitive constants.NonfatalCheck usage of Stateflow transitions > Check that no actions access context-sensitive constants
Action must not access custom data.NonfatalCheck usage of Stateflow transitions > Check that no actions access custom data

Transition must not use any of the following unsupported operations on enumeration type operands:

  • + or +=

  • - or -=

  • * or *=

  • / or /=

  • & or &=

  • | or |=

  • ^ or ^=

  • %%

  • ~

  • || or &&

  • > or <

  • <= or >=

  • ~= or <>

  • >> or <<

NonfatalCheck usage of Stateflow transitions > Check that conditions and actions do not have unsupported operations on enumeration type operands
Transition must not have an event trigger.NonfatalCheck usage of Stateflow transitions > Check that no transitions have event triggers
Transition must not have a transition action.NonfatalCheck usage of Stateflow transitions > Check that transitions do not have transition actions

Math functions in actions must have:

  • Single or double type arguments for the following functions:

    • acos, asin, atan

    • ceil, cosh, cosh

    • exp, fabs, floor

    • fmod, ldexp, log

    • log10, pow, sin

    • sinh, sqrt, tan, tanh

  • Non-boolean arguments for the following functions:

    • abs, max, min

  • Integer type argument for the labs function.

NonfatalCheck usage of Stateflow transitions > Check that no actions contain a function whose argument is of an invalid data type
Stateflow transitions must not reuse induction variables outside of a loop.NonfatalCheck usage of Stateflow transitions > Check that Stateflow transitions do not reuse induction variables outside of a loop
Stateflow loops must not have unsupported step in transitions.NonfatalCheck usage of Stateflow transitions > Check that transitions do not have an unsupported loop step
Stateflow loops must not have an unsupported body in transitions.NonfatalCheck usage of Stateflow transitions > Check that transitions do not have an unsupported loop body
Stateflow loops must not have an unsupported condition in transitions.NonfatalCheck usage of Stateflow transitions > Check that transitions do not have an unsupported loop condition
Stateflow loops must have a valid induction variable in transition that defines loop condition.NonfatalCheck usage of Stateflow transitions > Check for valid induction variable in transition that defines loop condition
Stateflow loops must not have unsupported initialization actions in transitions.NonfatalCheck usage of Stateflow transitions > Check that transitions do not have unsupported loop induction variable initialization
Action must not contain a binary operator with mixed data type operands.NonfatalCheck usage of Stateflow transitions > Check that no actions contain a binary operator whose operands are of mixed data type
Transition must not have a function with more than 2 arguments.NonfatalCheck usage of Stateflow transitions > Check that no transitions have a function with more than 2 arguments
Actions must not access time.NonfatalCheck usage of Stateflow transitions > Check that no actions access time (t)
Actions must not contain an XOR operator with boolean operands when model parameter Casting modes is set to Standards.NonfatalCheck usage of Stateflow transitions > Check that no actions contain an xor operator with boolean operands
Charts must not have graphical function calls with unassigned outputs.NonfatalCheck usage of Stateflow transitions > Check unassigned graphical function outputs
Charts must not contain transitions that are configured as variant transitions.NonfatalCheck usage of Stateflow transitions > Check that Stateflow transitions are not configured as variant transitions

Stateflow Truth Tables

Truth Table ConstraintFATAL / NonfatalCompatibility Check
Control flows must not have cycles.FATALCheck usage of Stateflow truth tables > Check that control flows do not have cycles
Truth table property Function Inline Option (InlineOption) must not be Auto or Function.NonfatalCheck usage of Stateflow truth tables > Check usage of InlineOption setting
Truth table must not be recursive.NonfatalCheck usage of Stateflow truth tables > Check usage of recursive Stateflow function
Truth table property Language must be set to C.NonfatalCheck usage of Stateflow truth tables > Check usage of Stateflow truth table Language
Control flows must be structured.FATALCheck usage of Stateflow truth tables > Check that control flows are structured
States must not specify truth tables with different actual and expected argument data types.NonfatalCheck usage of Stateflow states > Check data type of truth table arguments
States must not specify truth tables with different actual and expected argument sizes.NonfatalCheck usage of Stateflow states > Check dimensions of truth table arguments
Transitions must not specify truth tables with different actual and expected argument data types.NonfatalCheck usage of Stateflow transitions > Check data type of truth table arguments
Transitions must not specify truth tables with different actual and expected argument sizes.NonfatalCheck usage of Stateflow transitions > Check dimensions of truth table arguments

Related Topics