Source
Adapted from my own handwritten and hand-typed notes from Year 1 to Year 3 of my EEE degree
Design Steps
Steps:
- study the specification and identify inputs and outputs (block diagram, timing diagram or flow chart)
- draw the state diagram
- build the present state / next state table
- choose the number of flip-flops: for states, since
- assign a binary code to each state (state assignment)
- choose the flip-flop type and use its excitation table to fill in the flip-flop inputs
- use K-maps to find the next-state decoder and output decoder equations, with unused codes as don't-cares
- draw the circuit
State Diagram Guidelines
Tips:
- write sample input and output sequences to understand the problem
- decide the reset state first
- add a state for each partial sequence that must be "remembered"
- before adding a new state, check whether an arrow can go back to an existing state
- every state needs exactly one outgoing arrow for each input combination
- test the finished diagram with the sample sequences
Example: 101 Sequence Recognizer
One input , one output when the last three inputs were 101, with overlapping allowed:
X = 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0
Z = 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0States (Mealy):
- S0: reset, nothing useful received
- S1: last input was 1
- S2: last two inputs were 10
| Present | ||
|---|---|---|
| S0 | S0, 0 | S1, 0 |
| S1 | S2, 0 | S1, 0 |
| S2 | S0, 0 | S1, 1 |
From S2 a 1 completes 101 and goes to S1, since that final 1 can start the next sequence (overlap).
Three states need flip-flops. With S0 = 00, S1 = 01, S2 = 10 (), D flip-flops, and 11 as don't-care:


Example: Robot Maze Controller
A robot has an obstacle sensor and outputs (turn left) and (turn right). On meeting an obstacle it turns right until clear; on the next obstacle it turns left, and so on. Four states remember whether an obstacle is present and which way it turned last: NL, OR, NR, OL.

With NL = 00, OR = 01, NR = 11, OL = 10 (a Gray-code style assignment) and JK flip-flops:
Example: Vending Machine Controller
A candy costs 40 cents and the machine takes 10 cent () and 20 cent () coins, with outputs (release candy) and (return 10 cents change). States S0 to S3 store 0, 10, 20 and 30 cents ( = 00, 01, 10, 11), and is a don't-care. Using T flip-flops: