In-Order Scoreboards
Build a scoreboard that compares expected and actual transactions in protocol order, with clear synchronization, diagnostics, and failure handling.
Learning objectives
- Recognize when an in-order scoreboard is the appropriate checking architecture.
- Explain how expected and actual transaction streams remain aligned.
- Build an in-order scoreboard using UVM analysis FIFOs.
- Compare transactions without duplicating DUT implementation logic.
- Detect mismatches, unexpected transactions, and missing transactions.
- Use scoreboard diagnostics to distinguish data errors from synchronization problems.
- Understand the limitations of in-order checking and when an out-of-order scoreboard is required.
Why in-order scoreboards matter
An in-order scoreboard is the simplest useful architecture for comparing predicted behavior with observed DUT behavior when transactions are guaranteed to complete in the same order in which they were accepted.
The important assumption is not that the simulation is sequential. Multiple transactions may be outstanding at the same time. The important assumption is that the ordering relationship is preserved.
E0, E1, E2... and the DUT monitor observes actual transactions in the
corresponding order A0, A1, A2..., the scoreboard can compare them
pair by pair.
Request stream
|
v
+-----------+
| Predictor |
+-----------+
|
| Expected transactions
v
+-------------------+
| Expected FIFO |
+-------------------+
|
| compare in order
v
+-------------------+ Actual transactions
| In-Order | <--------------------+
| Scoreboard | |
+-------------------+ +-----------+
| DUT |
+-----------+
|
v
Monitor
This architecture is intentionally different from the ID-keyed associative-array approach introduced later for out-of-order checking. Do not add transaction IDs to the comparison algorithm simply because IDs exist in the protocol. If ordering is guaranteed, a queue or FIFO may be all that is required.
Step 1: Determine whether the protocol is truly in order
Before writing the scoreboard, establish the ordering guarantee from the protocol. Ask what event creates an expected transaction and what event creates the corresponding actual transaction.
- Can multiple requests be outstanding?
- Can a later request complete before an earlier request?
- Can responses be retried or duplicated?
- Does the protocol guarantee response ordering?
- Can reset discard transactions already accepted?
- Are there separate channels with independent ordering rules?
For example, suppose a simple FIFO DUT accepts writes and later produces results in the same order. If the predictor produces:
Expected:
E0 = result for request 0
E1 = result for request 1
E2 = result for request 2
and the monitor observes:
Actual:
A0 = result for request 0
A1 = result for request 1
A2 = result for request 2
then the natural checking operation is:
compare(E0, A0)
compare(E1, A1)
compare(E2, A2)
A1 to arrive before A0, positional
comparison is no longer sufficient. That is the problem addressed by
Lesson 25: Out-of-Order Scoreboards.
Step 2: Separate prediction from comparison
Lessons 22 and 23 established an important architectural boundary: the reference model determines expected behavior, while the predictor turns observed input into expected transactions.
The scoreboard should not become another reference model. Its job is to answer: Did the observed DUT behavior match the expected behavior?
Monitor input
|
v
+------------+
| Predictor |
+------------+
|
| expected
v
+----------------+
| Expected FIFO |
+----------------+
|
| Actual
| |
v v
+----------------------+
| In-Order Scoreboard |
+----------------------+
|
v
pass / error
This separation makes the environment easier to debug. A wrong expected value points toward the predictor or reference model. A correct expected value paired with a wrong DUT result points toward the DUT. A shifted comparison may indicate an ordering, reset, or transaction-boundary problem rather than a data-path bug.
Step 3: Buffer the two transaction streams
A practical UVM implementation can use uvm_tlm_analysis_fifo to buffer
expected and actual transactions.
The predictor publishes expected transactions through an analysis port. The DUT monitor publishes actual transactions through another analysis port. Each stream is connected to its own FIFO.
class packet_scoreboard extends uvm_scoreboard;
uvm_tlm_analysis_fifo #(packet) expected_fifo;
uvm_tlm_analysis_fifo #(packet) actual_fifo;
`uvm_component_utils(packet_scoreboard)
function new(string name = "packet_scoreboard",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
expected_fifo = new("expected_fifo", this);
actual_fifo = new("actual_fifo", this);
endfunction
endclass
The FIFO provides buffering; it does not decide whether the transactions are correct. That distinction is important.
- Analysis port: publishes a transaction.
- Analysis FIFO: buffers transactions for later consumption.
- Scoreboard: performs the functional comparison.
Step 4: Connect predictor and monitor outputs
The environment connects the predictor's expected-output analysis port to the expected FIFO and the DUT monitor's analysis port to the actual FIFO.
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
env.predictor.expected_ap.connect(
env.scoreboard.expected_fifo.analysis_export
);
env.agent.monitor.analysis_port.connect(
env.scoreboard.actual_fifo.analysis_export
);
endfunction
The direction is worth reading carefully:
predictor.expected_ap
|
v
expected_fifo.analysis_export
|
v
scoreboard reads expected_fifo
monitor.analysis_port
|
v
actual_fifo.analysis_export
|
v
scoreboard reads actual_fifo
The scoreboard therefore does not need to know how the predictor calculated the expected result or how the monitor reconstructed the actual transaction.
Step 5: Compare the streams in order
Because both streams are guaranteed to preserve transaction order, the scoreboard can retrieve one expected transaction and one actual transaction and compare them.
task run_phase(uvm_phase phase);
packet expected;
packet actual;
forever begin
expected_fifo.get(expected);
actual_fifo.get(actual);
if (!actual.compare(expected)) begin
`uvm_error("SB_MISMATCH",
$sformatf(
"Transaction mismatch:\nEXPECTED:\n%s\nACTUAL:\n%s",
expected.sprint(),
actual.sprint()
)
)
end
else begin
`uvm_info("SB_MATCH",
$sformatf("Transaction matched: id=%0d", actual.id),
UVM_HIGH)
end
end
endtask
Notice what this code does not do. It does not search an associative array, wait for a particular ID, or decide that transaction 17 can match transaction 18. The protocol's ordering guarantee makes positional comparison valid.
Step 6: Understand blocking behavior
The calls to get() are blocking. If the expected FIFO is empty, the
scoreboard waits until an expected transaction arrives. If the actual FIFO is empty,
it waits for actual traffic.
This is normally desirable. A scoreboard should not turn a missing transaction into a tight polling loop merely to avoid blocking.
expected_fifo.get(expected);
actual_fifo.get(actual);
The blocking call suspends the scoreboard process; it does not stop the DUT, monitor, predictor, or entire simulation.
However, the order of the two get() calls matters for debugging. If the
scoreboard waits for an expected transaction first, but the predictor is broken while
actual traffic continues, the scoreboard can remain waiting on the expected side.
This is why Lesson 14's discussion of blocking and nonblocking TLM operations matters here. A blocking call is a control-flow decision, not simply a performance detail.
Step 7: Add explicit transaction identity to diagnostics
An in-order scoreboard does not need an ID to perform the match, but IDs are extremely useful for debugging.
if (!actual.compare(expected)) begin
`uvm_error("SB_MISMATCH",
$sformatf(
"Mismatch at ordered position %0d: expected_id=%0d actual_id=%0d",
compare_count,
expected.id,
actual.id
)
)
end
Comparing IDs in the diagnostic output is especially useful because an ordering failure can appear as a data mismatch.
For example:
Expected: id=10 data=AAAA
Actual: id=11 data=BBBB
This is not necessarily a data-calculation problem. It may indicate that the DUT returned transactions in an unexpected order.
Step 8: Detect missing and unexpected transactions
A comparison loop alone does not completely define scoreboard correctness. You also need to reason about stream imbalance.
Unexpected actual transaction
If the DUT monitor reports an actual transaction but the predictor has not produced a corresponding expected transaction, that may indicate:
- the DUT produced an illegal response,
- the predictor missed an accepted request,
- the monitor reported a transaction that should not count, or
- the two components disagree about the transaction boundary.
Missing actual transaction
If an expected transaction remains in the scoreboard while no actual transaction arrives, the DUT may have failed to respond. But the predictor, monitor, or reset handling may also be responsible.
This is why end-of-test draining and timeout detection become important. Those topics are covered in more detail in Lessons 28 and 29.
Step 9: Handle end-of-test deliberately
A test should not simply stop the simulation while transactions are still buffered. Otherwise the scoreboard may never compare the final transactions.
A useful end-of-test policy is:
- Stop generating new stimulus.
- Allow accepted DUT activity to complete.
- Allow monitors and predictors to publish their final transactions.
- Drain the scoreboard.
- Report any unmatched expected or actual transactions.
- Only then end the test.
The exact implementation depends on the environment's objection and shutdown strategy.
Do not solve this by inserting an arbitrary delay such as #100ns.
A delay is not evidence that all transactions have completed.
A more complete scoreboard example
The following example keeps the implementation intentionally small while adding useful diagnostics and an ordered comparison count.
class packet_scoreboard extends uvm_scoreboard;
uvm_tlm_analysis_fifo #(packet) expected_fifo;
uvm_tlm_analysis_fifo #(packet) actual_fifo;
int unsigned compare_count;
int unsigned match_count;
int unsigned mismatch_count;
`uvm_component_utils(packet_scoreboard)
function new(string name = "packet_scoreboard",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
expected_fifo = new("expected_fifo", this);
actual_fifo = new("actual_fifo", this);
endfunction
task run_phase(uvm_phase phase);
packet expected;
packet actual;
forever begin
expected_fifo.get(expected);
actual_fifo.get(actual);
compare_count++;
if (actual.compare(expected)) begin
match_count++;
`uvm_info("SB_MATCH",
$sformatf(
"Match #%0d: expected_id=%0d actual_id=%0d",
compare_count,
expected.id,
actual.id
),
UVM_HIGH)
end
else begin
mismatch_count++;
`uvm_error("SB_MISMATCH",
$sformatf(
"Mismatch #%0d:\nEXPECTED:\n%s\nACTUAL:\n%s",
compare_count,
expected.sprint(),
actual.sprint()
)
)
end
end
endtask
function void report_phase(uvm_phase phase);
`uvm_info("SB_SUMMARY",
$sformatf(
"Comparisons=%0d Matches=%0d Mismatches=%0d",
compare_count,
match_count,
mismatch_count
),
UVM_LOW)
endfunction
endclass
This is a good starting point, but production scoreboards usually need stronger shutdown/drain handling, transaction-specific comparison policies, and more useful diagnostics. The architecture should grow from actual requirements rather than from copying a large generic scoreboard template.
Comparison policy: compare everything or selected fields?
Calling actual.compare(expected) is convenient when the transaction's
comparison policy is already well defined. It is not always the right policy.
Some fields may be:
- generated by the DUT and therefore not predicted directly,
- timing metadata that should be checked separately,
- don't-care fields for a particular protocol operation, or
- debug metadata that should never affect pass/fail.
A scoreboard may therefore use an explicit comparison function:
function bit compare_packet(packet expected,
packet actual);
if (expected.id != actual.id)
return 0;
if (expected.data != actual.data)
return 0;
if (expected.status != actual.status)
return 0;
return 1;
endfunction
The comparison policy should reflect the verification requirement, not blindly compare every field in the class.
Common failure patterns
1. Comparing before the protocol transaction is complete
If the monitor publishes an incomplete transaction, the scoreboard may correctly report a mismatch against an expected completed transaction. Fix the monitor's transaction boundary rather than weakening the scoreboard.
2. Predictor and monitor disagree about acceptance
The predictor should normally create an expected transaction when the DUT has actually accepted the relevant request. If the predictor reacts to stimulus intent while the monitor reacts to interface acceptance, the streams can become offset.
3. Reset leaves stale transactions in the FIFOs
Reset can invalidate transactions that were previously expected. Decide explicitly whether reset flushes pending transactions, preserves them, or establishes a new checking epoch.
4. Treating an ordering failure as a data failure
If IDs differ between expected and actual transactions, investigate ordering before debugging the reference model's arithmetic.
5. Using try_get() as a workaround
Replacing blocking operations with repeated try_get() calls does not fix a
broken predictor or missing DUT response. It can instead create a polling loop that makes
the environment harder to understand.
6. Building an out-of-order scoreboard by accident
If the protocol is guaranteed in order, do not introduce unnecessary ID-based matching, associative arrays, or complex transaction bookkeeping. Complexity should follow the protocol requirement.
Debugging an in-order mismatch
When the scoreboard reports a mismatch, debug the transaction pipeline in this order:
- Check the actual transaction. Did the monitor reconstruct the interface correctly?
- Check the expected transaction. Did the predictor receive the right input?
- Check the reference model. Is the predicted value correct for that input?
- Check transaction boundaries. Did both sides define the transaction at the same protocol event?
- Check ordering. Do expected and actual IDs still appear in the same sequence?
- Check reset. Was either stream cleared or restarted differently?
- Only then inspect the RTL.
Failure
|
+--> Actual transaction wrong?
| |
| +--> Monitor / interface interpretation
|
+--> Expected transaction wrong?
| |
| +--> Predictor / reference model
|
+--> IDs/order wrong?
| |
| +--> Protocol ordering / transaction boundary
|
+--> Everything above correct?
|
+--> Investigate DUT behavior
This workflow prevents the common mistake of immediately opening the RTL whenever a scoreboard error appears.
When an in-order scoreboard is the wrong architecture
In-order comparison becomes unsafe when the protocol permits responses to arrive in an order different from request acceptance.
For example:
Requests accepted:
REQ0
REQ1
REQ2
Responses:
RESP1
RESP0
RESP2
A positional scoreboard would incorrectly compare RESP1 against the
expectation for REQ0.
The solution is not to make the in-order scoreboard more complicated. The solution is to change the matching architecture.
Try it yourself
Build an in-order scoreboard for a simple request/response protocol.
- Create a predictor that publishes one expected response per accepted request.
- Connect the predictor output to an expected analysis FIFO.
- Connect the DUT monitor to an actual analysis FIFO.
- Compare transactions in order.
- Print the comparison index and transaction ID for every mismatch.
- Inject one incorrect DUT response and confirm that the scoreboard reports it.
Then create a second test in which the expected and actual streams contain the same data but different transaction IDs. Determine whether your scoreboard identifies the ordering problem clearly.
Challenge: prove the ordering assumption
Modify your environment so that several requests can be outstanding simultaneously. Instrument the scoreboard with a monotonically increasing comparison index and report:
comparison_index
expected_id
actual_id
expected_data
actual_data
Run enough randomized traffic to produce a meaningful sequence of transactions. Confirm that:
- the expected stream preserves predictor order,
- the actual stream preserves protocol response order,
- every comparison uses the corresponding ordered pair, and
- a deliberately reordered response is detected as an ordering/data mismatch.
Finally, ask the architectural question: What change would be required if the DUT were allowed to return responses out of order?
Self-check
-
Why can an in-order scoreboard compare transactions positionally?
Because the protocol guarantees that expected and actual transaction streams preserve the same relevant ordering. -
Does an in-order scoreboard require transaction IDs?
No. IDs are useful for diagnostics and correlation, but positional matching can be sufficient when ordering is guaranteed. -
Why use two analysis FIFOs?
To buffer expected and actual streams independently so the scoreboard can consume and compare them without requiring the producer processes to execute at exactly the same time. -
What does a mismatch with different expected and actual IDs suggest?
It may indicate an ordering problem, transaction-boundary problem, reset issue, predictor/monitor disagreement, or an actual DUT ordering violation. -
What should replace positional matching when responses may arrive out of order?
A correlation-based scoreboard, typically matching expected and actual transactions using a protocol-defined key such as an ID.
Key takeaways
- An in-order scoreboard is appropriate when the protocol guarantees a corresponding transaction order.
- Expected behavior belongs in the predictor/reference-model path; the scoreboard performs comparison.
- Analysis FIFOs provide useful buffering between producers and the scoreboard.
- Blocking
get()is usually appropriate for a scoreboard consumer process. - Transaction IDs are valuable diagnostic information even when they are not required for matching.
- Reset, transaction boundaries, and end-of-test draining are part of scoreboard correctness.
- An ordering mismatch can masquerade as a data mismatch, so inspect IDs and sequence order during debug.
- Do not add out-of-order machinery unless the protocol actually requires it.
Where this fits in the learning path
Lesson 21 Scoreboard Design Patterns
|
v
Lesson 22 Reference Models
|
v
Lesson 23 Predictors
|
v
Lesson 24 In-Order Scoreboards
|
+----> Lesson 25 Out-of-Order Scoreboards
|
+----> Lesson 26 Multi-Stream Scoreboards
|
+----> Lesson 27 Error Handling Strategies
|
+----> Lesson 28 Timeout Detection
|
+----> Lesson 29 End-of-Test Scoreboard Draining
|
+----> Lesson 30 Debug-Friendly Diagnostics
Lesson 24 establishes the simplest correct comparison architecture. Lesson 25 then changes one fundamental assumption—response ordering—and shows why that requires a different matching strategy. The later lessons add robustness around errors, timeouts, shutdown, and diagnostics rather than replacing the basic scoreboard concept.