🧩 Quick Recap from Lesson 2
Last time, we learned that the CPU reads instructions one at a time.
It does this by:
-
Fetching the instruction from memory
-
Decoding it to understand what it means
-
Executing it to do the job
This loop happens again and again, billions of times per second. It’s the main thing the CPU does all day, every day.
But now, let’s go even deeper and make this whole cycle as simple and clear as possible.
🌀 The Big Cycle That Runs Everything
You can think of the CPU like a super-fast robot that follows a simple plan:
“Look at what to do → Understand it → Do it → Repeat!”
This plan is called the Fetch–Decode–Execute Cycle.
Let’s understand this step by step.
🔎 Step 1: Fetch — Go Get the Next Job
Fetch means: “Go get the next instruction from memory.”
Imagine your teacher hands you a list of things to do:
-
First, clean your desk.
-
Then, draw a picture.
-
Then, write your name.
You don’t try to do all of them at once. You read one line, do it, and then go to the next one.
The CPU does the same thing.
🧠 But how does it know where to look?
That’s where the Program Counter comes in.
It points to the exact spot in memory where the next instruction lives.
So the CPU says:
“Hey memory! Give me the data at this spot right here!”
And memory gives it a bunch of 0s and 1s, which is the instruction.
🔍 Step 2: Decode — What Does This Even Mean?
Now the CPU has some 0s and 1s. But it needs to understand what they mean.
That’s the job of the decoder — a tiny part inside the CPU.
Think of it like reading a secret message.
Maybe “10000011” means “Add two numbers.”
Maybe “11001000” means “Save this number into memory.”
The decoder looks at the instruction and figures out:
-
What type of job is this? (Add? Move? Compare?)
-
Where is the data I need?
-
Where should I put the answer?
It turns the raw numbers into a clear action plan for the CPU to follow.
⚙️ Step 3: Execute — Let’s Do It!
Now the CPU knows what to do, so it goes ahead and does it.
-
If it needs to add two numbers, it sends them to the ALU (the tiny calculator inside the CPU).
-
If it needs to move data, it tells the registers to hold or pass values.
-
If it needs to talk to memory, it sends messages using the bus (a set of wires that carry data).
Once the job is done, the CPU goes back to fetch the next instruction.
And the cycle starts again!
🔁 The Loop That Never Stops
The CPU does this cycle over and over and over. It never rests.
Even when your computer seems “idle,” the CPU might be:
-
Checking for keyboard or mouse input
-
Running background tasks
-
Playing music
-
Updating clocks or notifications
Every one of those things is run by instructions that go through this same fetch-decode-execute loop.
💥 Billions of Times a Second?!
Yes!
Let’s say your CPU has a clock speed of 3 GHz. That means it can do 3 billion cycles every second.
Of course, some instructions take more than one cycle to finish. But still — the CPU is lightning fast.
Even blinking your eyes takes longer than a million CPU cycles!
🏗️ Let’s Imagine It Like a Factory
Here’s a fun way to think about the fetch-decode-execute cycle.
🎩 The CPU is a factory.
-
The Program Counter is like a clipboard with the current job number.
-
The Memory is the giant warehouse where all the jobs (instructions) are stored.
-
The Decoder is like the manager who reads each job and explains what it means.
-
The Executor (ALU, registers, etc.) is like the worker who does the actual job.
-
When one job is done, the clipboard moves to the next one, and it all repeats.
🧠 What About Smart Instructions?
Some instructions are a little smarter.
For example, the CPU might see:
“If this number is 10, skip the next instruction.”
This means the CPU needs to decide what to do next, instead of going in a straight line.
It uses logic gates inside to make these decisions. (We’ll learn more about this in the next part.)
🧠 Let’s Talk Details (But Keep It Simple)
Here are some extra technical truths, but we’ll explain them simply:
-
Some CPUs use something, called a queue to fetch multiple instructions ahead of time.
This is like looking at several jobs at once so you’re always ready. -
Sometimes, decoding is tricky — the instruction might involve moving things between memory and registers.
-
The CPU uses registers because they’re much faster than RAM.
Registers are like super-fast pockets that hold numbers just for a moment. -
The CPU’s clock ticks like a drum, and each tick moves the cycle forward one step.
👶 Even Simpler? Here’s a Very Simple Analogy:
Imagine you’re a robot helper in a toy store.
-
Your mom says: “Go to the shelf and read what the first note says.” → Fetch
-
You read the note. It says: “Put the teddy bear on the counter.” → Decode
-
You grab the teddy bear and place it where it belongs. → Execute
-
Then you go back and read the next note.
That’s exactly what a CPU does — just millions of times faster and with electricity!