1. Overview
This topic explores the inner workings of a computer, focusing on the Central Processing Unit (CPU) and its components. Understanding computer architecture is crucial for understanding how software interacts with hardware and how to optimise computer performance.
Key Definitions
- CPU (Central Processing Unit): The "brain" of the computer responsible for processing data and instructions.
- Microprocessor: A CPU contained on a single integrated circuit (chip).
- ALU (Arithmetic Logic Unit): Part of the CPU that performs arithmetic and logical operations.
- Control Unit: Part of the CPU that coordinates all operations by decoding instructions and sending control signals.
- Register: A small, high-speed storage location within the CPU.
- PC (Program Counter): A register that holds the memory address of the next instruction to be executed.
- MAR (Memory Address Register): A register that holds the memory address currently being accessed.
- MDR (Memory Data Register): A register that holds the data being transferred to or from memory.
- CIR (Current Instruction Register): A register that holds the instruction currently being decoded and executed.
- Accumulator: A register used to store the results of calculations performed by the ALU.
- Bus: A set of parallel wires that transmits data between different components.
- Address Bus: A unidirectional bus that carries memory addresses from the CPU to memory.
- Data Bus: A bidirectional bus that carries data between the CPU and memory, or between different components.
- Control Bus: A bus that carries control signals (e.g., read, write) between the CPU and other components.
- Fetch-Decode-Execute Cycle: The fundamental cycle of operations performed by the CPU.
- Core: An independent processing unit within a CPU.
- Cache Memory: Small, fast memory within the CPU used to store frequently accessed data.
- Clock Speed: The rate at which the CPU executes instructions, measured in Hertz (Hz).
- Instruction Set: The complete set of instructions that a CPU can execute.
- Embedded System: A dedicated computer system built into a device for a specific function.
Core Content
Role of the CPU
The CPU is the core component of a computer, responsible for:
- Fetching instructions from memory.
- Decoding instructions.
- Executing instructions.
- Performing arithmetic and logical operations.
- Controlling the flow of data within the computer.
Microprocessor
- A microprocessor is a CPU contained on a single integrated circuit or chip.
- Modern computers, smartphones, and embedded systems use microprocessors.
- They combine the ALU, control unit, and registers on a single chip.
CPU Components and Von Neumann Architecture
The Von Neumann architecture defines the basic structure of a computer, where both instructions and data are stored in the same memory location. The CPU contains the following key components:
- ALU (Arithmetic Logic Unit): Performs calculations and logical operations (e.g., addition, subtraction, AND, OR).
- Control Unit:
- Fetches instructions from memory.
- Decodes instructions to determine what operations to perform.
- Sends control signals to other components to coordinate operations.
- Registers: Small, high-speed storage locations within the CPU. Key registers include:
- PC (Program Counter): Holds the address of the next instruction to be executed.
- MAR (Memory Address Register): Holds the address of the memory location being accessed.
- MDR (Memory Data Register): Holds the data being transferred to or from memory.
- CIR (Current Instruction Register): Holds the instruction currently being decoded and executed.
- Accumulator: Stores the results of calculations performed by the ALU.
- Buses:
- Address Bus: Carries the memory address from the CPU to memory. It is unidirectional (CPU to memory).
- Data Bus: Carries data between the CPU and memory (or other components). It is bidirectional.
- Control Bus: Carries control signals (e.g., read, write, interrupt) between the CPU and other components.
Fetch-Decode-Execute (FDE) Cycle
The FDE cycle is the fundamental process by which the CPU executes instructions:
- FETCH:
- The PC contains the address of the next instruction.
- The address in the PC is copied to the MAR.
- The instruction at that address is fetched from memory and placed in the MDR.
- The instruction in the MDR is copied to the CIR.
- The PC is incremented to point to the next instruction.
- DECODE:
- The Control Unit decodes the instruction in the CIR.
- The Control Unit determines what operation needs to be performed.
- EXECUTE:
- The Control Unit sends signals to the appropriate components (e.g., ALU, registers) to perform the operation.
- If the instruction involves a calculation, the ALU performs the calculation.
- Data is moved between registers and memory as needed.
- The cycle repeats continuously.
Core, Cache and Clock
- Core:
- An independent processing unit within a CPU.
- Multi-core CPUs (dual-core, quad-core, etc.) can execute multiple instructions simultaneously, improving performance through parallelism.
- Cache:
- Small, fast memory within the CPU used to store frequently accessed data and instructions.
- Reduces the need to access slower main memory, improving performance.
- Levels of cache: L1 (fastest, smallest), L2, L3 (slowest, largest). L1 cache is closest to the core.
- Clock:
- Generates regular pulses to synchronize operations within the CPU.
- Clock speed is measured in Hertz (Hz) or Gigahertz (GHz), representing cycles per second.
- Higher clock speed generally means faster instruction execution. However, other factors like cache size and core architecture also influence performance.
Factors Affecting CPU Performance
| Factor | Effect on Performance |
|---|---|
| Clock Speed | Higher clock speed generally leads to faster instruction execution, but it's not the only factor. |
| Number of Cores | More cores allow for parallel processing, which can significantly improve performance for tasks that can be divided into smaller subtasks. |
| Cache Size | Larger cache size reduces the need to access slower main memory, leading to faster access to frequently used data and instructions. |
| Instruction Set Architecture | Some instruction set architectures (like RISC) are more efficient than others (like CISC), potentially leading to better performance with the same clock speed. |
Instruction Set
- The instruction set is the complete set of instructions that a CPU can execute.
- Instructions are typically represented in machine code (binary).
- Examples of instruction types:
- Data Transfer:
LOAD(copy data from memory to a register),STORE(copy data from a register to memory). - Arithmetic:
ADD(add two values),SUB(subtract two values),MUL(multiply two values),DIV(divide two values). - Logical:
AND(logical AND),OR(logical OR),NOT(logical NOT). - Control Flow:
JUMP(unconditional jump to a new address),BRANCH(conditional jump based on a condition),HALT(stop execution).
- Data Transfer:
Embedded Systems
- A dedicated computer system built into a device for a specific function.
- Characteristics:
- Single purpose (designed for a specific task).
- Runs continuously.
- Limited user interface (often no screen or keyboard).
- Low power consumption (important for battery-powered devices).
- Real-time operation (must respond quickly to events).
- Examples:
- Washing machines, microwave ovens, traffic lights, car engine management systems, smart thermostats, medical devices, ATMs.
Exam Focus
- Understand the roles of the CPU components (ALU, Control Unit, Registers, Buses).
- Be able to explain the Fetch-Decode-Execute cycle in detail, including the role of each register.
- Know how clock speed, number of cores, and cache size affect CPU performance.
- Be able to identify examples of embedded systems and their characteristics.
- Use precise terminology when describing CPU components and processes.
- Understand the purpose of the instruction set for a CPU.
- Be able to distinguish between different types of buses (address, data, control).
Common Mistakes to Avoid
- ❌ Wrong: The accumulator stores data being transferred to and from memory. ✓ Right: The MDR stores data being transferred to and from memory; the accumulator stores the result of ALU operations.
- ❌ Wrong: The address bus is bidirectional. ✓ Right: The address bus is unidirectional (CPU to memory).
- ❌ Wrong: The control unit performs arithmetic operations. ✓ Right: The ALU performs arithmetic operations. The control unit coordinates operations.
- ❌ Wrong: Cache memory is the same as main memory. ✓ Right: Cache memory is smaller and faster than main memory, used to store frequently accessed data.
Exam Tips
- When describing the FDE cycle, be specific about the roles of the PC, MAR, MDR, and CIR.
- Use diagrams to help explain complex concepts like the Von Neumann architecture or the FDE cycle (if allowed).
- When discussing CPU performance, consider multiple factors (clock speed, cores, cache) rather than focusing on a single factor.
- Practice defining key terms clearly and concisely.
- Know the characteristics that define an embedded system.