A robust scoreboard doesn't just check data; it helps you find bugs.
This implementation features Orphan Detection (missing packets) and Detailed
Reporting.
class eth_scoreboard extends uvm_scoreboard;
`uvm_component_utils(eth_scoreboard)
// FIFOs decouple the 'write' function from the 'compare' task
uvm_tlm_analysis_fifo #(eth_pkt) exp_fifo;
uvm_tlm_analysis_fifo #(eth_pkt) act_fifo;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
exp_fifo = new("exp_fifo", this);
act_fifo = new("act_fifo", this);
endfunction
// Main comparison loop
task run_phase(uvm_phase phase);
eth_pkt exp, act;
forever begin
// 1. Wait for BOTH streams to have data
exp_fifo.get(exp);
act_fifo.get(act);
// 2. Compare with detailed Diffing
if (!act.compare(exp)) begin
`uvm_error("MISMATCH", $sformatf("Packet Mismatch!\nExpected: %0h\nActual: %0h",
exp.data, act.data))
end else begin
`uvm_info("PASS", $sformatf("Match! ID: %0d", exp.id), UVM_HIGH)
end
end
endtask
// The "Orphan" Check: Did we lose any packets?
function void check_phase(uvm_phase phase);
if (exp_fifo.is_empty() && act_fifo.is_empty()) begin
`uvm_info("CHECK", "Scoreboard clean. No orphans.", UVM_LOW)
end else begin
`uvm_error("ORPHAN", $sformatf("Orphans detected! Exp Remaining: %0d, Act Remaining: %0d",
exp_fifo.used(), act_fifo.used()))
end
endfunction
endclass
Pro-Tip:
Transaction Recording
Stop debugging with just 1s and 0s.
Use begin_tr(tr) and end_tr(tr) in your monitor. This tells the
simulator (SimVision, Verdi) to draw a colored bubble or bar in the waveform
window for the duration of the packet. You can then click the bubble to see the
transaction fields!