Stateflow

Sequence Recognition Using Mealy and Moore Charts

This example shows how Mealy and Moore machines can be used in signal processing applications; in this case, for sequence recognition. In the Moore machine, actions can only be state actions, whereas in the Mealy machine, actions can only be condition actions.

The two Stateflow® charts are used to find the sequence 1,2,1,3 in the input signal from Signal Builder. The status of the sequence recognition is logged in the output variable "state." If the sequence is found, the variable seqFound is set to 1. On running the simulation and opening the scopes, notice that the Moore output is delayed by one time step. This is because the output from a Moore machine is based on the state from the previous time step, and the output from a Mealy machine is based on the state from the previous time step and the current input.

Ref: Digital Design: From Gates to Intelligent Machines, 2006 by Bruce F. Katz