Introduction to Stateflow with Applications

This chapter begins with an overview of the Mealy and Moore machines, then describes the procedure for creating Mealy and Moore charts in Stateflow, and concludes with illustrative examples for each.
In the theory of computation, a Mealy machine is a finite state machine that generates an output based on its current state and an input. This means that the state diagram will include both an input and output signal for each transition edge.
This is a Mealy machine example.
Let us consider the state table below denoted as Table 9.1.
| Present State | Input | Next State | Output | ||
|---|---|---|---|---|---|
| Q 1 n | Q 0 n | x | Q 1 n + 1 | Q 0 n+1 | y |
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 1 |
We can represent the state table above with the timing diagram shown in Figure 9.1 below.
The Mealy machine for the state table in Table 9.1 and timing diagram in Figure 9.1 is shown in Figure 9.2 below.
In the state diagram in Figure 9.2, the numbers inside the states represented by the circles are the four states of a synchronous counter...