UVM Coding Practice · Senior
Ordered FIFO Compare
In-order expected queue, compare on match, mismatch reporting.
Interview prompt
Sketch a scoreboard with expected and actual FIFOs for an in-order APB peripheral response stream.
diagram
WHITEBOARD CHAIN
1. DECLARE interfaces / types / ports you need
2. SKELETON class extends + utils macro + key methods
3. MECHANISM fill one critical method while narrating
4. PITFALL name one bug juniors make on this pattern
5. TEST how you would smoke-test the componentReference sketch (≤40 lines)
systemverilog
class apb_sb extends uvm_scoreboard;
`uvm_component_utils(apb_sb)
uvm_analysis_imp_exp #(apb_txn, apb_sb) exp_imp;
uvm_analysis_imp_act #(apb_txn, apb_sb) act_imp;
apb_txn exp_q[$], act_q[$];
function void write_exp(apb_txn t); exp_q.push_back(t); endfunction
function void write_act(apb_txn t);
act_q.push_back(t);
if (exp_q.size() && act_q.size())
compare_pair(exp_q[0], act_q[0]);
endfunction
function void compare_pair(apb_txn e, apb_txn a);
if (!e.compare(a)) `uvm_error("SB", "mismatch")
else begin exp_q.delete(0); act_q.delete(0); end
endfunction
endclassBuggy snippet — critique verbally
systemverilog
function void write_act(apb_txn t);
compare_pair(exp_q[0], t); // always compare — exp_q may be empty
endfunctionSmoke test (5 minutes)
One directed read/write sequence.
Inject single wrong data — expect one UVM_ERROR.
Check queues drain to zero after match.
Code lab drill
After reading, try Code lab exercise uvm-l8-int-scoreboard-fifo — topic reference: /topics/uvm/coding-practice/scoreboard/ordered-fifo-compare
Common pitfalls
Compare when exp_q empty — index error or bogus match.
No txn.compare() — field-wise typos missed.
Not deleting matched entries — duplicate compares.