Solution :
The penalty of the misprediction = 4 cycles
The conditional branches of instructions = 20%
The Branch taken is = 70%
2-bit predictor accuracy is = 70%
1). The predict always taken
The stall only for the conditional instruction for which branch is not taken.
Stalls = [tex]$0.2 \times (1-0.7) \times 4$[/tex]
[tex]$= 0.2 \times 0.3 \times 4$[/tex]
= 0.24 cycles
2). The predict not always taken
The stall only for the conditional instruction for which branch is taken.
Stalls [tex]$= 0.2 \times 0.7 \times 4$[/tex]
= 0.56 cycles
3). The 2- bit predictor
The stalls [tex]$= 0.2 \times (0.7 \times 0.3\times 4+0.3 \times 0.3\times 4)$[/tex]
= 0.2 x 1.2
= 0.24 cycles