Skip to content
Tactiverge

Textbooks/Computer Architecture/Chapter 2Lite (plain text) version

2The performance equation

Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Instruction-set design
  2. 2. The performance equation
  3. 3. Pipelining and hazards
  4. 4. Caches and the memory hierarchy
  5. 5. Input, output and the hardware–software boundary
  6. 6. Parallelism and acceleration
  7. 7. Energy and reduced precision
  8. 8. Measuring performance honestly

Introduction

Execution time is instructions × cycles per instruction × seconds per cycle. That one line, the Iron Law, keeps every performance argument honest. A faster clock means little if each instruction needs more cycles; a clever instruction means little if the clock must slow to fit it. This chapter finds the clock period from the critical path, compares single-cycle and multi-cycle datapaths, and budgets cycles for a real-time signal loop.

time = instructions × CPI ÷ clock rateA: CPI 1.2, 2.5 GHz0.48 sB: CPI 0.9, 1.8 GHz0.5 s10⁹ instructions in both cases.B does more per cycle, A has the faster clock;only the product decides which finishes first.
Figure 2.1. The clock is not the whole story. Two designs run the same one billion instructions. Design A has CPI 1.2 at 2.5 GHz and takes 0.48 s. Design B has a lower CPI of 0.9 but a slower 1.8 GHz clock and takes 0.5 s. Neither the clock rate nor the CPI alone decides which is faster.

Explanation

This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

2.1 How fast can the clock tick?

Why can't a processor designer just set the clock to 100 GHz and make everything 25 times faster?

The critical path

Every path from a register output through gates to a register input must settle within one clock period. The longest one sets the clock. In a ripple-carry adder it is the carry rippling through every column: about 2 gate delays per bit, so a 32-bit ripple adder is roughly eight times slower than a 4-bit one.

Shortening it

Designers attack the critical path with faster circuits (carry-lookahead adders compute carries in parallel at the cost of more gates), or by pipelining: putting registers in the middle of a long path so each piece fits a shorter period. The clock speeds up; each operation now takes more cycles, but a new one can start every cycle.

More cycles or faster cycles?

Run time = cycles × T_clk. A single-cycle design does everything in one long cycle; a multi-cycle design (like the 3-step model in the stepper) uses several short ones. Which wins depends on how evenly the work splits: the iron law T = IC × CPI × T_clk keeps every trade-off honest.

Derivation: The register-to-register timing constraint
  1. At a clock edge the launching register's output changes after t_clk→Q.

  2. The new value travels through combinational logic; the slowest route, the critical path, takes t_logic.

  3. The capturing register needs its input stable for t_setup before the next edge.

  4. So the next edge must come no sooner than T_clk ≥ t_clk→Q + t_logic + t_setup, and f_max = 1/T_clk.

  5. Example: 0.2 + 10 × 0.1 + 0.1 = 1.3 ns, so f_max = 1/1.3 ns ≈ 769 MHz.

Common mix-ups

  • A faster clock always means a faster program.
    ✓ If faster clocks need more cycles per operation, run time = cycles × period may not improve.

Open the full lesson: How fast can the clock tick? →

2.2 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?

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.

Derivation: The Iron Law, from units
  1. Time per program = (instructions / program) × (cycles / instruction) × (seconds / cycle).

  2. The units cancel: instructions × cycles/instruction × seconds/cycle = seconds. So T = IC × CPI × t_clk = IC × CPI / f.

  3. 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.

  4. Speed-up of B over A = T_A / T_B = (IC_A/IC_B) × (CPI_A/CPI_B) × (f_B/f_A).

  5. 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.

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.

Open the full lesson: Single-cycle, multi-cycle and the Iron Law →

2.3 Signals meet hardware: the cycle budget

A 48 MHz microcontroller sounds fast. Can it filter a 48 kHz audio signal in real time? It depends on one division.

The pipeline

Sensor → analog anti-aliasing filter → ADC (sample rate fs, N bits) → digital filter → decision or output. Each stage has a requirement from this term: fs > 2 × the highest wanted frequency with margin; N bits for the SNR you need; a filter whose response keeps the band and rejects noise; and a processor that keeps up.

