Verification #66 · 2026-11-28 · Scoreboard with a state model · Medium · about 30 min

Build the testbench for an interrupt controller

irq.sv is an interrupt controller with 8 sources. It keeps an 8-bit pending register and an 8-bit enable mask, both 0 after reset. A request is one clock with req 1 and an op:

  • RAISE (op 0): every bit set in data becomes pending (the bits are OR-ed in).
  • MASK (op 1): the enable mask is replaced by data.
  • CLAIM (op 2): among the sources that are both pending and enabled, the lowest-numbered one is cleared from pending, its number appears on id and ok is 1. If there is none, ok is 0 and nothing changes. data is ignored.

ok, id and pend (the pending register) are registered: they show the result of the previous edge. id only means something after a CLAIM 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:

  • irq_item: random op, data and gap (idle clocks before the item). Never produce op 3. RAISE and CLAIM must be common, and MASK must happen often enough that the enable mask changes. Make data mostly random but with the corner values 8'h00 and 8'hFF and the single high bit 8'h80 showing up regularly. Constrain gap to 0 to 5, with both back-to-back items (gap 0) and long gaps (3 or more) happening often.
  • irq_seq: sends count random items.
  • irq_driver: waits out reset, waits gap clocks, then drives req, op and data for exactly one clock, and returns req to 0. With gap 0, the next item follows on the very next clock.
  • irq_scoreboard: for each item the monitor reports, in order, apply it to a model of the controller, then compare ok and pend with the model, and id whenever a CLAIM returned a source. Count items in checked and mismatches in errors; report the first few with uvm_error. The monitor fills in the result fields (ok, id, pend) of the item from the pins, one clock after the request.

Run uses tb.sv: 50 random items into the correct controller. Submit runs your testbench against the correct controller 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.