3.3.7 · HinglishCombinational Circuits

Encoders and priority encoders

1,872 words9 min readRead in English

3.3.7 · Hardware › Combinational Circuits


Encoder KYA hota hai?

YEH KYUN exist karta hai? Socho ek keypad par 8 buttons hain. Har jagah 8 alag wires chalana wasteful hai. Iske bajay, "kaun sa button" encode karo sirf 3 wires mein (). Information ka compression position se number mein.


4-to-2 encoder scratch se KAISE derive karte hain

Humare paas inputs hain. Ek waqt mein sirf ek HIGH hoti hai. Outputs ko index binary mein dena chahiye.

Step 1 — truth table banao. (Kyun? Kyunki poora behaviour sirf "index → binary" hai.)

Active input
0 0
0 1
1 0
1 1

Step 2 — dekho ki kaun se inputs har output ko 1 banate hain.

  • jab active input ya ho (odd indices).
  • jab active input ya ho (indices ).

Yeh step kyun? Har output bit bas yahi hai ki "kaun se indices us bit position mein 1 rakhte hain?" Yeh literally binary representation hai.

Step 3 — generalize karo. Ek -to- encoder ke liye:

Kyun? Output bit ko 1 hona chahiye exactly un input indices ke liye jinka -vaan binary digit 1 hai.


Plain encoder ki PROBLEM


Priority Encoder — KYA aur KYUN

KYUN: real systems (interrupts, keypads) mein ek saath kai requests aa sakti hain. Humein ek deterministic rule chahiye: "sabse important ko serve karo." Priority = ek tie-breaker.

4-input priority encoder derive karna

Priority: . ka matlab "don't care" hai.

0 0 0 0 0
0 0 0 1 0 0 1
0 0 1 0 1 1
0 1 1 0 1
1 1 1 1

Step 1 — : valid tab jab kuch bhi on ho. Kyun? Sabhi inputs ka OR = "kam se kam ek active."

Step 2 — : indices 2 aur 3 ke liye 1 hona chahiye. present ⇒ . Ya present aur koi usse bada isko block na kare — lekin kyunki dono 2 aur 3 ke liye waise bhi hai: Pehle jaisa kyun? Dono indices 2 aur 3 mein bit-1 set hai, aur , par dominate karta hai lekin dono dete hain, isliye is bit ke liye koi suppression ki zaroorat nahi.

Step 3 — : indices 1 aur 3 ke liye 1. Lekin ko suppress karna padega agar koi usse bada input ( ya ) active ho (bade wale dete hain). kyun? Agar active hai to woh se upar hai; index 2 chahta hai . Isliye tabhi count hota hai jab off ho. hamesha force karta hai chahe kuch bhi ho (index 3 odd hai).


Worked Examples


Recall Feynman style: ek 12-saal ke bachche ko samjhao

Socho 8 doorbells ki ek row hai, 0 se 7 tak numbered. Daadi ke kamre mein 8 lambi wires bhejne ki bajay, hum sirf 3 wires bhejte hain jo number spell karte hain us bell ka jo bajaya gaya — binary mein (jaise 0-1-1 = bell 3). Woh gadget ek encoder hai. Lekin agar do bachche ek saath bells bajayein? Ek plain encoder confuse ho jaata hai aur galat number chillata hai. To hum ek rule add karte hain: "hamesha sabse bada bell number report karo." Woh polite, rule-following version ek priority encoder hai. Aur ek choti extra light () tabhi jalti hai jab koi sach mein bajata hai, taaki daadi "bell 0" aur "koi nahi hai" mein fark kar sake.


Flashcards

Encoder kya hota hai (inputs/outputs ke terms mein)?
Ek -to- device: inputs, outputs; jab ek input active hoti hai to woh us input ka binary index output karta hai.
Encoder vs decoder?
Decoder: (number to one-hot line). Encoder: (one-hot line to number). Dono ek doosre ke inverse hain.
4-to-2 plain encoder equations batao.
, .
Plain encoder multiple active inputs ke saath kyun fail hota hai?
OR gates alag indices ke bits ko merge kar dete hain, jo kisi bhi input ka code produce nahi karta (jaise ).
Plain encoder all-zero input ke saath kyun fail hota hai?
Output , " active" se ambiguous hai. "Kuch nahi" aur index 0 mein fark nahi kar sakte.
All-zero ambiguity ko kaun sa extra output fix karta hai?
Valid bit , HIGH tab jab kam se kam ek input active ho.
Priority encoder alag kya karta hai?
Jab kai inputs active hon to woh highest-priority (highest-index) wale ka code output karta hai, baaki ko ignore karke.
4-input priority encoder equations batao.
; ; .
mein term kyun hai?
(index 2), se upar hai; jab active ho, ka contribution suppress hona chahiye taaki index 2 ka code (10) produce ho.
Encoder ke output bit ke liye general rule kya hai?
Sabhi inputs ka OR jinke index mein bit 1 ke barabar ho.

Connections

  • Decoders — encoder ka bilkul ulta operation.
  • Multiplexers — muxes data select karte hain; encoders kaun si line active hai select karte hain.
  • Interrupt controllers — priority encoders ka real hardware use (kaun sa IRQ pehle serve karna hai).
  • Boolean algebra simplification — OR-based equations derive/minimize karne ke liye use hota hai.
  • Karnaugh maps — don't-cares ke saath priority-encoder logic derive karne ka tool.
  • Combinational circuits — parent topic; encoders memoryless logic hain.

Concept Map

opposite of

behaviour captured by

read off bits

generalizes to

built from

fails when

fails when

fixed by

fixed by

outputs highest index

includes

Decoder

Encoder

Truth table index to binary

4-to-2 equations Y0 Y1

General 2^n to n formula

OR gates only

Multiple inputs HIGH

No input HIGH

Priority encoder

Valid bit V