1.1.1 Structure and Function of the Processor
1.1.1(a) Processor Components
The processor (CPU - Central Processing Unit) is the brain of a computer system, responsible for executing instructions that allow programs to function.
ALU (Arithmetic and Logic Unit)
Arithmetic operations: Addition, subtraction, multiplication, division
Logical operations: AND, OR, NOT, XOR (Boolean logic)
CU (Control Unit)
• Directing the flow of data between the CPU and other components
• Coordinating the sequence of data processing steps
• Sending control signals to manage instruction execution
Registers
| Register | Full Name | Purpose |
|---|---|---|
| PC | Program Counter | Stores the address of the next instruction to be executed |
| ACC | Accumulator | Holds results of arithmetic and logic operations |
| MAR | Memory Address Register | Contains the address of the memory location to be read/written |
| MDR | Memory Data Register | Temporarily stores data being transferred to/from memory |
| CIR | Current Instruction Register | Stores the instruction currently being executed (split into opcode and operand) |
Buses
| Bus | Direction | Purpose |
|---|---|---|
| Data Bus | Bi-directional | Carries data and instructions between components |
| Address Bus | Unidirectional (CPU → Memory) | Carries memory addresses to identify where data should be read/written |
| Control Bus | Bi-directional | Carries control signals (read, write, clock) to coordinate actions |
1.1.1(b) The Fetch-Decode-Execute Cycle
FETCH Phase
- 1.The address in the PC (address of the next instruction) is copied to the MAR
- 2.The instruction at that address is fetched from RAM into the MDR
- 3.The PC is incremented (PC + 1) to point to the next instruction
- 4.The instruction is copied from the MDR to the CIR (ready for decoding_)
DECODE Phase
- 5.The instruction in the CIR is split into opcode (operation) and operand (data/address)
- 6.The Control Unit decodes the opcode to determine what operation to perform
EXECUTE Phase
- 7.The instruction is executed - this may involve:
Let's trace through the FDE cycle for the instruction "LDA 15" (Load the value from memory address 15 into the Accumulator).
Initial State:
• PC = 100 (next instruction is at address 100)
• ACC = 0
FETCH Phase:
1. PC (100) is copied to MAR
2. Address 100 sent along address bus
3. Read signal sent on control bus
4. Instruction "LDA 15" fetched from memory to MDR
5. PC incremented to 101
6. "LDA 15" copied from MDR to CIR
DECODE Phase:
7. CIR splits into: opcode = "LDA", operand = "15"
8. Control Unit decodes: "LDA" = Load value from memory address into ACC
EXECUTE Phase:
9. Operand (15) copied to MAR
10. Address 15 sent along address bus
11. Read signal sent on control bus
12. Value at address 15 fetched to MDR (let's say value is 42)
13. Value (42) copied from MDR to ACC
Final State:
• PC = 101 (ready for next instruction)
• ACC = 42 (loaded from memory)
• MAR = 15
• MDR = 42
Key Point: Notice how the FDE cycle uses registers and buses in a specific sequence. The MAR and MDR are used twice - first to fetch the instruction, then to fetch the data.
1.1.1(c) Factors Affecting CPU Performance
Clock Speed
| Advantage | Disadvantage |
|---|---|
| More instructions executed per second | Generates more heat |
| Faster program execution | Higher power consumption |
| Diminishing returns at very high speeds |
Number of Cores
| Advantage | Disadvantage |
|---|---|
| Parallel processing - multiple tasks simultaneously | Software must be written to utilise multiple cores |
| Better multitasking performance | Not all tasks can be parallelised |
| More efficient than increasing clock speed | Increased complexity and cost |
Cache Memory
| Level | Size | Speed | Location |
|---|---|---|---|
| L1 | Smallest (32-64KB) | Fastest | On CPU core |
| L2 | Medium (256KB-1MB) | Fast | On CPU (per core or shared) |
| L3 | Largest (2-32MB) | Slower than L1/L2 | Shared between all cores |
1.1.1(d) Pipelining
| Cycle | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Inst 1 | F | D | E | ||||||
| Inst 2 | F | D | E | ||||||
| Inst 3 | F | D | E |
| Cycle | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Inst 1 | F | D | E | ||
| Inst 2 | F | D | E | ||
| Inst 3 | F | D | E |
3 instructions complete in 5 cycles instead of 9!
| Advantage | Disadvantage |
|---|---|
| Increases instruction throughput | Pipeline stalls if one stage takes longer |
| Better utilisation of CPU components | Branch instructions cause pipeline flushes |
| No increase in clock speed needed | Adds complexity to CPU design |
1.1.1(e) Processor Architectures
Von Neumann Architecture
Harvard Architecture
Von Neumann vs Harvard Comparison
| Feature | Von Neumann | Harvard |
|---|---|---|
| Memory | Single memory for data & instructions | Separate memory for data & instructions |
| Buses | Shared data/instruction bus | Separate data and instruction buses |
| Fetch | Cannot fetch data & instruction simultaneously | Can fetch data & instruction simultaneously |
| Speed | Slower (bottleneck) | Faster (parallel fetching) |
| Complexity | Simpler, cheaper | More complex, expensive |
| Use | General-purpose computers | DSPs, microcontrollers, embedded systems |