Out-of-Order Scoreboards
Build a correlation-based scoreboard that correctly matches responses when completion order differs from request order.
Learning objectives
- Explain why positional comparison fails for out-of-order protocols.
- Identify a suitable correlation key for matching expected and actual transactions.
- Build an expected-transaction table using a SystemVerilog associative array.
- Match actual responses to expected transactions without depending on arrival order.
- Detect unexpected, duplicate, mismatched, and missing responses.
- Handle outstanding transactions and maximum in-flight depth.
- Understand how reset and end-of-test affect outstanding expectations.
- Recognize when a single correlation key is insufficient and a multi-stream architecture is needed.
Why out-of-order checking is different
Lesson 24 used an in-order scoreboard. It could compare the first expected transaction with the first actual transaction, the second with the second, and so on because the protocol guaranteed that responses completed in the same order.
An out-of-order protocol removes that assumption. Several requests may be outstanding simultaneously, and a later request may complete before an earlier request.
Requests accepted:
REQ0 REQ1 REQ2
| | |
v v v
Possible responses:
RESP1 RESP2 RESP0
A positional scoreboard would perform:
expected(REQ0) <--> RESP1 // wrong pair
expected(REQ1) <--> RESP2 // wrong pair
expected(REQ2) <--> RESP0 // wrong pair
The problem is not the data comparison itself. The problem is that the scoreboard no longer knows which expected transaction belongs to each response.
Step 1: Identify the correlation key
Most out-of-order protocols provide some field that identifies an outstanding operation. This may be a transaction ID, tag, sequence number, request identifier, or another protocol-defined value.
Suppose requests contain:
id
address
data
operation
and responses contain:
id
data
status
The id provides the relationship:
request.id == response.id
The scoreboard can therefore maintain:
ID 10 -> expected response for request 10
ID 11 -> expected response for request 11
ID 12 -> expected response for request 12
When response ID 11 arrives first, the scoreboard looks up ID 11 rather than assuming that the response belongs to the oldest request.
Step 2: Model outstanding expectations
A useful SystemVerilog representation is an associative array indexed by the transaction ID.
typedef int unsigned id_t;
packet expected_by_id[id_t];
The array represents the set of transactions that the predictor expects the DUT to complete but that have not yet been matched by an actual response.
Before requests:
expected_by_id = {}
After request ID 10:
expected_by_id[10] = expected_10
After request ID 11:
expected_by_id[10] = expected_10
expected_by_id[11] = expected_11
After response ID 11:
expected_by_id[10] = expected_10
ID 11 has been matched and removed.
This is fundamentally different from an ordinary FIFO. A FIFO answers: "What is the oldest transaction?" An associative array answers: "What transaction belongs to this key?"
Step 3: Store expected transactions when requests are accepted
The predictor should publish an expected response for an accepted request. The scoreboard receives that expected transaction and stores it under its correlation key.
function void write_expected(packet expected);
if (expected_by_id.exists(expected.id)) begin
`uvm_error("SB_DUP_EXPECTED",
$sformatf(
"Expected transaction already exists for id=%0d",
expected.id
)
)
end
else begin
expected_by_id[expected.id] = expected;
`uvm_info("SB_EXPECTED",
$sformatf(
"Stored expected transaction: id=%0d outstanding=%0d",
expected.id,
expected_by_id.size()
),
UVM_HIGH)
end
endfunction
The duplicate check is important. If the same ID is inserted twice while the first transaction is still outstanding, silently replacing the old expectation can hide a serious correlation or protocol problem.
Step 4: Match responses by ID
When the actual monitor publishes a response, the scoreboard uses its ID to locate the corresponding expected transaction.
function void write_actual(packet actual);
packet expected;
if (!expected_by_id.exists(actual.id)) begin
`uvm_error("SB_UNEXPECTED",
$sformatf(
"No expected transaction exists for response id=%0d",
actual.id
)
)
end
else begin
expected = expected_by_id[actual.id];
if (!actual.compare(expected)) begin
`uvm_error("SB_MISMATCH",
$sformatf(
"Response mismatch for id=%0d\nEXPECTED:\n%s\nACTUAL:\n%s",
actual.id,
expected.sprint(),
actual.sprint()
)
)
end
else begin
`uvm_info("SB_MATCH",
$sformatf(
"Matched response id=%0d",
actual.id
),
UVM_HIGH)
end
expected_by_id.delete(actual.id);
end
endfunction
Notice the sequence:
- Check whether the ID exists.
- Retrieve the expected transaction.
- Compare expected and actual.
- Remove the expectation after the response has been processed.
The deletion is what changes the transaction from outstanding to completed.
Step 5: Understand duplicate responses
Suppose ID 7 has already been matched:
expected_by_id.delete(7);
If another response with ID 7 arrives, the lookup fails:
if (!expected_by_id.exists(7))
// unexpected response
This allows the scoreboard to identify duplicate or otherwise unexpected responses.
A useful diagnostic distinguishes the possible situations:
- Expected ID exists: perform the comparison.
- Expected ID does not exist: response is unexpected, duplicate, or incorrectly correlated.
- Expected and actual IDs match but fields differ: transaction mismatch.
Step 6: Use separate analysis paths for expected and actual transactions
A practical scoreboard can receive expected transactions from the predictor and actual transactions from the monitor using two analysis implementations.
class packet_scoreboard extends uvm_scoreboard;
uvm_analysis_imp_expected #(packet, packet_scoreboard)
expected_imp;
uvm_analysis_imp_actual #(packet, packet_scoreboard)
actual_imp;
packet expected_by_id[int unsigned];
`uvm_component_utils(packet_scoreboard)
function new(string name = "packet_scoreboard",
uvm_component parent = null);
super.new(name, parent);
expected_imp = new("expected_imp", this);
actual_imp = new("actual_imp", this);
endfunction
function void write_expected(packet expected);
// Store expected transaction.
endfunction
function void write_actual(packet actual);
// Match actual transaction.
endfunction
endclass
The exact analysis implementation declarations depend on how the UVM environment defines its analysis implementation types. A common reusable pattern is to create separate analysis implementation classes or use the UVM analysis implementation macros for different callback names.
The architectural point is more important than the macro spelling: expected traffic and actual traffic enter the scoreboard through distinct paths.
Step 7: A clean FIFO-based alternative
If the scoreboard needs more control over synchronization or wants to perform checking in a dedicated process, the two streams can first enter analysis FIFOs.
uvm_tlm_analysis_fifo #(packet) expected_fifo;
uvm_tlm_analysis_fifo #(packet) actual_fifo;
However, the comparison cannot simply call:
expected_fifo.get(expected);
actual_fifo.get(actual);
That would reintroduce positional matching and therefore defeat the purpose of the out-of-order architecture.
Instead, the scoreboard must associate expected transactions by ID and process actual responses according to their IDs.
Expected:
ID 10 -> E10
ID 11 -> E11
ID 12 -> E12
Actual arrival:
A11 -> lookup 11 -> compare E11
A12 -> lookup 12 -> compare E12
A10 -> lookup 10 -> compare E10
Step 8: Protect against ID reuse
Many protocols allow IDs to be reused, but only after the previous transaction using that ID has completed.
Therefore, the scoreboard should treat an already-present ID as significant.
if (expected_by_id.exists(req.id)) begin
`uvm_error("SB_ID_REUSE",
$sformatf(
"ID %0d reused while previous transaction is outstanding",
req.id
)
)
end
Whether this is actually illegal depends on the protocol. The scoreboard should enforce the protocol's real ID reuse rules rather than assuming that every ID must be globally unique for the entire simulation.
Step 9: Track outstanding depth
The number of entries in the expected table represents the number of outstanding transactions known to the scoreboard.
int unsigned outstanding;
outstanding = expected_by_id.size();
This is useful for both verification and performance checking.
If the protocol allows at most 16 outstanding operations, for example:
if (expected_by_id.size() > 16) begin
`uvm_error("SB_DEPTH",
"Outstanding transaction count exceeded protocol limit")
end
Be careful about where this check belongs. If the DUT's maximum outstanding depth is a protocol requirement, it may also be appropriate as a dedicated protocol assertion or monitor check. The scoreboard's outstanding count is valuable diagnostic information, but it should not become a replacement for every other verification mechanism.
Step 10: Handle missing responses
An associative array makes missing responses visible because an expected transaction remains in the table.
expected_by_id[10] = expected_10;
expected_by_id[11] = expected_11;
// Only response 11 arrives
expected_by_id:
ID 10 -> still outstanding
At this point, the scoreboard knows that ID 10 has not been completed. It does not automatically know whether ID 10 is late, lost, or still legitimately processing.
That distinction requires timing or timeout policy. Lesson 28 develops timeout detection in detail.
Step 11: Reset outstanding transactions correctly
Reset is especially important for out-of-order scoreboards because outstanding state may exist when reset occurs.
Consider:
ID 10 -> expected response
ID 11 -> expected response
ID 12 -> expected response
RESET
DUT restarts
If reset invalidates those operations, retaining the entries would cause later responses to be compared against stale expectations.
A reset-aware environment therefore needs an explicit policy, such as:
- flush all outstanding expectations,
- wait for a defined reset-completion point,
- restart correlation state for the new epoch, or
- preserve specific transactions if the protocol explicitly requires it.
Do not blindly call expected_by_id.delete() on every reset without first
confirming the protocol semantics.
A compact correlation-based scoreboard
The core algorithm can be represented independently of the surrounding UVM plumbing:
class packet_scoreboard extends uvm_component;
packet expected_by_id[int unsigned];
function void add_expected(packet expected);
if (expected_by_id.exists(expected.id)) begin
`uvm_error("SB_EXPECTED",
$sformatf(
"Duplicate outstanding ID %0d",
expected.id
)
)
return;
end
expected_by_id[expected.id] = expected;
endfunction
function void check_actual(packet actual);
packet expected;
if (!expected_by_id.exists(actual.id)) begin
`uvm_error("SB_ACTUAL",
$sformatf(
"Unexpected response ID %0d",
actual.id
)
)
return;
end
expected = expected_by_id[actual.id];
if (!actual.compare(expected)) begin
`uvm_error("SB_MISMATCH",
$sformatf(
"Mismatch for ID %0d\nEXPECTED:\n%s\nACTUAL:\n%s",
actual.id,
expected.sprint(),
actual.sprint()
)
)
end
else begin
`uvm_info("SB_MATCH",
$sformatf(
"Matched ID %0d; outstanding=%0d",
actual.id,
expected_by_id.size() - 1
),
UVM_HIGH)
end
expected_by_id.delete(actual.id);
endfunction
endclass
This code captures the essential architecture:
expected transaction
|
v
store by ID
|
v
+-----------------------+
| Outstanding expected |
| transactions |
| |
| 10 -> E10 |
| 11 -> E11 |
| 12 -> E12 |
+-----------------------+
^
|
actual response ID
|
v
lookup -> compare -> delete Failure classification
A production scoreboard should distinguish different failure classes instead of reporting every problem as "mismatch."
| Condition | Likely meaning | Useful diagnostic |
|---|---|---|
| Expected ID already exists | ID reuse or duplicate prediction | Report ID and outstanding depth |
| Actual ID does not exist | Unexpected or duplicate response | Report ID and recent transaction context |
| ID exists but fields differ | Functional mismatch | Show expected and actual contents |
| Expected entry remains at shutdown | Missing or incomplete response | Report outstanding IDs |
| Many IDs mismatch after one event | Possible ordering, reset, monitor, or predictor issue | Inspect correlation history and transaction boundaries |
Common mistakes
1. Matching by arrival order
The most serious mistake is using FIFO-to-FIFO positional comparison for a protocol that permits out-of-order completion.
2. Deleting the expectation before comparing
Delete the entry only after retrieving the expected transaction and performing the required comparison. Otherwise a debug failure may lose the context needed to explain it.
3. Silently replacing duplicate IDs
An assignment such as:
expected_by_id[id] = expected;
can overwrite an existing expectation. If ID reuse is not allowed while a transaction is outstanding, detect that condition first.
4. Treating an absent ID as proof that the DUT is wrong
An unexpected response can come from the DUT, but it can also result from a predictor that missed a request or a monitor that reconstructed the wrong ID.
5. Assuming an outstanding entry means the DUT is stuck
An outstanding transaction may simply be slow. Missing-response detection requires a timeout or completion policy.
6. Ignoring reset
Stale expectations surviving a reset can create misleading mismatches long after the original problem occurred.
Debugging an out-of-order mismatch
When a response does not match, use the correlation key to trace the entire transaction path.
Request accepted
|
v
Predictor
|
| expected ID = 37
v
Scoreboard stores E37
|
| DUT processing
v
Monitor observes response
|
| actual ID = 37
v
Scoreboard lookup
|
+---- ID missing? ----> correlation/predictor/monitor problem
|
+---- ID found
|
+---- fields match ----> PASS
|
+---- fields differ --> model/DUT/monitor problem
For a mismatch, log at least:
- transaction ID,
- expected transaction contents,
- actual transaction contents,
- number of outstanding transactions,
- request/response ordering information when available, and
- reset state or transaction epoch when relevant.
The key diagnostic question is: Did the scoreboard fail to find the correct expectation, or did it find the correct expectation and discover incorrect DUT behavior?
Out-of-order does not mean unrestricted
An out-of-order protocol still has rules. It may allow responses to reorder across requests while preserving order within a particular channel, ID, or dependency group.
For example:
Allowed:
REQ0(ID=1)
REQ1(ID=2)
REQ2(ID=3)
RESP2
RESP0
RESP1
does not necessarily mean that every permutation is legal. A protocol might require all transactions sharing an ID to remain ordered.
Therefore, the scoreboard has two separate responsibilities:
- correlate each actual response with its expected transaction, and
- enforce any ordering or dependency rules that are part of the verification requirement.
Do not assume that "out-of-order" means "no ordering constraints."
When one ID is not enough
Consider an environment with two independent channels:
Channel A:
ID 5
Channel B:
ID 5
If the scoreboard stores only:
expected_by_id[5]
the two transactions collide.
The correlation key may instead need to contain both channel and ID:
{channel_id, transaction_id}
or use separate tracking structures for independent streams.
Try it yourself
Build an out-of-order scoreboard for a request/response protocol with transaction IDs.
- Generate five requests with unique IDs.
- Create expected responses for all five requests.
- Allow responses to arrive in a different order.
- Store expected transactions in an associative array indexed by ID.
- Match each actual response using its ID.
- Delete the expectation after successful processing.
- Inject an incorrect response for one valid ID.
- Inject a response using an ID that has no outstanding expectation.
- Send a duplicate response for an already-completed ID.
Your scoreboard should classify these failures differently rather than reporting all of them as generic mismatches.
Challenge: bounded outstanding transactions
Extend the scoreboard so that it tracks the maximum number of outstanding transactions observed during the test.
current_outstanding
maximum_outstanding
completed_count
mismatch_count
unexpected_count
Then create a test that deliberately reaches the protocol's maximum allowed outstanding depth.
As an additional challenge, reuse an ID while the original transaction is still outstanding and verify that the scoreboard detects the collision.
Self-check
-
Why does positional comparison fail for out-of-order responses?
Because the first actual response is not necessarily the response corresponding to the first expected transaction. -
What is the primary job of the correlation key?
It identifies which expected transaction belongs to an actual response. -
Why is an associative array useful?
It allows the scoreboard to retrieve an expected transaction directly by its correlation key rather than consuming transactions in arrival order. -
What should happen after a response is matched?
The corresponding outstanding expectation should be removed so that the same ID cannot accidentally match again. -
What does an actual response with no matching expectation mean?
It is unexpected from the scoreboard's current state. Possible causes include a DUT error, duplicate response, predictor error, monitor error, or reset/correlation problem. -
Does an outstanding expectation automatically mean the DUT has timed out?
No. The scoreboard knows that completion has not occurred, but timeout requires a defined time or cycle limit. -
What if two independent streams can use the same ID?
The correlation key must include enough context to distinguish the streams, such as a channel identifier plus transaction ID.
Key takeaways
- Out-of-order scoreboards match transactions by correlation key rather than arrival position.
- The expected transaction table represents currently outstanding operations.
- A SystemVerilog associative array is a natural implementation for key-based lookup.
- Always detect duplicate expected IDs before silently overwriting an outstanding expectation.
- Unexpected responses, mismatches, and missing responses are different failure classes.
- An outstanding transaction is not automatically a timeout; timeout requires a defined completion deadline.
- Reset must explicitly define what happens to outstanding expectations.
- Out-of-order protocols can still have ordering constraints within channels or dependency groups.
- If one ID is not globally unique, the correlation key needs additional context.
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
|
v
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 established positional comparison under an ordering guarantee. Lesson 25 removes that guarantee and introduces correlation-based matching. Lesson 26 will extend correlation to multiple independent streams, while Lessons 27–30 make scoreboard behavior more robust under errors, timeouts, shutdown, and debugging.