Sequence Debugging
Learn how to trace UVM stimulus from a sequence through the sequencer and driver, identify where transactions stop or change, and systematically debug sequence failures.
Learning objectives
- Trace a transaction from a sequence to the DUT.
- Identify common sequence failures such as hangs, missing transactions, and unexpected values.
- Use UVM reporting and transaction printing to make stimulus visible.
- Debug
start_item(),finish_item(), and randomization problems. - Distinguish sequence, sequencer, driver, and DUT responsibilities.
- Use a systematic debugging workflow instead of changing multiple components at once.
Step 1: Know what you are debugging
A UVM sequence does not directly drive DUT pins. It creates and sends transaction objects through a sequencer to a driver.
The basic stimulus path is:
Sequence
│
│ sequence item
▼
Sequencer
│
│ item transfer
▼
Driver
│
│ protocol signals
▼
DUT
│
▼
Monitor
│
▼
Scoreboard / Coverage
When a test fails, your first question should be: Where did the transaction stop being what I expected?
That question is much more useful than immediately changing the driver or scoreboard.
Step 2: Make the sequence visible
Debugging is difficult when you cannot see what the sequence generated. During development, use UVM reporting to show important transaction information.
task body();
bus_transaction req;
repeat (5) begin
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);
end
endtask
This gives you an immediate answer to an important question: Did the sequence generate the transaction I expected?
Once the problem is understood, verbose debug messages can be reduced or removed.
Step 3: Debug randomization first
Lesson 39 introduced constrained-random stimulus. If a sequence generates unexpected values, inspect randomization before investigating the driver.
start_item(req);
if (!req.randomize()) begin
`uvm_fatal("RANDFAIL",
"Unable to generate a legal transaction")
end
`uvm_info("SEQ",
$sformatf("addr=%0h data=%0h write=%0b",
req.addr, req.data, req.write),
UVM_MEDIUM)
finish_item(req);
Check:
- Are the fields declared
rand? - Are the constraints correct?
- Are the constraints too restrictive?
- Are inline constraints changing the scenario?
- Did
randomize()succeed?
If the transaction is already wrong here, do not debug the driver yet. The driver can only work with the transaction it receives.
Step 4: Understand where a sequence can hang
One of the most common beginner UVM problems is a test that appears to stop inside a sequence.
For example:
start_item(req);
if (!req.randomize()) begin
`uvm_error("RANDFAIL", "Randomization failed")
end
finish_item(req);
If execution appears to stop around start_item() or
finish_item(), investigate the sequence-driver path rather than assuming
the sequence itself is broken.
The useful debugging questions are:
- Did the sequence start?
- Did it reach
start_item()? - Did randomization complete?
- Did it reach
finish_item()? - Did the driver request the item?
- Did the driver eventually call
item_done()?
These checkpoints narrow a large problem into one small section of the transaction path.
Step 5: Add checkpoints to the sequence
Temporary debug messages can tell you exactly how far the sequence progressed.
`uvm_info("SEQDBG", "Before start_item()", UVM_LOW)
start_item(req);
`uvm_info("SEQDBG", "After start_item()", UVM_LOW)
if (!req.randomize()) begin
`uvm_error("RANDFAIL", "Randomization failed")
end
`uvm_info("SEQDBG", "Before finish_item()", UVM_LOW)
finish_item(req);
`uvm_info("SEQDBG", "After finish_item()", UVM_LOW)
If you see:
Before start_item()
After start_item()
Before finish_item()
but never:
After finish_item()
you have learned something important: the sequence has not completed the item transfer. Now investigate the sequencer and driver path.
Step 6: Check the driver
The driver should request the item, drive the DUT, and indicate completion.
task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
`uvm_info("DRV",
$sformatf("Received:\n%s", req.sprint()),
UVM_MEDIUM)
drive_transfer(req);
seq_item_port.item_done();
end
endtask
Add a message before and after the DUT-driving operation:
`uvm_info("DRV", "Before drive_transfer()", UVM_LOW)
drive_transfer(req);
`uvm_info("DRV", "After drive_transfer()", UVM_LOW)
seq_item_port.item_done();
If the driver receives the transaction but never reaches
item_done(), investigate the driver's protocol timing.
For example, a driver waiting forever for ready can prevent the sequence
from making progress.
Step 7: Separate UVM handshake from DUT handshake
There are two different interactions to keep in mind.
| Interaction | Purpose |
|---|---|
start_item() / finish_item() |
Sequence-side transaction transfer through UVM |
get_next_item() / item_done() |
Driver-side transaction request and completion |
valid / ready |
DUT protocol handshake |
A sequence can successfully generate a transaction while the driver later waits for a DUT protocol condition.
Therefore, a sequence hang does not always mean the sequence is incorrect. The driver may be waiting for a DUT response.
Step 8: Debug missing transactions
Another common problem is: "My sequence ran, but I do not see any transactions at the DUT."
Work through the path in order:
- Did the test start the sequence?
- Did the sequence enter
body()? - Did the sequence create a request?
- Did
randomize()succeed? - Did the sequence complete the item transfer?
- Did the driver receive the item?
- Did the driver drive the interface?
- Did the monitor observe the resulting protocol transaction?
Do not jump directly to the waveform. First establish where the transaction exists in the software path.
Step 9: Debug unexpected transaction values
Suppose the sequence prints:
addr=20 data=AA write=1
but the driver appears to drive different values.
Compare the transaction at each boundary:
Sequence
↓
"addr=20 data=AA"
↓
Driver receives
"addr=20 data=AA"
↓
Driver drives pins
"addr=20 data=AA"
↓
Monitor observes
"addr=20 data=??"
The first point where the values differ is the place to investigate.
This method is much faster than changing all components at once.
Step 10: Debug sequence ordering
Sometimes the values are correct, but the transactions happen in an unexpected order.
repeat (3) begin
req = bus_transaction::type_id::create("req");
start_item(req);
req.write = 1'b1;
req.addr = addr;
req.data = data;
finish_item(req);
end
If the sequence depends on changing values such as addr or
data, verify that those values are updated before each transaction is
completed.
For reusable sequences, helper tasks can make ordering easier to understand:
task send_write(
bit [7:0] addr,
bit [7:0] data
);
bus_transaction req;
req = bus_transaction::type_id::create("req");
start_item(req);
req.write = 1'b1;
req.addr = addr;
req.data = data;
finish_item(req);
endtask
Then the sequence body becomes easier to read:
task body();
send_write(8'h10, 8'hAA);
send_write(8'h20, 8'h55);
send_write(8'h30, 8'hFF);
endtask Step 11: Debug random test failures
Constrained-random tests introduce another challenge: the failure may not happen every time.
When a randomized test fails, record:
- The simulation seed
- The failing sequence
- The transaction values
- The transaction number
- The relevant configuration
- The first incorrect observed result
For example:
`uvm_error("SEQFAIL",
$sformatf("Failure at transaction %0d: %s",
transaction_count,
req.sprint()))
Once the failing transaction is known, reproduce it with the same seed or create a directed sequence containing the problematic values.
Step 12: Use the waveform as confirmation
Waveforms are extremely useful, but they should usually be used together with transaction-level debug messages.
A good workflow is:
Sequence log
↓
Driver log
↓
Monitor transaction
↓
Waveform
↓
Scoreboard result
The log tells you what the verification environment believes happened. The waveform tells you what actually happened on the interface.
If they disagree, investigate the boundary between them.
Common sequence-debugging failures
- Sequence never starts: check the test and the call to
start(). - Randomization fails: inspect constraints and check the return value of
randomize(). - Sequence hangs: determine whether it is waiting for the sequencer, driver, or DUT protocol.
- Driver receives nothing: verify the sequence/sequencer/driver connection.
- Driver receives the wrong values: compare the sequence transaction with the driver's received transaction.
- Driver hangs: inspect protocol waits such as
readyor response signals. - Transactions appear in the wrong order: inspect sequence control flow and item completion.
- Random failure cannot be reproduced: record the seed and failing transaction information.
- Everything is debugged simultaneously: isolate one boundary at a time.
A systematic debugging workflow
When a sequence does not behave as expected, use this checklist:
- Start: confirm the sequence was started.
- Create: confirm the sequence item exists.
- Randomize: confirm the item contains legal expected values.
- Transfer: confirm the sequence reaches the item-completion point.
- Receive: confirm the driver receives the same transaction.
- Drive: confirm the driver produces the intended protocol activity.
- Observe: confirm the monitor sees the expected transaction.
- Check: confirm the scoreboard or assertions evaluate the result correctly.
Mini debug example
Imagine the sequence prints:
SEQ: Generated addr=10 data=AA
SEQ: Before finish_item()
but the next message never appears.
The first hypothesis should not be "the DUT is broken." Instead, trace the transaction path:
finish_item()
↓
Sequencer
↓
Driver get_next_item()
↓
Driver drive
↓
item_done()
↓
Sequence continues
Add driver messages around get_next_item() and
item_done(). If the driver never receives the item, investigate the
sequencer-driver connection. If the driver receives it but never completes it,
investigate the driver's protocol logic.
Try it yourself
Create a sequence that sends five transactions and add temporary debug messages at these points:
- Before
start_item() - After
start_item() - After
randomize() - Before
finish_item() - After
finish_item()
Add similar messages to the driver before and after
get_next_item(), the DUT-driving operation, and
item_done().
Then intentionally introduce one problem—for example, make the driver wait for a condition that never occurs—and use the messages to determine where the transaction stops.
Challenge
Take your constrained-random sequence from Lesson 39 and make it easier to debug.
- Print every generated transaction at
UVM_MEDIUM. - Keep a transaction counter.
- Report randomization failures clearly.
- Identify the first transaction that causes an unexpected result.
- Record enough information to reproduce the failure.
- Use the driver and monitor logs to trace that transaction through the environment.
The goal is not simply to add more messages. The goal is to create a trace that answers: What was generated, where did it go, what reached the DUT, and where did the behavior first become incorrect?
Key takeaways
- Debug sequences by tracing the complete path: sequence → sequencer → driver → DUT → monitor.
- Make transactions visible with
uvm_info(),sprint(), and temporary debug checkpoints. - Always check whether
randomize()succeeded before sending the transaction. - A sequence hang may actually be caused by the sequencer, driver, or DUT protocol.
- Distinguish the UVM item handshake from the DUT's protocol handshake.
- Find the first point where the transaction or timing differs from what you expected.
- Use logs and waveforms together rather than relying on either one alone.
- Record seeds and transaction information so constrained-random failures can be reproduced.
- Debug one boundary at a time instead of modifying the entire testbench simultaneously.