Fetch, Decode, Execute
Run a program inside the CPU
Your mission
A tiny program is waiting in memory. Find out how the CPU runs it, one instruction at a time. Then take over as the CPU's control unit and run a program yourself, without crashing it.
Explore
Tap each part of this simplified computer to find out what it does.
- Fetch
- Decode
- Execute
Tap a part of the computer to explore it.
This is a simplified computer, running a tiny program. Tap each highlighted part (the control unit, the ALU, the registers, the buses and the memory) to find out what it does.
0 of 5 parts explored
Experiment
Press Step to run the program one small step at a time, or press Play and watch. Run it all the way to HALT to continue.
Try this: after one run, change the numbers in addresses 5 and 6, or switch ADD to SUB, then run the program again. What ends up in address 7?
Run the program all the way to HALT to continue.
Challenge
You're the control unit now. Choose what happens next at each step of the program. You have three lives.
Loading…
Answer all 10 questions to continue.
Understand
Here is what the game was showing you, in the words you need for the exam.
What just happened?
For every instruction, the CPU repeated the same three steps:
- Fetch: the control unit uses the address in the program counter to get the next instruction from memory. The program counter then moves on to the next address.
- Decode: the control unit works out what the instruction means.
- Execute: the instruction is carried out. The ALU does any calculating, and data is read from or written to memory as needed.
Then the cycle starts again with the next instruction, until the program stops.
Programs live in memory
You saw instructions (addresses 0 to 3) and numbers (addresses 5 to 7) stored side by side in the same memory. This is the von Neumann architecture: programs and data are both stored in memory, and the CPU fetches the instructions from there.
The three buses
- Address bus: carries memory addresses, from the CPU to memory.
- Data bus: carries data and instructions, in both directions.
- Control bus: carries signals such as READ and WRITE.
Think of buses as public transport: shared routes that connect all the parts.
How fast does this happen?
A real CPU repeats the cycle billions of times every second. Clock speed is measured in hertz (Hz): 1 GHz means 1 billion cycles per second, so a 3 GHz CPU completes 3 billion clock cycles each second. Careful, though: clock speed alone doesn't decide how quickly a program finishes.
Words to know
- Control unit
- Arranges and sequences instructions: it fetches, decodes and directs.
- ALU
- Arithmetic-logic unit. Performs arithmetic and logical operations.
- Registers
- Very fast storage spaces inside the CPU.
- Program counter (PC)
- A register holding the address of the next instruction.
- Instruction register (IR)
- A register holding the instruction being decoded and executed.
- Accumulator (ACC)
- A register holding the result of a calculation.
Exam tip
If you're asked to put the steps in order, it's always fetch, decode, execute. And remember which way the buses go: addresses travel from the CPU to memory, while data can travel either way, depending on whether the CPU is reading or writing.