In-Order Checking
Learn how to match expected and actual transactions in the same order using a simple UVM scoreboard and transaction queues.
Learning objectives
- Explain what in-order checking means and when it is appropriate.
- Use queues to store expected transactions until the DUT produces results.
- Compare expected and actual transactions in arrival order.
- Detect missing, unexpected, and mismatched transactions.
- Understand when simple in-order checking is not sufficient.
Step 1: Understand the concept
In-order checking means that expected transactions and actual transactions are matched in the same sequence in which they are produced.
For example, suppose the reference model predicts:
Expected: A B C D
and the DUT produces:
Actual: A B C D
The scoreboard can compare the first expected transaction with the first actual transaction, the second with the second, and so on.
This works well when the DUT preserves transaction ordering. Simple pipelines, many FIFO-style designs, and deterministic request/response paths are common examples.
Step 2: Why do we need a queue?
The reference model and DUT do not necessarily produce their results at exactly the same simulation time.
The reference model may calculate an expected result before the DUT response arrives. Instead of losing that result, the scoreboard stores it in a queue.
Reference Model
|
v
Expected Queue
+---+---+---+---+
| A | B | C | D |
+---+---+---+---+
^
|
Scoreboard
DUT ---> Monitor ---> Actual Transaction
When an actual transaction arrives, the scoreboard removes the oldest expected transaction and compares the two.
SystemVerilog queues make this natural:
expected_queue.push_back(expected);
expected = expected_queue.pop_front();
push_back() adds a new expected transaction to the end of the queue. pop_front() removes the oldest transaction.
Step 3: Build a basic in-order scoreboard
A simple scoreboard can receive expected transactions from the reference model and actual transactions from the DUT monitor.
class bus_scoreboard extends uvm_scoreboard;
`uvm_component_utils(bus_scoreboard)
uvm_analysis_imp #(bus_transaction, bus_scoreboard)
expected_imp;
uvm_analysis_imp #(bus_transaction, bus_scoreboard)
actual_imp;
bus_transaction expected_queue[$];
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
expected_imp = new("expected_imp", this);
actual_imp = new("actual_imp", this);
endfunction
function void write_expected(bus_transaction t);
bus_transaction expected;
expected = bus_transaction::type_id::create("expected");
expected.copy(t);
expected_queue.push_back(expected);
`uvm_info("SB",
"Expected transaction queued",
UVM_MEDIUM)
endfunction
function void write_actual(bus_transaction t);
bus_transaction expected;
if (expected_queue.size() == 0) begin
`uvm_error("SB",
"Actual transaction arrived with no expected transaction")
return;
end
expected = expected_queue.pop_front();
if (expected.compare(t)) begin
`uvm_info("SB",
"In-order transaction matched",
UVM_MEDIUM)
end
else begin
`uvm_error(
"SB",
$sformatf(
"Mismatch!\nExpected:\n%s\nActual:\n%s",
expected.sprint(),
t.sprint()
)
)
end
endfunction
endclass
The important algorithm is small:
- Receive an expected transaction.
- Store it at the back of the expected queue.
- Receive an actual transaction.
- Check that an expected transaction exists.
- Remove the oldest expected transaction.
- Compare expected against actual.
- Report a match or mismatch.
Step 4: Connect expected and actual paths
The reference model produces expected transactions. The monitor produces actual transactions. Both paths eventually reach the scoreboard.
+------------------+
| Reference Model |
+--------+---------+
|
Expected
|
v
+------------------+
| |
Monitor ---> Actual ---> | Scoreboard |
| |
+------------------+
The connections are made during connect_phase().
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
reference_model.expected_port.connect(
scoreboard.expected_imp
);
agent.monitor.analysis_port.connect(
scoreboard.actual_imp
);
endfunction
This keeps the responsibilities separated:
| Component | Responsibility |
|---|---|
| Monitor | Observe the DUT and reconstruct actual transactions. |
| Reference model | Predict expected behavior. |
| Scoreboard | Match and compare expected and actual transactions. |
Step 5: Handle the three important cases
A good in-order scoreboard should recognize more than a simple mismatch.
Case 1: Expected and actual match
Expected: A B C
Actual: A B C
Result: PASS
Each actual transaction matches the oldest expected transaction.
Case 2: Actual transaction has no expected transaction
Expected: A B
Actual: A B C
Result: unexpected actual transaction
The DUT or monitor produced something for which the reference model did not produce an expectation.
Case 3: Expected transaction remains at the end
Expected: A B C
Actual: A B
Result: missing actual transaction
The DUT may have failed to produce a response, or the test may have ended before the final response arrived.
These cases are different failures and should be reported differently.
Step 6: Check for leftover transactions
A scoreboard can inspect the expected queue during check_phase(). This is useful because the test may finish even though some expected transactions were never observed.
function void check_phase(uvm_phase phase);
super.check_phase(phase);
if (expected_queue.size() != 0) begin
`uvm_error(
"SB",
$sformatf(
"%0d expected transactions were never observed",
expected_queue.size()
)
)
end
else begin
`uvm_info(
"SB",
"All expected transactions were observed",
UVM_LOW
)
end
endfunction
This creates an important verification habit: do not only check transactions that arrived; also check for transactions that should have arrived but did not.
Step 7: Debug an in-order mismatch
Suppose the scoreboard reports:
Expected: addr=10 data=AA
Actual: addr=10 data=55
Do not immediately conclude that the DUT is broken. Trace the transaction through the complete path:
Sequence
|
v
Driver
|
v
DUT
|
v
Monitor
|
v
Actual transaction
|
+--------------------+
|
Reference Model ------> Scoreboard
^
|
Expected transaction
Ask these questions in order:
- Did the sequence generate the intended input?
- Did the driver put the correct information on the interface?
- Did the monitor sample the correct protocol transfer?
- Did the reference model calculate the expected value correctly?
- Did the scoreboard pair the correct expected and actual transactions?
- Only then: is the DUT behavior incorrect?
When in-order checking is appropriate
In-order checking is a strong starting point when the DUT preserves ordering.
- FIFO-like designs
- Simple request/response interfaces
- Deterministic pipelines
- Single-stream data processing
- Designs where response order is guaranteed by the specification
It becomes insufficient when responses can legitimately arrive in a different order.
Requests: A B C
Responses: B C A
A simple FIFO comparison would incorrectly compare A with B. More advanced environments can match transactions using IDs, tags, addresses, or other protocol information.
Try it yourself
Build a small in-order scoreboard for five transactions.
- Generate five expected transactions from a reference model.
- Store them in an expected queue.
- Send five matching actual transactions from the monitor.
- Verify that all five comparisons pass.
- Change the third actual transaction and verify that the scoreboard reports a mismatch.
- Remove the fifth actual transaction and verify that
check_phase()detects the leftover expectation. - Add an extra actual transaction and verify that the scoreboard reports an unexpected transaction.
Challenge: Print the queue size whenever an expected or actual transaction arrives. Use the output to understand how the scoreboard tracks outstanding predictions.
Key takeaways
- In-order checking matches expected and actual transactions in arrival order.
- An expected transaction queue is a simple way to handle timing differences between prediction and observation.
- The scoreboard should detect mismatches, unexpected actual transactions, and missing actual transactions.
check_phase()is useful for detecting expected transactions that were never observed.- In-order checking is appropriate only when the DUT's specification guarantees ordering.
- For out-of-order protocols, later verification environments can use IDs, tags, or other matching mechanisms.
Core mental model
Predict → Queue → Observe → Match → Compare
Expected: A → B → C → D
Actual: A → B → C → D
Oldest expected ↔ oldest actual
If they match:
continue
If they differ:
report mismatch
If actual arrives with no expected:
report unexpected transaction
If expected remains at the end:
report missing transaction
Reference model predicts. Monitor observes. Scoreboard matches and compares.
What comes next?
In-order checking works well when transactions naturally line up. The next lessons move deeper into UVM reporting and test completion, where verification results must be communicated clearly and the test must know when it is truly finished.