The Reference Model
The monitor produces a stream of observed transactions. Deciding whether any of them were actually correct needs an independent prediction of what should have happened — a reference model. This page builds it as its own class, deliberately separate from whatever eventually compares against it.
A golden model of "what a correct FIFO does"
class fifo_ref_model;
bit [7:0] model_q[$];
function void write(fifo_txn txn);
if (txn.op == fifo_txn::WRITE)
model_q.push_back(txn.wr_data);
endfunction
function bit [7:0] predict_read();
if (model_q.size() == 0) begin
$error("Reference model: read predicted with nothing queued");
return 'x;
end
return model_q.pop_front();
endfunction
endclass
model_q is the model's own queue — a completely independent copy of "what the FIFO should currently contain," built only from write transactions, with no connection whatsoever to the DUT's actual internal storage. write() pushes; predict_read() pops and returns what the next read should produce. This class knows nothing about mailboxes, the monitor, or comparison — its only job is answering "given everything written so far, what should the next read return."
Why this is its own class, not folded into the checker
This is worth being honest about: UVM's own scoreboard, for this identical FIFO, does not separate these two responsibilities — its expected_q[$] queue and its comparison logic both live inside one fifo_scoreboard class. For a DUT this small, that's a completely reasonable choice.
This topic pulls them apart anyway, for a specific reason: keeping "what's correct" (the model) and "did it match" (the next page's job) as two separate classes means each can be understood, and tested, in isolation — a model bug ("the reference queue predicted the wrong value") and a comparison bug ("the check compared the right values incorrectly") are otherwise easy to conflate when they live in the same run() loop. At real scale, with a reference model complex enough to be worth reusing across more than one checker, this separation stops being a stylistic preference and becomes the only way to test the model on its own at all.
What's next
The reference model can predict; nothing yet consumes what the monitor observed and asks it. The next page builds that: the scoreboard.