Verification #64 · 2026-11-26 · Scoreboard for an arbiter · Hard · about 40 min

Build the testbench for a 2x2 crossbar

xbar.sv is a 2x2 crossbar. It has two input lanes (0 and 1) and two output ports (0 and 1). On any clock a lane can carry a packet: 8 bits of data and the output it is for (in_dst). Each lane has its own FIFO, so nothing is lost on the way in. Every clock, for each output, the packets at the head of the two FIFOs that are for that output compete. One wins (they take turns if both want it) and appears on the output registers one edge later, with out_src saying which lane it came from.

So packets from one lane to one output always come out in the order they went in, but how packets from the two lanes interleave on an output is up to the arbiter, and a test can't predict it. The provided monitors in env.sv send every packet seen on an input lane to the scoreboard's write_in, and every packet seen on an output to write_out (src, dst, data in an xpkt).

Write the verification components in components.sv. The skeleton already has the class headers, the analysis ports and the uvm_analysis_imp_decl macros. Fill in the four classes:

  • xbar_item: one clock of input traffic: v0, v1 (a packet on lane 0 / lane 1), dst0, dst1, data0, data1, and gap (idle clocks before the item). At least one lane must be valid. Constrain it so the interesting cases come up often: both lanes busy and sending to the same output, back-to-back items (gap 0 most often, with the odd long idle gap), and the data values 0 and 255 as well as ordinary ones.
  • xbar_seq: sends count random items.
  • xbar_driver: waits out reset, waits gap clocks, then drives in_valid, in_dst and in_data for exactly one clock, and returns in_valid to 0. With gap 0, the next item follows on the very next clock.
  • xbar_scoreboard: counts every input packet in sent and every output packet in checked. Each output packet must be the oldest packet still waiting that came in on the same lane and was for that output, with the same data. Count disagreements in errors and report the first few with uvm_error. At the end of the test (check_phase) nothing may still be waiting: every packet still stored counts as an error.

Run uses tb.sv: 50 random items into the correct crossbar. Submit runs your testbench against the correct crossbar and five faulty ones. Your scoreboard must stay quiet on the first (and have checked every packet) and catch each of the others.

Write and run your answer in the browser. The hidden tests check it, and it’s free.