The instruction cycle (also known as the fetch–decode–execute cycle, or simply the fetch-execute cycle) is the cycle that the central processing unit (CPU) follows from boot-up until the computer has shut down in order to process instructions. It is composed of three main stages: the fetch stage, the decode stage, and the execute stage.
The program counter (PC) is a special register that holds the memory address of the next instruction to be executed. During the fetch stage, the address stored in the PC is copied into the memory address register (MAR) and then the PC is incremented in order to "point" to the memory address of the next instruction to be executed. The CPU then takes the instruction at the memory address described by the MAR and copies it into the memory data register (MDR). The MDR also acts as a two-way register that holds data fetched from memory or data waiting to be stored in memory (it is also known as the memory buffer register (MBR) because of this). Eventually, the instruction in the MDR is copied into the current instruction register (CIR) which acts as a temporary holding ground for the instruction that has just been fetched from memory. During the decode stage, the control unit (CU) will decode the instruction in the CIR. The CU then sends signals to other components within the CPU, such as the arithmetic logic unit (ALU) and the floating point unit (FPU). The ALU performs arithmetic operations such as addition and subtraction and also multiplication via repeated addition and division via repeated subtraction. It also performs logic operations such as AND, OR, NOT, and binary shifts as well. The FPU is reserved for performing floating-point operations.
Each computer's CPU can have different cycles based on different instruction sets, but will be similar to the following cycle:
Registers Involved In Each Instruction Cycle:
Adapted from:
Updated: 02/07/2022 by Computer Hope The steps performed by the computer processor for each machine language instruction received. The machine cycle is a four-process cycle that includes reading and interpreting the machine language, executing the code, and then storing that code. Tip The process of cycling instructions may also be known as the E-cycle (execution cycle), I-cycle (instruction cycle), fetch-decode-execute cycle, or fetch-execute cycle.
Below is an example of a machine cycle performing the steps mentioned above for a math problem.
Improvements with pipeliningEarly computer processors needed to wait until an instruction completed all four stages before beginning work on the next instruction. However, today's computers use pipelining, which allows the processor to begin fetching a second instruction before it has completed the machine cycle for another instruction. ALU, Control Unit, CPU terms, Cycle, Instruction, Machine, Machine language, Program counter When software is installed onto a computer (by downloading it from the Internet or installing off a disk), the program and any associated files are stored in secondary memory. The program’s code is stored as a series of bits that represent machine instructions. The code remains there until the user chooses to execute the program in question, on which point sections of the code are loaded into the computer’s memory. To actually run the code, the processor then needs to retrieve instructions one by one from memory so it can run them. This process consists of three stages: fetching the instruction, decoding the instruction, and executing the instruction - these three steps are known as the machine cycle. A processor spends all of its time in this cycle, endlessly retrieving the next instruction, decoding it, and running it. In the fetch cycle, the control unit looks at the program counter register (PC) to get the memory address of the next instruction. It then requests this instruction from main memory and places it in the instruction register (IR). Here, the control unit checks the instruction that is now stored within the instruction register (IR). It looks at the instruction - which is just a sequence of 0s and 1s and decides what needs to be done. Does the instruction say to add two numbers? Does it say to load a value from memory? Where in memory? The control unit interprets the binary instruction to answer questions like these. Now the control unit sends the signals that tell the ALU, memory, and other components signals to cause them to perform the correct work. The video below demonstrates a simple program running on a computer. This imaginary computer shown uses special registers to hold memory address (MAR) and data that just came in from memory (MBR). It also uses registers called AL and BL to hold values temporarily. Don’t worry about the details of those other registers, focus on the fetch/decode/execute cycle and how the PC and IR are used. |