What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?

A machine cycle consists of the steps that a computer’s processor executes whenever it receives a machine language instruction. It is the most basic CPU operation, and modern CPUs are able to perform millions of machine cycles per second. The cycle consists of three standard steps: fetch, decode and execute. In some cases, store is also incorporated into the cycle.

The machine cycle is the most basic operation that a computer performs, and in order to complete menial tasks such as showing a single character on the screen, the CPU has to perform multiple cycles. The computer does this from the moment it boots up until it shuts down.

The steps of a machine cycle are:

  • Fetch – The control unit requests instructions from the main memory that is stored at a memory’s location as indicated by the program counter (also known as the instruction counter).
  • Decode – Received instructions are decoded in the instruction register. This involves breaking the operand field into its components based on the instruction’s operation code (opcode).
  • Execute – This involves the instruction’s opcode as it specifies the CPU operation required. The program counter indicates the instruction sequence for computer. These instructions are arranged into the instructions register and as each are executed, it increments the program counter so that the next instruction is stored in memory. Appropriate circuitry is then activated to perform the requested task. As soon as instructions have been executed, it restarts the machine cycle that begins the fetch step.

Share this Term

  • What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?
  • What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?
  • What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?

A computer program is made up of sets of instructions that are encoded using the binary numbering system.  The fetch – decode – execute cycle is the order of steps that the Central Processing Unit (CPU) uses to follow instructions.  The fetch execute cycle was first proposed by John von Neumann who is famous for the Von Neumann architecture, the framework which is being followed by most computers today.

The CPU is the brain of the computer and is known as the processor.  It is responsible for implementing a sequence of commands called a program.  A program takes inputs, processes them, and outputs results.  CPUs are found everywhere, like in mobile phones, computer tablets, and washing machines.

A CPU has the following components:

  • Control Unit – controls all parts of the computer system. It manages the four basic operations of the Fetch Execute Cycle as follows:
    1. Fetch – gets the next program command from the computer’s memory
    2. Decode – deciphers what the program is telling the computer to do
    3. Execute – carries out the requested action
    4. Store – saves the results to a Register or Memory
  • Arithmetic Logic Unit (ALU) – performs arithmetic and logical operations
  • Register – saves the most frequently used instructions and data

The primary task of the CPU is to execute programs using the fetch – decode – execute cycle.  This is also called the instruction cycle.  The cycle begins as soon as the computer is turned on and ends when the computer is shut down.

In plain CPUs the fetch execute cycle is carried out progressively, each instruction is being handled before the succeeding one is initiated.  In modern CPUs the fetch execute cycle is executed simultaneously, in parallel via an instruction pipeline, which means the next command starts being executed before the previous command has been completed.  This is made possible since the cycle has been broken up into separate steps.

To run a program, the program code is copied from secondary storage into the primary memory.  The CPU’s program counter is specified to the memory location where the first command in the program has been saved and execution starts.  The program starts running.  A program counter keeps track of the memory address of the command to be executed next.

In a program, each machine code command occupies a space in the main memory.  These memory locations each have a specific memory address.  The program counter saves the address of each command and instructs the CPU in what sequence they should be executed.

When a program is being carried out, the CPU implements the fetch – decode – execute cycle, which recurs over and over again until arriving at the STOP instruction.

Here’s a summary of the fetch – decode – execute cycle:

  1. The processor reviews the program counter to see which command to execute next.
  2. The program counter gives an address value in the memory of where the next command is.
  3. The processor fetches the command value from the memory location.
  4. Once the command has been fetched, it needs to be decoded and executed. For example, this could include taking one value, putting it into the Arithmetic Logic Unit (ALU), then taking a different value from a register and adding the two together.
  5. Once this has been completed, the processor returns to the program counter to find the next command.
  6. This cycle is replicated until the program stops.

The Execute Cycle is the only step useful to the end-user, everything else is required to make the execute cycle happen, as it performs the function of the command.  The ALU is utilized if the command involves arithmetic or logical operations.

Further Readings:

What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?

What are the 3 phases of the CPU cycle while executing a program what happens to the program counter during this cycle?

Introduction to Machine Cycle

