Professional Documents
Culture Documents
Fall 2015 - CS704 - 3 - MS150200187
Fall 2015 - CS704 - 3 - MS150200187
MS150200187
Q#1
a)
1 2
I ID
F
IF
3
E
x
ID
4
ME
M
Ex
IF
ID
IF
Clock cycle
5
6
7
8
stal WB
l
stal ME
WB
l
M
stal Ex
ME
WB
l
M
stal ID
Ex
ME
l
M
IF
ID
Ex
IF
10
11
WB
ID
ME
M
Ex
IF
ID
WB
ME
M
Ex
WB
ME
M
In this code we have 13 clock cycle. There is a hazard in add instruction due to
dependence on lw instruction.
b) Instructions to avoid pipeline stalls
LW R1, 0(R0)
LW R2, 4(R0)
LW R4, 8(R0)
ADD R3, R1, R2
SW R3, 12(R0)
ADD R5, R1, R4
SW R5, 16(R0)
Both hazard will be eliminated by moving up the third lw.
12
W
B
Sequence will complete in two fewer cycles than the original version with
forwarding.
Clock cycle is 11.
C) cycles are saved after executing the reordered instructions
1. 13s clock cycle before in given instruction
LW R1, 0(R0)
LW R2, 4(R0)
ADD R3, R1, R2
SW R3, 12(R0)
LW R4, 8(R0)
ADD R5, R1, R4
SW R5, 16(R0)
2. 11s clock cycle after recording
LW R1, 0(R0)
LW R2, 4(R0)
LW R4, 8(R0)
ADD R3, R1, R2
SW R3, 12(R0)
ADD R5, R1, R4
SW R5, 16(R0)
Q#2
Ans:
(a)
The behavior of this new branch prediction method and difference form
the standard 2-bit predictor is as follows:
According to the picture if the state is set to predict taken and
after that predict not taken then the state will remain to predict
taken but if again predict not taken the state will change to
predict not taken. This same as in 2-bit predictor.
Until we take predict not taken twice, it will remain into predict
taken state.
When the predict not taken branch is set and after this predict
taken, then the state will change into predict taken which is
different from 2-bit predictor in which if the state is set at not
taken then it has to be wrong for two time before its state is
changed to taken.
Therefore, in this predictor decision to be set wrong twice before
prediction is reversed to predict taken to be changed to predict
not taken. In this case of prediction not taken, decision has to be
wrong once before prediction is reversed to predict not taken to
be changed to predict taken.
(b)