A processor has a 5-stage pipeline operating at a clock frequency of 2.0 GHz. Branch instructions account for 20% of all instructions. The branch predictor correctly predicts 80% of these branches. A misprediction incurs a 2-cycle penalty. Assuming a base CPI (Cycles Per Instruction) of 1.0 for non-branch and correctly predicted branch instructions, what is the total execution time for a program with 1,000,000 instructions?
Explanation: Clock period = 1 / 2.0 GHz = 0.5 ns. Branch frequency = 20% (0.20). Misprediction rate = 100% - 80% = 20% (0.20) of branches. Penalty per misprediction = 2 cycles. Average CPI penalty = Branch_Frequency Misprediction_Rate Penalty = 0.20 0.20 2 = 0.08 cycles. Total Average CPI = Base_CPI + Penalty = 1.0 + 0.08 = 1.08. Total time = Instruction_Count Total_CPI Clock_Period = 1,000,000 1.08 0.5 ns = 540,000 ns = 0.54 ms.