Verification #63 · 2026-11-25 · Scoreboard with a memory model · Medium · about 30 min
Build the testbench for a pipelined accumulator memory
accmem.sv is a small accumulator memory: 8 entries of 8 bits, all 0 after reset. On a clock edge where req is 1:
clr= 1: entryaddrbecomes 0.clr= 0: entryaddrbecomes its old value plusdin, stopping at 255 (it saturates, it does not wrap).
The new value of the entry appears on rdata, with rvalid = 1, two clock edges after the request edge. Requests can come on every clock, and results come back in order. The memory is a pipeline with bypassing, so back-to-back requests to the same address are exactly where it can go wrong.
Write the verification components in components.sv. The monitor and environment in env.sv are provided: the monitor pairs each request with its result and sends one acc_item per request, in order, with rdata filled in. They use your four classes by name:
acc_item: randomclr,addr,dinandgap(idle clocks before the request). Constraingapto 0 to 5 with back-to-back requests (gap 0) the most common. Make the same addresses come up often, and let all 8 addresses appear. Makedinsmall often and large often, andclrrare but not very rare.acc_seq: sendscountrandom items.acc_driver: waits out reset, waitsgapclocks, then drivesreq,clr,addranddinfor exactly one clock, and returnsreqto 0. Withgap0, the next item follows on the very next clock.acc_scoreboard: keeps a model of the 8 entries. For each item the monitor reports, in order, update the model and compare the item'srdatawith the new value. Count items incheckedand mismatches inerrors; report the first few withuvm_error.
Run uses tb.sv: 50 random items into the correct memory. Submit runs your testbench against the correct memory 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.