Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Calculate CPI with branch and cache penalties

Hardware interview practice

Calculate CPI with branch and cache penalties

MediumComputer ArchitectureSystemVerilog

A five-stage pipeline completes 100 instructions. Base time is N+4 cycles. Ten mispredictions add two cycles each, five cache misses add eight cycles each, and penalties do not overlap. Write the total-cycle and CPI calculation.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

N = 100 instructions
base cycles = N + 4
10 branch misses × 2 cycles
5 cache misses × 8 cycles
no penalty overlap
Reviewed example

Work through one case

Input
Case 1: Base contribution
Case 2: Penalty contribution
Case 3: Final result
Expected output
Case 1: 100 + 4 = 104 cycles.
Case 2: 10×2 + 5×8 = 60 cycles.
Case 3: 164 cycles and CPI 1.64.

The shown result follows by applying this rule: Pipeline fill and both penalty classes are counted once. The cases also demonstrate this requirement: Report CPI = 164 / 100 = 1.64 and state the no-overlap assumption.

What to cover

Requirements

  1. Compute base time as 104 cycles.
  2. Add 20 branch-penalty cycles and 40 cache-penalty cycles.
  3. Report total cycles = 164.
  4. Report CPI = 164 / 100 = 1.64 and state the no-overlap assumption.
Continue practicing

Related questions

Computer ArchitectureRecognize write-back cache behavior→Computer ArchitecturePartition a cache address→Computer ArchitectureStress a page-walk and cache race→
asic.fyi · Learn silicon end to end.info@asic.fyi