How Events Drive Chart Execution

How Stateflow Charts Respond to Events

Stateflow® charts in Simulink® models execute in response to an event in a cyclical manner.

Because a chart runs on a single thread, actions that take place based on an event are atomic to that event. All activity caused by the event in the chart finishes before execution returns to the activity that was taking place before receiving the event. Once an event initiates an action, the action completes unless interrupted by an early return.

Sources for Stateflow Events

Simulink events awaken Stateflow charts. You can use events to control the processing of your charts by broadcasting events, as described in Broadcast Local Events to Synchronize Parallel States. For examples using event broadcasting and directed event broadcasting, see:

Events have hierarchy (a parent) and scope. The parent and scope together define a range of access to events. The parent of an event usually determines who can trigger on the event (has receive rights). See the Name and Parent fields for an event in Set Properties for an Event for more information.

How Charts Process Events

Stateflow charts process events from the top down through the chart hierarchy:

  1. Executes during and on event_name actions for the active state

  2. Checks for valid transitions in substates

All events, except for the output edge trigger to a Simulink block (see the following note), have the following execution in a chart:

  1. If the receiver of the event is active, then it executes (see Execution of a Stateflow Chart). (The event receiver is the parent of the event unless a directed event broadcast occurs using the send() function.)

  2. If the receiver of the event is not active, nothing happens.

  3. After broadcasting the event, the broadcaster performs early return logic based on the type of action statement that caused the event.

    To learn about early return logic, see Early Return Logic for Event Broadcasts.


    Output edge-trigger event execution in a Simulink model is equivalent to toggling the value of an output data value between 1 and 0. It is not treated as a Stateflow event. See Define Edge-Triggered Output Events.