Transaction Debugging
Learn how to inspect, print, trace, and debug UVM transactions from sequence generation through the driver, DUT, monitor, and scoreboard.
Learning objectives
- Explain why transaction visibility is essential for UVM debugging.
- Print and inspect sequence-item fields during simulation.
- Use
print(),print_object(), and UVM reporting to inspect transactions. - Understand the difference between a requested transaction and an observed transaction.
- Trace a transaction through the sequence, sequencer, driver, DUT, monitor, and scoreboard.
- Identify common transaction corruption and timing problems.
- Use a systematic debugging workflow instead of changing multiple components at once.
Step 1: Why transaction debugging matters
A UVM testbench can contain many components, threads, transactions, and protocol events. When a test fails, the final error message is often not where the original problem occurred.
For example, a scoreboard might report:
Expected data = 0x55
Actual data = 0xAA
The scoreboard may be completely correct. The real problem could be that:
- the sequence generated the wrong address,
- the driver interpreted the transaction incorrectly,
- the DUT received incorrect pin-level activity,
- the monitor sampled the wrong cycle, or
- the monitor constructed the wrong transaction.
This is why transaction-level visibility is so important.
Step 2: Know the transaction path
Before debugging, know where a transaction is supposed to travel.
Test
|
v
Sequence
|
| requested transaction
v
Sequencer
|
v
Driver
|
| pin-level activity
v
DUT
|
| interface activity
v
Monitor
|
| observed transaction
v
Scoreboard / Coverage
At each boundary, ask:
- What transaction should exist here?
- What values should its fields contain?
- What values actually exist?
- Where did the values first become different?
This turns a large debugging problem into a sequence of smaller questions.
Step 3: Print a transaction
UVM objects provide built-in printing support. If req is a sequence item,
you can print it:
req.print();
This is useful when you want to inspect the complete object using UVM's object printer.
For example:
bus_transaction req;
req = bus_transaction::type_id::create("req");
req.write = 1;
req.addr = 32'h1000;
req.data = 32'h55;
req.print();
Transaction printing is especially useful when a randomized transaction does not contain the values you expected.
Step 4: Print an object with UVM reporting
You can also use UVM reporting to place transaction information into the simulation log:
`uvm_info("TXN",
$sformatf("Generated transaction:\n%s", req.sprint()),
UVM_MEDIUM)
The sprint() method returns a formatted string representation of
the object instead of immediately printing it.
This is useful when you want the transaction contents to appear together with a timestamp, component name, and UVM message ID.
print() displays the object directly.
sprint() returns the formatted representation so you can include
it in another message.
Step 5: Create readable transaction messages
During early debugging, a compact message can be easier to read than a large object dump.
`uvm_info("DRIVER",
$sformatf("Driving %s addr=0x%08h data=0x%08h",
req.write ? "WRITE" : "READ",
req.addr,
req.data),
UVM_MEDIUM)
A useful debug message should answer:
- Which component produced the message?
- What transaction is being processed?
- What important fields does it contain?
- Is this a requested or observed transaction?
Avoid logging every signal transition. Transaction-level messages are usually much easier to understand than a huge stream of individual signal values.
Step 6: Debug the sequence first
The first place to inspect a stimulus transaction is often the sequence.
task body();
bus_transaction req;
req = bus_transaction::type_id::create("req");
start_item(req);
if (!req.randomize()) begin
`uvm_error("RANDFAIL", "Transaction randomization failed")
end
`uvm_info("SEQ",
$sformatf("Generated:\n%s", req.sprint()),
UVM_MEDIUM)
finish_item(req);
endtask
If the sequence creates:
WRITE addr=0x1000 data=0x55
but the driver later sees:
WRITE addr=0x1004 data=0xAA
the problem occurred somewhere between sequence generation and driver consumption.
Do not start by debugging the DUT. First establish whether the intended transaction was generated correctly.
Step 7: Debug the driver
The driver receives the sequence item and converts it into pin-level activity.
task run_phase(uvm_phase phase);
bus_transaction req;
forever begin
seq_item_port.get_next_item(req);
`uvm_info("DRIVER",
$sformatf("Received:\n%s", req.sprint()),
UVM_MEDIUM)
drive_transaction(req);
seq_item_port.item_done();
end
endtask
If the sequence and driver print different transaction contents, investigate the transaction handoff and object handling before investigating DUT behavior.
If both show the same transaction, the next question becomes: Did the driver translate the fields into the correct signals?
Step 8: Debug the monitor
The monitor has the opposite responsibility. It observes interface activity and reconstructs a transaction.
task run_phase(uvm_phase phase);
bus_transaction observed;
forever begin
@(posedge vif.clk);
if (vif.valid && vif.ready) begin
observed = bus_transaction::type_id::create("observed");
observed.write = vif.write;
observed.addr = vif.addr;
observed.data = vif.wdata;
`uvm_info("MONITOR",
$sformatf("Observed:\n%s", observed.sprint()),
UVM_MEDIUM)
ap.write(observed);
end
end
endtask
If the driver says it drove address 0x1000 but the monitor reports
0x1004, the monitor may be sampling the wrong cycle or reconstructing
the transaction incorrectly.
Step 9: Compare requested and observed transactions
A powerful debugging technique is to compare the transaction generated by the sequence with the transaction reconstructed by the monitor.
Requested:
WRITE
addr = 0x1000
data = 0x55
Observed:
WRITE
addr = 0x1000
data = 0x55
If they match, the transaction survived the stimulus path correctly.
If they do not:
Requested:
WRITE
addr = 0x1000
data = 0x55
Observed:
WRITE
addr = 0x1004
data = 0x55
you have strong evidence that the problem is in the driver, DUT interface, or monitor rather than in the original sequence generation.
Step 10: Understand object lifetime
Transaction debugging becomes more subtle when objects are reused.
Consider a monitor that repeatedly modifies the same object:
bus_transaction observed;
observed = bus_transaction::type_id::create("observed");
forever begin
sample_interface(observed);
ap.write(observed);
end
Reusing the same object can cause problems if another component stores the object and expects it to remain unchanged.
A common safer pattern is to create a fresh transaction for each observed operation:
forever begin
observed = bus_transaction::type_id::create("observed");
sample_interface(observed);
ap.write(observed);
end
The exact ownership and copying strategy depends on the environment, but the debugging lesson is important: know who owns and modifies each transaction object.
Step 11: Use transaction IDs when debugging long tests
Long simulations may contain thousands of transactions. A transaction identifier can make tracing much easier.
int unsigned transaction_id;
The sequence can assign an ID:
req.transaction_id = next_id;
Then the driver and monitor can include the same identifier in their messages:
[TXN 17] Sequence generated WRITE addr=0x1000 data=0x55
[TXN 17] Driver received WRITE addr=0x1000 data=0x55
[TXN 17] Monitor observed WRITE addr=0x1000 data=0x55
[TXN 17] Scoreboard checked transaction
This creates a transaction trace through the environment.
Transaction IDs are particularly useful for protocols with multiple outstanding operations, responses, or out-of-order behavior.
Step 12: Debugging randomization
Lesson 29 introduced constrained-random transaction generation. When a transaction contains unexpected values, check randomization before changing the driver.
if (!req.randomize()) begin
`uvm_error("RANDFAIL",
"Unable to generate a legal transaction")
end
`uvm_info("SEQ",
$sformatf("Randomized transaction:\n%s", req.sprint()),
UVM_MEDIUM)
If the values are legal but surprising, inspect:
- class-level constraints,
- inline constraints,
- field assignments made before or after randomization,
- constraint modes, and
- randomization return status.
A surprising transaction is not necessarily a randomization failure. The transaction may be perfectly legal but simply not what your test scenario intended.
Step 13: Debug the scoreboard last
The scoreboard is often where the failure becomes visible, but it is not necessarily where the failure originated.
Expected:
addr = 0x1000
data = 0x55
Actual:
addr = 0x1004
data = 0x55
Before modifying the scoreboard, verify:
- What did the sequence generate?
- What did the driver receive?
- What signals did the driver drive?
- What did the monitor observe?
- What transaction did the monitor publish?
- What transaction reached the scoreboard?
Only after those questions are answered should you decide whether the scoreboard itself is incorrect.
Step 14: A systematic debugging workflow
When a transaction-related test fails, follow this order:
1. Sequence
|
v
2. Sequencer
|
v
3. Driver
|
v
4. DUT signals
|
v
5. Monitor
|
v
6. Scoreboard
At each stage, verify three things:
- Existence: Did the transaction exist?
- Content: Did it contain the expected values?
- Timing: Did it occur at the expected time?
This gives you a simple debugging framework:
Step 15: A realistic debugging example
Imagine the scoreboard reports:
ERROR: Expected data 0x55, observed data 0xAA
Start at the sequence:
SEQ:
WRITE addr=0x1000 data=0x55
The sequence is correct.
Check the driver:
DRIVER:
WRITE addr=0x1000 data=0x55
The driver received the expected transaction.
Check the monitor:
MONITOR:
WRITE addr=0x1000 data=0xAA
The first visible mismatch is at the observed transaction.
Now investigate:
- Was the DUT actually given
0x55? - Did the driver drive the correct signal?
- Did the monitor sample the correct cycle?
- Did the monitor assign the correct signal to
data?
Notice what we did not do: immediately rewrite the scoreboard.
Step 16: Transaction debugging checklist
| Question | What it tells you |
|---|---|
| Was the item created? | Confirms stimulus generation started. |
| Did randomization succeed? | Confirms a legal randomized solution was found. |
| What did the sequence generate? | Establishes intended stimulus. |
| What did the driver receive? | Checks sequence-driver transfer. |
| What did the driver drive? | Checks transaction-to-signal translation. |
| What did the monitor observe? | Checks signal-to-transaction reconstruction. |
| What reached the scoreboard? | Checks transaction communication and checking input. |
| Where did the first mismatch occur? | Identifies the most likely fault location. |
Step 17: Avoid drowning in debug output
More messages do not automatically mean better debugging.
A test that prints every signal on every clock can produce thousands or millions of lines that hide the important information.
Prefer transaction-level messages at meaningful boundaries:
SEQ -> generated transaction
DRIVER -> received transaction
DRIVER -> completed bus operation
MONITOR -> observed transaction
SCOREBD -> checked transaction
Once the problem is localized, remove or reduce temporary debug messages. Keep permanent messages focused on useful verification information.
Step 18: The complete transaction-debugging mindset
A mature verification engineer does not ask only:
"Why did the scoreboard fail?"
Instead, ask:
"Where did the transaction first become different from what I expected?"
The complete reasoning path is:
Intent
|
v
Generated Transaction
|
v
Driver Input
|
v
DUT Activity
|
v
Observed Transaction
|
v
Scoreboard
|
v
Verification Result
If you can observe each boundary, you can usually localize the problem quickly.
Try it yourself
Build a small transaction-debugging experiment using the bus_transaction
from the previous lessons.
- Create and randomize a transaction in a sequence.
- Print the transaction after randomization.
- Print the transaction when the driver receives it.
- Print the transaction when the monitor reconstructs it.
- Send the observed transaction to a scoreboard.
- Print the transaction received by the scoreboard.
Your simulation log should allow you to follow one transaction through the verification environment.
SEQ : generated transaction
DRIVER : received transaction
MONITOR : observed transaction
SCOREBD : checking transaction
Key takeaways
- Transaction visibility is one of the most powerful tools for debugging a UVM environment.
- Use
print()andsprint()to inspect UVM objects. - Use
uvm_infoto place useful transaction information into the simulation log. - Debug the transaction path from sequence to sequencer to driver to DUT to monitor to scoreboard.
- Distinguish between requested transactions and observed transactions.
- Know who creates, modifies, and owns each transaction object.
- Check randomization success before assuming a transaction contains valid stimulus.
- Do not assume the scoreboard is the source of a scoreboard failure.
- Find the first point where the transaction differs from the expected behavior.
- Use transaction IDs when long tests or multiple outstanding operations make tracing difficult.
- Good debugging output is focused, temporary when appropriate, and organized around transaction boundaries.
- After this lesson, you should be able to follow a transaction through an entire basic UVM environment.