Docs

Topic 3 · Hardware

The CPU and the fetch-decode-execute cycle

Von Neumann architecture, the CPU's registers and buses, the fetch-decode-execute cycle, and what makes a CPU faster.

Lesson 1 of 4Syllabus 3.1updated October 31, 2026

What the CPU does

The central processing unit (CPU) processes instructions and data. Programs and their data are held in memory (RAM). The CPU fetches each instruction from memory, works out what it means, and carries it out, billions of times a second.

In the Von Neumann architecture, instructions and data are stored together in the same memory, and the CPU works through them one instruction at a time.

Inside the CPU

The CPU has three kinds of part: the control unit, the arithmetic logic unit, and a set of small, very fast storage locations called registers.

PartJob
CU control unitDecodes instructions and sends control signals to manage the rest of the CPU and memory.
ALU arithmetic logic unitDoes calculations (+, −) and logical operations (AND, OR, comparisons).
PC program counterHolds the address of the next instruction to fetch.
MAR memory address registerHolds the address in memory that is about to be read from or written to.
MDR memory data registerHolds the data or instruction just read from memory, or about to be written to it.
CIR current instruction registerHolds the instruction currently being decoded and executed.
ACC accumulatorHolds the result of calculations done by the ALU.

Buses

Buses are sets of parallel wires that connect the CPU to memory:

  • Address bus: carries an address from the MAR to memory. One direction only.
  • Data bus: carries data and instructions between the CPU and memory. Both directions.
  • Control bus: carries signals such as read, write, and clock pulses from the CU. Both directions.

The fetch-decode-execute cycle

Step through the cycle below. The memory holds a tiny program: LDA 0110 means "load the value stored at address 0110 into the accumulator". Watch the values move between registers.

Fetch-decode-executeInteractive
CPUCUALUACCPC0100MARMDRCIRcontrol busaddress busdata busRAM0100LDA 01100101ADD 01110110000501110003
Fetch 1: the PC holds the next address
The program counter holds 0100, the address of the next instruction.
Step 1 / 8
Every program you run is this cycle repeated billions of times.

What makes a CPU faster

FactorWhat it isWhy it helps
Clock speedNumber of clock cycles per second, in GHzMore clock cycles per second, so instructions are processed faster
CoresSeparate processing units inside one CPUSeveral instructions can be processed at the same time
CacheVery fast memory inside the CPUFrequently used data and instructions are fetched without going to slower RAM

Watch out. Doubling the cores does not always double the speed. Some programs cannot be split into parts that run at once, and cores have to coordinate.

Instruction sets and embedded systems

An instruction set is the list of all the machine code commands a CPU can understand and carry out, such as load, add, store, and jump.

An embedded system is a computer built into a larger device to do one dedicated job, such as the controller in a washing machine, a microwave, a car's engine management, or a heating thermostat. Embedded systems are small, cheap, and use little power, but they are hard to upgrade.

Key terms

Von Neumann architecture
A design where instructions and data share the same memory.
Register
A small, very fast storage location inside the CPU.
Bus
A set of parallel wires that carries addresses, data, or control signals.
Cache
Small, fast memory in the CPU that stores frequently used data and instructions.
Embedded system
A computer system built into a device to perform a dedicated function.

Check yourself

Which register holds the address of the next instruction?Show answer

The program counter (PC).

Describe what happens to the MAR and MDR during the fetch stage.Show answer

The address from the PC is copied into the MAR. The instruction at that address is read from memory along the data bus into the MDR.

Why does a larger cache improve performance?Show answer

More frequently used data and instructions can be kept in fast cache, so the CPU waits less for slower RAM.

Give two examples of embedded systems.Show answer

For example: a washing machine controller, a microwave, a smart thermostat, a car's anti-lock braking system.