Welcome to the Brain of the Computer!
Hi there! Today, we are going to peel back the plastic and metal to look at the most important part of any computer: the CPU (Central Processing Unit). Think of the CPU as the brain of the system. Without it, your computer couldn't think, calculate, or follow a single instruction.
Don’t worry if this seems a bit technical at first—we’re going to break it down using simple analogies like kitchens and post offices so it all makes sense!
1.1.1 Architecture of the CPU
What is the Purpose of the CPU?
The main job of the CPU is to process data and carry out instructions. It does this by constantly following a three-step cycle.
Did you know? A modern CPU can perform this cycle billions of times every single second!
The Fetch-Execute Cycle
To do its job, the CPU follows the Fetch-Decode-Execute Cycle. Imagine a chef in a kitchen:
1. Fetch: The CPU gets (fetches) an instruction from the main memory (RAM).
Analogy: The chef goes to the pantry to get a recipe.
2. Decode: The Control Unit works out what that instruction actually means.
Analogy: The chef reads the recipe to understand what needs to be cooked.
3. Execute: The CPU carries out the instruction. This might be a math calculation or moving data.
Analogy: The chef actually chops the vegetables and cooks the meal.
Key Takeaway:
The Fetch-Execute Cycle is the continuous process of getting an instruction, figuring it out, and doing it.
Common CPU Components
The CPU isn't just one single block; it’s made of several specialized parts working together.
1. Control Unit (CU)
The CU is like the manager of the CPU. Its main jobs are:
• Controlling the flow of data inside the CPU and between the CPU and other devices.
• Managing the Fetch-Decode-Execute cycle.
2. Arithmetic Logic Unit (ALU)
The ALU is the calculator. It does two things:
• Arithmetic: Addition, subtraction, multiplication, and division.
• Logic: Comparing things (is 5 greater than 3?) and using logic gates like AND, OR, and NOT.
3. Cache
Cache (pronounced "cash") is extremely fast memory built right into the CPU.
• It stores frequently used data so the CPU doesn't have to wait for the slower RAM.
• Analogy: If RAM is a bookshelf across the room, Cache is the book you are currently holding in your hand. It’s much faster to look at!
4. Registers
Registers are tiny, super-fast storage areas inside the CPU. They hold specific bits of information that the CPU needs right now. We will look at the specific ones next!
Quick Review:
• CU: The Manager.
• ALU: The Calculator.
• Cache: High-speed temporary storage for common data.
The Von Neumann Architecture
Most modern computers are based on the Von Neumann Architecture. This is a design where both the program instructions and the data are stored in the same memory (RAM). To make this work, the CPU uses specific Registers:
1. Program Counter (PC)
The PC holds the memory address of the next instruction to be fetched. It’s like a bookmark telling the CPU where to read next.
2. Memory Address Register (MAR)
The MAR holds the address of the location in memory that the CPU wants to read from or write to.
Memory Aid: Think of the "A" in MAR for "Address" (where it is).
3. Memory Data Register (MDR)
The MDR holds the actual data or instruction that has just been fetched from memory or is about to be written to memory.
Memory Aid: Think of the "D" in MDR for "Data" (what it is).
4. Accumulator (ACC)
The Accumulator is where the results of calculations from the ALU are temporarily stored.
Analogy: If you are adding up a list of numbers in your head, the "running total" you keep is like the Accumulator.
Important Distinction: Data vs. Address
Struggling to tell the difference? Think of a house:
• An Address is the house number (e.g., 22 Baker Street). It tells you where to find something. The MAR and PC deal with addresses.
• Data is the people or furniture inside the house. It is the actual content. The MDR deals with data.
Summary Table for Registers
PC: Holds the address of the NEXT instruction.
MAR: Holds the address of the CURRENT instruction/data being accessed.
MDR: Holds the actual DATA/INSTRUCTION itself.
Accumulator: Holds the result of the math!
Common Mistake to Avoid:
Students often mix up the MAR and the MDR. Always ask yourself: "Am I looking for a location (Address) or the stuff inside (Data)?"
• MAR = The Map (Address).
• MDR = The Box (Data).
Quick Check-Up!
Before you move on, see if you can answer these:
1. Which part of the CPU does math? (ALU)
2. What are the three stages of the CPU cycle? (Fetch-Decode-Execute)
3. Which register acts as a "running total" for calculations? (Accumulator)
4. Why is Cache useful? (It is faster than RAM)
Great job! You've just mastered the basics of CPU Architecture. Keep this "brain" logic in mind as you move on to learning about what makes one CPU faster than another!