← Back to GCSE guidesCodeBash GCSE Computer Science← PreviousNext →
Computer Systems

The Fetch-Execute Cycle

A CPU only really does one thing, over and over, billions of times a second: fetch an instruction from memory, work out what it means, and carry it out. Below is a genuinely wired simulation, watch data actually travel along the address bus and data bus, not just a list of registers changing.

Section 2

The CPU's components

Registers are tiny, extremely fast storage locations inside the CPU, each with one specific job. The Control Unit and ALU aren't registers, but they're just as central to the cycle.

ComponentFull nameJob
PCProgram CounterHolds the address of the next instruction to fetch
MARMemory Address RegisterHolds the address currently being read from or written to
MDRMemory Data RegisterHolds the data just fetched from (or about to be written to) memory
CIRCurrent Instruction RegisterHolds the instruction currently being decoded and executed
CUControl UnitDecodes instructions and generates the signals that coordinate every other component
ALUArithmetic Logic UnitCarries out calculations (add, subtract) and comparisons
ACCAccumulatorHolds the running result of calculations
Section 3

Watch a real program run, wire by wire

This uses the same simplified instruction set taught in Little Man Computer: LDA (load), ADD, SUB, STA (store), HLT (halt). Pick a program, then step through it, watching exactly which wire lights up at each micro-step.

Program

FETCH DECODE EXECUTE Step 0 / 0
Address Bus Data Bus Control signal
Ready. Pick a program and press Step to begin.

Main memory (RAM)

The general algorithm

Controls

Section 4

An instruction is just a binary number

Nothing magic is happening inside CIR: each instruction is stored as one ordinary byte, split into two halves, exactly the same idea as the number representation work you've already covered.

InstructionOpcode (4 bits)Meaning
HLT0000Stop execution
LDA n0001ACC ← memory[n]
ADD n0010ACC ← ACC + memory[n]
SUB n0011ACC ← ACC − memory[n]
STA n0100memory[n] ← ACC

Example: LDA 4 is opcode 0001 (LDA) plus operand 0100 (address 4), giving the single byte 00010100, or 0x14 in hex. The first 4 bits say what to do, the last 4 say which address.

Section 5

Clock speed: how fast the cycle repeats

Clock speed, measured in Hz, is how many times per second the CPU can step through this cycle. A higher clock speed generally means more instructions completed every second.

Clock speed

Exam tips

  • Clock speed alone doesn't tell the whole story: number of cores (separate processing units working in parallel) and cache size (fast memory built into the CPU) both also affect real-world performance.
  • A single "instruction" in a real CPU can take several clock cycles, as this simulation shows: LDA, ADD, SUB and STA all need a second memory access during execute to actually read or write their operand.
  • Clock speed is measured in Hertz (Hz): 1 Hz is 1 cycle per second. Modern CPUs run at gigahertz (GHz), billions of cycles per second.
Section 6

Check your understanding