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 (
op0): ifkeyis already stored, its value is replaced andokis 1. Otherwise, if fewer than four entries are stored, the pair is added andokis 1. Otherwise nothing changes andokis 0. - GET (
op1): ifkeyis stored,rvalis its value andokis 1; otherwiseokis 0. - DEL (
op2): ifkeyis stored, it is removed andokis 1; otherwiseokis 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: randomop,key,valandgap(idle clocks before the item). Never produceop3. 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). Constraingapto 0 to 5, with both back-to-back items (gap 0) and long gaps (3 or more) happening often.kv_seq: sendscountrandom items.kv_driver: waits out reset, waitsgapclocks, then drivesreq,op,keyandvalfor exactly one clock, and returnsreqto 0. Withgap0, 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 compareokandcntwith the model, andrvalwhenever a GET found its key. Count items incheckedand mismatches inerrors; report the first few withuvm_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.