This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Design Considerations for Moore Charts

Moore machines are finite state machines in which output is modified at clock edges. In Moore charts, output is a function of the current state only. At every time step, a Moore chart wakes up, computes its output, and then evaluates its input to reconfigure itself for the next time step. For example, after evaluating its input, the chart can transition to a new configuration of active states. The chart computes its output before evaluating its input and updating its state. Moore semantics are supported only in Stateflow® charts in Simulink® models.

Moore Semantics

To ensure that output is a function only of the current state, Moore state machines enforce these semantics:

  • Outputs do not depend on inputs.

  • Outputs do not depend on previous outputs.

  • Outputs do not depend on temporal logic.

Design Rules for Moore Charts

To conform to the Moore definition of a state machine, ensure that every time that a Moore chart wakes up, it computes outputs from the current set of active states without regard to inputs.

Restrictions on State Actions

To ensure that outputs depend solely on the current state, you can compute outputs in state actions, subject to these restrictions:

  • Combine Actions. In Moore charts, you can include only one action per state. The action can consist of multiple command statements. Stateflow evaluates states in Moore charts from the top level down. Active states in Moore charts execute the state action before evaluating the transitions. Therefore, outputs are computed at each time step whether an outer transition is valid or not.

  • Do Not Label State Actions. Do not label state actions in Moore charts with any keywords, such as entry,during, or exit. By default, Moore charts execute the actions in the active states before evaluating inputs and updating state.

Restrictions on Transition Actions

Transitions in Moore charts can contain condition and transition actions if these actions do not introduce a dependency between output values and input values. For example, in this chart, each transition tests the input u in a condition and modifies the output y in a condition action. Because the output value depends on the value of the input, this construct violates Moore semantics and triggers an error.

Do Not Use Inputs to Compute Outputs

In Moore charts, outputs cannot depend on inputs. Using an input to contribute directly or indirectly to the computation of an output triggers an error.

Restrict Data Scope

In Moore charts, these data restrictions apply:

  • Restrict Machine-Parented Data. Machine-parented data is data that you define for a Stateflow machine. The Stateflow machine is the highest level of the Stateflow hierarchy. When you define data at this level, every chart in the machine can read and modify the data. To ensure that Moore charts do not access data that can be modified unpredictably outside the chart, do not use machine-parented data.

  • Do Not Define Data Store Memory. You cannot define data store memory (DSM) in Moore charts because objects external to the chart can modify DSM objects. A Stateflow chart uses data store memory to share data with a Simulink model. Data store memory acts as global data. In the Simulink hierarchy that contains the chart, other blocks and models can modify DSM. Moore charts must not access data that can change unpredictably.

Do Not Use coder.extrinsic to Call Extrinsic Functions

When calling extrinsic functions with coder.extrinsic, it is not possible to enforce that the outputs depend only on the current state. Calling an extrinsic function with coder.extrinsic in a Moore chart triggers an error.

Do Not Use Simulink Functions

You cannot use Simulink functions in Moore charts. This restriction prevents violations of Moore semantics during chart execution.

Do Not Export Functions

You cannot export functions in a Moore chart.

Do Not Disable Inlining

Moore chart semantics require inlining.

Do Not Enable Super Step Semantics

You cannot use super step semantics in a Moore chart.

Do Not Use Messages

You cannot use messages in a Moore chart.

Restrict Use of Events

Limit the use of events in Moore charts:

  • Valid Uses:

    • Use only one input event to trigger the chart.

    • Use event-based temporal logic to guard transitions.

      The change in value of a temporal logic condition behaves like an event that the Moore chart schedules internally. At each time step, the number of ticks before the temporal event executes depends only on the state of the chart. For more information, see Operators for Event-Based Temporal Logic.

      Note

      In Moore charts, the base event for temporal logic operators must be a predefined event such as tick or wakeup (see Keywords for Implicit Events).

  • Invalid Uses:

    • You cannot broadcast an event of any type.

    • You cannot use local events to guard transitions. Local events violate Moore semantics because they are not deterministic and can occur while the chart computes its outputs.

    • You cannot use implicit events such as chg(data_name), en(state_name), or ex(state_name).

Do Not Use Moore Charts for Modeling Continuous-Time Systems

In Moore charts, you cannot set the update method to Continuous. For modeling systems with continuous time in Stateflow, use Classic or Mealy charts.

Related Topics