Skip to content
Skip to main content

The Fetch-Decode-Execute Cycle: Instruction Execution and Pipelining

SS1 Term 1 • Week 7
About 45 minutes
Learning goals: Deconstruct the complete machine instruction cycle: Fetch, Decode, Execute, and Store. • Map register activity and bus traffic during each phase of the instruction cycle. • Explain the difference between machine Opcode (operation code) and Operand (data/address). • Describe Instruction Pipelining and explain how parallel instruction execution increases processor throughput.

Every computer game, video stream, artificial intelligence model, and operating system ever created ultimately reduces to one ceaseless, microscopic rhythm:

$$\mathbf{Fetch \implies Decode \implies Execute \implies Store}$$

This continuous rhythm is the Machine Instruction Cycle (or Fetch-Decode-Execute Cycle). A modern processor executes this cycle billions of times every single second without pause!

In this lesson, we will deconstruct each phase of the machine cycle, analyze how the CPU decodes machine instructions into Opcodes and Operands, and explore Instruction Pipelining—the architectural technique that allows processors to execute instructions in parallel like an automotive assembly line.


Learning Outcomes

By the end of this lesson, you will be able to:

  1. Explain each phase of the Fetch-Decode-Execute cycle in detail.
  2. Deconstruct a machine instruction into its Opcode and Operand.
  3. Trace register transfer operations throughout the cycle.
  4. Explain Instruction Pipelining and calculate pipeline speedup.

Key Vocabulary

Term Technical Role
F-D-E Cycle The fundamental operational process by which a CPU retrieves, decodes, and executes instructions.
Opcode (Operation Code) The binary portion of an instruction specifying the action to perform (e.g., LOAD, ADD, STORE).
Operand The binary portion of an instruction specifying the data value or memory address to be operated on.
Instruction Pipelining Overlapping the execution stages of sequential instructions to maximize CPU throughput.
Pipeline Stall (Hazard) A delay occurring when an instruction must wait for a previous result before it can execute.

Anatomy of the Fetch-Decode-Execute Cycle

               +---------------------------------------+
               |     1. FETCH INSTRUCTION FROM RAM     |
               | - PC address sent to MAR via bus      |
               | - Instruction arrives in MDR, then CIR|
               | - PC increments: PC = PC + 1          |
               +---------------------------------------+
                                  |
                                  v
               +---------------------------------------+
               |       2. DECODE INSTRUCTION (CU)      |
               | - Control Unit interprets the Opcode  |
               | - Determines required data & pathways |
               +---------------------------------------+
                                  |
                                  v
               +---------------------------------------+
               |       3. EXECUTE OPERATION (ALU)      |
               | - Math or logic calculated in ALU     |
               | - Data fetched if operand is address  |
               +---------------------------------------+
                                  |
                                  v
               +---------------------------------------+
               |       4. STORE / WRITE-BACK           |
               | - Result saved in Accumulator or RAM  |
               +---------------------------------------+
                                  |
                                  +---> (Cycle Repeats Continuously!)

Study Notes: The Phases Dissected

1. Phase 1: The FETCH Stage

The objective is to retrieve the next instruction from memory into the CPU: 1. The address in the Program Counter (PC) is copied into the Memory Address Register (MAR). 2. The PC is incremented by 1 ($\text{PC} \leftarrow \text{PC} + 1$). 3. The Control Unit sends a Memory Read signal across the Control Bus. 4. The RAM memory places the instruction onto the Data Bus, where it lands in the Memory Data Register (MDR). 5. The instruction is copied from the MDR into the Current Instruction Register (CIR).

2. Phase 2: The DECODE Stage

The instruction sitting in the CIR is split into two functional parts:

+-----------------------+---------------------------------------+
|  OPCODE (4 to 8 bits) |         OPERAND (12 to 24 bits)       |
|  "What to do" (ADD)   |   "Target data or address" (0x004F)   |
+-----------------------+---------------------------------------+
  • The Control Unit decodes the Opcode using internal logic decoders.
  • It identifies what operations must occur: Does this instruction require the ALU? Does it need an additional number from RAM?

3. Phase 3: The EXECUTE Stage

