No history yet

Instruction Execution Cycle

The CPU's Rhythm

At its core, a CPU's job is surprisingly simple: it follows instructions. But it does this at an incredible speed, billions of times per second. This relentless process is known as the fetch-decode-execute cycle. It's the fundamental rhythm that powers every action on your computer, from moving your mouse to loading a webpage.

Think of it like a chef following a recipe. The chef first needs to find the next step (fetch), read and understand what it says (decode), and then actually perform the action, like chopping an onion (execute). The CPU does this for every single instruction in a program.

Fetching the Next Step

The cycle begins with a fetch. The CPU needs to know which instruction to grab next. For this, it relies on a special register called the Program Counter (PC). The Program Counter doesn't count programs; it holds the memory address of the next instruction to be executed. Think of it as a bookmark in the computer's massive recipe book (its memory, or RAM).

The Control Unit, the CPU's traffic cop, tells the memory to send the instruction located at the Program Counter's address. This instruction travels to another register, the Instruction Register (IR), to be held for the next stage.

Once the instruction is fetched, the Program Counter automatically increments, pointing to the address of the very next instruction in line. This ensures the CPU is always ready to continue the sequence without delay.

Decoding and Execution

Now that the instruction is sitting in the Instruction Register, the Decode stage begins. The Control Unit steps in again. It inspects the instruction, which is just a pattern of bits (machine code), and figures out what operation it represents. Is it an addition? A data move? A comparison?

The Control Unit is like the brain's language center, translating the raw binary code into a set of signals it can use to direct other parts of the CPU. It identifies which parts of the CPU are needed and prepares them for action.

Lesson image

Finally, we reach the Execute stage. This is where the actual work happens. The Control Unit sends signals to the appropriate component. If it's a mathematical or logical operation, the task is handed off to the (ALU). The ALU is the calculator of the CPU. It performs addition, subtraction, and logic operations like AND, OR, and NOT.

For example, if the instruction was ADD 5, 10, the Control Unit would tell the ALU to take the numbers 5 and 10 and add them together. The result is then typically stored in another register or written back to memory, completing the cycle for that single instruction.

The Pace of the Clock

So what keeps this whole cycle moving? The CPU clock. This isn't a clock that tells time, but rather an internal metronome that generates a steady electrical pulse, known as a clock cycle. Each stage of the fetch-decode-execute process takes at least one clock cycle to complete.

A CPU's speed is measured in gigahertz (GHz). A 3 GHz processor, for example, experiences 3 billion clock cycles every second. While not every instruction completes in a single cycle (some are more complex than others), the clock speed provides a good measure of how quickly the CPU can churn through its tasks.

This cycle of fetching, decoding, and executing is the heartbeat of your computer. It repeats relentlessly, translating the complex software you use into a series of simple, lightning-fast hardware operations.

Quiz Questions 1/5

What is the fundamental, three-stage process that a CPU continuously repeats to carry out program instructions?

Quiz Questions 2/5

Which CPU component's job is to act like a bookmark, holding the memory address of the next instruction to be processed?