ece/cs 552: pipelining (part...

109
CS/ECE 552: Pipelining (Part 3) Prof. Matthew D. Sinclair Lecture notes based in part on slides created by Mikko Lipasti, Mark Hill, Josh San Miguel, and John Shen

Upload: others

Post on 09-May-2020

8 views

Category:

Documents


0 download

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

109

COD Figure 4.65

How about this?