Given,
$25$% of the instruction is conditional branch instruction.
$75$% of the time branch is taken .
$25$% of the time branch is not taken .
branch address calculated at $ID2$ stage .So branch penalty for it $(4-1)=3$ cycle
Condition evaluated at $EX2$ stage.So branch penalty for it $(4-1)=6$ cycle
Case 1: Predicted the branch is taken .
in predicted branch scheme we assume branch is taken always and at the evaluation stage if found branch not taken then stall occurs.
So average CPI=$1+0.25*0.75*3+0.25*0.25*5=1.875$
[75% time branch taken and we assume branch always taken so we just need to spend time for address calculation which is 3 clock cycle . Now if branch not taken that we get to know in ex2 state for which we incurs 5 clock cycle]
Case 2: Predicted the branch is not taken
Here we assume branch will not taken always when a conditional branch instruction occurs .
Here average CPI$=1+0.25*0.75*5=1.9375$
because 75% of the time out of 25% branch instruction branch is taken for which we have stalls .
So assuming clock cycle time is same for both the cases speed up=$\frac{1.9375}{1.875}=1.03$