5.1.4 · D4 · HinglishInstruction Set Architecture (ISA)

ExercisesRegister file organization

2,760 words13 min read↑ Read in English

5.1.4 · D4 · Hardware › Instruction Set Architecture (ISA) › Register file organization

Shuru karne se pehle, yahan ek card par poora symbol kit hai taaki kuch bhi "kahin se bhi" nahi aata lage.

Figure — Register file organization

Upar diya gaya figure woh ek picture dikhata hai jis par sab kuch based hai: rows ka ek grid (ek row per register), har row cells wide, jisme read wires aur write wires har cell se guzar rahi hain. Is image ko apne dimag mein rakho — zyaadatar exercises sirf yahi hain ki "agar main ek number badloon toh is grid ka kya hoga?"


Level 1 — Recognition

Recall Solution

KYA: hum sabse chhota chahte hain jis par ho. KYU: har address bit se aap jo registers naam de sakte ho woh double ho jaata hai; aapko itne patterns chahiye ki har register ko ek unique naam mil sake. Check karo: exactly, toh 4 bits se saare 16 registers ko naam milte hain, koi bacha nahi.

Recall Solution
  • Read = ek ==-to-1 multiplexer== (MUX): bahut saare inputs, ek ko output wire par choose karo. Har read port ke liye ek MUX.
  • Write = ek ==-to- decoder== jiske outputs ek global WriteEnable ke saath AND hote hain: yeh exactly ek register ki capture line ko light up karta hai. YE DONO KYU, AUR KOI KYU NAHI? "Bahut saare mein se ek wire par choose karo" MUX ki definition hai; "ek wire ko bahut saare mein se ek ko bhejna" decoder ki definition hai. Ye dono ek doosre ke mirror image hain. Dekho Multiplexers and Decoders.

Level 2 — Application

Recall Solution

KYA: total state . KYU: ports wiring/area ko affect karte hain, stored data ko nahi. Jo aap store kar sakte ho woh sirf (slots ki sankhya) × (har slot ki width) hai.

Recall Solution

KYA: har register field bits ka hai, aur 3 fields hain. KYU YEH MATTER KARTA HAI: woh 15 bits tab hi khatam ho jaate hain jab aap opcode ke liye ek bhi bit nahi kharchte. Isliye badhana free nahi hai — yeh har instruction ko wide kar deta hai. Dekho Instruction Set Architecture (ISA).

Recall Solution

KYA: area , aur unchanged hain toh woh cancel ho jaate hain. YAISE DIKHTA HAI: grid figure mein, ports double karne se har cell ke through wire bundle mota ho jaata hai (zyada wires) aur har cell upar-neeche aur left-right bhi stretch hoti hai — height × width dono badhte hain, toh product square ke roop mein badhta hai. Chaar times bada, do times nahi.


Level 3 — Analysis

Recall Solution

KYA instruction maangta hai: add rd, rs1, rs2 ko ek hi cycle mein rs1 aur rs2 padhna hota hai (yeh 2 simultaneous reads hain) aur baad mein ek result rd mein store karna hota hai (1 write). KYU woh ports se map karta hai: ALU ke paas do operand inputs aur ek result output hai (dekho Datapath and ALU). Ek saath do operands read karna ⇒ ; ek result ⇒ . Kam read ports se ALU apne doosre operand ka wait karte karte bhookha reh jaata. Kya badal deta hai: ek cycle mein zyada instructions issue karna (superscalar), ya 3 source operands wala instruction (e.g. fused multiply-add 3 padhta hai), ko upar push karta hai; ek cycle mein do results commit karna ko upar push karta hai. Har bump square ka cost lagata hai.

Recall Solution

KYA hota hai timing policy par depend karta hai:

  • Read-first: read port purana R5 value dekhta hai (write clock edge par land hoti hai, read sample kar chuka hone ke baad).
  • Write-first / internal forwarding: nayi value ko read bus par steer kiya jaata hai, toh reader nayi R5 paata hai. KYU MATTER KARTA HAI: agar baad wali dependent instruction ko abhi-abhi compute ki gayi value chahiye aur file read-first hai bina kisi help ke, toh woh stale data padhti hai — ek data hazard. Real designs ek forwarding/bypass MUX add karte hain jo read address ko write address se compare karta hai aur, match hone par, fresh value seedha through feed karta hai. Dekho Pipeline Hazards.

Level 4 — Synthesis

Recall Solution

KYA: har issued op ko 2 reads aur 1 write chahiye, aur 3 parallel mein issue hote hain. Area factor: KYU YEH REAL CHIPS KO SHAPE KARTA HAI: ek 3-wide file single-issue wali ki area hai. Isliye wide machines aksar register file ko bank ya cluster karti hain — ise chhote copies mein split karo taaki har copy ke ports kam hon, square law se bachte huye. Yahi ek core reason hai ki superscalar design mushkil hai.

Recall Solution

KYA trick aapko deti hai:

  • mov rd, rs add rd, rs, r0 kyunki .
  • nop add r0, r0, r0 — yeh compute karta hai aur R0 mein write discard ho jaati hai, toh kuch nahi badlta. KYU YEH OPCODES BACHATA HAI: aap wahi ALU add reuse karte ho jo aapne already banaya hai; koi dedicated mov/nop opcode nahi chahiye, encoding space free hota hai (dekho RISC vs CISC). Hardware cost: basically kuch nahi — aap R0 ke liye flip-flops nahi banate; uska read-MUX input line low pe tied hota hai (constant 0), aur uski decoder line disconnect hai taaki writes gayab ho jaayein.

Level 5 — Mastery

Recall Solution

(a) Address width. bits. Kyun: saare registers ko naam deta hai, R0 samete (uska naam toh hai, bas hamesha 0 padhta hai). (b) Usable stored bits. Saare 32 slots ka naam hai lekin R0 ke flip-flops nahi hain, toh 31 real registers data store karte hain: (Naive ek aisa slot count karta hai jo kuch store nahi karta.) (c) add mein register-name bits. Teen fields, har ek : bits. (d) Widening factor. — chaar times area.

Recall Solution

Design A area (common drop karo): Design B area (do banks, unhe add karo): Ratio: . Design B is 4× chhota is simplified model mein. KYU REALITY REFLECT KARTA HAI: banking square law se bachta hai har bank ka port count kam rakh kar. Catch yeh hai (area formula mein nahi): ek operand jo "wrong" bank mein hai woh cross-bank read force karta hai, toh real designs operands ko sahi bank mein schedule karni padti hain — ek genuine engineering trade-off. Dekho Datapath and ALU.


Active Recall

Recall Quick self-quiz (answers hidden)
  1. ⇒ kitne address bits? → .
  2. , R0 hardwired ⇒ usable stored bits? → .
  3. jaane par area kitne times badha? → .
  4. 3-issue, 2R+1W each ⇒ aur area factor? → ; .
  5. Register file ko bank kyun karte hain? → ports-per-bank kam rakhne ke liye, square law se bachte huye.

Connections


For registers, how many address bits per register field?
.
Going from to , how many times larger is the register file?
.
Why bank/cluster a superscalar register file?
To keep each bank's port count low and dodge the area square law.