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): with val = 0 the watchdog is disarmed and bark is cleared. Otherwise the timeout becomes val, the countdown restarts at val, the watchdog is armed and bark is cleared (even if it was already armed).
  • KICK (op = 2): if the watchdog is armed and bark is 0, the countdown restarts at the timeout. Otherwise nothing happens.
  • DISARM (op = 3): the watchdog is disarmed and bark is cleared.
  • Idle (op = 0): if armed and not barking, the countdown goes down by one. When it reaches 0, bark is 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: random op (only 1, 2 or 3), val and gap (idle clocks before the item). Make KICK the most common operation, then ARM, with DISARM least often. Make val often 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). Make gap mostly 0 to 3 and sometimes longer, with a rare gap of 140 to 300 clocks, so a large timeout can run out.
  • wd_seq: sends count random items.
  • wd_driver: waits out reset, then for each item waits gap clocks with op at 0, drives op and val for exactly one clock, and returns op to 0. With gap 0, the next item follows on the very next clock.
  • wd_scoreboard: write is called once per clock. Keep a cycle model of the watchdog (armed, timeout, countdown, bark). On each call compare t.bark with the model first, then apply t.op and t.val to the model. Count every call in checked, every call with op not 0 in ops, and mismatches in errors; report the first few with uvm_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.