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 XOR 8'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. Make in_v 1 about three clocks in four, stall about 3 in 10, and flush rare (about 1 in 12). Make in_d often (about one value in five) 251 to 255, and otherwise anything.
  • pipe_seq: sends count random items, then one last item with in_v, stall and flush all 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: write is called once per clock. Keep a model of the three stages (valid and data for each). On each call compare t.out_v and t.out_d with the model first (data only when the model's output is valid), then apply the clock's inputs to the model. Count every call in checked, every call with t.out_v 1 in outputs, and mismatches in errors; report the first few with uvm_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.