Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Verify predictor rollback after a misprediction

Hardware interview practice

Verify predictor rollback after a misprediction

HardComputer ArchitectureSystemVerilog

A speculative branch predictor may update at prediction time but must repair or discard wrong-path state after a redirect. Design a reference model, checks, and coverage for rollback behavior.

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

predict: fetch_id, pc, predicted_taken, target
resolve: fetch_id, actual_taken, target
commit: fetch_id
flush: new_epoch
reset_n
Reviewed example

Work through one case

Input
Case 1: IDs 10,11,12 predict; ID 10 mispredicts
Case 2: Two PCs alias one table entry, but only the committed path
Case 3: Reset during an unresolved branch
Expected output
Case 1: IDs 11 and 12 are killed.
Case 2: Determines final modeled state.
Case 3: Clears model and DUT predictor-valid state.

The shown result follows by applying this rule: Fetch IDs and epochs prevent wrong-path events from matching new work. The cases also demonstrate this requirement: Cover correct/mispredicted direction, target miss, aliasing, rollback depth, and resolution order.

What to cover

Requirements

  1. Track every prediction by fetch ID and epoch, and compare direction and target against a separate predictor model.
  2. On flush, discard all younger wrong-path entries and prevent their speculative updates from becoming committed state.
  3. Test nested branches, aliasing PCs, delayed resolution, back-to-back redirects, and reset coincident with resolve.
  4. Cover correct/mispredicted direction, target miss, aliasing, rollback depth, and resolution order.
asic.fyi · Learn silicon end to end.info@asic.fyi