Verification #61 · 2026-11-23 · Scoreboard with an associative-array model · Medium · about 30 min

Build the testbench for a four-entry key/value store

kv.sv is a small key/value store: up to four entries, each a 3-bit key and an 8-bit value. A request is one clock with req 1 and an op:

  • PUT (op 0): if key is already stored, its value is replaced and ok is 1. Otherwise, if fewer than four entries are stored, the pair is added and ok is 1. Otherwise nothing changes and ok is 0.
  • GET (op 1): if key is stored, rval is its value and ok is 1; otherwise ok is 0.
  • DEL (op 2): if key is stored, it is removed and ok is 1; otherwise ok is 0.

ok, rval and cnt (the number of entries stored) are registered: they show the result of the previous edge. rval only means something after a GET with ok 1. op 3 is never used.

Write the verification components in components.sv. The monitor and environment in env.sv are provided, and they use your four classes by name:

  • kv_item: random op, key, val and gap (idle clocks before the item). Never produce op 3. All three operations must be common. Keep the keys in a small range so that requests hit stored keys and the store fills up (there are only 8 possible keys, and a 4-entry store needs repeats of the same key to be interesting). Constrain gap to 0 to 5, with both back-to-back items (gap 0) and long gaps (3 or more) happening often.
  • kv_seq: sends count random items.
  • kv_driver: waits out reset, waits gap clocks, then drives req, op, key and val for exactly one clock, and returns req to 0. With gap 0, the next item follows on the very next clock.
  • kv_scoreboard: for each item the monitor reports, in order, apply it to a model of the store, then compare ok and cnt with the model, and rval whenever a GET found its key. Count items in checked and mismatches in errors; report the first few with uvm_error. The monitor fills in the result fields (ok, rval, cnt) of the item from the pins, one clock after the request.

Run uses tb.sv: 50 random items into the correct store. Submit runs your testbench against the correct store and five faulty ones. Your scoreboard must stay quiet on the first and catch each of the others.

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