RTL Design #47 · 2026-11-09 · Cache tags · Medium · about 15 min

An invalidate that hits the wrong line

dm_tags is the tag array of a 16-line direct-mapped cache. Address bits [5:2] pick the line and bits [15:6] are the tag. hit is combinational: the line is valid and its tag equals the lookup tag.

  • fill_en: at the next edge the line for fill_addr becomes valid and holds that tag.
  • inv_en: at the next edge the line for inv_addr is invalidated, but only if it currently holds inv_addr's tag. A line holding some other address is left alone.
  • If a fill and an invalidate hit the same line in the same cycle, the fill wins.
  • rst_n (synchronous, active low) invalidates every line.

Invalidates are dropping lines they shouldn't. Fix tags.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.