ece/cs 552: pipelining (part...
TRANSCRIPT
![Page 1: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/1.jpg)
CS/ECE 552: Pipelining (Part 3)
Prof. Matthew D. Sinclair
Lecture notes based in part on slides created by MikkoLipasti, Mark Hill, Josh San Miguel, and John Shen
![Page 2: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/2.jpg)
Announcements 2/20
• Project Design Review Monday 2/24– My office, 6369 CS
• Midterm coming up next week (3/5 in class)– Closed book, one double-sided hand-written cheat sheet– Calculators allowed– MIPS green cards provided– Covers Weeks 1 through 6– Will post additional Midterm Details today under Week 7 on Canvas
• HW3 Posted Tomorrow, Due 2/28• Project Phase 1 due 3/13• HW1 Grades Released• HW2 Canvas Submission – per group
2
![Page 3: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/3.jpg)
Announcements 2/25
• Midterm coming up next week (3/5 in class)– Closed book, one double-sided hand-written cheat sheet– Calculators allowed– MIPS green cards provided– Covers Weeks 1 through 6– Posted additional Midterm Details
• Practice Exams posted on Canvas Week 7• Link to Course Website with topics that will covered
– Next Tuesday: exam review – bring questions!
• HW3 Posted Friday, Due 2/28• Project Phase 1 due 3/13• HW1 Grades Released
– Expectations for your homework and project submissions
• HW2 Grading In Progress
3
![Page 4: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/4.jpg)
Today’s Learning Objectives
• Analyze how branches impact the performance of pipelined programs
• Identify branch delay slots, and revise code to utilize them
• Demonstrate how branches require additional forwarding
4
![Page 5: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/5.jpg)
Data Hazards?
• Pipelining, without forwarding:– assume RF bypassing– average CPI = 1
5
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
RAW (20%)
RAW (50%)
![Page 6: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/6.jpg)
Data Hazards?
• Pipelining, without forwarding:– assume RF bypassing– average CPI = 1 + (1 × 20%) + (2 × 50%) = 2.2– 770 ps per instruction 6
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
RAW (20%)
RAW (50%)
![Page 7: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/7.jpg)
Data Hazards?
• Pipelining, with forwarding:– assume RF bypassing– average CPI = 1
7
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
load-to-use (25%)
![Page 8: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/8.jpg)
Data Hazards?
• Pipelining, with forwarding:– assume RF bypassing– average CPI = 1 + (1 × 25%) = 1.25– 437.5 ps per instruction 8
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
load-to-use (25%)
![Page 9: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/9.jpg)
Control Dependences• Conditional branches (e.g., beq, bne):
– Branch must execute to determine which instruction to fetch next; subsequent instructions are control-dependent on the branch instruction
– COD Figure 4.65, branches resolved in ID stage:
9
![Page 10: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/10.jpg)
Control Dependences• Conditional branches (e.g., beq, bne):
– Branch must execute to determine which instruction to fetch next; subsequent instructions are control-dependent on the branch instruction
– COD Figure 4.65, branches resolved in ID stage:
10
target
condition
![Page 11: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/11.jpg)
Control Dependences
beq $s1, $s2, SKIP
add $s4, $s5, $s6
...
SKIP: sub $s4, $s5, $s6
With predict-not-taken (flush otherwise):
11
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F
![Page 12: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/12.jpg)
Control Dependences
beq $s1, $s2, SKIP
add $s4, $s5, $s6
...
SKIP: sub $s4, $s5, $s6
With predict-not-taken (flush otherwise):
12
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D
add F
![Page 13: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/13.jpg)
Control Dependences
beq $s1, $s2, SKIP
add $s4, $s5, $s6
...
SKIP: sub $s4, $s5, $s6
With predict-not-taken (flush otherwise):
13
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X
add F D
sub F
![Page 14: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/14.jpg)
Control Dependences
beq $s1, $s2, SKIP
add $s4, $s5, $s6
...
SKIP: sub $s4, $s5, $s6
With predict-not-taken (flush otherwise):
14
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X
add F =
sub F
![Page 15: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/15.jpg)
Control Dependences
beq $s1, $s2, SKIP
add $s4, $s5, $s6
...
SKIP: sub $s4, $s5, $s6
With predict-not-taken (flush otherwise):
15
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
sub F D X M W
![Page 16: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/16.jpg)
16
COD Figure 4.65
Set PC to IF/ID.BranchAddr
Set IF/ID.Instruction to 0x00000000(sll $0, $0, 0)
Control Dependences
![Page 17: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/17.jpg)
Control Hazards?
• Pipelining, with predict-not-taken:– assume branches resolved in ID, flush if branch taken– average CPI = 1
17
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
60% branches taken
![Page 18: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/18.jpg)
Control Hazards?
• Pipelining, with predict-not-taken:– assume branches resolved in ID, flush if branch taken– average CPI = 1 + (1 × 60%) = 1.6– 560 ps per instruction 18
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
60% branches taken
![Page 19: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/19.jpg)
Control Hazards?
• Pipelining, with dynamic branch prediction:– assume branches resolved in ID, flush if branch mispredicted– average CPI = 1
19
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
90% branches predicted correctly
![Page 20: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/20.jpg)
Control Hazards?
• Pipelining, with dynamic branch prediction:– assume branches resolved in ID, flush if branch mispredicted– average CPI = 1 + (1 × 10%) = 1.1– 385 ps per instruction 20
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
90% branches predicted correctly
![Page 21: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/21.jpg)
21
COD Figure 4.65
condition
…But RAW Hazard at ID?
![Page 22: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/22.jpg)
add $s1, $s2, $s3
beq $s1, $s4, SKIP
With no forwarding to branch decision circuit in ID(assume RF bypassing):
22
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
add
beq
…But RAW Hazard at ID?
![Page 23: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/23.jpg)
add $s1, $s2, $s3
beq $s1, $s4, SKIP
With no forwarding to branch decision circuit in ID(assume RF bypassing):
23
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
add F D X
beq F
…But RAW Hazard at ID?
![Page 24: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/24.jpg)
add $s1, $s2, $s3
beq $s1, $s4, SKIP
With no forwarding to branch decision circuit in ID(assume RF bypassing):
24
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
add F D X M W
beq F * * D X M W
…But RAW Hazard at ID?
![Page 25: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/25.jpg)
25
COD Figure 4.65
condition
…But RAW Hazard at ID?
![Page 26: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/26.jpg)
add $s1, $s2, $s3
beq $s1, $s4, SKIP
With forwarding to branch decision circuit in ID(assume RF bypassing):
26
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
add F D X
beq F
…But RAW Hazard at ID?
![Page 27: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/27.jpg)
add $s1, $s2, $s3
beq $s1, $s4, SKIP
With forwarding to branch decision circuit in ID(assume RF bypassing):
27
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
add F D X M W
beq F * D X M W
…But RAW Hazard at ID?
![Page 28: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/28.jpg)
CS/ECE 552: Pipelining (Part 4)
Prof. Matthew D. Sinclair
Lecture notes based in part on slides created by MikkoLipasti, Mark Hill, Josh San Miguel, and John Shen
![Page 29: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/29.jpg)
Pipeline Diagrams
beq $s1, $s2, DEST
add $s4, $s5, $s6
...
DEST: sub $s4, $s5, $s6
With predict-not-taken:
29
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
![Page 30: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/30.jpg)
Pipeline Diagrams
beq $s1, $s2, DEST
add $s4, $s5, $s6
...
DEST: sub $s4, $s5, $s6
With predict-not-taken:
30
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
![Page 31: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/31.jpg)
Pipeline Diagrams
beq $s1, $s2, DEST
add $s4, $s5, $s6
...
DEST: sub $s4, $s5, $s6
With predict-not-taken:
31
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 32: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/32.jpg)
Pipeline Diagrams
beq $s1, $s2, DEST
add $s4, $s5, $s6
...
DEST: sub $s4, $s5, $s6
With predict-not-taken:
32
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F D X M W
DEST F D X M W
NOP
![Page 33: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/33.jpg)
33
beq
Control Hazards
add
cycle 2:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 34: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/34.jpg)
34
add (NOP)
Control Hazards
DEST beq
cycle 3:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 35: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/35.jpg)
35
add (NOP)
Control Hazards
DEST beq
cycle 4:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 36: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/36.jpg)
36
add (NOP)
Control Hazards
DEST beq
cycle 5:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 37: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/37.jpg)
37
add (NOP)
Control Hazards
DEST
cycle 6:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F =
DEST F D X M W
![Page 38: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/38.jpg)
Branch Delay Slots
beq $s1, $s2, DEST
add $s4, $s5, $s6 # branch delay slot
...
DEST: sub $s4, $s5, $s6
With one branch delay slot:
38
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
![Page 39: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/39.jpg)
Branch Delay Slots
beq $s1, $s2, DEST
add $s4, $s5, $s6 # branch delay slot
...
DEST: sub $s4, $s5, $s6
With one branch delay slot:
39
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F D X M W
![Page 40: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/40.jpg)
Branch Delay Slots
beq $s1, $s2, DEST
add $s4, $s5, $s6 # branch delay slot
...
DEST: sub $s4, $s5, $s6
With one branch delay slot:
40
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
add F D X M W
sub F D X M W
![Page 41: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/41.jpg)
Branch Delay Slots
beq $s1, $s2, DEST
sll $0, $0, 0 # branch delay slot
add $s4, $s5, $s6
...
DEST: sub $s4, $s5, $s6
With one branch delay slot:
41
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
beq F D X M W
NOP F D X M W
sub F D X M W
![Page 42: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/42.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
sll $0, $0, 0 # branch delay slot
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
42
![Page 43: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/43.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
sub $s5, $s6, $s7 # branch delay slot – legal?
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
43
![Page 44: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/44.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
sub $s5, $s6, $s7 # branch delay slot – legal? yes
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
44
![Page 45: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/45.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
add $s1, $s2, $s3 # branch delay slot – legal?
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
45
![Page 46: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/46.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
add $s1, $s2, $s3 # branch delay slot – legal? no
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
46
![Page 47: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/47.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
add $s4, $s5, $s6 # branch delay slot – legal?
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
47
![Page 48: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/48.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
add $s4, $s5, $s6 # branch delay slot – legal? no
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
48
![Page 49: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/49.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
or $s4, $s4, $s7 # branch delay slot – legal?
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
49
![Page 50: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/50.jpg)
Branch Delay Slots
sub $s5, $s6, $s7
add $s1, $s2, $s3
beq $s1, $s4, T1
or $s4, $s4, $s7 # branch delay slot – legal? yes
add $s4, $s5, $s6
j T2
…
T1: or $s4, $s4, $s7
slt $s2, $s4, $s6
T2: and $s2, $s2, $s3
50
![Page 51: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/51.jpg)
Branch Delay Slots
51
![Page 52: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/52.jpg)
Branch Delay Slots
jal FUNC
sll $0, $0, 0 # branch delay slot
add $s4, $s5, $s6
...
FUNC:
or $s4, $s5, $s6
jr $ra
52
![Page 53: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/53.jpg)
Branch Delay Slots
jal FUNC
sll $0, $0, 0 # branch delay slot
add $s4, $s5, $s6
...
FUNC:
or $s4, $s5, $s6
jr $ra
sll $0, $0, 0 # branch delay slot
53
![Page 54: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/54.jpg)
BACKUP
54
![Page 55: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/55.jpg)
Why Pipelining?
55
![Page 56: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/56.jpg)
Why Pipelining?
56
![Page 57: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/57.jpg)
Why Pipelining?
57
![Page 58: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/58.jpg)
Why Pipelining?
58
![Page 59: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/59.jpg)
Why Pipelining?
59
![Page 60: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/60.jpg)
Why Pipelining?
60
![Page 61: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/61.jpg)
Why Pipelining?
61
![Page 62: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/62.jpg)
Why Pipelining?
62
![Page 63: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/63.jpg)
Why Pipelining?
63
![Page 64: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/64.jpg)
Why Pipelining?
64
![Page 65: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/65.jpg)
Why Pipelining?
65
![Page 66: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/66.jpg)
Why Pipelining?
66
![Page 67: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/67.jpg)
Why Pipelining?
67
![Page 68: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/68.jpg)
Why Pipelining?
68
I1I2I3
![Page 69: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/69.jpg)
Why Pipelining?
69
I1
I2I3I4
![Page 70: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/70.jpg)
Why Pipelining?
70
I1
I2I3I4
![Page 71: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/71.jpg)
Why Pipelining?
71
I1
I2I3I4
![Page 72: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/72.jpg)
Why Pipelining?
72
I1
I2I3I4
![Page 73: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/73.jpg)
Why Pipelining?
73
I2I3I4
I1
![Page 74: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/74.jpg)
Why Pipelining?
74
I1I2I3
![Page 75: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/75.jpg)
Why Pipelining?
75
I2I3I4
I1
![Page 76: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/76.jpg)
Why Pipelining?
76
I3I4I5
I2 I1
![Page 77: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/77.jpg)
Why Pipelining?
77
I4I5I6
I3 I2 I1
![Page 78: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/78.jpg)
Why Pipelining?
78
I5I6I7
I4 I3 I2 I1
![Page 79: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/79.jpg)
Why Pipelining?
79
I6I7I8
I5 I4 I3 I2 I1
![Page 80: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/80.jpg)
Why Pipelining?
80
250 ps 150 ps 100 ps 350 ps 150 ps
![Page 81: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/81.jpg)
Why Pipelining?
• Single-cycle:– clock period = 1 ns– CPI = 1– 1 ns per instruction 81
250 ps 150 ps 100 ps 350 ps 150 ps
![Page 82: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/82.jpg)
Why Pipelining?
• Pipelining:– clock period = max{IF,ID,EX,MEM,WB} = 350 ps
82
250 ps 150 ps 100 ps 350 ps 150 ps
![Page 83: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/83.jpg)
Why Pipelining?
• Pipelining:– clock period = max{IF,ID,EX,MEM,WB} = 350 ps– individual CPI = 5
83
250 ps 150 ps 100 ps 350 ps 150 ps
![Page 84: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/84.jpg)
Why Pipelining?
• Pipelining:– clock period = max{IF,ID,EX,MEM,WB} = 350 ps– individual CPI = 5, average CPI = (#insns + 4) / #insns ≈ 1
84
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
![Page 85: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/85.jpg)
Why Pipelining?
• Pipelining:– clock period = max{IF,ID,EX,MEM,WB} = 350 ps– individual CPI = 5, average CPI = (#insns + 4) / #insns ≈ 1– 350 ps per instruction 85
250 ps 150 ps 100 ps 350 ps 150 ps
I5 I4 I3 I2 I1
![Page 86: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/86.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
86
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
![Page 87: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/87.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
87
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F
![Page 88: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/88.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
88
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F D* D
![Page 89: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/89.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
89
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F D* D X M W
![Page 90: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/90.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
90
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F D* D X M W
add F* F
![Page 91: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/91.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
91
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F D* D X M W
add F* F D* D
![Page 92: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/92.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
92
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
lw $s3 F D* D X M W
add F* F D* D X M W
![Page 93: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/93.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
93
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
add F* F D* D X M W
![Page 94: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/94.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
94
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 95: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/95.jpg)
Pipeline Diagrams
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
95
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
stalls
NOP
NOP
![Page 96: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/96.jpg)
96
lw $s3
Data Hazards
add lw $s1
cycle 3:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 97: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/97.jpg)
97
lw $s3
Data Hazards
add lw $s1
cycle 3:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 98: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/98.jpg)
98
lw $s3
Data Hazards
add NOP
cycle 4:
lw $s1
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 99: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/99.jpg)
99
lw $s3
Data Hazards
add NOP
cycle 5:
lw $s1
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 100: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/100.jpg)
100
lw $s3
Data Hazards
add NOP
cycle 5:
lw $s1
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 101: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/101.jpg)
101
lw $s3
Data Hazards
add NOP
cycle 5:
lw $s1
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 102: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/102.jpg)
102
lw $s3
Data Hazards
add NOP
cycle 6:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
NOP
![Page 103: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/103.jpg)
103
lw $s3
Data Hazards
add
cycle 7:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
NOP
![Page 104: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/104.jpg)
104
lw $s3
Data Hazards
add
cycle 7:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
NOP
![Page 105: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/105.jpg)
105
Data Hazards
add
cycle 8:
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
NOP
![Page 106: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/106.jpg)
MEM-to-EX Forwarding
lw $s1, 0($s2)
lw $s3, 4($s1)
add $s5, $s4, $s3
Assume full forwarding and bypassing:
106
insn\cycle 1 2 3 4 5 6 7 8 9 10 11 12 13
lw $s1 F D X M W
X M W
lw $s3 F D* D X M W
X M W
add F* F D* D X M W
![Page 107: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/107.jpg)
107
COD Figure 4.65
MEM-to-EX Forwarding
![Page 108: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/108.jpg)
108
COD Figure 4.65
Why not this?
![Page 109: ECE/CS 552: Pipelining (Part 3)pages.cs.wisc.edu/~sinclair/courses/cs552/spring2020/handouts/lec… · CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based](https://reader030.vdocuments.mx/reader030/viewer/2022040408/5eb59aeefe363668db668882/html5/thumbnails/109.jpg)
109
COD Figure 4.65
How about this?