module 4-Pipelining
module 4-Pipelining
Pipelined
Overview of Pipelining
• The washer, dryer, folder, and store each take 30 minutes for their task.
• Sequential laundry takes 8 hours for 4 loads of wash, while pipelined laundry
takes just 3.5 hours.
• If all the stages take about the same amount of time and there is enough work
to do, then the speed-up due to pipelining is equal to the number of stages
Overview of Pipelining
• The same principles apply to processors where we pipeline instruction-
execution.
• Pipe lining doesn’t reduce the time take to complete a single task.
Example
• We are creating a pipeline for the execution of eight instructions:
• load word (lw), store word (sw), add (add), subtract (sub), AND (and), OR (or), set
less than (slt), and branch on equal (beq).
• Compare the average execution time for a single-cycle implementation to a
pipelined implementation.
• The operation times for the major functional units are:
• 200 ps for memory access,
• 200 ps for ALU operation, and
• 100 ps for register file read or write
Single-Cycle versus Pipelined
Performance
Total time for each instruction calculated from the time for each component. This calculation assumes
that the multiplexors, control unit, PC accesses, and sign extension unit have no delay
Single-Cycle versus Pipelined
Single-Cycle versus Pipelined
• In order to compare the pipelined and non pipelined approach, we
consider the example which involves the execution of 3 load word
instructions.
• If the stages are perfectly balanced, then the time between instructions
• Here, since the stages are imperfectly balanced, speed-up will be less than
the number of pipeline stages.
• The four fold improvement is not reflected in total execution time as the no:of
instructions is less.
Designing Instruction Sets for
Pipelining
• MIPS instruction set was designed for pipelined execution:
• This restriction makes it much easier to fetch instructions in the first pipeline
stage and to decode them in the second stage.
• There are situation in pipelining when the next instruction cannot execute in
the following clock cycle.
• These events are call hazards, and there are three different types:
• Structural hazard.
• Data Hazards
• Control Hazards
Structural hazard.
• Hardware cannot support the combination of instructions that we
want to execute in the same clock cycle.
• If the pipeline had a fourth instruction, we would see that in the same
clock cycle the first instruction is accessing data from memory while the
fourth instruction is fetching an instruction from that same memory.
• Control hazard arising from the need to make a decision based on the
results of one instruction while other are executing.
• When the guess is wrong, the pipeline control must ensure that the
instructions following the wrongly guessed branch have no effect and
must restart the pipeline from the proper branch address.
Pipelined Data path and Control
• The division of an instruction into five stages means a five-stage
pipeline.
• We must separate the data path into five pieces, with each piece
named corresponding to a stage of instruction execution:
Pipelined Data path and Control
• The write-back stage, which places the result back into the register
file in the middle of the data path
• The selection of the next value of the PC, choosing between the
incremented PC and the branch address from the MEM stage
The pipelined version of the
data path
The pipelined version of the
data path
• Pipeline registers: Need registers between stages to hold information
produced in previous cycle.
• The registers must be wide enough to store all the data corresponding
to the lines that go through them.
The pipelined version of the
data path
• For example, the IF/ID register must be 64 bits wide, because it must
hold both the 32-bit instruction fetched from memory and the
incremented 32-bit PC address.
Pipelined Control
• Just as we added control to the single-cycle data path we now add
control to the pipelined data path
• We can divide the control lines into five groups according to the
pipeline stage.