School/✦ Research Engineer/Week 20
Single-cycle, multi-cycle and the Iron Law
Chip A runs at 4 GHz, chip B at 2 GHz. B finishes your program first. How?
About 45 min · 3 goals · Checked by automated tests
1.Why should I care?
Clock frequency is the number on the box, but it is one factor of three. Every architecture decision, from the instruction set to the cache, moves instruction count, cycles per instruction or cycle time, and usually trades one against another. The Iron Law is how architects keep score.
- ◇ State the Iron Law T = IC × CPI × cycle time and say which design choices change each factor.
- ◇ Compare a single-cycle and a multi-cycle datapath by cycle time and CPI.
- ◇ Compute execution time and speed-up for two designs from their IC, CPI and clock frequency.
2.Discover
Open the Nibble machine and step your multiply program through fetch, decode and execute. Count how many steps each instruction takes: that count is the machine's CPI per instruction type, and the step time is its cycle time.
Can't use the interactive? Read a description instead
The Nibble machine activity can be done on paper: list the instructions of the multiply program, give each a step count (fetch, decode, execute), and add them up over the loop iterations to get cycles and CPI.
3.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1 · a fresh version every time
A program executes 750 million instructions with an average CPI of 0.8 on a 2 GHz processor. How long does it take, in milliseconds?
4.Apply it
Your Nibble multiply program runs a loop. Count its dynamic instruction count for 3 × 5 and estimate CPI from the steps you counted. If the machine ran at 1 MHz, how long would 15 × 15 take? Which factor would you attack first to speed it up?
5.Understand
Single-cycle datapath
Every instruction completes in one long clock cycle, so CPI = 1, but the cycle must be long enough for the slowest path (instruction memory → register read → ALU → data memory → register write, for a load). Simple instructions waste most of the cycle.
Multi-cycle datapath
Break execution into steps (fetch, decode, execute, memory, write-back) and give each step one short cycle. Instructions use only the steps they need, so CPI is now an average (perhaps 4) but the cycle is about the length of one step. Hardware can be reused across steps: one memory and one ALU instead of separate ones.
Three factors, coupled
A richer instruction set lowers IC but may raise CPI or the cycle time. A deeper pipeline shortens the cycle but raises CPI when hazards hit. A good comparison quotes all three and measures them on the same program, compiled the same way, which is why benchmark suites exist.
Explain it another way
Your journey time is number of stops × minutes per stop × how long each minute takes. A train that stops less often can beat a faster train that stops everywhere.
CPI = Σᵢ (fraction of instruction class i) × CPIᵢ. MIPS and GHz alone are misleading because they ignore IC and CPI. Only total execution time on a defined workload is a fair performance metric.
For a mix with fractions pᵢ and step counts cᵢ on a multi-cycle machine with step time τ: T = IC × (Σ pᵢcᵢ) × τ. Single-cycle: T = IC × 1 × max(path delays). Multi-cycle wins when Σ pᵢcᵢ × τ < max delay.
Arm Cortex-M0 microcontrollers take more than one cycle for some instructions but run at low clocks with tiny power; desktop cores push CPI well below 1 by issuing several instructions per cycle. Both are judged by the same equation.
Derivation: The Iron Law, from units
Time per program = (instructions / program) × (cycles / instruction) × (seconds / cycle).
The units cancel: instructions × cycles/instruction × seconds/cycle = seconds. So T = IC × CPI × t_clk = IC × CPI / f.
IC is set by the algorithm, the compiler and the instruction set. CPI by the microarchitecture (pipelining, caches, prediction). t_clk by the circuit and the process technology.
Speed-up of B over A = T_A / T_B = (IC_A/IC_B) × (CPI_A/CPI_B) × (f_B/f_A).
Example: A has IC = 10⁹, CPI = 2, 4 GHz: T = 0.5 s. B has IC = 0.8×10⁹, CPI = 1.1, 2 GHz: T = 0.44 s. B wins by 0.5/0.44 ≈ 1.14× despite half the clock.
Worked example 1
A mix is 50% ALU (4 steps), 20% loads (5), 10% stores (4), 20% branches (3). Step time 200 ps. Compare with an 800 ps single-cycle design.
CPI = 0.5×4 + 0.2×5 + 0.1×4 + 0.2×3 = 4.0. Time per instruction = 4.0 × 200 ps = 800 ps: a tie. Shorten the step to 180 ps (balancing stages better) and multi-cycle wins: 720 ps.
Common mix-ups
- A higher clock frequency always means a faster computer.
✓ Only if IC and CPI stay the same. Execution time on the real workload is the only fair measure. - Multi-cycle machines are slower because CPI > 1.
✓ Their cycle is much shorter, so time per instruction can be lower; CPI alone says nothing.
6.Watch
→ Count the micro-steps each instruction needs: those are the cycles of a multi-cycle machine.
Shows instructions as bit patterns with an opcode and an address field, then runs a small program step by step.
Length: see YouTube · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2 · a fresh version every time
A program's mix is 60% ALU (1 cycle), 15% loads (2 cycles), 20% branches (3 cycles) and 5% stores (2 cycles). What is the average CPI?
Practice 3
A compiler optimisation removes redundant instructions without changing the hardware. Which Iron Law factor does it change most directly?
Practice 4 · a fresh version every time
A program executes 200 million instructions with an average CPI of 1.8 on a 3 GHz processor. How long does it take, in milliseconds?
Practice 5
Design A: CPI 1.6 at 3 GHz. Design B: CPI 1.0 at 2.4 GHz, same instruction count. What is B's speed-up over A?
8.Predict
A single-cycle CPU must fit its slowest instruction (a load, 800 ps) into every cycle. A multi-cycle version uses 200 ps steps; loads take 5 steps and ALU ops 4. For a program of only ALU ops, which is faster?
Guess first. Being wrong here is how the surprise works.
9.Reflect
Concepts: Pipelining, hazards and the Iron Law · Inside a microcontroller · Sequential logic and memory