Finite state machines (Mealy and Moore)
WHAT is a Finite State Machine?
The whole distinction between Mealy and Moore lives in the output function :
| Type | Output function | Output depends on | Written |
|---|---|---|---|
| Moore | state only | output labelled inside the state | |
| Mealy | state AND current input | output labelled on the transition arrow |
HOW an FSM is built in hardware
Every FSM has the same three-block skeleton:

- State register — flip-flops holding the current state . Updated on each clock edge to the next state .
- Next-state logic — combinational logic computing .
- Output logic — combinational logic computing .
Deriving the number of flip-flops
Worked Example 1 — "detect 11" sequence detector (Moore)
Goal: output whenever the input bit stream has produced two consecutive 1s.
States (what each remembers):
- : "no useful 1s seen yet" — output 0
- : "last bit was a single 1" — output 0
- : "saw 11" — output 1
Transition table (derived by asking "where do I go on 0 and on 1?"):
| State | in=0 → | in=1 → | output |
|---|---|---|---|
| 0 | |||
| 0 | |||
| 1 |
Why this step? On a 0 any run of 1s is broken, so we reset toward . On a 1 we advance our "how many 1s in a row" counter, saturating at .
Input 0 1 1 0 1:
- Start →(1) →(1) (out=1 here) →(0) →(1)
- Output stream:
0 0 1 0 0. Note the1appears one cycle after the second1— Moore's characteristic delay.
Worked Example 2 — same detector as a Mealy machine
Now output on the transition, so we can flag on the very edge that completes 11.
| State | in=0 (next / out) | in=1 (next / out) |
|---|---|---|
| (no 1 yet) | / 0 | / 0 |
| (one 1) | / 0 | / 1 |
Why only 2 states? Because the output "is this a completing 1?" is answered by looking at the input, so we don't need a separate state — we merge it into a transition label. This is the classic "Mealy uses fewer states."
Input 0 1 1 0 1:
- →(0,out0)→(1,out0)→(1,out1)→(0,out0)→(1,out0)
- Output stream:
0 0 1 0 0but the1is produced the same cycle as the second1— one cycle earlier in "time" than Moore.
Common Mistakes
Recall Feynman: explain it to a 12-year-old
Imagine a board game where you have a little marker sitting on one square. Every "tick" of a clock you read a card (the input) and the rules tell you which square to move to. Each square is a state, and the marker is the machine's memory. In a Moore game, the prize you win is printed on the square you land on. In a Mealy game, the prize is printed on the arrow you walk along, so it also depends on which card you read. Same game, but Mealy pays you as you move while Moore pays you once you've landed.
Active-Recall Flashcards
What are the 6 tuple components of an FSM?
In a Moore machine the output depends on what?
In a Mealy machine the output depends on what?
Where is the output written on a Moore state diagram?
Where is the output written on a Mealy state diagram?
How many flip-flops are needed for states?
Which machine typically needs fewer states, Mealy or Moore?
Which machine has glitch-free, synchronous outputs?
Which machine can react to an input change within the same clock cycle?
Why does the reset/initial state matter in real hardware?
Three hardware blocks of any FSM?
Connections
- Flip-flops — the storage element for the state register
- Sequential Circuits — FSMs are the canonical clocked sequential circuit
- Combinational Logic — builds the and blocks
- State minimization — reducing to save flip-flops/logic
- State encoding — binary / one-hot / Gray assignment of codes to states
- Clocking and timing — why Moore is glitch-free and Mealy can glitch
- Sequence detectors — the classic FSM application
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, ek normal combinational circuit ka output sirf abhi ke inputs par depend karta hai — usko koi memory nahi hoti. Lekin bahut baar hume "yaad" rakhna padta hai ki pehle kya hua, jaise vending machine ko yaad rehna chahiye ki kitne paise pade hain. Isi kaam ke liye Finite State Machine (FSM) use hoti hai: yeh flip-flops mein ek state store karti hai, aur har clock edge par input ke hisaab se ek state se doosri state mein jump karti hai. State register + next-state logic + output logic — bas yeh teen blocks hote hain.
Ab Mealy vs Moore ka pura funda sirf ek cheez par tika hai: output kis cheez se banta hai. Moore mein output sirf state se banta hai (diagram mein output state ke bubble ke andar likhte hain). Mealy mein output state aur current input dono se banta hai (output arrow par likhte hain). Yaad rakhne ka trick: Mealy matlab input yes. Circuit mein farak sirf itna hai ki Mealy mein ek input wire seedha output logic tak jaati hai; Moore mein nahi jaati.
Practical difference kya hai? Moore ka output clock edge ke baad, ek cycle late aata hai, par woh glitch-free aur clean hota hai. Mealy turant, usi cycle mein react karta hai aur aksar kam states chahiye hote hain, par glitch aa sakta hai. Humne "11 detect karo" wala example dono tarike se banaya — Moore ko 3 states lage, Mealy ko sirf 2, kyunki Mealy ne "yeh 1 sequence complete kar raha hai" wali baat state ki jagah arrow par label kar di.
Exam aur real design dono mein: states ginne ke baad flip-flops formule se nikaalo, aur reset state define karna kabhi mat bhoolo — warna power-on ke baad machine kahin bhi atak sakti hai. Yeh chota concept controllers, protocols, sabme aata hai, isliye ise achhe se pakdo.