5.1.1 · D3 · HinglishInstruction Set Architecture (ISA)

Worked examplesCISC vs RISC philosophies

3,698 words17 min read↑ Read in English

5.1.1 · D3 · Hardware › Instruction Set Architecture (ISA) › CISC vs RISC philosophies

Yeh page CISC vs RISC philosophies ki hands-on companion hai. Wahan humne philosophy build ki thi; yahan hum compute karte hain. Har example neeche diye matrix ka ek cell cover karta hai, taaki end tak koi bhi CISC-vs-RISC arithmetic question exam mein aisa na ho jo tumne already worked form mein na dekha ho.

Koi bhi number chhune se pehle, chalte hain us ek tool ko re-anchor karte hain jis par sab kuch tika hua hai.

Hum ise baar baar use karenge, toh chalte hain ek baar ise picture karte hain.

Figure — CISC vs RISC philosophies

Figure ko ek volume ki tarah padho: depth hai, width hai, height hai, aur CPU time woh box hai jo ye sab enclose karte hain. Ek edge badhao aur do ghataao, aur box phir bhi shrink ho sakta hai — isliye RISC afford kar sakta hai badhana agar woh CPI aur zyada hard shrink kare. Har box ke neeche number uska volume = CPU time hai.


The scenario matrix

Har CISC-vs-RISC computation jo tumse kabhi bhi poochi jaayegi, woh in cells mein se ek mein hoti hai. Har row ek case class hai; last column us example ka naam deta hai jo ise cover karta hai.

# Case class Tricky kyon hai Covered by
A RISC wins (the "normal" bet pays off) zyada , lekin CPI + dominate karte hain Example 1
B CISC wins (the bet fails) jab RISC ka blow-up bahut bada ho Example 2
C Exact tie boundary — koi bhi faster nahi Example 3
D Mixed units ( vs frequency ) GHz diya hai, ns nahi Example 4
E Degenerate: everywhere limiting "ideal RISC" Example 5
F Zero / pathological input , ya stall se CPI blow up ho jaaye Example 6
G Real-world word problem English → equation mein translate karo Example 7
H Exam twist: solve for the unknown answer diya hai, ek factor dhundho Example 8
I Instruction-count from code (μop expansion) RISC lines vs ek CISC line count karo Example 9

Example 1 — Cell A: the RISC bet pays off

Step 1 — CISC time compute karo. Yeh step kyun? Hum sirf wahi ek equation apply kar rahe hain — koi shortcuts nahi. Hum end mein milliseconds mein convert karte hain taaki dono numbers ek nazar mein comparable hon (, toh decimal 6 jagah move karo).

Step 2 — RISC time compute karo. Yeh step kyun? Same equation, RISC ke numbers ke saath. Dhyaan do bada pehla factor lekin chhote baaki do. Phir wahi conversion se .

Step 3 — Ratio lo (slower upar). Yeh step kyun? "Kitne factor se" ka jawab ratio se milta hai, difference se nahi — yeh batata hai kitne times faster, units se independent. CISC (slower, bigger time) ko upar rakha taaki answer padhe "RISC is 3.03× faster."

Recall Verify

Units: ✓. RISC faster hai despite 50% zyada instructions — extra crush ho gaya CPI drop aur cycle-time drop se. Yahi puri RISC argument ek ratio mein hai.


Example 2 — Cell B: the bet fails, CISC wins

Step 1 — CISC time. Yeh step kyun? Same equation. CISC ka high CPI uski weakness hai — lekin uska tiny dekho. Convert: .

Step 2 — RISC time. Yeh step kyun? RISC ka 12× explode hua kyunki ek CISC string instruction ko poore software loop ki zaroorat thi. Yeh uske CPI/ advantage se zyada hai. Convert: .

Step 3 — Ratio (slower upar). Yeh step kyun? Yahan RISC slower hai, toh RISC ka time upar jaata hai; result padhta hai "RISC is 1.8× slower than CISC." Hamesha bada time upar rakho taaki factor ho.

Recall Verify

RISC 1.8× slower hai yahan. Lesson yeh hai: RISC ka bet ek bet hai, koi law nahi. Jab ek workload exactly us specialised instruction par map karta hai jo CISC provide karta hai (string moves, REP MOVSB on x86), tab blow-up sab kuch overwhelm kar sakta hai. Isliye modern RISC ISAs ne richer extensions add kiye — dekho x86 vs ARM.


Example 3 — Cell C: the exact tie

Step 1 — CISC time. Yeh step kyun? Hum CISC se start karte hain kyunki hum hamesha pehle dono raw times compute karte hain, phir compare karte hain. rule se ms mein convert karo taaki dono ek hi scale par padhein: .

