Moore and Mealy machines: state diagrams and tables, sequence detectors with and without overlap, analysis of clocked sequential circuits, state assignment, state reduction and the minimum number of flip-flops.
A finite state machine (FSM) is a synchronous sequential circuit with a finite set of states. It has three parts: a state register of flip-flops that holds the present state , next-state logic that computes the flip-flop inputs from and the input , and output logic.
Moore machine
Mealy machine
Output depends on
present state only
present state and present input
Output written
inside the state circle
on the arrow, as input/output
States for a detector
usually one more
fewer (or equal)
Output timing
changes only after a clock edge, for a full cycle
can change as soon as the input changes
Glitches on input
do not reach the output
can pass to the output
With flip-flops, at most states are available, so a machine with states needs at least
Every Mealy machine has an equivalent Moore machine and vice versa. The Moore version may need more states, and its output appears one clock cycle later, because a Moore output can only change when the state changes.
Unused states: if , some codes are unused. A safe design checks that each unused state leads back into the main sequence. A circuit that stays stuck in unused states is said to lock up.
General FSM: next-state logic feeds the flip-flops, which hold the present state Q. In a Moore machine the output logic sees only Q; in a Mealy machine it also sees the input x (dashed).
2. Sequence detectors
A sequence detector outputs 1 when the last few input bits match a given pattern. Each state remembers how much of the pattern has been matched so far.
Mealy design for a pattern of length : states , where means "the last bits match the first bits of the pattern". The output 1 is put on the arrow that completes the pattern. So a Mealy detector needs states.
Moore design: add one more state ("pattern seen") whose output is 1. So states.
Overlap. With overlapping detection, the end of one match can start the next. In 1011011, the pattern 1011 occurs at bits 1–4 and 4–7. After a match, go to the state for the longest suffix of what has been seen that is also a prefix of the pattern. Without overlap, go back to after every match.
Wrong-input arrows. When the next bit does not extend the match, do not jump straight to . Find the longest suffix of the bits seen so far that is a prefix of the pattern. Example for 101: in (seen 10), input 0 gives 100, whose longest useful suffix is empty, so go to ; in (seen 1), input 1 gives 11, whose suffix 1 is a prefix, so stay in .
Pattern length
Mealy states
Moore states
3 (e.g. 101)
3 (2 flip-flops)
4 (2 flip-flops)
4 (e.g. 1011)
4 (2 flip-flops)
5 (3 flip-flops)
Mealy detector for 101 with overlap. S0: nothing matched, S1: seen 1, S2: seen 10. Labels are input/output. After 101 the machine goes to S1, because the final 1 can start the next match.
3. Analysing a clocked sequential circuit
To find what a given circuit does:
Write the flip-flop input equations from the gates (for example ).
Convert them to next-state equations using the characteristic equations: , , .
Build the state table: every present state (and input combination), the next state and the output.
Draw the state diagram and read the behaviour: a count sequence, a detector, a divider.
All flip-flops are clocked together, so at each edge every flip-flop uses the old values of all outputs. Fill the whole row of the table from the present state before moving to the next row.
Example. , :
next
00
0
1
01
01
1
0
10
10
1
1
11
11
0
0
00
The sequence is : a 2-bit (mod-4) up counter. Each flip-flop output has a frequency of () and ().
Always complete the table for all states, including those not reached from the start state. Questions often ask what happens from an unused state: whether it joins the main cycle or locks up.
4. Design steps and state reduction
Design flow:
Draw the state diagram from the word description.
Reduce the number of states (below).
Assign binary codes to states, using flip-flops. One-hot assignment uses flip-flops with exactly one 1, trading flip-flops for simpler logic.
Write the state table with present code, input, next code and output.
From the flip-flop excitation table, find the flip-flop inputs for each row, and minimise them with K-maps, using unused codes as don't-cares.
State equivalence. Two states are equivalent if, for every input sequence, they produce the same output sequence. Equivalent states can be merged.
A quick test: two states with the same outputs and the same next states for every input are equivalent. The full test is partitioning:
: group states with identical output rows.
: split a group if, for some input, its members go to states in different groups of .
Stop when a partition repeats. Each final group becomes one state.
Same next states alone is not enough; the outputs must also match. And same outputs alone is not enough; the next states must be equivalent too. State reduction can lower the number of flip-flops, for example from 5 states (3 flip-flops) to 3 states (2 flip-flops).
Formulas to remember
Minimum flip-flops states, binary encoding
One-hot encodingOne flip-flop per state
Sequence detector statesPattern of length
Moore output
Mealy output
Next stateThrough , or
Common mistakes
Using the number of states as the number of flip-flops. The minimum is ⌈log₂ N⌉, and only a one-hot design uses N.
Sending every wrong input back to the start state in a sequence detector. Go to the state for the longest suffix that is still a prefix of the pattern.
Mixing up overlapping and non-overlapping detection. After a match, overlap keeps the useful suffix; non-overlap returns to the start state.
Updating one flip-flop and then using its new value for the next flip-flop in the same clock edge. All flip-flops use the old present state.
Merging states that have the same next states but different outputs, or the same outputs but non-equivalent next states.
Ignoring unused states. A question may ask whether the circuit recovers or locks up when it starts in one.
Worked examples
Try each step yourself, then reveal the working.
Example 1: Mealy detector for 110 with overlap
numerical
Design the state diagram of a Mealy machine that outputs 1 whenever the last three inputs are 110 (overlap allowed). How many flip-flops are needed? What is the output for the input 0110110?
Step 1: Define the states by how much of 110 has been matched.
Try it on paper first.
Example 2: Analysing two D flip-flops
numerical
A circuit has two D flip-flops with and . Starting from , find the state sequence. What happens if the circuit powers up in 11?
Step 1: Compute the next state of each state.
Try it on paper first.
Example 3: Reducing a state table
numerical
A Mealy machine has the table below (next state/output for and ). A: B/0, C/0. B: D/0, E/0. C: D/0, E/0. D: A/0, E/1. E: A/0, E/1. Find the minimal number of states and flip-flops.
Step 1: Group by output rows.
Try it on paper first.
Example 4: Mealy or Moore for 1011?
conceptual
For an overlapping detector of 1011, compare the Mealy and Moore designs in number of states, flip-flops and output timing.
Step 1: Count the Mealy states.
Try it on paper first.
Previous year questions
1 official GATE EC question on this topic, newest first.
9 questions: up to 1 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.
Mark as mastered
Loading your progress…
My revision notes
Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.