Transaction Correlation
Learn how to associate requests with their corresponding responses when transactions can be delayed, reordered, or processed concurrently.
Learning objectives
- Explain why transaction correlation is required when multiple transactions are outstanding.
- Distinguish correlation by transaction ID from correlation by arrival order.
- Design a scoreboard that stores expected transactions until the corresponding response arrives.
- Implement request/response correlation using a SystemVerilog associative array.
- Detect missing, duplicated, unexpected, and mismatched responses.
- Understand how correlation prepares you for out-of-order scoreboards.
Step 1: Understand the problem
A simple scoreboard can compare transactions in arrival order: the first expected transaction is compared with the first observed transaction, the second with the second, and so on.
That approach breaks when the DUT allows multiple requests to be outstanding. A response may return later, or responses may return in a different order than the requests were issued.
Request order:
ID 10
ID 11
ID 12
Response order:
ID 11
ID 10
ID 12
If the scoreboard compares only by position, it incorrectly compares response ID 11 against request ID 10. The DUT may be completely correct while the verification environment reports a false failure.
Transaction correlation solves this problem by giving the verification environment a reliable way to answer: "Which request does this response belong to?"
Step 2: Choose a correlation key
The correlation key is the information that uniquely connects a request to its response. Common choices include:
- Transaction ID: an ID field carried by the protocol.
- Sequence number: a verification-generated identifier.
- Address: useful only when the protocol guarantees sufficient uniqueness.
- Tag or channel ID: common in multi-channel interfaces.
- Composite key: a combination such as channel plus transaction ID.
A good correlation key should be stable, available on both sides, and sufficiently unique to distinguish outstanding transactions.
Step 3: Model requests and responses
Consider a simple protocol in which every request contains an ID and the DUT returns the same ID in its response.
class packet extends uvm_sequence_item;
rand bit [7:0] id;
rand bit [31:0] addr;
rand bit [31:0] data;
`uvm_object_utils(packet)
function new(string name = "packet");
super.new(name);
endfunction
endclass
class response extends uvm_sequence_item;
bit [7:0] id;
bit [31:0] data;
`uvm_object_utils(response)
function new(string name = "response");
super.new(name);
endfunction
endclass
The important design decision is not the class syntax. It is the presence of
the id field that allows the scoreboard to establish the relationship
between the two transactions.
Step 4: Store outstanding transactions
The scoreboard cannot immediately discard an expected transaction after receiving a request. It must keep the prediction until the corresponding response arrives.
An associative array is a natural SystemVerilog data structure for this purpose:
packet expected_by_id [bit [7:0]];
The transaction ID becomes the lookup key.
expected_by_id[req.id] = req;
Conceptually, the scoreboard now contains:
ID Expected transaction
---
10 request for address A
11 request for address B
12 request for address C
When response ID 11 arrives, the scoreboard performs a direct lookup rather than assuming that ID 10 must arrive first.
Step 5: Implement correlation in the scoreboard
A practical scoreboard can receive requests and responses through separate analysis paths. The request side creates the expected entry; the response side consumes and checks that entry.
class correlation_scoreboard extends uvm_scoreboard;
`uvm_component_utils(correlation_scoreboard)
uvm_tlm_analysis_fifo #(packet) request_fifo;
uvm_tlm_analysis_fifo #(response) response_fifo;
packet expected_by_id [bit [7:0]];
function new(string name = "correlation_scoreboard",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
request_fifo = new("request_fifo", this);
response_fifo = new("response_fifo", this);
endfunction
task run_phase(uvm_phase phase);
fork
collect_requests();
check_responses();
join
endtask
task collect_requests();
packet req;
forever begin
request_fifo.get(req);
if (expected_by_id.exists(req.id)) begin
`uvm_error("CORR",
$sformatf("Duplicate outstanding request ID %0d", req.id))
end
else begin
expected_by_id[req.id] = req;
`uvm_info("CORR",
$sformatf("Stored request ID %0d", req.id),
UVM_MEDIUM)
end
end
endtask
task check_responses();
response rsp;
packet req;
forever begin
response_fifo.get(rsp);
if (!expected_by_id.exists(rsp.id)) begin
`uvm_error("CORR",
$sformatf("Unexpected response ID %0d", rsp.id))
continue;
end
req = expected_by_id[rsp.id];
if (rsp.data !== req.data) begin
`uvm_error("CORR",
$sformatf(
"Data mismatch for ID %0d: expected=%08h actual=%08h",
rsp.id,
req.data,
rsp.data))
end
else begin
`uvm_info("CORR",
$sformatf("Matched request/response ID %0d", rsp.id),
UVM_MEDIUM)
end
expected_by_id.delete(rsp.id);
end
endtask
endclass
Notice the key operation:
req = expected_by_id[rsp.id];
The response does not need to arrive in request order. Its ID determines which expected transaction must be checked.
Step 6: Connect the analysis FIFOs
The monitor publishes transactions through analysis ports. The scoreboard uses analysis FIFOs to decouple transaction arrival from the checking threads.
class my_env extends uvm_env;
my_monitor monitor;
correlation_scoreboard sb;
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
monitor.request_ap.connect(sb.request_fifo.analysis_export);
monitor.response_ap.connect(sb.response_fifo.analysis_export);
endfunction
endclass
This creates two independent data paths:
Request monitor
|
v
request_ap
|
v
request_fifo
|
v
correlation scoreboard
^
|
response_fifo
^
|
response_ap
^
|
Response monitor
The important architectural principle is that the monitor remains responsible for observing the protocol, while the scoreboard owns the correlation policy.
Step 7: Handle the failure modes
Correlation logic is not complete if it checks only successful matches. A production-quality scoreboard should explicitly detect abnormal cases.
1. Unexpected response
if (!expected_by_id.exists(rsp.id))
`uvm_error("CORR", "Unexpected response")
This means a response arrived for which no outstanding request exists.
2. Duplicate request ID
If the protocol does not permit two outstanding requests with the same ID, a duplicate ID is a scoreboard error.
3. Data mismatch
The ID matched, but the response contents did not match the expected result. This is a functional DUT failure rather than a correlation failure.
4. Missing response
A request remains in the associative array after the test should have completed. This indicates that the DUT never produced the expected response, or that the verification environment failed to observe it.
5. Reused ID
Some protocols allow IDs to be reused, but only after the previous transaction has completed. The scoreboard must understand that protocol rule rather than assuming every ID is globally unique for the entire simulation.
Step 8: Correlation versus ordering
These concepts are related but they are not the same.
| Concept | Question being answered |
|---|---|
| Ordering | Which transaction should be checked first? |
| Correlation | Which request belongs to this response? |
| Prediction | What response should the DUT produce? |
| Scoreboarding | Does the observed behavior satisfy the expected behavior? |
In an in-order protocol, ordering can be sufficient for correlation. In an out-of-order protocol, a transaction ID or another explicit key is usually required.
Step 9: Build a deterministic experiment
Before introducing random traffic, deliberately create a response-ordering scenario.
Requests:
ID 1 -> data A
ID 2 -> data B
ID 3 -> data C
Responses:
ID 2 -> data B
ID 3 -> data C
ID 1 -> data A
A correct correlation scoreboard should report three successful matches and zero mismatches.
Now deliberately inject an error:
Response:
ID 2 -> data X
The scoreboard should identify ID 2 as the failing transaction. This is much more useful than reporting a generic "transaction mismatch."
Step 10: Improve diagnostics
Correlation bugs can become difficult to debug when transactions are large. Include enough information in diagnostics to identify both sides of the comparison.
`uvm_error("CORR",
$sformatf(
"Mismatch: ID=%0d expected=%08h actual=%08h",
rsp.id,
req.data,
rsp.data))
In a larger environment, consider adding timestamps, channel IDs, sequence numbers, addresses, and transaction names to the diagnostic message.
Common mistakes
- Comparing by FIFO arrival order: This silently assumes an ordering guarantee that may not exist.
- Using a non-unique key: Two outstanding transactions can overwrite one another.
- Deleting the expected transaction too early: The scoreboard then cannot check a delayed response.
- Ignoring missing responses: A test can finish without detecting that an expected transaction was never returned.
- Reporting only "mismatch": Without the correlation ID and expected/actual values, debugging becomes unnecessarily slow.
- Putting correlation policy in the monitor: The monitor should observe and publish protocol transactions; the scoreboard should determine how those transactions are matched and checked.
Connection to the next lessons
Transaction correlation is the foundation for the next level of scoreboard architecture.
- Lesson 18 — Out-of-Order Responses: extend correlation to protocols where responses intentionally return in arbitrary order.
- Lesson 19 — Latency-Aware Checking: correlate transactions while also reasoning about timing and response latency.
- Lesson 21 — Scoreboard Design Patterns: turn the correlation mechanism into a reusable checking architecture.
- Lesson 25 — Out-of-Order Scoreboards: build a complete scoreboard around keyed matching and outstanding transactions.
Try it yourself
Build a correlation scoreboard for a simple request/response protocol. Each request has an 8-bit ID and expected data.
- Send requests with IDs 10, 11, and 12.
- Store each expected transaction in an associative array.
- Return responses in the order 11, 10, 12.
- Verify that all three responses match the correct request.
- Send a response with an unknown ID and verify that the scoreboard reports an error.
- Send a response with a valid ID but incorrect data and identify the mismatch.
- End the test with one request still outstanding and detect the missing response.
Challenge:
Modify the design so that the correlation key contains both a
channel_id and a transaction_id. Explain why using
only transaction_id would be unsafe if IDs are reused independently
on different channels.
Self-check
- Why is FIFO order insufficient for an out-of-order response protocol?
- What makes a good correlation key?
- Why is an associative array useful for outstanding transactions?
- What should happen when a response ID does not exist in the expected table?
- How can a scoreboard detect a missing response?
Key takeaways
- Correlation answers the question: which request belongs to this response?
- Use an explicit protocol ID, tag, sequence number, or composite key when arrival order is not reliable.
- Store outstanding expected transactions until their corresponding responses arrive.
- Always check for unexpected responses, duplicate IDs, mismatches, and missing responses.
- Keep observation in monitors and correlation/checking policy in scoreboards.
- Transaction correlation is a fundamental building block for out-of-order and latency-aware scoreboards.