Step 2 — RISC time. Yeh step kyun? RISC ke liye same equation. Products same number par land karte hain — dono dete hain usi conversion ke baad, jo is boundary case ka pura point hai.

Step 3 — Ratio (koi bhi upar). Yeh step kyun? Jab koi bhi slower nahi hota, ratio exactly hota hai chahe koi bhi time upar rakho — yeh tie ka unambiguous fingerprint hai.

Recall Verify

Ratio dead tie. Yeh boundary case hai: RISC ka on exactly cancel karta hai uska on CPI (). Aise boundary cases prove karte hain ki equation ek genuine trade-off surface hai, ek one-sided win nahi.


Example 4 — Cell D: cycle time nahi, frequency diya hai

Step 1 — Frequency ko cycle time mein convert karo. Clock frequency ticks per second count karta hai; cycle time sirf uska reciprocal hai, kyunki "seconds per tick" "ticks per second" ka ulta hai: Yeh step kyun? Equation ko seconds per cycle chahiye; problem ne cycles per second diya hai. Pehle flip karna zaroori hai warna har unit downstream galat ho jaayega. Yeh exam ka sabse common trap hai.

Step 2 — CISC time. Yeh step kyun? Ab nanoseconds mein hai, toh hum teen factors ko usual taur par multiply kar sakte hain. Result ko rule se convert karo: .

Step 3 — RISC time. Yeh step kyun? Same equation RISC ke converted ke saath. Hum dono machines ke liye same units (ns) rakhte hain taaki comparison apples-to-apples ho; phir convert karo: .

Step 4 — Ratio (slower upar). Yeh step kyun? CISC yahan slower machine hai, toh uska time upar jaata hai; directly padhta hai "RISC is 3.72× faster." Ratio shared ms unit bhi cancel karta hai, ek pure number deta hai.

Recall Verify

, toh ✓ — reciprocal genuinely ek time produce karta hai. RISC faster hai. Agar tumne GHz flip karna bhool ke aur directly as times plug kiye hote, toh har answer ke factor se galat hota — units tumhari alarm bell hain.


Example 5 — Cell E: the ideal-RISC limit,

Step 1 — Cycle time. Yeh step kyun? Frequency → time, same reciprocal pehle jaisa, kyunki equation seconds per cycle maangti hai.

Step 2 — Total time at the CPI floor. Yeh step kyun? ke saath, middle factor 1 se multiply karta hai aur effectively disappear ho jaata hai — time par collapse ho jaata hai, yaani exactly ek tick per instruction. Hum ise explicitly compute karte hain taaki woh collapse dikhe, phir convert karo . Yeh woh limiting best case hai jo ek single-issue pipeline reach kar sakti hai; CPI se neeche nahi jaa sakte bina ek cycle mein ek se zyada instruction issue kiye (superscalar, out of scope yahan). Dekho Pipelining.

Recall Verify

✓ — identical, confirm karta hai ki CPI equation ko "ek cycle each" tak collapse kar deta hai. Degenerate case exactly waisa behave karta hai jaise picture predict karti hai.


Example 6 — Cell F: pathological inputs (zero, aur ek stall blow-up)

Step 1 — (a) The zero case. Yeh step kyun? poore product ko kill kar deta hai baaki factors chahe jo bhi hon — koi instructions nahi, koi time nahi. Yeh trivial floor hai, aur yeh confirm karta hai ki ek genuine multiplicative factor hai (ek sum-based formula yahan misbehave karta).

Step 2 — (b) Weighted average se effective CPI build karo. Non-load instructions cost 1 cycle; loads cost cycles. Half and half: Yeh step kyun? CPI instruction mix par ek average hai, toh jab instruction classes alag amounts cost karti hain to hum har class ko weight karte hain uski frequency se — yahan 50% cheap ( cycle) aur 50% expensive ( cycles). Dono costs ka plain average tab hi kaam karta hai jab split 50/50 ho; generally tum har class ki frequency se weight karte ho. Yeh honest real CPI hai, ideal nahi.

Step 3 — Blown-up CPI ke saath total time. Yeh step kyun? Hum effective CPI (fantasy CPI of 1 nahi) ko master equation mein feed karte hain, kyunki yahi woh CPI hai jo hardware actually experience karta hai. rule se convert karo: .

Recall Verify

(a) ms ✓. (b) CPI of zyattar CISC se bhi worse hai — proof ki RISC ka low-CPI promise conditional hai memory system ke cooperate karne par. Jab nahi karta, RISC ka "1 cycle each" fantasy collapse ho jaata hai. Exactly isliye real chips transistors caches par spend karte hain, sirf ISA par nahi.


Example 7 — Cell G: real-world word problem

