The fetch-decode-execute cycle

The Fetch-Decode-Execute Cycle

Definition:

  • The Fetch-Decode-Execute Cycle, also known as the Instruction Cycle, is the process that a computer uses to retrieve data (instructions), interpret it, and complete the instruction.

Phases of the Fetch-Decode-Execute Cycle:

  • Fetch: The CPU retrieves an instruction from the memory via the bus system. It places the instruction in the Instruction Register (IR). The address of the next instruction is kept in the Program Counter (PC) which subsequently increments to prepare for next retrieval.
  • Decode: In this stage, the Control Unit within the CPU interprets the instruction, identifying what operations need be performed and what data is necessary.
  • Execute: The CPU performs the required operation, which could be arithmetic (handled by the Arithmetic Logic Unit) or some sort of data movement from one register to another. The results are stored in register or memory.

Key Characteristics:

  • Repetition: After the completion of the Execute stage, the CPU returns to the Fetch stage and the whole cycle begins again, repeating this process millions of times per second.
  • Core operation: The Fetch-Decode-Execute Cycle is the core operation of the entire computer system, responsible for executing every instruction and process.

Applications:

  • The cycle underpins numerous computational operations such as data processing, running software applications, operating system tasks, etc. It’s foundational to practically everything a computer does.

Challenges:

  • Pipelining: One challenge is around efficient scheduling of different stages of the cycle for multiple instructions. Modern processors use pipelining to overlap these stages for different instructions, to increase performance.
  • Branch Prediction: Predicting the next instruction to fetch - particularly when a program “branches”, or moves to a non-sequential instruction - can be complex. Mis-predictions can result in wasted cycles and reduced performance.

Key Concepts for Revision:

  • Understand the three stages of instruction cycle: fetch, decode and execute.
  • Grasp the role of the CPU in this cycle: fetching from memory, decoding via the Control Unit, and executing operations.
  • Be familiar with concepts such as pipelining and branch prediction as ways to optimise the cycle.