Finite state machines (Mealy and Moore)
3.4.10· Hardware › Sequential Circuits
Finite State Machine KYA hai?
Mealy aur Moore ke beech ka poora distinction output function mein hi rehta hai:
| Type | Output function | Output depend karta hai | Likha jaata hai |
|---|---|---|---|
| Moore | sirf state par | output state ke andar label hota hai | |
| Mealy | state AUR current input par | output transition arrow par label hota hai |
Hardware mein FSM KAISE banta hai
Har FSM ka ek hi three-block skeleton hota hai:

- State register — flip-flops jo current state hold karte hain. Har clock edge par next state par update hota hai.
- Next-state logic — combinational logic jo compute karta hai.
- Output logic — combinational logic jo compute karta hai.
Flip-flops ki sankhya derive karna
Worked Example 1 — "detect 11" sequence detector (Moore)
Goal: jab bhi input bit stream ne do consecutive 1s produce kiye hon tab output karo.
States (har ek kya yaad rakhta hai):
- : "abhi tak koi useful 1 nahi dekha" — output 0
- : "last bit ek single 1 tha" — output 0
- : "11 dekha" — output 1
Transition table ("0 aur 1 par main kahan jaaunga?" pooch ke derive kiya gaya):
| State | in=0 → | in=1 → | output |
|---|---|---|---|
| 0 | |||
| 0 | |||
| 1 |
Yeh step kyun? 0 par 1s ki koi bhi run toot jaati hai, toh hum ki taraf reset karte hain. 1 par hum apna "kitne 1s row mein hain" counter aage badhate hain, par saturate karte hain.
Input 0 1 1 0 1:
- Start →(1) →(1) (out=1 yahan) →(0) →(1)
- Output stream:
0 0 1 0 0. Note karo ki1doosre1ke ek cycle baad aata hai — yeh Moore ki characteristic delay hai.
Worked Example 2 — same detector Mealy machine ke roop mein
Ab output transition par do, taaki hum usi edge par flag kar sakein jo 11 complete karta hai.
| State | in=0 (next / out) | in=1 (next / out) |
|---|---|---|
| (abhi tak 1 nahi) | / 0 | / 0 |
| (ek 1) | / 0 | / 1 |
Sirf 2 states kyun? Kyunki output "kya yeh completing 1 hai?" ka jawab input dekh ke milta hai, toh hume alag state ki zaroorat nahi — hum use transition label mein merge kar dete hain. Yeh classic "Mealy uses fewer states" hai.
Input 0 1 1 0 1:
- →(0,out0)→(1,out0)→(1,out1)→(0,out0)→(1,out0)
- Output stream:
0 0 1 0 0lekin1doosre1ke same cycle mein produce hota hai — Moore se "time" mein ek cycle pehle.
Common Mistakes
Recall Feynman: ek 12-saal ke bachche ko explain karo
Ek board game imagine karo jahan ek chhota marker ek square par rakha hai. Clock ki har "tick" par tum ek card padhte ho (input) aur rules batate hain ki marker ko kis square par le jaana hai. Har square ek state hai, aur marker machine ki memory hai. Moore game mein, jo prize tum jeetते ho woh us square par likha hota hai jahan tum land karte ho. Mealy game mein, prize us arrow par likha hota hai jis par tum chalte ho, toh yeh is par bhi depend karta hai ki tumne kaun sa card padha. Same game hai, lekin Mealy tumhe chalte waqt pay karta hai jabki Moore land karne ke baad pay karta hai.
Active-Recall Flashcards
FSM ke 6 tuple components kya hain?
Moore machine mein output kis par depend karta hai?
Mealy machine mein output kis par depend karta hai?
Moore state diagram mein output kahan likha hota hai?
Mealy state diagram mein output kahan likha hota hai?
states ke liye kitne flip-flops chahiye?
Kaun si machine ko aam taur par kam states ki zaroorat hoti hai, Mealy ya Moore?
Kaun si machine ke outputs glitch-free aur synchronous hote hain?
Kaun si machine same clock cycle mein input change par react kar sakti hai?
Real hardware mein reset/initial state kyun matter karta hai?
Kisi bhi FSM ke teen hardware blocks kaun se hain?
Connections
- Flip-flops — state register ke liye storage element
- Sequential Circuits — FSMs canonical clocked sequential circuit hain
- Combinational Logic — aur blocks banata hai
- State minimization — flip-flops/logic bachane ke liye reduce karna
- State encoding — states ko codes assign karna binary / one-hot / Gray mein
- Clocking and timing — kyun Moore glitch-free hai aur Mealy glitch kar sakta hai
- Sequence detectors — classic FSM application