For the central processing unit (CPU) the machine cycle is considered a list of steps to execute the machine instruction in the computer processor. The machine cycle is considered a list of steps that are required for executing the instruction is received. The machine cycle includes four process cycle which is required for executing the machine instruction. The four process includes reading of instruction, interpretation of machine language, execution of code and storing the result. The processor performs all these four processes in repetition in a sequential manner so that instruction can be executed.

What is Machine Cycle?

Machine cycle is also known as the processor cycle. The Central processing unit (CPU) is the main component for the execution of the machine cycle as it is the main component of the computer system. The main components of the machine cycle are the central processing unit and memory unit. The machine cycle is considered a sequence of four different processes that run in a repetitive manner for the execution of an instruction. The four processes include are, a) fetch b) decode c) execute d) store. In the first process fetch, the control unit asks in main memory for the first instruction for executing which is store in the memory as some specific address which can be easily identified by a program counter (control unit). After getting the instruction the next step is to decode the incoming instruction. The CPU contains the control unit which is used for decoding the instruction in the instruction register. The register is the small component of memory that perform the operations and speed up the processing of the operation. The registers store the instruction which is fetched from the main memory of CPU. The decoding of instruction includes the breaking of the operand field in small components on the basis of instructions opcode. The opcode is part of machine language instructions which gives information about what operation needs to be performed on the instruction. After that, the instruction is executed by the computer processor. The program counter is used for tracking the instruction sequence and track the instruction address as the instruction is executed and the next instruction in the queue for the execution. As the execution of an instruction is completed the output is stored in the memory for later use so that if there is a requirement then the result can be fetched easily.

Steps involved in Machine Cycle

The four steps are briefly discussed in the below section:

1. Fetch Process

In this process, the program counter value fetched which gives the address of the instruction which needed to be executed by the CPU. The instruction is fetched from memory that needs to be executed by the processor. The computer’s main memory stores all the instruction which needs to be executed by the processor. The control unit is the component that is responsible for fetching the instruction from the memory. All instructions are stored at some address location in main memory which can be tracked using the component named as instruction counter.

2. Decode Process

In this process, the fetched instruction is decoded for the execution of an instruction. The decoding process uses the instruction register contents to decode the type of operation which needs to be applied to instruction and inform ALU (Arithmetic logic unit) so that it can be executed for the decoded operand. In the CPU architecture, the control unit takes responsibility for decoding and translating the instruction. After decoding and translating instruction the signals are sent to ALU for the execution of the decoded instruction.

3. Execute Process

In this process, the decoded instruction is finally executed by the computer processor. The CPU is responsible to execute the instruction on the input data (operand). For the computer instruction, there are majorly two components which are operation code (OP code) and operand. The Arithmetic logic unit (ALU) is the component that executes the instruction as per the OP code on the operand which is the input data. For different operation the value of OP code is different. And according to the OP code, the ALU performs the operation on instruction and then the instruction is executed by the processor.

4. Store Process

In this process, the execution result is stored in memory. Once the Arithmetic logical unit operates on data, the result of the operation and processed data is sent to the main memory for the restoration of the result. The memory (RAM) is the main component in this process as the result is stored for later use. For displaying the output on the screen the result is fetched from the main memory or can be used for some other operation as per the requirement. And the stored data is deleted after the use and the whole process is again repeated for the next instruction. All these processes are critical to the processor as the processing speed and the performance of the processor is dependent on these four processes.

Why we Need Machine Cycle?

The machine cycle is required to tell the complete flow of instruction execution so that the internal of the instruction execution can be better understand and if there is any requirement it can be further improved. The machine cycle is the sequential steps for the execution of the instruction and if it is mot there the instructions will not be able to execute properly which can give wrong results. The machine cycle is required for the execution of machine instructions by the processor.

Importance of Machine Cycle

The machine cycle is important for the execution of machine instruction by the computer processor as the device performance is based on the machine cycle. If the instruction is not performed properly the performance can be degraded by the processor. The processing speed and the performance of the device are calculated by the number of instructions that it can execute in the given time span.

Conclusion

The machine cycle has four processes i.e. fetch process, decode process, execute process and store process. All these processes are necessary for the instruction execution by the processor. By the machine cycle, the performance of the processor can be calculated and the device can be selected.

Recommended Article

This is a guide to What is Machine Cycle?. Here we discuss the introduction to Machine Cycle and its importance along with its steps in detail. You can also go through our other suggested articles to learn more –