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 (
op0): every bit set indatabecomes pending (the bits are OR-ed in). - MASK (
op1): the enable mask is replaced bydata. - CLAIM (
op2): among the sources that are both pending and enabled, the lowest-numbered one is cleared from pending, its number appears onidandokis 1. If there is none,okis 0 and nothing changes.datais 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: randomop,dataandgap(idle clocks before the item). Never produceop3. RAISE and CLAIM must be common, and MASK must happen often enough that the enable mask changes. Makedatamostly random but with the corner values8'h00and8'hFFand the single high bit8'h80showing up regularly. Constraingapto 0 to 5, with both back-to-back items (gap 0) and long gaps (3 or more) happening often.irq_seq: sendscountrandom items.irq_driver: waits out reset, waitsgapclocks, then drivesreq,opanddatafor exactly one clock, and returnsreqto 0. Withgap0, 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 compareokandpendwith the model, andidwhenever a CLAIM returned a source. Count items incheckedand mismatches inerrors; report the first few withuvm_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.