The cycle budget

Cycles available per sample = f_clk / fs. Processor load = fs × (cycles per sample) / f_clk. Keep it well under 100 %, because interrupts, communication and the rest of the program need cycles too. A first-order IIR needs about two multiplies and an add per sample; an M-point moving average can be done with a running sum in constant time.

Trading between stages

A better analog filter lets you sample more slowly, saving cycles. More bits cost ADC time and memory but not filter cycles. An IIR filter gives strong smoothing for a handful of cycles but with phase lag; a long FIR filter has linear phase but costs a multiply per tap. Systems engineering is choosing these together, not one at a time.

Common mix-ups

  • If the average load is under 100 %, the system is real-time.
    ✓ Real-time needs the worst case to fit in every sample period, with margin for everything else.

Open the full lesson: Signals meet hardware: the cycle budget →

2.4 Time, memory, accuracy: pick your trade

Halve the step size and the answer gets better. Halve it again and it gets slower. When do you stop?

Order of accuracy

A method of order p has global error ≈ C·h^p. Halving h divides the error by 2^p and doubles the work. Plot error against h on log–log axes: the slope is p, which is a powerful check that your code is correct. Below some h, rounding error in each step starts to accumulate and the curve turns back up.

Growth rates

An O(n) algorithm on a million items does about a million operations; O(n log n) about twenty million; O(n²) a trillion. For small n, a simple O(n²) method may be faster and far easier to verify. Choose by the sizes you actually face, measured, and by the cost of getting it wrong.

Memory as a resource

Storing results can save time (a lookup table replaces a slow sin(x)) at the cost of memory, and the table's spacing sets its accuracy. A microcontroller with 32 KB of RAM can't hold a 64 K-entry table, so you interpolate a smaller one. This is time versus memory versus accuracy in one decision.

Fixed point: precision you can count

Fixed-point stores x as an integer X = round(x·2^f) with f fractional bits. Resolution is 2^−f; rounding error is at most half of that per operation. Q8 (f = 8) resolves 1/256 ≈ 0.0039. It is fast and predictable on chips without a floating-point unit, but you must check the range (overflow) and the accumulated rounding in long loops.

Common mix-ups

  • Smaller steps are always more accurate.
    ✓ Truncation error falls but rounding error grows with the number of steps; there is an optimum, and a cost.
  • The algorithm with the best big-O is always the right choice.
    ✓ For the sizes you actually face, constant factors, memory and verifiability can matter more.

Open the full lesson: Time, memory, accuracy: pick your trade →

Worked examples

How fast can the clock tick?: example 1

A 16-bit ripple adder has 2 gate delays per bit plus 1, at 0.08 ns each, between registers with t_cq = 0.15 ns and t_su = 0.1 ns. Find f_max.

Solution

Gate delays = 2 × 16 + 1 = 33; t_logic = 2.64 ns. T = 0.15 + 2.64 + 0.1 = 2.89 ns. f_max ≈ 346 MHz.

Single-cycle, multi-cycle and the Iron Law: 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.

Solution

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.

Signals meet hardware: the cycle budget: example 1

An 80 MHz processor filters a 44.1 kHz signal with a 128-tap FIR at 3 cycles per tap plus 100 cycles of overhead. What is the load?

Solution

Cycles per sample = 128 × 3 + 100 = 484. Load = 44,100 × 484 / 80,000,000 ≈ 26.7 %.

Time, memory, accuracy: pick your trade: example 1

Euler gives error 0.32 at h = 0.4 and 0.16 at h = 0.2. Estimate p, then predict the error at h = 0.05.

Solution

p = log(0.32/0.16)/log(2) = 1. At h = 0.05 (8× smaller than 0.4) the error ≈ 0.32/8 = 0.04, for 8× the steps.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

What sets the maximum clock frequency of a synchronous design?

Practice 2

Adding a pipeline register halfway along the critical path usually…

Practice 3

A compiler optimisation removes redundant instructions without changing the hardware. Which Iron Law factor does it change most directly?

Practice 4

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?

×

Practice 5

A 16 MHz microcontroller samples at 8 kHz. How many clock cycles are available per sample?

cycles

Practice 6

