11
1 Pipelining(2) Pipelining(2) CDA 3101 Discussion Section 09 CDA 3101 Discussion Section 09

1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

Embed Size (px)

Citation preview

Page 1: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

1

Pipelining(2)Pipelining(2)

CDA 3101 Discussion Section 09CDA 3101 Discussion Section 09

Page 2: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

2

Question 1Question 1Identify all of the data dependencies and necessary forwarding in the following code. No branch prediction, No Delayed Slot.

addi $t1,$0,0addi $t2,$0,100

LOOP: lw $t4, 200($t2)add $t1, $t1, $t4addi $t2, $t2, -4bne $t2, $0,LOOP

Page 3: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

3

Question 1Question 1

Instruction CC1 CC2 CC3 CC4 CC5 CC6 CC7 CC8 CC9 CC 10

addi $t1,$0,0

IF ID EX MEM WB

addi $t2,$0,100

IF ID EX MEM WB

lw $t4, 200($t2)

IF ID EX MEM WB

add $t1, $t1, $t4

IF ID EX MEM WB

addi $t2, $t2, -4

IF ID EX MEM WB

bne $t2, $0,LOOP

IF ID

Page 4: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

4

Question 1(cont)Question 1(cont)

Instruction CC8 CC9 CC 10

CC 11

CC 12

CC 13

CC 14

CC 15

CC 16

CC 17

bne $t2, $0,LOOP

IF ID

lw $t4, 200($t2)

IF ID EX MEM WB

add $t1, $t1, $t4

IF ID EX MEM WB

addi $t2, $t2, -4

IF ID EX MEM WB

bne $t2, $0,LOOP

IF ID

Page 5: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

5

Question 1(cont)Question 1(cont)

Instruction CC 15

CC 16

CC 17

CC 18

CC 19

CC 20

CC 21

CC 22

CC 23

CC 24

bne $t2, $0,LOOP

IF ID

lw $t4, 200($t2)

IF ID EX MEM WB

add $t1, $t1, $t4

IF ID EX MEM WB

addi $t2, $t2, -4

IF ID EX MEM WB

bne $t2, $0,LOOP

IF ID

Page 6: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

6

Question 2Question 2Rewrite the following code with delay slot:

addi $t1,$0,0addi $t2,$0,100

LOOP: lw $t4, 200($t2)add $t1, $t1, $t4addi $t2, $t2, -4bne $t2, $0,LOOP

Page 7: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

7

Question 2Question 2Rewrite the following code with delay slot:

addi $t1,$0,0addi $t2,$0,100

LOOP: lw $t4, 200($t2)

addi $t2, $t2, -4bne $t2, $0,LOOP

Delay Slot: add $t1, $t1, $t4

Page 8: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

8

Question 2Question 2Instruction CC

1CC2

CC3

CC4

CC5

CC6

CC7

CC8

CC9

CC 10

CC 11

CC 12

addi $t1,$0,0

IF ID EX MEM

WB

addi $t2,$0,100

IF ID EX MEM

WB

lw $t4, 200($t2)

IF ID EX MEM

WB

addi $t2, $t2, -4

IF ID EX MEM

WB

bne $t2, $0,LOOP

IF ID

add $t1, $t1, $t4

IF ID EX MEM

WB

lw $t4, 200($t2)

IF ID EX MEM

WB

Page 9: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

Question 3Question 3• Assume we have 10 branch

outcomes as{T T T NT T T T NT NT T} , simulate the sequence on:

• 1-Bit predictor: (assume the original state is predict_bit =0)

• 2-Bit predictor: (assume the original state is predict_bit =01(weakly not taken)

9

Page 10: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

1-Bit predictor1-Bit predictor

10

Outcome Predict bit(before)

Prediction Prediction bit (after)

T 0 NT Wrong 1

T 1 T Right 1

T 1 T Right 1

NT 1 T Wrong 0

T 0 NT Wrong 1

T 1 T Right 1

T 1 T Right 1

NT 1 T Wrong 0

NT 0 NT Right 0

T 0 NT Wrong 1

Page 11: 1 Pipelining(2) CDA 3101 Discussion Section 09. 2 Question 1 Identify all of the data dependencies and necessary forwarding in the following code. No

2-Bit predictor2-Bit predictor

11

Outcome Predict bit(before)

Prediction Prediction bit (after)

T 01 NT Wrong 11

T 11 T Right 11

T 11 T Right 11

NT 11 T Wrong 10

T 10 T Right 11

T 11 T Right 11

T 11 T Right 11

NT 11 T Wrong 10

NT 10 T Wrong 00

T 00 NT Wrong 01