3.3.13 · HinglishCombinational Circuits

ALU design fundamentals

1,696 words8 min readRead in English

3.3.13 · Hardware › Combinational Circuits


ALU KYA hota hai?

Core insight: ek ALU = arithmetic unit + logic unit, dono ek selector ko feed hote hain.


Ise HOW build karte hain — first principles se

Step 1: 1-bit full adder (arithmetic ka dil)

Step 2: SAME hardware se ADD aur subtract karo

Step 3: Logic unit

Bitwise AND, OR, XOR, NOT sirf gates hain jo parallel mein har bit pair par apply hote hain — sasta aur fast.

Step 4: MUX se select karo

Saare operation results ek saath exist karte hain; select lines ek MUX drive karti hain taaki sirf ek par appear ho. Nayi operation add karna = uska circuit add karo + ek aur MUX input.

Figure — ALU design fundamentals

Status Flags (har ek derive karo)


Worked Examples (4-bit ALU)


Common Mistakes


Active Recall

Recall Reveal se pehle predict karo (Forecast-then-Verify)
  1. Ek control bit adder ko subtractor kyun bana sakta hai? → Kyunki ; ko ke saath XOR karo aur ko ke roop mein feed karo.
  2. Overflow kyun hota hai? → Sign bit mein jaane wali aur bahar aane wali carry disagree karti hain ⇒ sign corrupt ho gayi.
  3. Operation ka "selection" kahan hota hai? → Select lines se drive ek MUX ek parallel result ko pick karta hai.
Recall Feynman: 12-saal ke bachche ko explain karo

Imagine ek calculator jo already har jawab compute kar chuka hai — plus ka jawab, minus ka jawab, "compare" ka jawab — sab ek saath, aur unhe lineup mein rakh diya. Phir ek chhota sa switch (select lines) simply us drawer ki taraf point karta hai jo tumne manga aur woh jawab deta hai. Yahi ALU hai: sab kuch karo, phir pick karo. Subtraction ek cheeky trick hai — B ke saare bits flip karo aur ek add karo, aur "add" ko "subtract" mein convert kar liya bina nayi machinery ke.


Flashcards

What is an ALU?
Ek combinational circuit jo do n-bit inputs par arithmetic + logic karta hai, control lines se select hota hai, aur result plus status flags (Z,C,N,V) produce karta hai.
Why is the ALU purely combinational?
Iska output sirf current inputs A, B, S par depend karta hai; iske andar koi internal memory ya clock nahi — state bahar ke registers mein hoti hai.
Sum bit formula of a full adder?
(parity: 1 jab odd number of inputs 1 hon).
Carry-out formula of a full adder?
(generate OR propagate).
How does one control bit make an adder subtract?
B ko S_sub ke saath XOR karo aur carry-in c0 = S_sub set karo; phir S_sub=1 deta hai A + ¬B + 1 = A − B.
Overflow (signed) flag formula?
: sign bit mein jaane wali carry aur bahar jaane wali carry alag hain.
Zero flag formula?
— saare result bits ka NOR (1 tab jab result zero ho).
Difference between Carry and Overflow flags?
C = unsigned overflow (carry out of MSB); V = signed overflow (sign bit corrupt ho gayi).
For a two's-complement subtractor, what does C=1 mean?
Koi borrow nahi hua (result non-negative); borrow = ¬C.
How is one of many operations selected in an ALU?
Saare ops parallel mein compute hote hain; select lines se drive ek multiplexer chosen result ko F par route karta hai.

Connections

  • Full Adder — ALU ka arithmetic core
  • Two's Complement — kyun kaam karta hai
  • Multiplexer — operation kaise select hota hai
  • Carry Lookahead Adder — addition path ko speed up karna
  • Status Flags and Condition Codes — flags branches ko kaise drive karte hain
  • Ripple Carry Adder — sabse simple add implementation
  • Datapath and Control Unit — CPU mein ALU kahan hota hai

Concept Map

feed

feed

arith result

logic result

pick one

outputs

converts adder to A - B

derives

carry-out cn

contains

ALU Combinational Unit

Inputs A and B

Select lines S

Full Adder Chain

Logic Unit AND OR XOR NOT

Multiplexer

Result F

Status Flags

Sub control XOR + c0