No of instructions = 12
each clock cycle takes = 11ns (max(5,7,10,8,6) + 1ns)
I4 is the branch instruction so till I4 ,
I1-I3 will take total time of 11ns to execute so 3 * 11ns = 33ns
I4
So we know the target address of I9 only after completing the execution phase of I4 , but till that point I5 - I8 will already start
their execution , so there will be stalls or wastage of cycle till that point
therefore time taken for I4-I8 to execute is = 5 * 11ns = 55ns (For all I1-I8 , CPI = 1 )
Then at I9 , CPI will be 4 ( As that will execute after execution phase so CPI = 4 for I9)
So time taken for I9 to execute = 4 * 11 = 44ns (CPI * time taken for each cycle)
Then again from I10 - I12 again they take CPI = 1 , so time taken by them is = 3 * 11ns = 33ns
Total time taken to execute this program is = 33ns + 55ns + 44ns + 33ns = 165ns