A) To calculate the expected CPI using detect-and-forward for data dependencies and detect-and-stall for branches, we need to take into account the different types of instructions, their frequencies, and the impact of data dependencies and branches.
First, we need to calculate the ideal CPI, assuming no stalls or delays:
Ideal CPI = (0.20 x 1) + (0.15 x 1) + (0.30 x 1) + (0.10 x 1) + (0.25 x 1) = 1.
Next, we need to calculate the impact of data dependencies. Since 40% of instructions are dependent on the previous instruction, we can assume that 0.40 of the instructions will have data dependencies. For these instructions, we will need to detect the dependency and forward the data, which will take one extra cycle:
Dependency CPI = (0.40 x 1 x 1) = 0.4
Next, we need to calculate the impact of branches. Since 25% of instructions are branches and 60% of them are taken, we can assume that 0.25 x 0.60 = 0.15 of the instructions will cause a branch delay. For these instructions, we will need to detect the branch, stall the pipeline, and then restart the pipeline after the branch is resolved, which will take two extra cycles:
Branch CPI = (0.15 x 2) = 0.3
Therefore, the expected CPI using detect-and-forward for data dependencies and detect-and-stall for branches would be:
Expected CPI = Ideal CPI + Dependency CPI + Branch CPI = 1 + 0.4 + 0.3 = 1.7
b) To calculate the expected CPI using detect-and-forward for data dependencies and predict-not-taken for branches, we need to take into account the same factors as in part (a), but we will use a different method to handle branches.
Instead of stalling the pipeline for branches, we will predict that branches are not taken. Since 60% of branches are actually not taken, this prediction will be correct 60% of the time. For the remaining 40% of branches that are taken, we will need to detect the branch, flush the pipeline, and then restart the pipeline after the branch is resolved, which will take three extra cycles.
Predict-not-taken CPI = (0.25 x 0.60 x 1) + (0.25 x 0.40 x 3) = 0.6 + 0.3 = 0.9
Therefore, the expected CPI using detect-and-forward for data dependencies and predict-not-taken for branches would be:
Expected CPI = Ideal CPI + Dependency CPI + Predict-not-taken CPI = 1 + 0.4 + 0.9 = 2.3
c) For the multi-cycle processor described in class, we assume that each instruction takes five cycles to execute. Therefore, the expected CPI would be:
Expected CPI = (0.20 x 5) + (0.15 x 5) + (0.30 x 5) + (0.10 x 5) + (0.25 x 5) = 2.5
Therefore, the multi-cycle processor would have a higher CPI than both the detect-and-forward with detect-and-stall and detect-and-forward with predict-not-taken pipelines.