top of page

The CPU Fetch/Decode/Execute cycle

​The CPU continuously repeats a  fetch-decode-execute cycle , in order to execute the instructions in a program, one by one.

In this cycle, the CPU goes through three main stages:

​

  1. Fetches a program instruction from the main memory;

  2. Decodes the instruction, i.e. it works out what needs to be done;

  3. Executes ( i.e. carries out) the instruction.

​

FetchDecodeExecute_00.png

During the fetch stage of the cycle, the content of the memory cell addressed by the program counter is retrieved and placed into the Instruction Register (IR).

​

fetch.gif

In the decode part of the cycle, the Control Unit works out what needs to be done by the instruction, and sends control signals to coordinate the other components.

​

decode.gif

During the execute stage of the cycle, the instruction is executed, using the ALU if necessary. Sometimes, this stage may involve the loading or saving of data from and to the main memory.

​

execute.gif

Then, the content of the PC is increased to point to the next instruction to be executed, and a new fetch cycle starts again. In this specific case the PC is incremented by two, because the RAM memory is organized in bytes, and the size of each CPU instruction is two bytes.

It is worthwhile noticing here that real CPUs, in order to improve their speed, perform the increment of the PC in parallel to previous operations, during the Execute cycle.

​

end.gif
References & Helpful Links: 
​
  1. The fetch-decode-execute cycle: https://isaaccomputerscience.org/concepts/gcse_sys_fetch_decode_execute?examBoard=all&stage=all 

                                                            CC BY-NC-SA 4.0                                                                                              Credits

bottom of page