P. 1
What is Pipelining

What is Pipelining

|Views: 3|Likes:
Published by Bijay Mishra

More info:

Published by: Bijay Mishra on Jul 29, 2013
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less





What is Pipelining

Pipelining is an implementation technique that overlaps multiple instruction execution.
MIPS instructions takes 5 steps 1.Fetch instruction from memory [ IF ] 2.Read insrtuction while decoding instruction. [ ID ] 3.Execute operation or calculate an address. [EX] 4.Access an operand in data memory. [ MEM ] 5.Write the result into registers. [ WB ]

Example (without pipelining)

Five steps are involved in the lw fetch and execution. Time taken to complete each step is as follows:
Instruction fetch: Register read: ALU: Memory read: Register write: 200 ps 100 ps (for base value) 200 ps (for memory address) 200 ps (for reading data from memory) 100 ps (for register write)

Execution time for lw instruction = 800 ps Execution time for a sequence of 3 lw instructions = 2400 ps

Example (with pipelining)
Since the lw instruction is divided into five steps, a 5 stage pipeline is employed.
 

Each pipeline stage takes one clock cycle. Clock cycle for a pipeline stage must be long enough to accommodate the slowest operation (200 ps in our example). Nonpipelined versus pipelined execution of 3 lw instructions

Figure 6.3

Tthe total execution time for the sequence of 3 lw instructions is 1400 ps

Figure 6.3

Nonpipelined versus pipelined execution of 3 lw instructions

Pipeline Performance .Summary  Pipeline does not change the individual instruction execution time  Pipeline improves performance by increasing the instruction throughput  The pipelined processor has a lower average CPI when compared to a multicycle implementation with the same clock rate.  The pipelined processor has a lower product of clock rate and CPI when compared to the single cycle implementation  Ideal speedup is proportional to the number of stages .

Pipeline Hazards Hazard: A situation in pipelining when the next instruction cannot execute in the next clock cycle Three types of hazards:  Structural hazard  Data hazard  Control (branch) hazard .

.Structural Hazard The hardware cannot support the combination of instructions that we want to execute in the same clock cycle.

$s0. $t3 The sub instruction is dependent on the result in register $s0 of the first instruction.Data Hazards Data hazard can occur when one or more of the instructions in the pipeline are data dependent. $t0.fullerton. $t3 The data required by the sub instruction is available only after the fourth stage of the first instruction.ecs. $s0. 20 ($t1) sub $t2.edu . S. $t1 sub $t2. Consider the following sequence of instructions: lw $s0.edu http://sbarua. Consider the following sequence of instructions: add $s0. Barua – CPSC 440 sbarua@fullerton.

6). . This guarantees correct execution.Data Hazard . we would have to stall by one stage (Figure 6. but could result in a lower performance. In our example (lw followed by sub).5)  Pipeline stall (bubble) Stall the pipeline by the required number of stages.Solutions Two methods are used to resolve a data hazard.  Forwarding or bypassing Retrieves the missing data element from internal buffers instead of waiting for it to come from the registers or memory location specified by the instruction (Figure 6.

5 Forwarding or bypassing .Figure 6.

Figure 6.6 Pipeline stall (bubble) .

an instruction is fetched at every clock cycle to sustain the pipeline. . the decision about whether to branch does not occur until the execution pipeline stage. The delay in determining the proper instruction to fetch is called a “control hazard” or “branch hazard”. If the instruction fetched is a “branch” instruction.Control (Branch) Hazards In a pipeline.

.  Assume branch not taken Execution of the branch instruction is continued in the pipeline assuming that the branch is not likely to take place. The penalty will be several clock cycles.Resolving Branch Hazards Techniques employed are:  Always stall Pipeline is stalled until the pipeline determines the outcome of the branch and knows what instruction address to fetch from. If the branch is taken. the instructions that are being fetched and decoded are discarded (flushed).

. thereby improving the system performance. Hazards limit the performance improvement. but appropriate hardware/software techniques can be devised to circumvent these limits.Performance of Pipelined Systems Pipelining reduces the average execution time per instruction.

Barua – CPSC 440 sbarua@fullerton.edu .ecs.S.fullerton.edu http://sbarua.


fullerton.edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.S.edu .ecs.


fullerton.ecs. Barua – CPSC 440 sbarua@fullerton.edu .S.edu http://sbarua.

S.ecs.edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.fullerton.edu .

fullerton.S. Barua – CPSC 440 sbarua@fullerton.ecs.edu http://sbarua.edu .

fullerton.S.edu http://sbarua.ecs. Barua – CPSC 440 sbarua@fullerton.edu .

Barua – CPSC 440 sbarua@fullerton.S.edu htt .

Barua – CPSC 440 sbarua@fullerton.edu http://sbarua.fullerton.ecs.edu .S.

ecs.fullerton.S. Barua – CPSC 440 sbarua@fullerton.edu http://sbarua.edu .

fullerton.edu .S.edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.ecs.

edu .S.ecs.edu http://sbarua.fullerton. Barua – CPSC 440 sbarua@fullerton.

fullerton.S.ecs.edu . Barua – CPSC 440 sbarua@fullerton.edu http://sbarua.

S.edu http://sbarua.edu .ecs.fullerton. Barua – CPSC 440 sbarua@fullerton.

Barua – CPSC 440 sbarua@fullerton.S.edu .ecs.fullerton.edu http://sbarua.

ecs. Barua – CPSC 440 sbarua@fullerton.edu .edu http://sbarua.fullerton.S.

fullerton. Barua – CPSC 440 sbarua@fullerton.edu http://sbarua.edu .S.ecs.

edu http://sbarua.fullerton. Barua – CPSC 440 sbarua@fullerton.ecs.S.edu .


S. Barua – CPSC 440 sbarua@fullerton.fullerton.edu http://sbarua.edu .ecs.

edu .fullerton.edu http://sbarua.S. Barua – CPSC 440 sbarua@fullerton.ecs.

Barua – CPSC 440 sbarua@fullerton.fullerton.S.edu .edu http://sbarua.ecs.

edu .edu http://sbarua.fullerton. Barua – CPSC 440 sbarua@fullerton.S.ecs.

Barua – CPSC 440 sbarua@fullerton.fullerton.ecs.edu http://sbarua.S.edu .

edu http://sbarua.ecs.fullerton.S. Barua – CPSC 440 sbarua@fullerton.edu .

ecs.fullerton.edu http://sbarua.S.edu . Barua – CPSC 440 sbarufullerton.

ecs.edu . Barua – CPSC 440 sbarua@fullerton.fullerton.S.edu http://sbarua.

Barua – CPSC 440 sbarua@fullerton.edu http://sbarua.fullerton.edu .ecs.S.

edu .ecs.fullerton.S.edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.

edu http://sbarua.ecs.fullerton.edu . Barua – CPSC 440 sbarua@fullerton.S.

ecs.edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.S.fullerton.edu .

edu .edu http://sbarua. Barua – CPSC 440 sbarua@fullerton.S.fullerton.ecs.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->