Q033FreeDesign Verification
Match out-of-order packets by ID
Interview prompt
Question
Implement a scoreboard for responses that may arrive in any cross-ID order while preserving order within each ID. Support more than one outstanding packet with the same ID.

Candidate starting point
Implementation scaffold
`include "uvm_macros.svh"
package exercise_71;
timeunit 1ns; timeprecision 1ps;
import uvm_pkg::*;
class txn extends uvm_sequence_item;
int unsigned id;
logic [31:0] data;
`uvm_object_utils_begin(txn)
`uvm_field_int(id, UVM_ALL_ON)
`uvm_field_int(data, UVM_ALL_ON)
`uvm_object_utils_end
function new(string name = "txn"); super.new(name); endfunction
endclass
class id_scoreboard extends uvm_scoreboard;
`uvm_component_utils(id_scoreboard)
function new(string name, uvm_component parent); super.new(name,parent); endfunction
txn expected_by_id[int unsigned][$];
function void write_expected(txn item);
// TODO: implement this body.
endfunction
function void write_actual(txn actual);
// TODO: implement this body.
endfunction
function void check_phase(uvm_phase phase);
// TODO: implement this body.
endfunction
endclass
endpackageReviewed example
Trace one case
Input
expected: id1=A, id1=B, id2=C; responses: id2=C, id1=A, id1=BExpected output
all three match; per-ID queues emptyCross-ID reordering is legal, but the two id1 responses still consume A before B from that ID's FIFO.
What to cover
Requirements
- Store a FIFO of expected transactions for every ID instead of one value per ID.
- Reject an output whose ID has no pending expectation.
- Compare with the oldest expected packet for that ID and remove it only after selecting it.
- Report every nonempty per-ID queue at end of test.
- Assume non-null transaction handles. Deliver an expectation before its corresponding actual callback; callers serialize callbacks in observation order.
