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_flag is 1 (rejected). Otherwise the value is kept and rsp_flag is 0. rsp_data is 0.
  • pop: if the queue is empty, rsp_flag is 1 and rsp_data is 0. Otherwise rsp_data is the smallest value held, which is removed, and rsp_flag is 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: random push, data and gap (idle clocks before the item). Constrain gap to 0 to 3, mix pushes and pops about evenly, and make data reach corner values (0 and 255) often, not once in a thousand items.
  • pq_seq: sends count random items.
  • pq_driver: waits out reset, waits gap clocks, then presents one item for exactly one clock. With gap 0, 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 both rsp_flag and rsp_data. Count items in checked and mismatches in errors; report the first few with uvm_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.