Processor Fundamentals
Inside the processor: the Von Neumann model, registers, buses, performance and ports; and the fetch–execute cycle and interrupts.
The Von Neumann model and the stored program
Instructions and data sit together in one main memory, so one computer can run any program you load.
In the Von Neumann model, a single processor fetches and executes instructions one at a time.
A program's instructions and the data they use:
- are stored together in the same main memory
- are stored as binary
- travel along the same buses
This is the stored program concept: a program is loaded into main memory and runs from there.
Example:The same laptop runs a game, then a browser. You only load different instructions into its memory.
Watch out:Nothing marks a word in memory as an instruction or as data. Whatever the PC points at is fetched and treated as the next instruction.
Inside the processor: ALU, CU, clock, IAS and registers
The ALU calculates, the control unit gives orders, the clock keeps time, and registers hold values close at hand.
| Part | Its job |
|---|---|
| ALU (arithmetic and logic unit) | arithmetic and logic: add, subtract, AND, OR, compare, shift |
| CU (control unit) | decodes each instruction; sends control signals so the other parts carry it out |
| System clock | sends timing signals so every part works in step; speed is pulses per second, such as 3 GHz |
| IAS (immediate access store) | the main memory the processor reads and writes directly |
Registers are very fast stores inside the processor.
- A general purpose register holds any data being worked on. Cambridge questions have only one: the ACC.
- Each special purpose register has one fixed job. The box below lists them.
PC program counter: the address
of the NEXT instruction to fetch
MAR memory address register: the
address of the location being
read from or written to
MDR memory data register: the data
or instruction just read from
memory, or about to be written
to it
CIR current instruction register:
the instruction being decoded
and executed
IX index register: a number added
to an address to give another
address (indexed addressing)
SR status register: flags, bits set
or cleared by the results of
arithmetic and logic operations
(e.g. overflow), and interrupt
flags
ACC accumulator: the value being
worked on; ALU results go here.
The syllabus lists it with the
special purpose registers, but
questions treat it as the one
general purpose register.Three buses, and what their widths allow
Three buses link the processor to memory and devices; their widths set how much memory and how fast.
| Bus | Carries | Direction |
|---|---|---|
| Address bus | the address of a memory location, from the processor to memory or to an I/O device | one-way |
| Data bus | data and instructions between the processor, memory and I/O devices | both ways |
| Control bus | control signals: memory read, memory write, timing signals from the clock, interrupt requests | both ways |
Address bus width sets how many locations can be addressed. n lines give 2^n addresses.
| Address lines | Locations | If each location holds a byte |
|---|---|---|
| 16 | 2^16 = 65 536 | 64 KiB |
| 32 | 2^32 = 4 294 967 296 | 4 GiB |
Data bus width sets how many bits move in one transfer. A wider data bus moves more data at once.
- 8 lines wide: 1 byte per transfer
- 64 lines wide: 8 bytes per transfer
Watch out:n lines give 2^n addresses, not 2 × n.
What makes a processor faster
A processor gets faster with a faster clock, more cores, a wider data bus, more cache, or a better design.
| Change | Why it helps |
|---|---|
| Faster clock | more fetch–execute cycles each second, so more instructions |
| More cores | several tasks run at the same time |
| Wider data bus | more bits move in each transfer |
| More cache (a small, fast memory for often-used instructions and data) | fewer slow trips to main memory |
| Processor type | some designs do more work in each clock cycle |
Watch out:One task speeds up only if it can be split between the cores. So doubling the cores does not always double the speed.
Example:In the figure, 4 cores finish at 8, not 6, because job E cannot be split.
Ports: USB, HDMI and VGA
A port is a socket for a device: USB for most devices, HDMI for digital video and sound, VGA for analogue video.
A port is the socket that a peripheral device plugs into.
| USB | HDMI | VGA | |
|---|---|---|---|
| Full name | Universal Serial Bus | High Definition Multimedia Interface | Video Graphics Array |
| Used for | general purpose: keyboards, printers, flash drives | monitors, TVs, projectors | video (an older port) |
| Carries | data, serially: one bit after another | digital high-definition video and sound together, in one cable | analogue video only, no sound |
More about USB:
- It uses a standard connector.
- The computer recognises a device when it is plugged in, and loads its driver.
- USB can also power the device.
Watch out:VGA carries no sound, so a separate sound cable is needed.
The fetch–execute cycle in register transfer notation
Every instruction is fetched in the same four steps, written in register transfer notation.
Register transfer notation (RTN) is a short way to write data moving between registers.
| Symbol | Means | Example |
|---|---|---|
| ← | copy into | MAR ← [PC] |
| [ ] | the contents of | [PC] is the address held in the PC, not the PC itself |
The fetch is the same four steps for every instruction (see the box below).
Points the examiner looks for:
- The MAR, not the PC, puts the address on the address bus.
- The instruction comes back along the data bus into the MDR.
- The PC is increased during the fetch, before the instruction is executed. So it already points at the next instruction.
- Then the control unit decodes the instruction in the CIR, and it is executed.
Remember:A jump simply overwrites the PC with a new address.
FETCH (the exam asks for these four
lines in RTN)
MAR ← [PC]
copy the address of the next
instruction
PC ← [PC] + 1
the PC now points at the one after
MDR ← [[MAR]]
the instruction, along the data bus
CIR ← [MDR]
into the current instruction register
then the CU decodes the instruction
in the CIR, and it is executed.
EXECUTE, e.g. LDD 107 (these lines
explain it; the exam does not require
them in RTN)
MAR ← 107
the address part of the instruction
MDR ← [[MAR]]
the data, along the data bus
ACC ← [MDR]
ACC is 51Interrupts
An interrupt is a signal that something needs attention; the processor checks for one after every cycle.
An interrupt is a signal telling the processor that something needs attention.
| Source | Example |
|---|---|
| hardware | a key is pressed; the printer is out of paper; a transfer has finished |
| a timer | a time slice has ended |
| a program error | division by zero |
| a hardware fault | the power is failing |
The processor never stops half-way through an instruction. It checks for interrupts at the end of every fetch–execute cycle.
If the interrupt has a higher priority than the current task:
- The registers are saved.
- Its interrupt service routine (ISR) runs.
- The registers are restored.
A lower-priority interrupt waits.
a device or event sets a flag in the
interrupt register
at the end of each fetch-execute cycle
the processor checks:
no interrupt flagged
→ fetch the next instruction
flagged
→ find its source and compare
priorities
not higher than the current task
→ it waits
higher:
1 save the registers (PC, ACC,
SR ...) on the stack
2 PC ← the start address of
that source's ISR
3 run the ISR
4 restore the registers from
the stack
5 carry on exactly where the
program stopped- Click the stages below in the order they happen.
KEY TERMS
CHECK YOURSELF
1.An address bus has 16 lines. How many memory locations can it address?
2.What does the stored program concept say?
3.When does the processor check whether an interrupt is waiting?
4.Which register holds the address of the memory location being read from or written to?
5.Why does doubling the number of cores not always halve the time a task takes?
6.In the fetch, which register is increased by 1 before the instruction is executed?
7.Which port carries analogue video only, with no sound?