5 stage pipeline
Branch instructions = 20%
So for other 80% instructions Data Hazard may occur.
So number of stalls due to data hazard = 80% * 1/5 = 0.8*0.2 =0.16 cycles
Number of stalls due to branch instructions= 20% * Branch mis prediction ratio * branch penalty = 0.2*0.05*2 cycles= 0.02
Total stalls/instruction = 0.16+0.02=0.18 stalls.
Average Execution Time A = (1+#stalls)*cycle time = (1+0.18) * 1 ns = 1.18 ns
12 stage pipeline
Branch instructions = 20%
So for other 80% instructions Data Hazard may occur.
So number of stalls due to data hazard = 80% * 3/8 =0.3 cycles
Number of stalls due to branch instructions= 20% * Branch mis prediction ratio * branch penalty = 0.2*0.05*5 cycles= 0.05 cycles
Total stalls/instruction = 0.3+0.05=0.35 stalls.
Average Execution Time B = (1+#stalls)*cycle time = (1+0.35) * 0.6 ns = 0.81ns
SpeedUp of B(12) over A(5) = 1.18/0.81 = 1.456