4.1.3 · D3Computer Architecture (Deep)

Worked examples — ISA (Instruction Set Architecture) — RISC vs CISC

2,540 words12 min readBack to topic

This page is a drill. The parent note (ISA — RISC vs CISC) built the ideas; here we hammer every case class until none can surprise you in an exam. We lean on one master tool the parent already earned — the Iron Law:

Recall Unit refresher (so no symbol sneaks in undefined)

s (a nanosecond, one-billionth of a second). ticks per second. These are the only units on this page.


The scenario matrix

Every problem this topic can throw is one of these cells. The examples below are labelled with the cell they cover, and together they hit all of them.

Cell What varies Example that covers it
A. Baseline compare Both machines fully specified, no equal factors Ex 1
B. Tie / degenerate One factor equal → does it cancel? Ex 2
C. Zero / limiting A knob → 0 or → ∞ (, ideal pipeline) Ex 3
D. Sign / direction of change Speedup vs slowdown — which way does the arrow point? Ex 4
E. Solve for the unknown knob Given and two knobs, back out the third Ex 5
F. Load/store translation Count instructions from CISC vs RISC code Ex 6
G. Real-world word problem Frequency in GHz, code in a loop, phones vs servers Ex 7
H. Exam twist / trap "RISC always wins?" steel-man, hidden equal-CPI case Ex 8

Ex 1 — Cell A: full baseline compare

Step 1 — Compute CISC time. Why this step? Multiply all three knobs; the units cancel to seconds.

Step 2 — Compute RISC time. Why this step? Same law, same units, so the two are directly comparable.

Step 3 — Compare. Why this step? Smaller = faster program.

Verify: Speedup . Units: . ✔


Ex 2 — Cell B: one factor is equal (does it cancel?)

Step 1 — Form the products only. Why this step? Any factor equal on both sides cancels when we take the ratio — computing it is wasted effort for deciding the winner (but we keep it for the final time).

Step 2 — Multiply the shared back in. Why this step? To report actual times.

Verify: ✔ and ✔. Ratio , and the clock's ns cancels: . ✔


Ex 3 — Cell C: the limiting/ideal case ()

Step 1 — Compute the ideal (floor) time. Why this step? Set to its limiting value — the best a one-instruction-per-cycle pipeline can do.

Step 2 — Compute the realistic time. Why this step? Real pipelines stall (cache misses, hazards) so .

Step 3 — Interpret the limit. Why this step? To see what "pushing toward its floor" buys. The realistic machine is slower than the theoretical floor — exactly the ratio, since the other knobs are shared. (See Pipelining and CPI and the Iron Law of Performance for why can't drop below 1 on a single-issue machine.)

Verify: ✔; = ✔.


Ex 4 — Cell D: which direction? speedup or slowdown

Step 1 — Before. Why this step? Establish the baseline time.

Step 2 — After. Why this step? Same law with the new knobs.

Step 3 — Sign of the change. Why this step? Positive change in means the "optimization" slowed the machine.

Verify: ✔; ✔; ✔.


Ex 5 — Cell E: solve for the missing knob

Step 1 — Write the tie condition. Why this step? "Tie" means equal times; set them equal and treat as the unknown.

Step 2 — Solve. Why this step? Isolate the unknown — pure algebra (divide both sides by ).

Step 3 — Convert to frequency. Why this step? ; architects quote GHz, not ns.

Verify: ✔; ✔.


Ex 6 — Cell F: count instructions from load/store code

Figure — ISA (Instruction Set Architecture) — RISC vs CISC

Step 1 — Write the CISC version. Why this step? CISC arithmetic reads/writes memory directly, so the whole expression collapses.

ADD  C, A, B     ; C = A + B    (memory operands)
SUB  C, C, D     ; C = C - D

.

Step 2 — Write the RISC (load/store) version. Why this step? In load/store, EVERY memory value must be LW-ed into a register first, ALU works register-to-register, then SW back. This is forced by the rule.

LW   r1, A       ; load A
LW   r2, B       ; load B
LW   r3, D       ; load D
ADD  r1, r1, r2  ; r1 = A + B
SUB  r1, r1, r3  ; r1 = (A+B) - D
SW   r1, C       ; store result to C

.

Step 3 — Ratio. Why this step? This is the " went up" half of every Iron-Law trade.

Verify: , , ratio ✔.


Ex 7 — Cell G: real-world word problem (phone loop)

Step 1 — Clock period from frequency. Why this step? The Iron Law needs , but we're given GHz. Invert: .

Step 2 — Time for one iteration. Why this step? Iron Law with the per-iteration instruction count.

Step 3 — Total time for a million iterations. Why this step? Total = per-iteration × iteration count; equivalently multiply the per-iteration time.

Verify: s ms ✔. Forecast "milliseconds" confirmed. (Caches and Memory Hierarchy would raise the real if the loop misses cache — this is the ideal-cache number.)


Ex 8 — Cell H: the exam trap ("RISC always wins")

Step 1 — Both times. Why this step? Two knobs equal → they cancel in the ratio, so alone decides.

Step 2 — Winner. Why this step? Smaller time wins.

Step 3 — Find the RISC that ties. Why this step? To see how much advantage RISC needs to overcome its penalty. Set times equal, unknown :

Verify: , ✔; tie ✔.


Recall Self-test (cover the answers)

All three knobs of the Iron Law ::: A machine has equal and to its rival but 2× the instructions — who wins? ::: The rival (fewer instructions), since only differs. Why does load/store RISC emit more instructions for mem+mem? ::: Arithmetic can't touch memory, so each operand needs an explicit LW and the result a SW. GHz clock → period? ::: ns. Smallest a single-issue pipeline can reach? ::: (one instruction finishing per cycle).