Verification #58 · 2026-11-20 · Driver and scoreboard under back-pressure · Medium · about 30 min
Build the testbench for a sliding-window maximum
win_max.sv tracks the maximum of the last four samples. A beat is accepted on any clock edge where in_valid and in_ready are both 1; in_ready drops now and then, at times you can't predict, so the driver has to hold a beat until it is accepted. Idle clocks and stalled clocks don't change anything inside the block.
flush |
meaning of an accepted beat |
|---|---|
| 0 | data (signed 8-bit) joins the window. The window keeps the last four samples since the last flush, or fewer if there haven't been four yet. |
| 1 | The window is emptied. data is ignored. |
One clock after an accepted beat, out_valid is 1 for a clock and out_max holds the largest (signed) sample now in the window, or 0 for a flush beat.
Write the verification components in components.sv. The monitor and environment in env.sv are provided, and they use your four classes by name:
win_item: randomflush,dataandgap(idle clocks before the item). Constraingapto 0 to 3. Flushes must be fairly rare, so the window gets full between them, but they must still happen, including right after another beat. Makedatahit -128 and 127 often, and let both signs appear.win_seq: sendscountrandom items.win_driver: waits out reset, waitsgapclocks, then presents one item and keeps it on the pins untilin_readyis 1 at a clock edge, which is when the beat is accepted. Then it dropsin_valid, or presents the next item at once if itsgapis 0.win_scoreboard: for each item the monitor reports, in order, update a model of the window fromflushanddata, work out the expected maximum, and compare it withresult. Count items incheckedand mismatches inerrors; report the first few withuvm_error. The monitor'sresultis the 8-bitout_max(all X if the DUT never answered).
Run uses tb.sv: 50 random items into the correct block. Submit runs your testbench against the correct block and four 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.