Verification #73 · 2026-12-05 · Corner-case stimulus and a reference model · Medium · about 25 min

Build the testbench for a multi-cycle divider

divu.sv is an 8-bit unsigned divider that takes a few clocks per division.

  • A clock with start = 1 while busy = 0 accepts a and b. start while busy = 1 is ignored.
  • A few clocks later done is 1 for exactly one clock, and q = a / b, r = a % b on that clock.
  • Division by zero gives q = 8'hFF and r = a.

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 remembers a and b when a division is accepted, and when done is 1 it sends one dv_item with those operands and the q and r it sees.

  • dv_item: random a, b and gap (idle clocks before the item). Shape them so the interesting cases come up all the time: a is often 00 or FF, b is often 00, 01, FF or a value with its top bit set, and a equals b now and then. Make gap mostly 0, sometimes up to 10. q and r are filled in by the monitor.
  • dv_seq: sends count random items.
  • dv_driver: waits out reset, then for each item waits gap clocks, drives start, a and b for exactly one clock, and only then waits for the division to finish (done = 1) before item_done. With gap 0, the next division starts as soon as the last one finishes.
  • dv_scoreboard: write is called once per finished division. Compute the expected q and r from t.a and t.b (the division-by-zero rule included), and compare them with t.q and t.r. Count every call in checked and every mismatch in errors, and report the first few with uvm_error.

Run uses tb.sv: 40 random divisions into the correct divider. Submit runs your testbench against the correct divider and five 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.