Verification #71 · 2026-12-03 · Scoreboard with stall and flush · Medium · about 30 min
Build the testbench for a stallable pipeline
pipe3.sv is a three-stage pipeline with a stall and a flush. On every clock after reset:
flush= 1: every stage is emptied, and the input on this clock is dropped. Flush wins over stall.- else
stall= 1: nothing moves, and the input on this clock is not taken. - else: stage 0 takes
(in_v, in_d), stage 1 takes stage 0 with the data plus 5 (8-bit, wrapping), and stage 2 takes stage 1 with the data XOR8'hA5.
out_v and out_d show stage 2, and are registered: on any clock they show the result of the clocks before. out_d only matters when out_v is 1. An item offered at one clock shows up on the output three clocks later, if nothing stalls or flushes it.
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: for each clock it sends one pipe_item whose in_v, in_d, stall and flush are what the DUT is about to sample, and whose out_v and out_d are the output pins at that same clock.
pipe_item: one item is one clock of input pins, all random. Makein_v1 about three clocks in four,stallabout 3 in 10, andflushrare (about 1 in 12). Makein_doften (about one value in five) 251 to 255, and otherwise anything.pipe_seq: sendscountrandom items, then one last item within_v,stallandflushall 0, so the pins end idle.pipe_driver: waits out reset, then drives one item per clock, back to back: the next item goes out on the very next clock.pipe_scoreboard:writeis called once per clock. Keep a model of the three stages (valid and data for each). On each call comparet.out_vandt.out_dwith the model first (data only when the model's output is valid), then apply the clock's inputs to the model. Count every call inchecked, every call witht.out_v1 inoutputs, and mismatches inerrors; report the first few withuvm_error.
Run uses tb.sv: 50 random items into the correct pipeline. Submit runs your testbench against the correct pipeline 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.