Digital Logic
Finite State Machines
Decide Mealy vs Moore from where the output lives, then draw overlapping sequence detectors carefully.
GATE CSE FSMs — Mealy vs Moore with diagrams, 101 sequence detectors, overlap vs non-overlap, state tables/reduction, and exam tricks.
Learning outcomes
- Distinguish Mealy and Moore output dependency and timing
- Draw Mealy/Moore state diagrams for short binary sequence detectors
- Handle overlapping vs non-overlapping fallback after a match
- Build a state table and merge equivalent states by inspection
Mealy vs Moore
- Moore: output Z = f(present state only). Changes when the state register updates (clocked).
- Mealy: output Z = f(present state, present input). Can change as soon as X changes — faster reaction, more glitch risk.
- Diagram cue: Moore labels outputs in/ beside nodes; Mealy labels edges as input/output.
- For the same external behaviour, Mealy often needs fewer or equal states (outputs on edges encode distinctions).
- Both are still synchronous FSMs if next-state is clocked — “async output” ≠ “async state”.
| Machine | Output depends on | Timing cue |
|---|---|---|
| Moore | State only | Stable between clocks |
| Mealy | State + input | May change with input |
State diagrams & tables
- States = memory of “what matters so far”. Reset/idle is the known start after power-on/reset.
- Every state must define a next state for each input symbol (complete specification) unless don’t-cares are stated.
- State table columns: present state, next state for each X, and outputs (Moore: per state; Mealy: per transition).
- Implementation path: encode states → FF bits → next-state + output equations → excitation (Sequential lesson).
Formulas to remember
-
n FF bits ⇒ ≤ 2^n usable encodings -
Unused codes: treat as don’t-care or force reset
Sequence detector — Mealy “101”
- States track the longest prefix of the target pattern that is also a suffix of the input so far.
- For “101”: idle → got 1 → got 10 → (on 1) detect.
- Mealy: assert Z=1 on the transition that completes the pattern (edge label 1/1).
- After detect with overlap: go to “got 1” because the last bit 1 is already a prefix of 101.
Worked example
Problem. Stream 10101 on an overlapping Mealy 101 detector — how many times is Z=1?
Solution. Twice: ending at positions 3 and 5 (…101 and …101).
Sequence detector — Moore “101”
- Moore needs a dedicated Detect state where Z=1 is attached to the state itself.
- You enter Detect after the completing input, on the next clock — output is delayed by one state update vs Mealy’s edge assertion.
- From Detect, transitions encode overlap/non-overlap just like Mealy fallbacks.
- GATE ask: “when can Z rise?” → only after entering Detect (not mid-cycle from X alone).
Worked example
Problem. Why does Moore often have one more state than Mealy for the same detector?
Solution. Detection is a state (Z=1) rather than a transition attribute, so an extra node appears.
Overlapping vs non-overlapping
- Non-overlapping: after a hit, return to idle/start; ignore using match bits as a new prefix.
- Overlapping: after a hit, keep the longest suffix of the matched string that is still a prefix of the pattern.
- Example pattern 101 on stream 10101: overlap detects twice; non-overlap detects once then needs a fresh 101.
- Always read the stem — “overlapping allowed” changes next-state arrows after success.
Formulas to remember
-
Overlap fallback = longest proper suffix ∩ prefixes of pattern -
Non-overlap fallback = reset / idle
State reduction (exam depth)
- Equivalent states: identical outputs and transitions that lead to equivalent states (recursive definition).
- Merge them to cut FF count / logic. Implication charts exist but GATE usually wants inspection on 3–5 states.
- Don’t merge states that differ only “sometimes” — one wrong output row blocks equivalence.
- After reduction, re-encode and rebuild the state table before writing equations.
GATE exam tricks — FSMs
- First question: is Z on the node (Moore) or on the arc with X (Mealy)?
- Mealy can assert Z in the same cycle the last bit arrives; Moore waits until Detect is entered.
- Overlapping 101/1101 traps: after success, do not blindly reset — check the suffix.
- Count states before drawing; unreachable states waste time and confuse options.
- Completeness: every state × every input needs a next state (unless X is restricted).
- “Minimum states” ⇒ try Mealy + overlap-aware design, then reduce equivalents.
- Implementation numericals: k states ⇒ ≥ ⌈log₂ k⌉ FFs (same as mod-N sizing idea).
- Reset state must be reachable from power-up; unused encodings should not lock the machine.
Formulas to remember
-
FF bits ≥ ⌈log₂ (#states)⌉ -
Mealy edge label: X / Z
Worked example
Problem. A Moore machine has 5 states. Minimum flip-flops?
Solution. ⌈log₂ 5⌉ = 3 FFs (with 3 unused codes).
Exam tips
- Ask: is output tied to a state or to a transition/input?
- Overlapping detectors: after success, fall back to the suffix that is still a prefix.
- Count states before drawing — don’t invent unreachable ones.
- Mealy Z can follow X combinationally; Moore Z waits for the Detect state.
- Stream trace: tick state after each bit, then read Z (Mealy from edge, Moore from node).
- Non-overlap ≠ overlap — hit counts on 10101 differ.
- Equivalent states need matching outputs and matching successor classes.
- Link to Sequential: next-state bits → D/T/JK excitation tables.
10 GATE-style MCQs for Finite State Machines with full explanations. Attempt each question before revealing the answer.
Moore outputs depend on:
Show answer & explanation
Answer: B
Output = f(state).
Mealy outputs can change:
Show answer & explanation
Answer: B
Output = f(state,input).
Sequence detector FSMs are usually:
Show answer & explanation
Answer: B
Need memory of partial matches.
Overlapping detector for 101 after a hit may return to:
Show answer & explanation
Answer: B
Overlap reuses trailing bits.
Equivalent states can be merged if:
Show answer & explanation
Answer: B
Standard equivalence.
Finite state machine memory is finite because:
Show answer & explanation
Answer: B
Definition of FSM.
State diagram edges are labeled with:
Show answer & explanation
Answer: B
Mealy puts outputs on edges; Moore on nodes.
A reset state typically:
Show answer & explanation
Answer: B
Initialized by reset signal.
Compared to Moore, Mealy often has:
Show answer & explanation
Answer: B
Outputs on transitions can encode distinctions without extra states.
Non-overlapping detector after success:
Show answer & explanation
Answer: B
Non-overlap restarts cleanly after a detection.
Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.
Output associated only with states ⇒
Show answer & explanation
Answer: B) Moore
Moore definition.
Fastest reaction to input change typically:
Show answer & explanation
Answer: B) Mealy
Combinational dependence on input.
Detector for pattern length k needs on the order of:
Show answer & explanation
Answer: B) About k states (prefixes)
Prefix automaton size ~k for a single pattern.
State table columns usually include:
Show answer & explanation
Answer: B) Present state, input, next state, output
Standard FSM table.
Two states with different Moore outputs:
Show answer & explanation
Answer: B) Cannot be equivalent
Outputs must match for equivalence.
FSM implemented with FFs + combinational logic is:
Show answer & explanation
Answer: B) Standard hardware realization
State register + next-state/output logic.
Self-loop on a state means:
Show answer & explanation
Answer: B) Remain in state for that input
Transition to same state.
Binary encoding of 5 states needs at least how many FFs?
Show answer & explanation
Answer: B) 3
2^2=4<5≤8.
One-hot encoding of 5 states uses:
Show answer & explanation
Answer: B) 5 FFs
One FF per state.
A non-overlapping sequence detector after a successful match typically:
Show answer & explanation
Answer: A) Returns toward the start/idle path without reusing the match as an overlapping prefix
Non-overlapping detectors restart cleanly after detection; overlapping ones reuse a suffix prefix.
Topic FAQs
Which is “better”, Mealy or Moore?
Neither universally. Mealy can be smaller/faster reacting; Moore outputs are synchronized to state and often glitch-friendlier.
How do I spot Mealy vs Moore on a diagram?
Moore: outputs written in the state bubbles. Mealy: outputs written on the transition arrows with the inputs (X/Z).
What does overlapping mean for a sequence detector?
After a successful match, the machine reuses the trailing bits as the start of a new match if they form a prefix of the pattern.
Why does a Moore detector often have an extra state?
Detection is represented by a state that outputs 1. Mealy can flag detection on the completing transition without that extra node.
When can two states be merged?
When they produce the same outputs and their next states (for every input) are pairwise equivalent.
How many flip-flops for an FSM with k states?
At least ⌈log₂ k⌉. Unused binary codes should be handled (don’t-care or reset) so the machine cannot hang.
Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.