A system is at 95 % load. Which change reduces load WITHOUT reducing the frequencies you can capture?

Practice 7

A sensor value is stored in Q8 fixed point (8 fractional bits). What is the largest possible rounding error for one stored value?

Practice 8

You sort 40 sensor readings once per second on a microcontroller. Is a simple O(n²) insertion sort acceptable?

  1. What sets the maximum clock frequency of a synchronous design?
    • The shortest register-to-register path
    • The longest register-to-register path (the critical path)
    • The number of registers
    • The supply voltage only
  2. Adding a pipeline register halfway along the critical path usually…
    • Halves the clock frequency
    • Allows a faster clock but makes each operation take one more cycle
    • Removes the need for a clock
    • Has no effect
  3. A compiler optimisation removes redundant instructions without changing the hardware. Which Iron Law factor does it change most directly?
    • Instruction count
    • Cycle time
    • Clock frequency
    • None
  4. 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? (×)
  5. A 16 MHz microcontroller samples at 8 kHz. How many clock cycles are available per sample? (cycles)
  6. A system is at 95 % load. Which change reduces load WITHOUT reducing the frequencies you can capture?
    • Halve the sample rate
    • Replace a long FIR filter with a first-order IIR that meets the smoothing requirement
    • Use fewer ADC bits
    • Lower the clock frequency
  7. A sensor value is stored in Q8 fixed point (8 fractional bits). What is the largest possible rounding error for one stored value?
  8. You sort 40 sensor readings once per second on a microcontroller. Is a simple O(n²) insertion sort acceptable?
    • No: O(n²) is always too slow
    • Yes: 40² = 1,600 comparisons is tiny, and simpler code is easier to verify
    • Only if n is exactly 40
    • Sorting is never needed

Engineering applications

  • Choosing a microcontroller

    For a control loop at 8 kHz, divide the clock rate by the sample rate to get the cycle budget per sample. That number, not the clock rate on the box, says whether the filter will fit.

  • Compiler flags

    An optimising compiler mostly cuts instruction count; some options trade more instructions for fewer stalls. The Iron Law explains why a 'bigger' program can run faster.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

Covers caches, pipelining, branch prediction and multiple cores: the tricks that make processors fast, in one sitting.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

On a real breadboard computer, works out which control signals must be on during each step of fetch and execute: register-transfer design you can touch.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Advanced CPU Designs: Crash Course Computer Science #9 (CrashCourse)
  • 8-bit CPU control logic: Part 1 (Ben Eater)

Chapter summary

  • CPU time = instruction count × CPI × clock period; improve any factor without making the others worse.
  • The clock period must cover the slowest register-to-register path, plus clock-to-Q and setup times.
  • Single-cycle datapaths have CPI 1 but a long period; multi-cycle designs shorten the period and raise CPI.
  • Real-time code has a cycle budget per sample: clock rate ÷ sample rate.

Glossary

Clock speed, cycles and CPI
Execution time equals the number of instructions times the average cycles per instruction (CPI) divided by the clock frequency.
Propagation delay
Propagation delay is the time a gate's output takes to respond to a change at its input. The slowest path between flip-flops, the critical path, sets the fastest safe clock.
D flip-flop
A D flip-flop stores one bit. On each rising clock edge it copies its D input to its Q output and holds that value until the next edge.
Word size
A processor's word size is the number of bits it naturally handles in one operation: its register width and usually its main data path.

Definitions from the Field Guide.

Project: Does the filter fit?

A sensor is sampled at a rate you choose between 1 and 20 kHz. Estimate the instruction count of a 16-tap filter, assume a CPI with stated reasons, and find the slowest clock that leaves 30 % headroom. Show the Iron Law calculation.

Deliverables

  • Instruction-count estimate with assumptions
  • Cycle budget per sample and headroom
  • The chosen clock with a one-paragraph argument

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • John L. Hennessy and David A. Patterson (2017). Computer Architecture: A Quantitative Approach, 6th edition. Morgan Kaufmann.
  • David A. Patterson and John L. Hennessy (2017). Computer Organization and Design RISC-V Edition: The Hardware Software Interface. Morgan Kaufmann.

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.