edited by
877 views
0 votes
0 votes

A CPU has five-stage pipeline and runs at 1 GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch instruction computes the target address and evaluates the condition in the third stage of the pipeline. The processor stops fetching new instructions following a conditional branch until the branch outcome is known. Assuming that 20% of all instruction executed are branch instructions. A program executes 109 instructions out of which 40% are conditional branches and 50% of the conditional branch instructions the conditions are false. If each instruction takes one cycle to complete on average, then total execution time of the program is   

i am getting 1.32 

edited by

2 Answers

Best answer
0 votes
0 votes

Frequency=1 GHz, Cycle time=1/1=1 ns

Average instruction execution time = (1+0.20[0.60 x 2 + 0.40(0.50 x 2 +0.50 x 0)) x 1 ns

                                                                 = (1+0.20 x 3 x 0.80) x 1ns

                                                                 = 1.32 ns

Total execution time=1.32 ns x 109   =1.32 sec.

selected by
1 votes
1 votes
A conditional branch instruction evaluates the condition in the third stage of the pipeline.

So,  branch penalty=2.

Assuming that 20% of all instruction executed are branch instructions.

Out of which 40% are conditional branches and 60% unconditional branches

 50% of the conditional branch instructions the conditions are false

#stall cycle/instruction=$0.2*0.6*2+0.2*0.4*0.5*2=0.24+0.08=0.32$

Avg.inst exe. time=(1+# of stalls/inst)×cycletime$=(1+0.32)\times 1=1.32$

No related questions found