Verification #65 · 2026-11-27 · Beat-level driver and corner-case stimulus · Medium · about 30 min

Build the testbench for a packet monitor

pktmon.sv is a packet monitor. A packet is a run of beats, where a beat is a clock edge with vld = 1, and the packet ends with a beat that also has last = 1. Idle clocks (vld = 0) may appear inside a packet and between packets; they are not counted. One clock after a packet's last beat:

  • done is 1 for one clock.
  • plen shows the number of beats in the packet, stopping at 15.
  • ovr is 1 if the packet had more than 8 beats.
  • pcnt shows how many packets have ended so far, including this one. It is 4 bits and wraps from 15 to 0.

After reset the beat count and pcnt are 0. plen, ovr and pcnt keep their value until the next packet ends.

Write the verification components in components.sv. The monitor and environment in env.sv are provided, and they use your four classes by name. The monitor counts beats from the pins itself and puts the count in beats, then fills plen, ovr and pcnt one clock after the last beat.

  • pm_item: random len (beats in the packet), gap (idle clocks before the first beat) and stall (1 means one idle clock after the first beat, if len is more than 1). Constrain len to 1 to 20, gap to 0 to 4. One-beat packets, packets of exactly 8 and 9 beats, packets longer than 15, back-to-back packets (gap 0) and stalled packets must all be common.
  • pm_seq: sends count random items.
  • pm_driver: waits out reset, waits gap clocks, then drives the len beats on consecutive clocks (vld 1, last 1 on the final beat only), with the one idle clock after the first beat when stall is set and len > 1. Afterwards vld and last return to 0. With gap 0 the next packet's first beat follows on the very next clock.
  • pm_scoreboard: for each item the monitor reports, in order, compute the expected plen, ovr and pcnt from t.beats and the number of packets so far, and compare. Count items in checked and mismatches in errors; report the first few with uvm_error.

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