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 whilebusy= 0 acceptsaandb.startwhilebusy= 1 is ignored. - A few clocks later
doneis 1 for exactly one clock, andq=a / b,r=a % bon that clock. - Division by zero gives
q=8'hFFandr=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: randoma,bandgap(idle clocks before the item). Shape them so the interesting cases come up all the time:ais often00orFF,bis often00,01,FFor a value with its top bit set, andaequalsbnow and then. Makegapmostly 0, sometimes up to 10.qandrare filled in by the monitor.dv_seq: sendscountrandom items.dv_driver: waits out reset, then for each item waitsgapclocks, drivesstart,aandbfor exactly one clock, and only then waits for the division to finish (done= 1) beforeitem_done. Withgap0, the next division starts as soon as the last one finishes.dv_scoreboard:writeis called once per finished division. Compute the expectedqandrfromt.aandt.b(the division-by-zero rule included), and compare them witht.qandt.r. Count every call incheckedand every mismatch inerrors, and report the first few withuvm_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.