computer organization- pipe lining
DESCRIPTION
Computer Organization- Pipe LiningTRANSCRIPT
![Page 1: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/1.jpg)
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 ]
![Page 2: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/2.jpg)
Example (without pipelining)
Five steps are involved in the lw fetch and execution.
Time taken to complete each step is as follows:
Instruction fetch: 200 psRegister read: 100 ps (for base value)ALU: 200 ps (for memory address)Memory read: 200 ps (for reading data from memory)Register write: 100 ps (for register write)
Execution time for lw instruction = 800 psExecution time for a sequence of 3 lw instructions = 2400 ps
![Page 3: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/3.jpg)
Example (with pipelining)
Since the lw instruction is divided into five steps, a 5 stage pipeline isemployed.
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).
Figure 6.3 Nonpipelined versus pipelined execution of 3 lw instructions
Tthe total execution time for the sequence of 3 lw instructions is 1400 ps
![Page 4: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/4.jpg)
Figure 6.3 Nonpipelined versus pipelined execution of 3 lw instructions
![Page 5: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/5.jpg)
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
![Page 6: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/6.jpg)
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
![Page 7: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/7.jpg)
Structural Hazard
The hardware cannot support the combination of
instructions that we want to execute in the same
clock cycle.
![Page 8: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/8.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
Data Hazards
Data hazard can occur when one or more of the instructions in the
pipeline are data dependent.
Consider the following sequence of instructions:
add $s0, $t0, $t1
sub $t2, $s0, $t3
The sub instruction is dependent on the result in register $s0 of the first
instruction.
Consider the following sequence of instructions:
lw $s0, 20 ($t1)
sub $t2, $s0, $t3
The data required by the sub instruction is available only after the fourth
stage of the first instruction.
![Page 9: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/9.jpg)
Data Hazard - Solutions
Two methods are used to resolve a data hazard.
Forwarding or bypassingRetrieves the missing data element from internal buffersinstead of waiting for it to come from the registers or memory location specified by the instruction (Figure 6.5)
Pipeline stall (bubble)
Stall the pipeline by the required number of stages. This guarantees correct execution, but could result in a lower performance.
In our example (lw followed by sub), we would have to stall
by one stage (Figure 6.6).
![Page 10: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/10.jpg)
Figure 6.5 Forwarding or bypassing
![Page 11: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/11.jpg)
Figure 6.6 Pipeline stall (bubble)
![Page 12: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/12.jpg)
Control (Branch) Hazards
In a pipeline, an instruction is fetched at every clock cycle to
sustain the pipeline.
If the instruction fetched is a “branch” instruction, 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”.
![Page 13: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/13.jpg)
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. The penalty will be several clock cycles.
Assume branch not taken Execution of the branch instruction is continued in
the pipeline assuming that the branch is not likely to take place.
If the branch is taken, the instructions that are being fetched and decoded are discarded (flushed).
![Page 14: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/14.jpg)
Performance of Pipelined Systems
Pipelining reduces the average execution time per
instruction, thereby improving the system performance.
Hazards limit the performance improvement, but
appropriate hardware/software techniques can be
devised to circumvent these limits.
![Page 15: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/15.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 16: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/16.jpg)
![Page 17: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/17.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 18: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/18.jpg)
![Page 19: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/19.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 20: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/20.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 21: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/21.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 22: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/22.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 23: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/23.jpg)
S. Barua – CPSC 440 [email protected] htt
![Page 24: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/24.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 25: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/25.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 26: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/26.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 27: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/27.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 28: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/28.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 29: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/29.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 30: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/30.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 31: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/31.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 32: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/32.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 33: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/33.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 34: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/34.jpg)
![Page 35: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/35.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 36: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/36.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 37: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/37.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 38: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/38.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 39: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/39.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 40: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/40.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 41: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/41.jpg)
S. Barua – CPSC 440 sbarufullerton.edu http://sbarua.ecs.fullerton.edu
![Page 42: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/42.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 43: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/43.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 44: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/44.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 45: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/45.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 46: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/46.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu
![Page 47: Computer Organization- Pipe Lining](https://reader033.vdocument.in/reader033/viewer/2022061118/5469ae2baf79593b558b4da4/html5/thumbnails/47.jpg)
S. Barua – CPSC 440 [email protected] http://sbarua.ecs.fullerton.edu