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:
doneis 1 for one clock.plenshows the number of beats in the packet, stopping at 15.ovris 1 if the packet had more than 8 beats.pcntshows 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: randomlen(beats in the packet),gap(idle clocks before the first beat) andstall(1 means one idle clock after the first beat, iflenis more than 1). Constrainlento 1 to 20,gapto 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: sendscountrandom items.pm_driver: waits out reset, waitsgapclocks, then drives thelenbeats on consecutive clocks (vld1,last1 on the final beat only), with the one idle clock after the first beat whenstallis set andlen> 1. Afterwardsvldandlastreturn to 0. Withgap0 the next packet's first beat follows on the very next clock.pm_scoreboard: for each item the monitor reports, in order, compute the expectedplen,ovrandpcntfromt.beatsand the number of packets so far, and compare. Count items incheckedand mismatches inerrors; report the first few withuvm_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.