Verification #69 · 2026-12-01 · UVM scoreboard with rare-event stimulus · Medium · about 30 min

Check a bank of saturating bin counters

hist_cnt.sv has four 3-bit bin counters. On any rising clock edge where valid is 1 it accepts one operation, chosen by op:

  • INC: adds 1 to counter bin. A counter that reaches 7 stays at 7 (it saturates).
  • RD: one clock after the edge that accepted it, rd_valid is 1 for one clock and rdata holds the count of counter bin as it was when the read was accepted.
  • CLR: sets all four counters to 0 (bin is ignored).

Reset clears the counters. Operations can follow each other on consecutive clocks, or after any number of idle clocks.

Write the verification components in components.sv. The monitor and environment in env.sv are provided, and they use your four classes by name:

  • hist_item: op (OP_INC, OP_RD or OP_CLR), bin, and gap, the number of idle clocks before the operation (0 to 3). Make INC the most common operation by far, reads fairly common, and CLR rare. Make gap 0 the most common value, but let gaps reach 3.
  • hist_seq: sends count random operations.
  • hist_driver: waits out reset, then for each item waits gap clocks with valid 0, presents the operation for exactly one clock with valid 1, and drops valid again. With gap 0, operations go back to back.
  • hist_scoreboard: the monitor reports every operation, in order, and reads arrive with rdata filled in. Keep a model of the four counters, count every item in checked, and compare each read's rdata with the model (count mismatches in errors, and report the first few with uvm_error).

One simulator quirk: a dist directly on an enum field doesn't give you the weights you ask for here. Put the weights on an integer and constrain the enum from it.

Run uses tb.sv: 100 random operations into the correct counter. Submit runs your testbench against the correct counter and against four 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.