Verification #70 · 2026-12-02 · Cycle-accurate scoreboard with long idle gaps · Medium · about 30 min
Build the testbench for a watchdog timer
wdg.sv is a watchdog timer. On each clock after reset, op selects what happens:
- ARM (
op= 1): withval= 0 the watchdog is disarmed andbarkis cleared. Otherwise the timeout becomesval, the countdown restarts atval, the watchdog is armed andbarkis cleared (even if it was already armed). - KICK (
op= 2): if the watchdog is armed andbarkis 0, the countdown restarts at the timeout. Otherwise nothing happens. - DISARM (
op= 3): the watchdog is disarmed andbarkis cleared. - Idle (
op= 0): if armed and not barking, the countdown goes down by one. When it reaches 0,barkis set, and it stays set until an ARM or a DISARM.
So after ARM with val = N, the Nth idle clock sets bark, if no KICK comes first. bark is registered: on any clock it shows the result of the previous clock.
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 reports every clock, idle ones too: for each clock it sends one wd_item whose op and val are what the DUT is about to sample, and whose bark is the value of the pin at that same clock.
wd_item: randomop(only 1, 2 or 3),valandgap(idle clocks before the item). Make KICK the most common operation, then ARM, with DISARM least often. Makevaloften tiny (1 to 6, so a countdown ends within a few clocks and a KICK can land on its last clock), sometimes 0 and sometimes medium, and now and then large (130 to 255). Makegapmostly 0 to 3 and sometimes longer, with a rare gap of 140 to 300 clocks, so a large timeout can run out.wd_seq: sendscountrandom items.wd_driver: waits out reset, then for each item waitsgapclocks withopat 0, drivesopandvalfor exactly one clock, and returnsopto 0. Withgap0, the next item follows on the very next clock.wd_scoreboard:writeis called once per clock. Keep a cycle model of the watchdog (armed, timeout, countdown, bark). On each call comparet.barkwith the model first, then applyt.opandt.valto the model. Count every call inchecked, every call withopnot 0 inops, and mismatches inerrors; report the first few withuvm_error.
Run uses tb.sv: 50 random items into the correct watchdog. Submit runs your testbench against the correct watchdog 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.