Sequence Items
Learn how uvm_sequence_item turns a transaction into a first-class UVM object that sequences can generate and drivers can consume.
Learning objectives
- Explain what a
uvm_sequence_itemis and why UVM uses it. - Build a basic sequence item with meaningful transaction fields.
- Understand the relationship between a sequence item, sequence, sequencer, and driver.
- Use the UVM factory to create sequence items.
- Understand the purpose of
uvm_object_utils. - Distinguish sequence items from sequences and components.
- Recognize common sequence-item design mistakes.
Step 1: What is a sequence item?
In Lesson 27, we learned that a transaction is a data model for a meaningful protocol operation.
A sequence item is the UVM object used to represent that transaction when it participates in the UVM stimulus flow.
Sequence items normally extend uvm_sequence_item:
class bus_transaction extends uvm_sequence_item;
rand bit write;
rand bit [31:0] addr;
rand bit [31:0] data;
`uvm_object_utils(bus_transaction)
function new(string name = "bus_transaction");
super.new(name);
endfunction
endclass
The class contains the information needed to describe one bus operation. Later, a sequence creates this object, a sequencer transfers it, and a driver converts it into pin-level activity.
Step 2: Understand the UVM hierarchy
uvm_sequence_item is part of the UVM object hierarchy.
uvm_object
|
+-- uvm_transaction
|
+-- uvm_sequence_item
|
+-- bus_transaction
This is different from the UVM component hierarchy:
uvm_component
|
+-- uvm_driver
+-- uvm_monitor
+-- uvm_agent
+-- uvm_env
+-- uvm_test
This distinction is important:
| UVM object | Purpose | Examples |
|---|---|---|
uvm_sequence_item |
Represents transaction data | Read, write, packet, FIFO operation |
uvm_sequence |
Generates a sequence of transactions | Reset sequence, burst sequence, error sequence |
uvm_component |
Builds the persistent testbench structure | Driver, monitor, agent, scoreboard |
Step 3: Build a simple sequence item
Start with the transaction fields identified in Lesson 27. Suppose our DUT accepts simple read and write operations.
class bus_transaction extends uvm_sequence_item;
rand bit write;
rand bit [31:0] addr;
rand bit [31:0] data;
`uvm_object_utils(bus_transaction)
function new(string name = "bus_transaction");
super.new(name);
endfunction
endclass
The fields describe the operation:
writetells us whether this is a read or write.addridentifies the target address.datacontains the write data or other transaction data.
Notice what is not present: clock, reset, valid, ready, or individual signal transitions. Those are normally handled by the driver and monitor.
Step 4: Why extend uvm_sequence_item?
UVM's sequence mechanism expects transaction objects that can participate in the sequence-driver communication model.
By extending uvm_sequence_item, our transaction becomes compatible
with the standard UVM sequence infrastructure.
This lets us use the standard flow:
sequence
|
| sequence item
v
sequencer
|
| sequence item
v
driver
|
| pin-level signals
v
DUT
The sequence does not need to know how the driver implements the bus. The driver does not need to know why the sequence chose a particular transaction.
Step 5: Sequence item versus sequence
Beginners often confuse these two concepts because their names are similar.
Sequence item
Represents one transaction.
WRITE 0x1000 = 0x55
Sequence
Generates one or more sequence items according to a scenario.
RESET
WRITE 0x1000 = 0x55
WRITE 0x1004 = 0xAA
READ 0x1000
READ 0x1004
A useful mental model is:
Sequence
|
+-- Item 1
+-- Item 2
+-- Item 3
+-- Item 4
Step 6: Create sequence items with the factory
UVM code commonly creates sequence items through the factory:
bus_transaction req;
req = bus_transaction::type_id::create("req");
This is preferable to directly constructing the object with new()
in reusable UVM code because factory creation supports later replacement
and overrides.
You can think of the factory as allowing the testbench to say:
"Create the transaction type registered under this name."
The details of factory overrides are covered later in the curriculum.
For now, establish the habit of using type_id::create() for
UVM sequence items.
Step 7: What does uvm_object_utils do?
The macro:
`uvm_object_utils(bus_transaction)
registers the class with UVM's object/factory infrastructure.
This is why the following factory construction is possible:
bus_transaction::type_id::create("req");
You will encounter several UVM macros throughout the course. At this stage, focus on their practical purpose rather than memorizing every implementation detail.
Step 8: Understand the constructor
A basic sequence item constructor looks like this:
function new(string name = "bus_transaction");
super.new(name);
endfunction
The constructor gives the object a UVM name and calls the parent constructor.
Unlike UVM components, sequence items do not have a parent component argument. They are objects, not components in the testbench hierarchy.
This is an important distinction:
// Component
agent = bus_agent::type_id::create("agent", this);
// Object
req = bus_transaction::type_id::create("req");
Components have a parent in the UVM component hierarchy. Sequence items do not.
Step 9: Add useful transaction information
A sequence item should contain enough information to represent its operation clearly.
For example, a memory operation might use:
class memory_item extends uvm_sequence_item;
rand bit write;
rand bit [31:0] address;
rand bit [31:0] write_data;
bit [31:0] read_data;
bit error;
`uvm_object_utils(memory_item)
function new(string name = "memory_item");
super.new(name);
endfunction
endclass
Here, the randomized fields represent requested stimulus:
write
address
write_data
The non-random fields can represent information discovered later:
read_data
error
This is only one possible design. Whether a field belongs in the request, response, or observed transaction depends on the protocol.
Step 10: Random fields versus non-random fields
A field declared with rand can participate in SystemVerilog
constrained-random generation.
rand bit [31:0] address;
rand bit [31:0] data;
A normal field is not randomized automatically:
bit [31:0] response_data;
bit error;
This distinction is useful because the testbench may generate some information and observe other information.
Do not make every field rand simply because the class is a
sequence item. Randomization should reflect what the testbench is trying to generate.
Step 11: The sequence-driver handshake
The most important reason sequence items matter is that they form the data exchanged between a sequence and a driver.
A simplified driver looks like this:
task run_phase(uvm_phase phase);
bus_transaction req;
forever begin
seq_item_port.get_next_item(req);
// Convert req into DUT pin activity.
drive_transaction(req);
seq_item_port.item_done();
end
endtask
The sequence creates the request, while the driver receives and consumes it.
The driver should not need to know whether the transaction came from a directed sequence, a random sequence, a regression test, or another scenario.
Step 12: A complete small example
Here is a compact sequence-item definition suitable for a simple bus environment:
class bus_transaction extends uvm_sequence_item;
rand bit write;
rand bit [31:0] addr;
rand bit [31:0] data;
`uvm_object_utils(bus_transaction)
function new(string name = "bus_transaction");
super.new(name);
endfunction
endclass
A sequence can create one:
bus_transaction req;
req = bus_transaction::type_id::create("req");
req.write = 1;
req.addr = 32'h1000;
req.data = 32'h55;
Conceptually, the resulting object represents:
WRITE
Address = 0x1000
Data = 0x55
The driver can then translate this object into whatever signal-level protocol the DUT requires.
Step 13: Common sequence-item mistakes
Mistake 1: Confusing the item with the sequence
The item represents one transaction. The sequence generates a series of items.
Mistake 2: Extending the wrong UVM class
A normal transaction used by the sequence-driver mechanism should extend
uvm_sequence_item, not uvm_component.
Mistake 3: Forgetting factory registration
If you intend to use type_id::create(), make sure the class is
registered appropriately with UVM.
Mistake 4: Putting protocol timing into the item
The sequence item should describe the operation. The driver should handle clock-by-clock protocol behavior.
Mistake 5: Making every field random
Randomization belongs on fields that represent generated stimulus. Observed results and DUT responses are often not randomized.
Mistake 6: Creating an interface mirror
Do not automatically duplicate every interface signal in the transaction. Preserve the transaction-level abstraction established in Lesson 27.
Step 14: Debugging a sequence item
When stimulus looks wrong, inspect the transaction before investigating complicated driver timing.
Ask:
- Was the sequence item created successfully?
- Were the expected fields assigned?
- Did randomization produce the intended values?
- Did the sequencer deliver the item?
- Did the driver receive the expected item?
- Did the driver interpret each field correctly?
A useful debugging path is:
Sequence
|
| expected item
v
Sequencer
|
| received item
v
Driver
|
| generated signals
v
DUT
Find the first point where the transaction differs from what you expected. That is usually more useful than starting at the final DUT failure.
Step 15: Sequence item design checklist
Before moving on, ask these questions about your transaction class:
- What single operation does this item represent?
- Are all required transaction fields present?
- Are unnecessary interface timing signals excluded?
- Which fields are generated stimulus?
- Which fields are observed results?
- Does the class extend
uvm_sequence_item? - Is the class registered for factory use?
- Can a driver consume the item without knowing the test scenario?
- Can the item be printed or inspected during debugging?
Try it yourself
Create a fifo_item for a simple FIFO verification environment.
Start with these operations:
WRITE data
READ
RESET
Design a sequence item that can represent them.
- Create a class extending
uvm_sequence_item. - Add an operation field such as an enum.
- Add a data field for writes.
- Register the class with the UVM factory.
- Add the constructor.
- Decide which fields should be
rand.
fifo_item moves from a sequence to a sequencer,
then to a driver, and finally to the FIFO DUT.
Identify exactly where the transaction becomes pin-level activity.
Key takeaways
- A sequence item is a UVM transaction object used by the sequence-driver mechanism.
- Sequence items normally extend
uvm_sequence_item. - A sequence item represents one operation; a sequence generates a scenario containing multiple items.
- Sequence items are objects, while drivers, monitors, agents, and scoreboards are components.
- Use
type_id::create()for factory-based sequence-item creation. uvm_object_utilsregisters the sequence item for UVM object/factory support.- Use
randfor fields that represent generated stimulus when randomization is desired. - Keep clock-level timing and pin manipulation in the driver and monitor.
- The sequence creates intent; the driver translates that intent into DUT activity.
- A well-designed sequence item makes stimulus generation, driving, checking, and debugging easier.