3.4.10 · HinglishSequential Circuits

Finite state machines (Mealy and Moore)

1,772 words8 min readRead in English

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:

Figure — Finite state machines (Mealy and Moore)
  1. State register — flip-flops jo current state hold karte hain. Har clock edge par next state par update hota hai.
  2. Next-state logic — combinational logic jo compute karta hai.
  3. 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 ki 1 doosre 1 ke 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 0 lekin 1 doosre 1 ke 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?
States , initial state , inputs , outputs , next-state function , output function .
Moore machine mein output kis par depend karta hai?
Sirf current state par: .
Mealy machine mein output kis par depend karta hai?
Current state AUR current input par: .
Moore state diagram mein output kahan likha hota hai?
State bubble ke andar.
Mealy state diagram mein output kahan likha hota hai?
Transition arrows par.
states ke liye kitne flip-flops chahiye?
.
Kaun si machine ko aam taur par kam states ki zaroorat hoti hai, Mealy ya Moore?
Mealy.
Kaun si machine ke outputs glitch-free aur synchronous hote hain?
Moore.
Kaun si machine same clock cycle mein input change par react kar sakti hai?
Mealy (uska output input mein combinational hai).
Real hardware mein reset/initial state kyun matter karta hai?
Power-up state undefined hoti hai; reset FSM ko ek known mein force karta hai.
Kisi bhi FSM ke teen hardware blocks kaun se hain?
State register, next-state (combinational) logic, output (combinational) logic.

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

Concept Map

defined as

includes

includes

state only

state AND input

glitch-free but late

immediate but glitchy

built from

holds state

computes delta

computes lambda

needs

drives

Finite State Machine

6-tuple S s0 I O delta lambda

Next-state function delta

Output function lambda

Moore machine

Mealy machine

Design trade-offs

Three-block skeleton

State register flip-flops

Next-state logic

Output logic

n equals ceil log2 of S flip-flops