Fetch-decode-execute

Fetch-Decode-Execute Cycle

  • The Fetch-Decode-Execute Cycle, also known as the instruction cycle, is a three-step process that a CPU carries out to process instructions.

Fetch

  • The fetch step is when the CPU gets an instruction from the memory.
  • It receives the address of the next instruction through the Program Counter (PC).
  • The instruction found at that address is brought into the CPU and stored in the Instruction Register.

Decode

  • In the decode step, the fetched instruction is translated into a form the CPU can understand.
  • This is carried out by the Control Unit (CU), which determines what operation is needed.
  • Each instruction has an operation code (opcode) that tells the CPU what task to perform.

Execute

  • The third step is the execute part, where the CPU performs the operation.
  • This could involve different parts of the CPU, such as the Arithmetic Logic Unit (ALU) for mathematical operations, or other components for data transfer or input/output operations.
  • Once an instruction has been executed, the cycle begins again with the CPU fetching the next instruction.

Importance and Efficiency

  • Understanding the Fetch-Decode-Execute Cycle is key to understanding how a computer processes tasks.
  • Improvements in efficiency can be achieved by pipelining: allowing the fetch and decode of the next instruction while the current instruction is being executed.

Interrupts

  • An interrupt is a signal that pauses the Fetch-Decode-Execute Cycle allowing the CPU to deal with high priority events.
  • Once the interrupt has been dealt with, the CPU goes back completing the Fetch-Decode-Execute Cycle where it left off.