The hardware carries out the instruction: - If the instruction is arithmetic (e.g., ADD), the ALU adds the numbers and places the result in the Accumulator (ACC). - If the instruction is a jump (e.g., JMP 0x0100), the Control Unit overwrites the Program Counter with the target address, changing where the program flows next!

4. Phase 4: The STORE (Write-Back) Stage

The final result of the calculation is committed to its destination: written back to an internal register, or copied across the Data Bus into RAM storage.


Modern Hardware Acceleration: Instruction Pipelining

In early computers, the processor had to wait until an entire instruction finished all four stages before starting the next one. This was inefficient, because while the ALU was executing instruction 1, the Fetch circuitry was sitting completely idle!

Modern microprocessors use Instruction Pipelining, inspired by automotive manufacturing assembly lines:

Clock Cycle:      1         2         3         4         5         6
-------------------------------------------------------------------------
Instruction 1:  [FETCH]  [DECODE]  [EXECUTE] [STORE]
Instruction 2:           [FETCH]   [DECODE]  [EXECUTE] [STORE]
Instruction 3:                     [FETCH]   [DECODE]  [EXECUTE] [STORE]
Instruction 4:                               [FETCH]   [DECODE]  [EXECUTE]
-------------------------------------------------------------------------
  • In Cycle 1, Instruction 1 is fetched.
  • In Cycle 2, while Instruction 1 is being decoded, Instruction 2 is already being fetched!
  • In Cycle 3, while Instruction 1 is executing and Instruction 2 is decoding, Instruction 3 is being fetched!
  • Once the pipeline is full, one complete instruction finishes on every single clock cycle, quadrupling processor throughput!

Worked Example: Pipeline Throughput Comparison

Scenario: A program has 100 sequential instructions. Each instruction takes 4 clock cycles (Fetch, Decode, Execute, Store).

  • Non-Pipelined Processor:

$$100\text{ instructions} \times 4\text{ cycles} = \mathbf{400\text{ clock cycles}}$$

  • 4-Stage Pipelined Processor:
    It takes 4 cycles to fill the pipeline for instruction 1. After that, 1 instruction finishes on every subsequent cycle:

$$\text{Total Cycles} = 4 + (100 - 1) = \mathbf{103\text{ clock cycles}}$$

Result: Pipelining executes the exact same program nearly four times faster without increasing the clock frequency!


Practical Class Activity: The Pipeline Assembly Line

Four students model a 4-stage processor pipeline: 1. Student 1: Fetcher (Pulls an instruction card from the 'RAM' desk). 2. Student 2: Decoder (Reads the instruction aloud and identifies the math sign). 3. Student 3: Executer (Calculates the arithmetic on a whiteboard). 4. Student 4: Storer (Writes the result on the 'Accumulator' notebook).

Execution:
Process three instruction cards: ADD 5, SUB 2, ADD 10. Notice how as soon as Student 1 hands the card to Student 2, Student 1 immediately reaches for the next card!


Common Mistakes & Corrections

Common Mistake Why It Is Incorrect Proper Correction
"The Program Counter increments during the Execute stage." The PC increments during the Fetch stage immediately after the address is copied to the MAR. $\text{PC} \leftarrow \text{PC} + 1$ happens during Fetch so the next address is ready.
"Pipelining makes a single individual instruction run faster." Each instruction still takes 4 cycles from start to finish. Pipelining increases overall system throughput by overlapping multiple instructions.

Notebook Summary

Copy Into Your Computing Notebook

  • The F-D-E Cycle: Fetch (retrieves instruction from RAM) → Decode (interprets opcode in CU) → Execute (calculates in ALU) → Store (writes result to register/RAM).
  • Opcode: Specifies the operational command. Operand: Specifies the target data or address.
  • Instruction Pipelining: Overlaps the stages of sequential instructions, dramatically increasing processor throughput.

Check your understanding

What is the primary activity performed during the 'FETCH' phase of the machine cycle?
Which component of the CPU is responsible for DECODING the instruction to determine what control lines to activate?
In a machine instruction like 'ADD R1, R2', what is the term for the operation command ('ADD') and the data targets ('R1, R2')?
What is 'Instruction Pipelining' in modern high-performance microprocessors?
Feedback appears after you check your answer.