A levels Computer Science · Computer systems
Processor architecture and the fetch-execute cycle
1The von Neumann architecture
In the von Neumann architecture, programs and data are stored together in the same memory, and the processor fetches instructions one at a time.
The von Neumann architecture. The CPU's control unit, ALU and registers are linked to main memory by the address, data and control buses.
| Component | Job |
|---|---|
| control unit (CU) | decodes instructions and sends control signals to coordinate the other parts |
| arithmetic logic unit (ALU) | does calculations and logical comparisons |
| registers | very fast storage locations inside the CPU |
| clock | sends regular pulses that keep every part in step |
| main memory (RAM) | holds the program and data being used |
Check yourself
What does the von Neumann architecture store in the same memory?
Show the answer
Both program instructions and data
Stored-program concept.
2Registers
| Register | Holds |
|---|---|
| program counter (PC) | the address of the next instruction to fetch |
| memory address register (MAR) | the address about to be read from or written to |
| memory data register (MDR) | the data or instruction just read from memory, or about to be written |
| current instruction register (CIR) | the instruction being decoded and executed |
| accumulator (ACC) | the results of calculations in the ALU |
| status register | flags such as overflow, zero and negative |
Check yourself
Which register holds the address of the next instruction?
Show the answer
The program counter
PC points ahead.
3Buses
A bus is a set of parallel wires that carries signals between the CPU, memory and input/output controllers.
| Bus | Carries | Direction |
|---|---|---|
| address bus | memory addresses | one-way: CPU to memory |
| data bus | data and instructions | two-way |
| control bus | signals such as read, write, clock and interrupt | two-way |
The width of the address bus sets how much memory can be addressed: with n lines, 2ⁿ addresses. A 32-bit address bus can address 2³² = about 4.3 billion locations (4 GiB of bytes).
The width of the data bus sets how many bits move in one go: a wider bus moves more data each clock cycle.
Check yourself
Why is the address bus one-way?
Show the answer
Only the CPU sends addresses to memory
CPU chooses where.
4The fetch-decode-execute cycle
The CPU repeats this cycle billions of times a second. [X] means "the contents of X".
- Fetch: MAR ← [PC]. The address of the next instruction goes to the MAR.
- The address is sent along the address bus, and a read signal along the control bus.
- MDR ← [Memory[MAR]]. The instruction comes back along the data bus into the MDR.
- PC ← [PC] + 1, so it points to the next instruction.
- CIR ← [MDR]. The instruction is copied to the CIR.
- Decode: the control unit splits the instruction into opcode (what to do) and operand (what to use).
- Execute: the instruction is carried out, for example the ALU adds a value to the accumulator, or data is loaded or stored. A jump instruction changes the PC.
Check yourself
When is the program counter increased?
Show the answer
During the fetch stage, after its value is copied to the MAR
Points to the next one.
5Interrupts
An interrupt is a signal to the CPU that something needs attention, such as a key press, a printer running out of paper, a timer, or an error.
- At the end of each fetch-decode-execute cycle, the CPU checks for interrupts.
- If there is one with a higher priority than the current task, the CPU saves the contents of its registers (on a stack).
- It runs the interrupt service routine (ISR) for that interrupt.
- It restores the saved registers and carries on where it left off.
Interrupts let the CPU respond quickly to events without constantly checking every device (polling).
Check yourself
Why does the CPU save its registers before running an interrupt service routine?
Show the answer
So it can carry on the interrupted task exactly where it stopped
Return afterwards.
6Performance and other architectures
Factors that affect performance:
- Clock speed: more cycles per second, so more instructions per second.
- Number of cores: several instructions can run at once, but only if the program can be split into parallel tasks.
- Cache: small, very fast memory on the CPU holding frequently used data, reducing slow trips to RAM.
- Word length: the number of bits processed in one go.
- Bus width: more bits moved per cycle; a wider address bus allows more memory.
Pipelining overlaps stages: while one instruction executes, the next is decoded and the one after is fetched. A jump can force the pipeline to be flushed.
The Harvard architecture keeps instructions and data in separate memories with separate buses, so both can be fetched at the same time. It is used in embedded systems and digital signal processors, and inside CPU caches.
Check yourself
Why does doubling the number of cores not always double the speed?
Show the answer
Some tasks cannot be split into parts that run at the same time
Not all work is parallel.
Now test yourself
This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.
Practise in Impera