Every program you'll ever write — in Python or any language — ends up as instructions for one tiny, astonishingly fast chip: the CPU. People call it 'the brain of the computer', and while that's a friendly start, this chapter goes one level deeper so you actually understand what's happening when your code runs.
1The block diagram of a computer
At the highest level, a computer follows a simple flow: it takes input, the CPU processes it (using memory to hold data and instructions), and produces output. This is the classic model proposed by John von Neumann.
Two ideas from this model matter for the exam:
- The CPU and memory work together constantly — the CPU fetches instructions and data from memory and writes results back to it.
- In the von Neumann model, program instructions and data live in the same memory (the 'stored-program' concept).
- A computer follows: input → processing (CPU + memory) → output (the von Neumann model).
- The CPU constantly fetches instructions/data from memory and writes results back.
- Stored-program concept: instructions and data share the same memory.
2Inside the CPU: ALU, CU and registers
The CPU itself has three key parts. Knowing what each one does is a guaranteed exam question.
| Part | Full name | Job |
|---|---|---|
| ALU | Arithmetic Logic Unit | Does the actual work — arithmetic (add, subtract) and logic (AND, OR, comparisons). |
| CU | Control Unit | The manager — directs the flow of data, tells the ALU and memory what to do and when. It doesn't process data itself. |
| Registers | — | Tiny, ultra-fast storage cells inside the CPU that hold the data and instructions being worked on right now. |
Some named registers worth knowing: the Program Counter (PC) holds the address of the next instruction; the Accumulator (AC) holds intermediate results; the Instruction Register (IR) holds the instruction currently being executed.
- ALU (Arithmetic Logic Unit) performs arithmetic and logic operations.
- CU (Control Unit) directs and coordinates — it manages, it doesn't compute.
- Registers are tiny, ultra-fast storage inside the CPU holding what's being worked on now (PC, AC, IR).
3The instruction cycle: fetch, decode, execute
The CPU runs your program one instruction at a time, repeating the same three-step loop billions of times a second. This is the instruction cycle (or machine cycle):
Then the cycle repeats for the next instruction. The number of these cycles per second is roughly what 'clock speed' (measured in GHz) describes — a 3 GHz CPU steps about 3 billion times per second.
Step through one full instruction cycle below and watch which part of the CPU is active at each stage.
- The instruction cycle is Fetch → Decode → Execute, repeated continuously.
- Fetch (get instruction) and Decode are run by the Control Unit; Execute is done by the ALU.
- Clock speed (GHz) is roughly how many cycles the CPU performs per second.
★ Practical: trace a calculation
On paper, describe what happens inside the CPU when a program runs the statement total = 5 + 3:
- Which part fetches and decodes the 'add' instruction?
- Which part actually performs 5 + 3?
- Where is the result (8) held immediately after the calculation?
- Name the three steps of the cycle that just took place, in order.
Ready for the chapter test?
Answer 5 questions. Score 60% or more to mark this chapter complete.
Start the test →💡 Log in to save your progress and earn the certificate.