5.2.3 · HinglishProcessor Datapath & Pipelining

Classic 5-stage pipeline (IF - ID - EX - MEM - WB)

1,869 words8 min readRead in English

5.2.3 · Hardware › Processor Datapath & Pipelining


Paanch stages (WHAT har ek karta hai)

Figure — Classic 5-stage pipeline (IF - ID - EX - MEM - WB)

Pipeline registers (HOW stages alag rehte hain)

Chaar inter-stage registers ko IF/ID, ID/EX, EX/MEM, MEM/WB naam diya gaya hai. Yeh data (operands, immediate, ALU result) aur control signals (RegWrite, MemRead, MemWrite, ...) forward carry karte hain, kyunki ID mein liye gaye control decisions ko WB tak pahunchna hota hai chaar cycles baad.


Timing: throughput & speedup scratch se derive karna


Worked examples


Common mistakes (Steel-man + fix)


Recall Feynman: ek 12-saal ke bache ko explain karo

Socho bartan dhone ke 5 steps hain: khaana saaf karo, dhoo, rinse karo, sukhaao, stack karo. Agar ek baccha ek plate ke liye saare 5 steps kare agali plate uthane se pehle, toh chaar steps hamesha kuch nahi karte. Iske bajaye, 5 bachche line mein khade karo — jaise hi "scrape" wala baccha plate 1 finish karke age bhejta hai, woh plate 2 uthata hai. Ab har kuch seconds mein ek clean plate akhir mein nikalti hai chahe har plate 5 steps leti ho line traverse karne mein. Bachcho ke beech ke chhote trays jo half-done plate hold karte hain woh "pipeline registers" hain. Bilkul aise hi CPU instructions ko pipeline karta hai.


Active recall

Classic pipeline ke paanch stages order mein kya hain?
IF (fetch), ID (decode/register read), EX (execute/address calc), MEM (memory access), WB (write back).
Source registers kaun se stage mein read hote hain, aur results kaun se stage mein write hote hain?
ID mein read hote hain; WB mein write hote hain.
Clock period sabse slow stage delay plus latch overhead ke barabar kyun honi chahiye?
Sab stages ek clock share karte hain; pipeline har cycle advance hoti hai toh apne sabse slow stage ki pace se chalti hai, aur har stage ko apna result latch karna hota hai (delay d). .
k-stage pipeline mein N instructions (no stalls) kitne cycles mein chalenge?
— k fill karne mein, phir har subsequent cycle mein ek complete hoti hai.
k-stage pipeline ka ideal speedup limit kya hai jab N→∞?
k× (throughput stages ki number se bounded hai).
Kya pipelining ek single instruction ki latency reduce karta hai?
Nahi — single-instruction latency thodi badhti hai; yeh throughput (instructions per second) improve karta hai.
Pipeline registers (IF/ID, ID/EX, EX/MEM, MEM/WB) kya carry karte hain?
Data (operands, immediate, ALU result) AUR control signals sahi stage/cycle tak forward karte hain.
Store (sw) apne purpose ke liye kaun se stages actually use karta hai?
IF, ID (base+data read karo), EX (address = base+offset), MEM (write karo); no WB.
Add-type instructions MEM aur WB se kyun guzarte hain jab MEM idle hai?
Taaki sab instructions ki same 5-stage shape ho, control uniform rahe aur har cycle ek instruction finish ho sake.

Connections

Concept Map

goal

analogy

divides work into

step 1

feeds

feeds

feeds

feeds

separated by

named

carry data plus

clock set by

5-Stage Pipeline

Higher throughput

Assembly line

5 stages

IF Fetch from PC

ID Decode read regs

EX ALU compute

MEM Load or store

WB Write register file

Pipeline registers

IF/ID ID/EX EX/MEM MEM/WB

Control signals

T_clk = max stage + latch d