Table of contents
1.
Types of Pipeline in Computer Architecture
1.1.
1. Arithmetic Pipeline
1.2.
2. Instruction Pipeline
2.
Stages of Pipelining
3.
Pipeline Design
4.
Pipelined Execution
5.
Advantages of Pipelining
6.
Frequently Asked Questions
6.1.
What is Pipelining?
6.2.
What can be the issues in pipelining?
6.3.
Why is it called pipelining?
6.4.
How can we handle dependent instructions in a pipelined processor?
7.
Conclusion
Last Updated: Jul 12, 2024
Easy

Pipelining in Computer Architecture

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Pipelining in computer architecture is the processes of arranging the hardware so that simultaneous execution of multiple instructions takes place, thus, improving the overall performance. Pipelining is a fundamental concept in computer architecture that improves a processor's efficiency. It works by breaking down a complex instruction into smaller, more manageable steps. These steps are then executed in an assembly line fashion, like a factory pipeline.

Pipelining in Computer Architecture

Example of Pipelining in computer architecture

Let us consider a real-life example of taking food from a counter:

The entire process of taking food from the counter can be divided into various steps - Picking utensils, taking salad, taking food, taking vegetables, etc. Now consider the following two ways of executing this:

  1. One person enters and takes utensils, salad, food, vegetables, and leaves. Then another person enters and repeats the process.
  2. People stand in a queue such that when one person is taking vegetables, some other person will be taking food, someone will be taking salad and utensils. 

You can see that the first process will have much lower efficiency than the second. While one person is taking food, the utensils, salad, and vegetable stalls are unused. On the other hand, people are simultaneously using the counter in the second process. Thus we have improved the efficiency of the process just by simultaneously executing multiple processes. Note that we have not used any extra resources.

The above example is similar to what we do in pipelining. 

Types of Pipeline in Computer Architecture

The pipeline is divided into 2 categories:

  1. Arithmetic Pipeline
  2. Instruction Pipeline

1. Arithmetic Pipeline

An arithmetic pipeline focuses on dividing a single arithmetic operation (like addition, multiplication, etc.) into smaller stages. These stages could involve fetching operands from registers, performing the actual arithmetic calculation, and storing the result back in a register.

By pipelining arithmetic operations, the processor can potentially begin processing the next instruction while the current instruction is still completing in later stages. This improves the efficiency of the processor by keeping the arithmetic logic unit (ALU) constantly working on calculations.

2. Instruction Pipeline

An instruction pipeline breaks down the entire instruction fetch-decode-execute cycle into distinct stages. This might involve fetching the instruction from memory, decoding it to understand its operation, fetching operands, performing the operation, and storing the result.

With instruction pipelining, multiple instructions can be at different stages of execution concurrently, improving overall processor performance. This is because the processor is not stuck waiting for one instruction to complete all stages before it can begin processing the next one.

Stages of Pipelining

There are several stages of processing an instruction:

  1. Fetching the instruction - Reading instruction from memory.
  2. Decoding the instruction - Finding the type of instruction.
  3. Executing the instruction - Performing logical arithmetic operations according to the type of instruction.
  4. Memory Access - If the instruction requires read/write to the memory.
  5. Write Back - Storing the value back to the registers.

Without pipelining, one instruction will get processed at a time, but we can process multiple instructions simultaneously with pipelining. That means while one instruction is decoded, the next instruction will be fetched simultaneously, and so on.

However, this isn’t as simple as that. Some instructions may depend on other instructions. For example, instruction A updates a register, and instruction B uses the value stored in that register. So, we can’t directly decode instruction B until instruction A has completed written back. There are several ways to handle such scenarios like stalling, data forwarding, etc.

Also Read - Register in Computer and what is middleware

Pipeline Design

  1. The entire process is divided into several stages.
  2. We use buffers to hold intermediate output between two stages.
  3. The output of one stage is connected to the next stage's input.
  4. A common clock controls all the stages.

Pipelined Execution

Consider that there are two processes - P1, P2, and there are 4 stages of execution - S1, S2, S3, and S4. The execution without pipelining will look like:

Cycle ->12345678
S1P1   P2   
S2 P1   P2  
S3  P1   P2 
S4   P1   P2

The execution with pipelining will look like:

Cycle ->12345
S1P1P2   
S2 P1P2  
S3  P1P2 
S4   P1P2

We can see that without pipelining, it took 8 clock cycles to execute 3 instructions, while in pipelined execution, it took just 5 clock cycles.

Advantages of Pipelining

  • Increased Throughput: By executing multiple instructions concurrently, pipelining allows a processor to complete more work in a shorter time. Imagine a factory assembly line - pipelining enables a processor to work on several instructions at once, like different stages of assembling a product, significantly boosting its output.
  • Improved Performance: The overall performance of the processor is enhanced due to the increased throughput. More instructions completed in a shorter time translates to a faster and more responsive computer system.
  • Efficient Resource Utilization: Pipelining keeps the functional units of the processor busy most of the time, reducing idle cycles. By dividing tasks into smaller stages, pipelining ensures the processor's resources are constantly being used, minimizing wasted time.
  • Potential for Higher Clock Speeds: Pipelining can enable processors to operate at higher clock speeds because the work is divided into smaller stages. Each stage can potentially be completed in a shorter amount of time, allowing the processor to handle instructions at a faster rate.
  • Reduced Waiting Time: Pipelining can streamline the processing flow, reducing the time the processor spends waiting for data or resources. With instructions continuously moving through the pipeline, the processor experiences less downtime and can focus on completing tasks more efficiently.

Frequently Asked Questions

What is Pipelining?

Pipelining is one of the processes of arranging the hardware so that simultaneous execution of multiple instructions takes place, thus, improving the overall performance.

What can be the issues in pipelining?

Some instructions may depend on other instructions. For example, instruction A updates a register, and instruction B uses the value stored in that register. So, we can’t directly decode instruction B until instruction A has completed written back.

Why is it called pipelining?

It's called pipelining because it resembles a physical pipeline. Just like separate stages process items as they move through a pipe, instructions flow through the CPU's pipeline with each stage performing a specific task. This analogy reflects the assembly line-like structure of pipelined processing.

How can we handle dependent instructions in a pipelined processor?

We can use stalling, which means that we will stop the execution of the instruction till the other instruction on which it depends has completed its execution. There are other methods like data-forwarding, where we forward the data directly from one instruction to the other dependent instruction so we don’t have to stall it.

Conclusion

In this article, we learned Pipelining in computer architecture. Pipelining is a cornerstone of modern processor design, enabling significant performance gains and efficiency improvements. By breaking down instructions into manageable stages and executing them concurrently, pipelined processors achieve higher throughput and faster overall performance. 

If you want to learn more about such topics, you can visit Code360.

If you think that this blog helped you share it with your friends!. To be more confident in data structures and algorithms, try out our DS and Algo Course.

Recommended Reading: 

Practice makes a man perfect. To practice and improve yourself in the interview, you can check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews.

Live masterclass