Lite / Independent Engineering Research / 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?
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.
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?
- Single-cycle: 800 ps per instruction
- Multi-cycle: 800 ps per instruction, the same
- Multi-cycle is slower: it has more cycles
- Single-cycle, because CPI = 1 is always best
Guess first, then reveal
Multi-cycle takes 4 × 200 = 800 ps per ALU op: no gain on this program. It wins when instructions differ in length, because short ones no longer pay for the longest. Loads cost 1000 ps (worse!) but jumps or branches needing 3 steps cost only 600 ps.
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.
What the interactive shows (text version)
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.
Watch (optional)
Watch for: 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.
“Instructions & Programs: Crash Course Computer Science #8” by CrashCourse (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
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
Intuitive
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.
Technical
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.
Mathematical
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.
Applied
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.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
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?
Reflect
Which factor of the Iron Law did you think about least before today, and where have you seen it matter?
Write your answer on paper or in your own notes. Lite never stores what you write.