Finite state machine design
Fill in the state table of a Moore or Mealy machine and get the state diagram, the binary or Gray assignment, the excitation table for D, T, JK or SR flip-flops, the Karnaugh maps and the minimal equations, ready to build the circuit.
What you can do
- Moore and Mealy.
- Excitation tables for all four flip-flops.
- Minimal equations and the circuit built in the simulator.
Frequently asked questions
What is the difference between Moore and Mealy?
In Moore the output depends only on the state; in Mealy it depends on the state and the input.
Guide: designing state machines
A finite state machine describes a sequential circuit: at each clock edge it moves from one state to another depending on its inputs, and its outputs depend on the state. It is the systematic way to design sequence detectors, counters, traffic lights or controllers. This guide walks through the full method, from the state diagram to the flip-flop equations, with an example.
Moore and Mealy
- Moore: the output depends only on the state; it is written inside each state. It is more stable, but it usually needs more states and responds one cycle later.
- Mealy: the output depends on the state and the input; it is written on each arrow as input/output. It uses fewer states and responds in the same cycle.
The design method
- State diagram: what the machine must "remember", one state per distinct situation, and the transitions for each input value.
- State table: the diagram as a table: current state, input, next state and output.
- State assignment: a binary code for each state. N states need k = ⌈log₂ N⌉ flip-flops; unused codes are "don't care".
- Excitation table: which input each flip-flop needs to go from the current state to the next. With D flip-flops it is direct: D = Q⁺.
- Minimal equations: each flip-flop input and each output is simplified with its Karnaugh map.
Example: 101 sequence detector (Mealy, overlapping)
The output Z is 1 when 1, 0, 1 arrive in a row on input X. With overlap, the last 1 can start the next sequence: 10101 is detected twice.
- States: S0, nothing useful; S1, "1" received; S2, "10" received.
- Transitions:
- S0: on 0 stays in S0; on 1 goes to S1.
- S1: on 0 goes to S2; on 1 stays in S1, because that 1 may be a new start.
- S2: on 0 goes back to S0; on 1 it has detected 101, so Z = 1 and it goes to S1, because that last 1 serves as a start.
- Codes: 3 states need 2 flip-flops (Q1 Q0): S0 = 00, S1 = 01, S2 = 10; code 11 is "don't care".
- Equations with D flip-flops: the machine goes to S1 (Q0⁺ = 1) whenever X = 1, so D0 = X. It goes to S2 (Q1⁺ = 1) only from S1 with X = 0, so D1 = Q0·X′. The output is 1 in S2 with X = 1: Z = Q1·X.
These are exactly the equations the tool derives for this example. The Moore version needs a fourth state, "101 detected", in which the output is 1.
How to use the tool
- Choose Moore or Mealy and the number of inputs, outputs and states.
- Fill in the state table: the next state for each input and the outputs (0, 1 or X).
- Choose the flip-flop type (D, T, JK or SR) and the state assignment (binary or Gray).
- Read the state diagram, the transition and excitation tables and the minimal equations. "Build the circuit in the simulator" assembles it with flip-flops, the minimal logic and a clock, so you can test it.
Common mistakes
- Forgetting overlap: going back to S0 after a detection misses overlapping detections.
- Leaving transitions undefined for some input value.
- Using the wrong flip-flop's excitation table: a JK's is not a D's.
- Not using unused codes as "don't care", which simplify the equations.
Further reading
M. M. Mano and M. D. Ciletti, Digital Design (Pearson); J. F. Wakerly, Digital Design: Principles and Practices (Pearson). Simuveliq is not affiliated with these authors or publishers.
More tools
Versión en español
About Simuveliq · Privacy policy · Contact