The FSM Design Flow
This article organizes state machine concepts into a systematic engineering design procedure.
The eight-step design flow transforms functional specifications into gate-level sequential circuits:
- Functional Specification: Define input and output requirements.
- State Diagram Formulation: Model behavioral sequences as states and transitions.
- State Minimization: Eliminate redundant equivalent states.
- State Transition Table: Create tabular representations of transitions and outputs.
- State Encoding: Assign binary codes to symbolic states.
- Next-State Logic Derivation: Minimize Boolean equations for state register inputs.
- Output Logic Derivation: Minimize Boolean equations for circuit outputs.
- Implementation and Verification: Simulate gate-level netlists and verify timing.
Step 1: Functional Specification
Define the design requirements in precise technical terms.
Example Specification: Design a synchronous Moore state machine with binary input $x$ and output $z$. The circuit asserts $z = 1$ when input $x$ was equal to 1 during the two preceding consecutive clock cycles.
Step 2: State Diagram Formulation
The machine must record consecutive occurrences of input 1:
- State
A: Initial reset state, or previous input was 0 ($z = 0$). - State
B: Preceding input was 1 ($z = 0$). - State
C: Preceding two inputs were both 1 ($z = 1$).
Transitions:
- From
A: Transitions toAon $x = 0$; transitions toBon $x = 1$. - From
B: Transitions toAon $x = 0$; transitions toCon $x = 1$. - From
C: Transitions toAon $x = 0$; remains inCon $x = 1$.
Step 3: State Minimization Using Implication Tables
Two states $S_i$ and $S_j$ are equivalent if they satisfy two conditions:
- They generate identical output values for every input combination.
- They transition to equivalent next states for every input combination.
Designers use an implication table to detect and merge equivalent states.
Consider this five-state example:
| State | Output ($z$) | Next State ($x = 0$) | Next State ($x = 1$) |
|---|---|---|---|
| S1 | 0 | S2 | S3 |
| S2 | 0 | S4 | S3 |
| S3 | 1 | S3 | S2 |
| S4 | 0 | S2 | S5 |
| S5 | 1 | S3 | S2 |
First, eliminate state pairs with conflicting outputs. States S3 and S5 output 1, while S1, S2, and S4 output 0. Any pair combining these two groups cannot be equivalent.
Next, evaluate the remaining compatible pairs:
- Pair (S3, S5): On $x = 0$, both transition to
S3. On $x = 1$, both transition toS2. The next states are identical. Therefore,S3andS5are equivalent. - Pair (S1, S4): On $x = 0$, both transition to
S2. On $x = 1$, they transition to(S3, S5). BecauseS3andS5are equivalent,S1andS4are equivalent. - Pair (S1, S2): Requires equivalence of
(S2, S4). - Pair (S2, S4): Requires equivalence of
(S4, S2)and(S3, S5). Both conditions hold.
States S1, S2, and S4 merge into composite state P. States S3 and S5 merge into composite state Q. The five-state machine reduces to an equivalent two-state machine.
In our three-state example (A, B, C), state C has a unique output ($z = 1$). States A and B transition to different states on $x = 1$. Therefore, no states are equivalent.
Step 4: State Transition Table
Construct the state transition table for states A, B, and C:
| Present State | Input ($x$) | Next State | Output ($z$) |
|---|---|---|---|
| A | 0 | A | 0 |
| A | 1 | B | 0 |
| B | 0 | A | 0 |
| B | 1 | C | 0 |
| C | 0 | A | 1 |
| C | 1 | C | 1 |
Step 5: State Encoding
With three states, the design requires $n = \lceil \log_2 3 \rceil = 2$ flip-flops ($Q_1, Q_0$). Apply binary encoding:
A = 2'b00B = 2'b01C = 2'b10- Unused code:
2'b11(treated as don’t-care $X$)
| $Q_1 Q_0$ | Input ($x$) | Next State ($D_1 D_0$) | Output ($z$) |
|---|---|---|---|
| 00 | 0 | 00 | 0 |
| 00 | 1 | 01 | 0 |
| 01 | 0 | 00 | 0 |
| 01 | 1 | 10 | 0 |
| 10 | 0 | 00 | 1 |
| 10 | 1 | 10 | 1 |
| 11 | X | XX | X |
Step 6: Next-State Logic Minimization
Map inputs $D_1$ and $D_0$ onto Karnaugh maps with variables $Q_1, Q_0, x$ (Figures 1 and 2).
Minimize $D_1$ using the don’t-care states:
$$D_1 = (Q_0 \cdot x) + (Q_1 \cdot x) = x \cdot (Q_1 + Q_0)$$
Minimize $D_0$:
$$D_0 = \overline{Q_1} \cdot \overline{Q_0} \cdot x$$
Step 7: Output Logic Minimization
Because this is a Moore machine, output $z$ depends only on state variables $Q_1$ and $Q_0$ (Figure 3).
Group the logic 1 in state 10 with the don’t-care in state 11:
$$z = Q_1$$
Output $z$ requires no logic gates; it connects directly to the $Q_1$ flip-flop output.
Step 8: Implementation and Verification
The circuit uses two D flip-flops, one OR gate, two AND gates, and an inverter for $D_0$.
Simulate the gate-level circuit with input sequence: 0, 1, 1, 0, 1, 1:
| Clock Cycle | Current State ($Q_1 Q_0$) | Input ($x$) | Output ($z$) | Next State ($D_1 D_0$) | Next State |
|---|---|---|---|---|---|
| 0 | A (00) | 0 | 0 | 00 | A |
| 1 | A (00) | 1 | 0 | 01 | B |
| 2 | B (01) | 1 | 0 | 10 | C |
| 3 | C (10) | 0 | 1 | 00 | A |
| 4 | A (00) | 1 | 0 | 01 | B |
| 5 | B (01) | 1 | 0 | 10 | C |
During cycle 3, the machine enters state C and asserts output $z = 1$, matching the specification.
Practice Exercises
Problem 1
Evaluate this state transition table. Determine if any states are equivalent, and derive the minimal state machine.
| State | Output ($z$) | Next State ($x = 0$) | Next State ($x = 1$) |
|---|---|---|---|
| S1 | 0 | S2 | S3 |
| S2 | 0 | S1 | S4 |
| S3 | 0 | S2 | S3 |
| S4 | 0 | S1 | S3 |
Solution
All four states produce identical outputs ($z = 0$).
- Compare
(S1, S3): On $x = 0$, both transition toS2. On $x = 1$, both transition toS3. The transitions are identical. Therefore,S1andS3are equivalent. - Compare
(S2, S4): On $x = 0$, both transition toS1. On $x = 1$,S2transitions toS4andS4transitions toS3. This condition requires(S4, S3)equivalence. - Tracing the implications shows that all four states can transition among themselves without functional differences.
All four states merge into a single state S with output $z = 0$ and self-loops on both inputs.
Problem 2
For the three-state design example, identify the prime implicants for the $D_1$ Karnaugh map and prove the minimized expression.
Solution
The minterms for $D_1$ are $m(1, 1) = Q_0 x$ (minterm 3) and $m(2, 1) = Q_1 x$ (minterm 5), with don’t-cares at minterms 6 and 7 ($Q_1 Q_0 = 11$).
The prime implicants formed with don’t-cares are:
- Grouping minterm 3 with minterm 7: $Q_0 x$
- Grouping minterm 5 with minterm 7: $Q_1 x$
Factoring out $x$ yields the minimal sum-of-products equation:
$$D_1 = (Q_0 \cdot x) + (Q_1 \cdot x) = x \cdot (Q_1 + Q_0)$$
The next article applies this systematic flow to a complete traffic light controller design.