Lesson 8 — Intermediate
CPU Architecture & Fetch Cycle
CPU computer ka brain hai — lekin ye chalta kaise hai? Is lesson mein hum dekhenge registers, control unit, aur wo famous fetch-decode-execute cycle jo har instruction pe chalta hai. Ye interview ka sabse poochha jaane wala topic hai.
CPU ke andar kya hota hai
WHAT
CPU mein 3 core parts hain — ALU (calculation), Control Unit (coordination), aur Registers (turant storage). Inhi ka coordination se har instruction chalta hai.
WHEN
Har program run hote waqt — har ek line/instruction ye teeno use hoti hain. Ek keystroke bhi isi cycle se guzarta hai.
WHERE
CPU chip ke andar. Registers CPU ke sabse andar fast memory hain, ALU aur CU unke saath logic mein baithe hain.
CPU ko chalane ke liye ek sequence chahiye — ye sequence hai fetch-decode-execute cycle. Har instruction ke liye ye 3 step baar baar repeat hote hain.
Fetch-Decode-Execute cycle
1. FETCH : PC (Program Counter) se instruction address lo,
memory se instruction CPU mein lao,
PC ko agle instruction pe move karo
2. DECODE : Control Unit samjhe ye instruction kya keh raha hai
(add? load? jump?) — opcode identify karo
3. EXECUTE : ALU ya CU instruction ko actually perform karo
(calculation, data move, etc.)
4. STORE : Result wapas register/memory mein likho
Ye cycle repeats hoti hai — GHz speed pe billions cycles/sec
Registers important hain
- PC (Program Counter): agla instruction ka address (memory location).
- IR (Instruction Register): jo instruction abhi fetch hui hai wo.
- ACC (Accumulator): ALU ke results yahin store hote hain.
- SP (Stack Pointer): stack ke top ka address.
- FLAGS/PSW: status flags (zero, carry, sign) — comparison results.
Registers ko yaad karne ka trick: PC = future, IR = present, ACC = results. Ye teen CPU ki daily life hain.
Control Unit ke 2 tarike
Hardwired CU : Circuit design se control signals bante hain
Fast, lekin design change karna mushkil
Microprogrammed : Instructions chhote micro-instructions mein tod
Flexible, lekin thoda slow
Microprogram : Ek instruction → sequence of micro-operations
Control memory : Microinstructions stored yahin
Hardwired = fixed wiring (fast, rigid), Microprogrammed = stored program (flexible, slow). Exam mein dono ke comparison mein 1 question aksar aata hai.
Exercise
Question: Fetch cycle mein pehla step kya hai? (fetch/decode/execute)
Question: Program Counter (PC) kya rakhta hai — current instruction ka address ya next ka?
Question: ALU ke results kaunsa register store karta hai? (ACC/PC/IR)
Common mistakes
- PC ko current address samajhna: PC hamesha NEXT (agle) instruction ka address rakhta hai, current nahi.
- Fetch-Decode-Execute ka order ulta bolna: Sahi order: Fetch → Decode → Execute. Pehle aana padta hai tabhi samajh aayega.
- Control Unit ko processing samajhna: CU khud calculate nahi karta — wo sirf coordinate karta hai. Calculation ALU karta hai.
CPU ko kitchen samjho — chef (ALU) pakata hai, manager (CU) coordinate karta hai, aur ready order (ACC) rakhte hain:
Fetch : order padha (next recipe)
Decode : samjha kya banana hai
Execute : ALU ne calculation ki
Store : result dish mein (register)- GATE: fetch-decode-execute + register functions deep questions.
- TCS NQT: "What does PC store?" — next instruction address.
- Interview: hardwired vs microprogrammed CU comparison.
- Trap: "PC stores current instruction" — galat, woh IR hai.
CPU architecture clear! Agla lesson — Operating System — mein dekhenge OS kaise hardware manage karta hai.