Edexcel International Advanced Level Computer Science, point 1.1.4
The CPU is made of a few key components. You need to know what each does and why it is needed, and be able to complete a diagram of them.
Overview diagram
The specification uses standard symbols in CPU diagrams: a V-shaped trapezoid for the ALU, a rectangle for a register, and a square wave for the clock signal. Learn them, because you may have to read or complete a diagram drawn with them.
a. Control unit (CU)
- Definition: the part of the CPU that manages and coordinates everything the processor does.
- Function: it directs the operation of the processor: it fetches instructions, decodes them, and sends control signals to the other components so they carry them out in the right order. It also controls the flow of data between the registers, and manages input and output to and from the CPU.
- Why needed: without it, nothing would coordinate the components.
- Operation: it reads the instruction in the CIR, works out what it means, then sends signals (for example "read memory", "ALU add") along the control lines and the control bus.
b. Arithmetic logic unit (ALU)
- Definition: the part of the CPU that does the calculations and logical decisions.
- Function: it carries out arithmetic (add, subtract, and so on), logic (AND, OR, NOT, XOR), comparisons and shifts.
- Why needed: every calculation and comparison a program makes is done here.
- Operation: it takes two operands and an opcode (which operation to do) and produces a result and status flags (for example zero, negative, carry, overflow) that are stored in the status register.
c. General-purpose registers
- Definition: small, very fast storage locations inside the CPU that the programmer or compiler can use for any data.
- Function: they hold values being worked on, so the CPU needn't keep going to RAM, which is much slower.
d. Special-purpose registers
Each of these has one particular job.
| Register | Name | Holds | Used for |
|---|---|---|---|
| PC | Program counter | The address of the next instruction | Fetching instructions in order. It is incremented after each fetch, or changed by a jump |
| MAR | Memory address register | The address of the memory location to read or write | Sends the address to the address bus |
| MBR | Memory buffer register | The data or instruction that has just been read from, or is about to be written to, memory | Holds data on its way to or from memory (also called the MDR). Why needed: the CPU is much faster than RAM, so the MBR acts as a temporary store (buffer) between them, and frees the data bus for the next transfer |
| CIR | Current instruction register | The instruction currently being decoded and executed | Gives the CU the opcode and operands |
| ACC | Accumulator | The results of ALU calculations | A working register for arithmetic and logic |
| SP | Stack pointer | The address of the top of the stack in memory | Subroutine calls and returns, and saving data |
| SR | Status register | Flags: bits set by the ALU or the system | Records outcomes (zero, negative, carry, overflow) and states such as interrupts enabled |
Why registers rather than RAM?
Registers are the fastest memory in the computer, and sit inside the CPU, so access takes one clock cycle or less. RAM is much slower.
e. Clock
- Definition: a component that sends out a regular electrical signal (pulses) to the rest of the CPU.
- Function: it produces a regular stream of pulses that synchronise the CPU's operations. Each pulse starts the next step.
- Characteristic: its speed (frequency) is measured in hertz (GHz = billions of cycles a second). A higher clock speed lets the CPU do more steps per second, although heat and power use also rise.
How they work together
For a simple ADD instruction:
- The PC gives the address of the instruction. It is copied to the MAR.
- The instruction travels from memory to the MBR, then to the CIR.
- The CU decodes the instruction in the CIR.
- The CU sends signals so that the ALU adds two values, and the result goes to the ACC.
- The SR records, for example, whether the result was zero.
- The clock times each of these steps.
Worked example
Task: the ALU adds 200 and 100 in an 8-bit system, with the result stored in the accumulator. Describe what is stored in the ACC and the status register.
- , which is more than 255, so it doesn't fit in 8 bits.
- Binary: 11001000 + 01100100 = 1 00101100. The low 8 bits are 00101100 (decimal 44), with a carry out of the top bit.
- ACC holds 00101100 (44).
- SR has the carry flag set (and the zero flag clear), showing that the result overflowed the register. The program can test this flag to detect the problem.
Exam tip: learn what each register holds, not just its name: the PC holds an address, the MAR holds an address, the MBR holds data, the CIR holds an instruction, the ACC holds results. If the question asks "why needed", say what would go wrong without it. You may be asked to label or complete a diagram of the CPU.
Check yourself
What does the control unit do?
It fetches and decodes instructions and sends control signals to the other components so that they carry out the instructions in the right order.
What is the difference between the MAR and the MBR?
The MAR holds the address of the memory location to be accessed. The MBR holds the data or instruction that has been read from, or is about to be written to, that location.
What is stored in the program counter?
The address of the next instruction to be fetched.
Why are registers used in the CPU instead of just using RAM?
Registers are the fastest storage and are inside the CPU, so values can be used without the delay of going to RAM.
What is the status register used for?
It holds flags set by the ALU and system, such as zero, negative, carry and overflow, which show the outcome of operations.