Verification #67 · 2026-11-29 · Scoreboards · Medium · about 30 min
Build the testbench for a priority queue
pq.sv is a registered priority queue that holds up to 4 values and always gives back the smallest one first. One request is accepted on any clock edge where req_valid is 1 (req_push 1 = push req_data, 0 = pop). One clock later rsp_valid is 1 for a clock with the answer:
- push: if the queue already holds 4 values, it is left unchanged and
rsp_flagis 1 (rejected). Otherwise the value is kept andrsp_flagis 0.rsp_datais 0. - pop: if the queue is empty,
rsp_flagis 1 andrsp_datais 0. Otherwisersp_datais the smallest value held, which is removed, andrsp_flagis 0.
Write the verification components in components.sv. The monitor and environment in env.sv are provided, and they use your four classes by name:
pq_item: randompush,dataandgap(idle clocks before the item). Constraingapto 0 to 3, mix pushes and pops about evenly, and makedatareach corner values (0 and 255) often, not once in a thousand items.pq_seq: sendscountrandom items.pq_driver: waits out reset, waitsgapclocks, then presents one item for exactly one clock. Withgap0, items go back to back.pq_scoreboard: for each item the monitor reports, keeps its own model of the queue, works out what the queue should have answered, and compares bothrsp_flagandrsp_data. Count items incheckedand mismatches inerrors; report the first few withuvm_error.
Run uses tb.sv: 50 random items into the correct queue. Submit runs your testbench against the correct queue and against three 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.