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.

⏱ 16 min• Intermediate• Data Representation

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
Interview gold: Q: "Fetch cycle ke steps?" — Fetch, Decode, Execute (aur kabhi Store). Har CS interview mein ye aata hai. PC (Program Counter) hamesha AGLE instruction ka address rakhta hai — current nahi!

Registers important hain

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

Desi example: Kitchen ka head chef

CPU ko kitchen samjho — chef (ALU) pakata hai, manager (CU) coordinate karta hai, aur ready order (ACC) rakhte hain:

text
Fetch   : order padha (next recipe)
Decode  : samjha kya banana hai
Execute : ALU ne calculation ki
Store   : result dish mein (register)
Exam mapping (GATE / TCS / Interviews)
  • 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.
Lesson complete?

CPU architecture clear! Agla lesson — Operating System — mein dekhenge OS kaise hardware manage karta hai.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course