let there are n instructions, Normally Pipe line without hazards gives us CPI = 1,
but in this question, there are hazards ==> CPI > 1
Number of instructions which cause structural hazards = 2% = 0.02 * n
Given that it cause penalty of 1 clock cycle ===> this instruction cause 1 more clocks as penalty compare to normal instruction
∴ CPI for this type of instructions = 1+1 = 2
Number of instructions which cause Data hazards = 5% = 0.05 * n
Given that it cause penalty of 2 clock cycle ===> this instruction cause 2 more clocks as penalty compare to normal instruction
∴ CPI for this type of instructions = 1+2 = 3
Number of instructions which cause control hazards = 10% = 0.1 * n
Given that it cause penalty of 3 clock cycle ===> this instruction cause 3 more clocks as penalty compare to normal instruction
∴ CPI for this type of instructions = 1+3 = 4
Number of instructions which cause control and data hazards = 10% = 0.1 * n
it means, which cause control hazard, after stalling then it also cause data hazard....
and my assumption is this instructions are not counted twice
Given that it cause penalty of (3+2) clock cycle ===> this instruction cause 5 more clocks as penalty compare to normal instruction
∴ CPI for this type of instructions = 1+5 = 6
Number of instructions which cause none of the hazards = ( n - ( $\frac{(2+5+10+10)}{100}$*n ) ) = ( 1 - 0.27 ) * n = 0.73 * n
Normal instructions are having CPI = 1
Average CPI = $\frac{((0.02*n)*2)\;+\;((0.05*n)*3)\;+\;((0.1*n)*4)\;\;+\;((0.1*n)*6)\;+\;((0.73*n)*1)}{n}$
= $((0.02)*2)+((0.05)*3)+((0.1)*4)+((0.1)*6)+((0.73)*1)$
= 0.04 + 0.15 + 0.4 + 0.6 + 0.73 = 1.92