State Diagrams and State Tables
A digital designer can specify a finite state machine using a graphical state diagram or a tabular state transition table. Both representations contain identical functional data.
The state diagram visualizes sequential behavior during system architecture. The state table provides the structured format needed to derive next-state Boolean logic.
State Diagram Conventions
A state diagram is a directed graph:
- Vertices (States): Represented by circles containing the state identifier. In a Moore machine, the associated output value appears inside the circle (e.g.,
StateName / Output). - Directed Edges (Transitions): Represented by arrows connecting states. In a Mealy machine, the transition arrow contains both input condition and output value (e.g.,
InputCondition / Output). - Initial Reset State: Indicated by an incoming arrow originating from a solid dot.
- Transition Conditions: Written in minimal Boolean form. If multiple input conditions cause the same transition, join them with an OR operator.
For a deterministic state machine, outgoing transition conditions from any single state must be mutually exclusive and exhaustive.
State Transition Tables
A state transition table specifies next-state transitions $\delta(s, i)$ and output assignments $\lambda$.
For $|S|$ states and $|I|$ binary inputs, the complete truth table contains $|S| \times 2^{|I|}$ rows:
| Present State | Input Vector | Next State | Output Vector |
|---|
Once state identifiers receive binary encodings, the table defines the truth tables for next-state flip-flop inputs and combinational outputs.
Worked Example: Overlapping Serial Sequence Detector (1011)
Design a serial sequence detector that asserts output $Z = 1$ when the input bit stream contains the sequence 1011.
The machine must support overlapping sequences. In an overlapping sequence, the final bits of one matched sequence can serve as the prefix for a subsequent match.
State Definitions
Each state tracks how many consecutive prefix bits of 1011 have matched:
| State | Matched Prefix | Output ($Z$) |
|---|---|---|
| S0 | No prefix matched | 0 |
| S1 | Pattern 1 matched |
0 |
| S2 | Pattern 10 matched |
0 |
| S3 | Pattern 101 matched |
0 |
| S4 | Pattern 1011 matched |
1 |
Transition Evaluation
For each state, analyze the effect of incoming bit $X$:
- In state S0:
- $X = 0$: No matching prefix. Remain in
S0. - $X = 1$: Pattern
1detected. Transition toS1.
- $X = 0$: No matching prefix. Remain in
- In state S1 (prefix
1):- $X = 0$: Sequence forms
10. Transition toS2. - $X = 1$: Sequence forms
11. The trailing1preserves the prefix. Remain inS1.
- $X = 0$: Sequence forms
- In state S2 (prefix
10):- $X = 0$: Sequence forms
100. No matching prefix. Return toS0. - $X = 1$: Sequence forms
101. Transition toS3.
- $X = 0$: Sequence forms
- In state S3 (prefix
101):- $X = 0$: Sequence forms
1010. The suffix10matches the two-bit prefix. Transition toS2(overlapping transition). - $X = 1$: Sequence forms
1011. Transition toS4.
- $X = 0$: Sequence forms
- In state S4 (target
1011detected, $Z = 1$):- $X = 0$: Sequence ends in
10110. The suffix10matches a valid prefix. Transition toS2. - $X = 1$: Sequence ends in
10111. The suffix1matches a valid prefix. Transition toS1.
- $X = 0$: Sequence ends in
Figure 1 shows the resulting Moore state diagram.
State Transition Table
The five states and two input values produce ten rows:
| Present State | Input ($X$) | Next State | Output ($Z$) |
|---|---|---|---|
| S0 | 0 | S0 | 0 |
| S0 | 1 | S1 | 0 |
| S1 | 0 | S2 | 0 |
| S1 | 1 | S1 | 0 |
| S2 | 0 | S0 | 0 |
| S2 | 1 | S3 | 0 |
| S3 | 0 | S2 | 0 |
| S3 | 1 | S4 | 0 |
| S4 | 0 | S2 | 1 |
| S4 | 1 | S1 | 1 |
Graphical Comparison: Moore vs. Mealy Notation
Figure 2 illustrates Moore notation with outputs placed inside state vertices. Figure 3 illustrates Mealy notation with outputs placed on directed transition edges.
Common State Machine Design Errors
When creating state diagrams, inspect the design for these four structural errors:
- Incomplete Transitions: A state lacks transitions for specific input combinations. Ensure that the logical OR of all outgoing transition conditions from each state equals 1.
- Non-Deterministic Transitions: Two outgoing transitions from a single state are true simultaneously. Outgoing transition conditions must be mutually exclusive.
- Missing Reset Definition: The state diagram fails to identify an initial state, causing non-deterministic power-on behavior.
- Unassigned Outputs: Every Moore state and every Mealy transition must define all output signals explicitly.
Practice Exercises
Problem 1
Construct a Moore state diagram that detects three consecutive 1 bits (111), allowing overlapping sequences.
Solution
Define four states:
S0: Zero consecutive ones detected ($Z = 0$).S1: One1detected ($Z = 0$).S2: Two consecutive1s detected ($Z = 0$).S3: Three or more consecutive1s detected ($Z = 1$).
Transitions:
- When input $X = 0$, all states transition back to
S0. - When input $X = 1$:
S0transitions toS1.S1transitions toS2.S2transitions toS3.S3transitions toS3(self-loop, because receiving another1retains three consecutive ones).
Problem 2
Convert this state description into a state transition table:
- States:
A,B(output $Z = 0$), andC(output $Z = 1$). - Transitions:
- From
A: Transitions toBon input 0; remains inAon input 1. - From
B: Transitions toAon input 0; transitions toCon input 1. - From
C: Transitions toAon input 0; transitions toBon input 1.
- From
Solution
| Present State | Input ($X$) | Next State | Output ($Z$) |
|---|---|---|---|
| A | 0 | B | 0 |
| A | 1 | A | 0 |
| B | 0 | A | 0 |
| B | 1 | C | 0 |
| C | 0 | A | 1 |
| C | 1 | B | 1 |
Because this is a Moore machine, output $Z$ depends only on the present state.
Problem 3
In the 1011 sequence detector, explain why state S3 transitions to S2 instead of S0 when input $X = 0$.
Solution
In state S3, the sequence detector has matched 101.
When input $X = 0$ arrives, the sequence becomes 1010. While 1010 is not a complete match, its trailing two bits (10) match the first two bits of target pattern 1011.
Transitioning to S0 would discard these valid prefix bits, causing the circuit to miss valid patterns in overlapping bit streams such as ...101011.... State S2 represents prefix 10. Therefore, the machine transitions to S2.
The next article explores state assignment techniques, comparing binary, Gray, and one-hot encoding schemes.