Components of the CPU (OCR A-Level Computer Science): Revision Notes
Components of the CPU
Overview
The Central Processing Unit (CPU) is the brain of a computer, handling all processing tasks. It is composed of several key components that work together to execute instructions, perform calculations, and manage data flow. For A-Level Computer Science, understanding the CPU's main components—including the Arithmetic and Logic Unit (ALU), the Control Unit (CU), registers, and buses—is essential. Each component plays a specific role, allowing the CPU to carry out tasks efficiently and effectively, especially when running assembly language programmes.
Key Components
Arithmetic and Logic Unit (ALU)
- Purpose: The ALU is responsible for performing arithmetic (e.g., addition, subtraction) and logic (e.g., AND, OR) operations.
- Function: The ALU is where actual data manipulation occurs in the CPU. For example, if a programme instruction requires adding two numbers, this takes place in the ALU.
- Role in Execution: The ALU is involved in the "execute" phase of the fetch-decode-execute cycle, processing the data once it is fetched and decoded.
Control Unit (CU)
- Purpose: The CU directs and coordinates most of the CPU's activities. It manages the execution of instructions by sending control signals to other components.
- Function: It decodes instructions and determines the sequence of operations required. It also manages the flow of data within the CPU and between the CPU and memory.
- Role in Execution: The CU ensures each instruction is processed in the correct order, guiding the CPU through each stage of the cycle.
Registers
Registers are small, fast storage locations within the CPU that hold specific types of data temporarily. Each register has a unique purpose:
Program Counter (PC)
- Purpose: Holds the memory address of the next instruction to be executed.
- Function: Increments after each instruction, ensuring the CPU progresses through the programme in the correct order.
Accumulator (ACC)
- Purpose: Temporarily stores data that is currently being processed by the ALU.
- Function: Often holds intermediate results of calculations, such as sums or comparisons, making it easier to access during ongoing computations.
Memory Address Register (MAR)
- Purpose: Holds the memory address of the data or instruction currently being fetched or stored.
- Function: Serves as the bridge between the CPU and main memory, sending addresses to the address bus.
Memory Data Register (MDR)
- Purpose: Temporarily stores data being transferred to or from memory.
- Function: Works with the MAR to store data fetched from memory before it is processed or data ready to be written to memory.
Current Instruction Register (CIR)
- Purpose: Holds the current instruction being executed.
- Function: Allows the CPU to keep track of the specific operation that it is currently processing, especially during multi-step instructions.
Buses
Buses are communication pathways used to transfer data and signals between different components of the CPU and memory. There are three main types of buses:
Data Bus
- Purpose: Carries actual data between the CPU and memory or other hardware components.
- Function: Data flows through this bus in both directions (to and from the CPU).
- Role in Execution: Essential for reading and writing data, especially during data transfer instructions in assembly language.
Address Bus
- Purpose: Carries the address of memory locations where data needs to be fetched or stored.
- Function: Transmits the memory address from the MAR to main memory, allowing precise access to specific memory locations.
- Role in Execution: Ensures instructions access the correct data location in memory.
Control Bus
- Purpose: Carries control signals from the CU to coordinate activities across the CPU.
- Function: Manages the timing and direction of data flow and ensures different components work in sync.
- Role in Execution: Plays a critical role in the CPU's synchronisation and timing, especially during complex operations.
How CPU Components Relate to Assembly Language Programmes
Assembly language programmes consist of low-level instructions that directly control CPU operations. Each assembly instruction correlates to a specific task that engages one or more CPU components:
- Instruction Fetch: The PC, MAR, and address bus work together to fetch the next instruction.
- Instruction Decode: The CU decodes the fetched instruction, identifying required operations and data locations.
- Execute: The ALU may perform arithmetic or logical operations using data held in the ACC or other registers. Data is then routed via the data bus for storage or further processing.
Note Summary
Common Mistakes
- Confusing the Roles of Registers: It's easy to mix up the functions of registers, especially the MAR and MDR. Remember, the MAR holds addresses, while the MDR holds data.
- Overlooking the Direction of Data Flow in Buses: The data bus is bidirectional (data moves both ways), while the address bus is unidirectional (only addresses from CPU to memory).
- Assuming the CU Performs Calculations: The Control Unit only coordinates actions; all arithmetic and logic are handled by the ALU.
- Misinterpreting Register Names in Assembly: Understanding register purposes can help you interpret assembly language instructions accurately, especially when seeing "PC" or "ACC" used in pseudocode.
Key Takeaways
- The ALU performs all arithmetic and logic operations within the CPU.
- The Control Unit coordinates instruction execution by managing the CPU's components and timing.
- Registers like the PC, ACC, MAR, MDR, and CIR serve specific purposes in storing data and addresses temporarily.
- Buses (data, address, and control) facilitate data flow and communication between CPU and memory.
- Assembly language programmes operate directly with these CPU components, making understanding their functions crucial for low-level programming.