411 REFERENCE · Wikibooks
A-level Computing 2009/AQA/Computer Components, The Stored Program Concept and the Internet/Machine Level Architecture/The Fetch–Execute cycle and the role of registers within it
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Machine code and processor instruction set
The Fetch-Decode-Execute cycle of a computer is the process by which a computer:
fetches a program instruction from its memory,
determines what the instruction wants to do,
and carries out those actions.
This cycle is repeated continuously by the central processing unit (CPU), from bootup to when the computer is shut down. In modern computers this means completing the cycle billions of times a second! Without it nothing would be able to be calculated.
Registers/circuits involved
The circuits used in the CPU during the cycle are:
Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next...
Memory Address Register (MAR) - the address in main memory that is currently being read or written
Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory
Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory
Control Unit (CU) - decodes the program instruction in the CIR, selecting machine resources such as a data source register and a particular arithmetic operation, and coordinates activation of those resources
Arithmetic logic unit (ALU) - performs mathematical and logical operations
Register notation
To describe the cycle we can use register notation. This is a very simple way of noting all the steps involved. In all cases where you see brackets e.g. [PC], this means that the contents of the thing inside the brackets is loaded. In the case of the first line, the contents of the program counter is loaded into the Memory Address Register.
(Increment the PC for next cycle at the same time)
decoded then executed
Detailed description of Fetch-Decode-Execute Cycle
To better understand what is going on at each stage we'll now look at a detailed description:
350px|center
The contents of the Program Counter, the address of the next instruction to be executed, is placed into the Memory Address Register
350px|center
The address is sent from the MAR along the address bus to the Main Memory. The instruction at that address is found and returned along the data bus to the Memory Buffer Register. At the same time the contents of the Program Counter is increased by 1, to reference the next instruction to be executed.
350px|center
The MBR loads the Current Instruction Register with the instruction to be executed.
350px|center
The instruction is decoded and executed using the ALU if necessary.
The Cycle starts again!
Exercise: Fetch Execute Cycle
Name 3 registers involved in the Fetch Execute Cycle and describe what each does:
Program Counter (PC) - an incrementing counter that keeps track of the memory address of which instruction is to be executed next...
Memory Address Register (MAR) - holds the address in memory of the next instruction to be executed
Memory Buffer Register (MBR) - a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory
Current Instruction register (CIR) - a temporary holding ground for the instruction that has just been fetched from memory
Describe the Fetch Execute Cycle using register notation:
Complete the following diagrams showing each step of the fetch decode execute cycle:
350px
350px
350px
350px
350px
350px
350px
350px