What
is pipelining?
Pipelining forwarding is a method to prevent the hazards of pipelining.
If in a clock pulse multi-processes can be done, by availing this opportunity
leads the processing and efficiency of our software can be increased as time
consumption is much less.
Let’s take a simple example to learn the concept of pipelining. Suppose
Alex, Bob, Carol and David have to wash their clothes, each have one load of
clothes to wash, dry, fold and put away.
As, you can see from the figure, that sequential laundry takes 8 hours
to complete 4 loads. If we overlap the process, the time consumes less. So, if
it is a pipelined laundry, then the time can be reduced. The same 4 tasks/loads
can be processed in 3.5 hours rather in 8 hours, as shown below in figure
Types of pipeline
hazards
There are three types of
pipeline hazards.
- Structural Hazards
- Data Hazards
- Control/Branch Hazards
This
type of hazards occurs when two activities require the same resource simultaneously.
As,
in the above figure, you can see that in clock pulse 4 and 5 memory comes twice
which causes structural hazards of pipeline. To remove this duplication, we
should have to give a pause after 2nd instruction. This pause is
called stall. Stall is a gap between two instructions. When we apply a stall, at that time our CPU is idle.
To
solve structural hazards, we have two methods; one with single-port memory and second
with dual-port memory.
The
solution with single port is
Single-port
memory needs 3 cycles stall for load
by which 1.05 times faster clock rate than the unpipelined.
The
solution with dual-port is
Here, IM means Internal Memory an DM
means Dynamic Memory. Now, there will be no duplication in same clock pulse.
With dual-port, we don’t have to give stalls, because here the memory usage is
of two types; internal and dynamic.
2. Data Hazards:
Data Hazards
are also known as data dependency. Data dependency is the condition is the
condition in which the result of the current instruction is dependent on the
result of a previous instruction that has not been yet executed completely due
to the pipeline processing. Here, the Data
Hazards arise due to the need to preserve the order of the execution of
instructions.
The solution of data hazards is
3. Control Hazards
They
arise from the pipelining of branches and other instructions that change the
PC. There are 3 branch
delays in the following figure.
How to speed up
pipelining
To speed
pipelining, the equation is
Remember, for Ideal CPI pipelined machines is
almost 1. So,
Feel free to comment with your questions and suggestions regarding the post content...!
Nice artical
ReplyDelete