Welcome to the Engine Room: The Processor!
Ever wondered how your computer actually "thinks"? In this chapter, we are going inside the Central Processing Unit (CPU)—the brain of the computer. We’ll look at the tiny components that work together to run your favourite games and apps. Don't worry if it seems like a lot of jargon at first; we’ll break it down piece by piece with simple analogies!
1. The Processor and Its Components
Think of the processor like a very fast, very organized kitchen. To get a meal (a task) finished, different people have specific jobs. Here are the main parts of the CPU you need to know:
The Big Three Components
Arithmetic Logic Unit (ALU): This is the "calculator" of the CPU. It handles all the mathematical calculations (like adding and subtracting) and logical operations (like comparing two numbers to see which is bigger).
Control Unit (CU): This is the "manager." It doesn't do the calculations itself, but it sends signals to tell the rest of the computer how to respond to an instruction. It coordinates everything.
Clock: This is like a metronome. It sends out a continuous pulse to keep all the components in sync. Every time the clock "ticks," a tiny step of a task is completed.
The Dedicated Registers
Registers are incredibly fast, tiny storage locations inside the CPU. They hold specific pieces of data that the CPU is using right now. For AQA, you need to know these dedicated registers:
- Program Counter (PC): Holds the address of the next instruction to be fetched. It’s like a bookmark for your to-do list.
- Current Instruction Register (CIR): Holds the actual instruction that is currently being decoded and executed.
- Memory Address Register (MAR): Holds the memory address of the data or instruction currently being accessed in RAM.
- Memory Buffer Register (MBR): Also called the Memory Data Register. It holds the actual data that has just been read from, or is about to be written to, memory.
- Status Register: Holds bits that are set or cleared depending on the result of an instruction (e.g., if a calculation resulted in a negative number or an overflow error).
Quick Review: Remember the difference between MAR and MBR. The MAR is the map (the address), and the MBR is the box (the actual stuff inside)!
Key Takeaway: The CPU isn't just one block; it's a team of specialized units (ALU, CU) and fast "scratchpad" memories (Registers) working in sync with a Clock.
2. The Fetch-Execute Cycle
This is the heart of how a computer works. It repeats this cycle billions of times every second!
Step-by-Step:
- Fetch: The address in the Program Counter (PC) is copied to the MAR. The instruction at that address is moved from memory to the MBR. Simultaneously, the PC is incremented (points to the next instruction). Finally, the instruction moves from the MBR to the CIR.
- Decode: The Control Unit looks at the instruction in the CIR and figures out what needs to be done.
- Execute: The instruction is carried out. This might involve the ALU doing a calculation or data being moved between registers.
Don't worry if this seems tricky! Just remember the cycle: Get the instruction, Understand it, Do it. Repeat.
3. Processor Instruction Sets
An instruction set is the complete set of commands a specific processor can understand. Because different types of processors are built differently, instruction sets are processor specific.
Structure of an Instruction
A machine code instruction is usually split into two parts:
Opcode: Tells the CPU what to do (e.g., ADD, LOAD).
Operand: Tells the CPU what to do it to (e.g., a number or a memory address).
Addressing Modes
This is just a fancy way of saying "how do we find the data?"
- Immediate Addressing: The operand is the actual data. Example: ADD 5 means literally "add the number 5."
- Direct Addressing: The operand is the memory address where the data is kept. Example: ADD 102 means "go to memory location 102 and add whatever number you find there."
Analogy: Immediate addressing is like having £10 in your pocket. Direct addressing is like having a treasure map that tells you where the £10 is buried.
Key Takeaway: Instructions tell the CPU what to do (Opcode) and what to use (Operand). Addressing modes tell it if the operand is the actual value or just a location.
4. Interrupts
An interrupt is a signal sent to the processor by a device (like a keyboard or a printer) or a program to tell it that it needs immediate attention.
What happens when an interrupt occurs?
When the CPU receives an interrupt, it doesn't just forget what it was doing. It follows these steps:
- It finishes the current Fetch-Execute cycle.
- It saves the current state of the registers (the "volatile environment") so it can come back to them later.
- It runs a special piece of code called an Interrupt Service Routine (ISR) to handle the problem.
- Once finished, it reloads the saved register values and carries on where it left off.
Did you know? Without interrupts, your computer wouldn't know you pressed a key on the keyboard until it finished whatever task it was currently doing—which could take a while!
5. Factors Affecting Processor Performance
Why is a new gaming PC faster than an old laptop? Several factors play a role:
- Clock Speed: Measured in Hertz (\(Hz\)). The higher the frequency, the more instructions the CPU can process per second.
- Number of Cores: A core is a complete copy of a CPU. A "quad-core" processor can technically handle four different tasks at the exact same time.
- Cache Memory: A tiny amount of super-fast memory right next to the CPU. It stores frequently used data so the CPU doesn't have to wait for the slower RAM.
- Word Length: The number of bits a CPU can process as a single unit. A 64-bit processor is much more powerful than a 32-bit one.
- Bus Width: Think of buses as the "roads" connecting components. A wider data bus allows more data to flow at once. A wider address bus allows the CPU to access more total memory locations.
Common Mistake to Avoid: Many students think doubling the cores doubles the speed. It doesn't! Some tasks can't be split up, and the cores have to spend time communicating with each other.
Key Takeaway: Performance is a balance. A fast clock is great, but you also need enough cores and fast cache to keep that clock busy!
Quick Review Box
- ALU: Does the math.
- CU: Manages the flow.
- PC: Points to the next job.
- MAR/MBR: The interface to memory.
- Fetch-Execute: The basic heartbeat of the CPU.
- Interrupts: Allow the CPU to multi-task and react to hardware.