Step 1 — CISC ka instruction count uske known time se recover karo. se, ke liye solve karo: . Yeh step kyun? directly nahi diya hai, lekin word problem ne time diya hai, toh hum equation ko invert karte hain hidden instruction count extract karne ke liye. Yeh bridge hai English se arithmetic tak.

Step 2 — RISC ke instruction count tak scale karo. Yeh step kyun? "1.3× as many instructions" par ek direct multiplier hai — compiler ka expansion factor. RISC ka time compute karne se pehle CISC instruction count ko RISC wale mein convert karna zaroori hai, kyunki dono machines alag amount ka kaam run karti hain. Dekho Compiler Optimization.

Step 3 — RISC cycle time aur total time. Yeh step kyun? RISC ki frequency ko cycle time mein flip karo (Example 4 jaisa same reciprocal rule), phir master equation apply karo RISC ke apne , CPI aur ke saath. Yahan sab kuch seconds mein rakhte hain kyunki laptop ka baseline already seconds mein hai — matching units matlab end mein koi conversion nahi.

Recall Verify

vs → phone laptop ke aadhe se bhi kam time mein finish karta hai. Sanity: CPI drop hua (), jo akele instruction growth aur slower clock ko beat karne ke liye kaafi hai. Gut confirmed.


Example 8 — Cell H: exam twist, unknown ke liye solve karo

Step 1 — CPI ke liye equation invert karo. Yeh step kyun? Unknown ab CPI hai, aur hume target time diya gaya hai — toh hum master equation ko rearrange karte hain CPI isolate karne ke liye na ki forward multiply karne ke liye. Same equation, alag unknown ke liye solve kar rahe hain.

Step 2 — Plug in karo. Yeh step kyun? Denominator woh "time if CPI were 1" hai. Target ko us se divide karne par, ek shot mein, pata chalta hai kitna CPI headroom hai. Note karo ki seconds top aur bottom cancel ho jaate hain, correctly CPI ko dimensionless chodh ke.

Recall Verify

ek bahut bada budget hai — RISC chip average 4 cycles per instruction stall kar sakta hai aur phir bhi tie kar sakta hai. Toh is RISC design ke paas enormous slack hai; realistic CPI ke saath woh CISC baseline ko demolish karega. Reverse-check: ✓.


Example 9 — Cell I: actual code se instructions count karna (μop expansion)

Step 1 — Instructions count karo. CISC: ek ADD [A],[B] per task → . RISC: LOAD, LOAD, ADD, STORE = 4 per task → . Yeh step kyun? literally executed instructions ka count hai, toh pehle hume code padhna aur count karna hoga. RISC ka load/store rule ADD mein memory operands forbid karta hai, toh ise zaroor 4 lines kharchhni padhengi jahan CISC 1 kharcha karta hai — dekho Addressing Modes.

Step 2 — CISC time. Yeh step kyun? CISC par master equation. Uska ek instruction expensive hai (8 cycles) kyunki internally uska microcode do loads aur ek store hide karta hai. Convert: .

Step 3 — RISC time. Yeh step kyun? RISC par master equation, counted use karke. Uske charon instructions mein se har ek cheap hai (1 cycle, short ). Convert: .

Step 4 — Ratio (slower upar). Yeh step kyun? CISC slower hai, toh uska time upar jaata hai; padhta hai "RISC is 3.33× faster." Shared ms unit cancel ho jaata hai, ek clean factor deta hai.

Figure — CISC vs RISC philosophies

Bars ise visually dikhate hain: RISC ka tower 4 bricks tall hai (zyada instructions) lekin har brick short aur fast hai, jabki CISC ek brick, per cycle 8× costly hai. Chhota-brick tower phir bhi chhota nikalta hai.

Recall Verify

RISC faster hai chahe instruction count 4× zyada ho, kyunki CISC ADDmicrocode ke andar do memory loads aur ek store chhupa ke — 8 cycles cost karta tha. Yeh Example 1 ki kahani actual assembly ke level par kahi gayi hai, matrix ka cell I close karte hue.


Wrapping up the matrix

Har cell A–I ke paas ab ek worked example hai: RISC wins (1), CISC wins (2), tie (3), frequency se unit-flipping (4), CPI limit (5), zero aur stall-blown inputs (6), ek word problem (7), unknown ke liye solve karna (8), aur real μop expansion se instructions count karna (9). Inme se sab mein ek hi thread hai: sirf ek factor se judge mat karo — hamesha product banao, units dekho, aur ratio se compare karo.

Recall Self-test

Sirf , , diya ho, CPI nikalo. ::: (Example 8). GHz par ek chip — kya hai? ::: ns (Example 4). Aadhi instructions 100 cycles stall karti hain, baaki 1 cost karti hain — effective CPI? ::: (Example 6).