Main Content

Design Considerations for Mealy Charts

Mealy machines are finite state machines in which transitions occur on clock edges. In Mealy charts, output is a function of input and state. At every time step, a Mealy chart wakes up, evaluates its input, and then transitions to a new configuration of active states, also called its next state. The chart computes its output as it transitions to the next state. Mealy semantics are supported only in Stateflow® charts in Simulink® models.

Mealy Semantics

To ensure that output is a function of input and state, Mealy state machines enforce these semantics:

  • Outputs do not depend on the next state.

  • The chart computes outputs only in transitions, not in states.

  • The chart wakes up periodically based on a system clock.


    A chart provides one time base for input and clock (see Calculate Output and State by Using One Time Base).

Design Rules for Mealy Charts

To conform to the Mealy definition of a state machine, ensure that every time there is a change on the input port, the chart computes outputs.

Compute Outputs in Condition Actions Only

You can compute outputs only in the condition actions of outer and inner transitions. A common modeling style for Mealy machines is to test inputs in conditions and compute outputs in the associated action.

Do Not Use State Actions or Transition Actions

You cannot use state actions or transition actions in Mealy charts. This restriction enforces Mealy semantics by:

  • Preventing the chart from computing output without considering changes on the input port.

  • Ensuring that output depends on the current state and not the next state.

Restrict Data Scope

In Mealy charts, these data restrictions apply:


  • Do Not Define Data Store Memory. You cannot define data store memory (DSM) in Mealy charts because objects external to the chart can modify DSM. 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. Mealy charts must not access data that can change unpredictably.

Restrict Use of Events

Limit the use of events in Mealy charts:

  • Valid Uses:

    • Use input events 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 Mealy 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 Temporal Logic Operators.



  • Invalid Uses:

    • You cannot broadcast an event of any type.

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


Calculate Output and State by Using One Time Base

You can use one time base for clock and input, as determined by the Simulink solver. The Simulink solver sets the clock rate to be fast enough to capture input changes. As a result, a Mealy chart commonly computes outputs and changes states in the same time step. For more information, see Compare Solvers.

Related Topics