FSM Execution Semantics
The FSM scheduler responds to new events caused by arriving data on input ports or via internal or special events.
Upon simulation startup, any action associated with the top level default entrance and the entry action of the initial state are performed. While the initial state is a hierarchical state, its default entrance action is executed and its default substate becomes the initial state, including execution of the state entry action.
After a FSM block received new events, the FSM scheduler passes through the following steps:
- All transitions, possessed by the current state and triggered by the received events, are searched.
Synchronous transitions are triggered by any event.
- In order of the priority of the triggered preemptive transitions, the guard conditions are evaluated. The first transition, whose guard condition evaluates to true fires.
- If a preemptive transition fires, goto step 7.
- If the current state contains a slave process, this slave process is executed.
- In order of the priority of the triggered non-preemptive transitions, the guard conditions are evaluated. The first transition, whose guard condition evaluates to true, fires.
- If no non-preemptive transition fires, goto step 13.
- The exit actions of all states, left by the firing transition, are performed in order up the hierarchy, starting with the current state. Additionally all histories of the leaving hierarchy are updated.
- The action of the firing transition is executed.
- If the firing transition points to a non-empty history, the state stored in the history becomes the new current state, otherwise the target state of the firing transition becomes the new current state.
- While the new current state is a hierarchical state, its default entrance destination becomes the new current state.
- The entry actions of all states, entered by the firing transition, are performed in order down the hierarchy, ending with the new current state.
In case a state hierarchy is entered by its default substate, the default entrance action is executed before the entry action of the default substate is performed.
- If the new current state possesses synchronous transitions, goto step 2.
- The current state memory is updated.