Sequencers
Learn how UVM sequencers manage sequence items, connect sequences to drivers, and coordinate stimulus when multiple sequences compete for the same driver.
Learning objectives
- Explain the role of a UVM sequencer.
- Understand the relationship between sequences, sequence items, sequencers, and drivers.
- Create a basic
uvm_sequencer. - Connect a sequencer to a driver.
- Understand the sequence-item request flow.
- Understand why a sequencer is useful when multiple sequences generate stimulus.
- Distinguish sequencer responsibilities from sequence and driver responsibilities.
- Debug common sequencer and sequence-driver connection problems.
Step 1: What is a sequencer?
A UVM sequencer manages the flow of sequence items from sequences toward a driver.
A sequence decides what transactions should be generated. A driver decides how those transactions should be converted into DUT signal activity.
The sequencer sits between them and manages the transaction flow.
Sequence
|
| sequence items
v
Sequencer
|
| transaction flow
v
Driver
|
| signal activity
v
DUT
Step 2: Why do we need a sequencer?
You might wonder why a sequence cannot simply communicate directly with a driver.
In simple environments, the difference can seem small. The sequencer becomes much more valuable as the verification environment grows.
Multiple sequences may want to generate transactions for the same driver. The sequencer provides the UVM mechanism for managing that stimulus flow.
For example:
reset_sequence \
\
normal_traffic_sequence ---> Sequencer ---> Driver
/
error_sequence /
The sequences generate transaction requests. The sequencer determines which sequence's item is delivered next.
The details of advanced arbitration will come later. For now, remember that the sequencer provides a controlled interface between sequences and the driver.
Step 3: Sequence, sequencer, and driver have different jobs
These three concepts are easy to confuse because they work together.
| Component | Main responsibility |
|---|---|
| Sequence | Generate and organize transaction-level stimulus. |
| Sequencer | Manage the flow of sequence items toward the driver. |
| Driver | Convert sequence items into DUT interface activity. |
A useful mental model is:
Sequence = "What should happen?"
Sequencer = "Which item goes next?"
Driver = "How do I drive it?" Step 4: Create a sequencer
A basic sequencer extends uvm_sequencer and specifies
the sequence-item type it manages.
class bus_sequencer extends uvm_sequencer #(bus_transaction);
`uvm_component_utils(bus_sequencer)
function new(string name = "bus_sequencer",
uvm_component parent = null);
super.new(name, parent);
endfunction
endclass
The parameter:
uvm_sequencer #(bus_transaction)
tells the sequencer that it manages
bus_transaction sequence items.
Unlike a sequence, the sequencer is a UVM component. Therefore, it has a parent component and participates in the UVM component hierarchy.
Step 5: Put the sequencer inside the agent
A typical active agent contains a sequencer and driver.
class bus_agent extends uvm_agent;
bus_sequencer sequencer;
bus_driver driver;
bus_monitor monitor;
`uvm_component_utils(bus_agent)
function new(string name = "bus_agent",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
sequencer = bus_sequencer::type_id::create(
"sequencer", this);
driver = bus_driver::type_id::create(
"driver", this);
monitor = bus_monitor::type_id::create(
"monitor", this);
endfunction
endclass
The agent now owns the three main pieces of the stimulus and observation architecture:
bus_agent
|
+-- sequencer
+-- driver
+-- monitor
The sequencer and driver will be connected during
connect_phase().
Step 6: Connect the sequencer to the driver
The sequencer and driver communicate through TLM interfaces. The driver has a sequence-item port.
class bus_driver extends uvm_driver #(bus_transaction);
`uvm_component_utils(bus_driver)
function new(string name = "bus_driver",
uvm_component parent = null);
super.new(name, parent);
endfunction
endclass
The driver inherits the standard
seq_item_port used to receive sequence items.
The agent connects the sequencer to that port:
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
sequencer.seq_item_export.connect(
driver.seq_item_port
);
endfunction
This connection establishes the transaction path:
Sequence
|
v
Sequencer
|
v
seq_item_export
|
v
seq_item_port
|
v
Driver
Step 7: The driver requests the next item
The driver normally waits for sequence items in its
run_phase().
task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
drive_transaction(req);
seq_item_port.item_done();
end
endtask
The driver asks the sequencer for the next available transaction.
After driving the transaction, the driver calls
item_done() to indicate that the item has been processed.
This is the basic handshake you saw in the previous lessons.
Step 8: Follow one transaction through the system
Let's trace one write transaction.
First, the sequence creates the item:
req = bus_transaction::type_id::create("req");
Then the sequence prepares it:
start_item(req);
req.write = 1;
req.addr = 8'h20;
req.data = 32'h55;
finish_item(req);
The sequencer manages the transfer of that item toward the driver.
The driver receives it:
seq_item_port.get_next_item(req);
The driver converts it into signal activity:
drive_transaction(req);
The transaction has now crossed all the major stimulus layers:
Sequence
|
| bus_transaction
v
Sequencer
|
| bus_transaction
v
Driver
|
| pins
v
DUT Step 9: Why multiple sequences make sequencers useful
Imagine a verification environment with several possible scenarios:
- normal traffic,
- boundary traffic,
- error injection,
- reset activity.
Different sequences can be started on the same sequencer.
normal_sequence
\
\
boundary_sequence ---> bus_sequencer ---> bus_driver
/
/
error_sequence
The sequencer provides the common transaction path toward the driver.
This allows the driver to remain focused on the protocol rather than knowing which sequence produced the transaction.
Step 10: Sequencer arbitration — the basic idea
If multiple sequences are active at the same time, the sequencer may have multiple requests competing for the driver.
The sequencer uses arbitration to determine which sequence gets to send the next item.
Sequence A ----\
Sequence B -----+----> Sequencer ----> Driver
Sequence C ----/
You do not need to memorize the arbitration algorithms yet. The important concept is that the sequencer provides a controlled point where competing stimulus can be managed.
Step 11: The sequencer does not drive DUT signals
A common architectural mistake is putting protocol code into the sequencer.
Do not turn the sequencer into another driver:
// Bad architecture
task run_phase(uvm_phase phase);
vif.valid = 1;
vif.data = 32'h55;
@(posedge vif.clk);
vif.valid = 0;
endtask
The sequencer should not know the detailed timing of the DUT interface.
That responsibility belongs to the driver.
| Layer | Should know |
|---|---|
| Sequence | Scenario intent and transaction values. |
| Sequencer | Transaction flow and sequencing. |
| Driver | Clocking, handshakes, pins, and protocol timing. |
Step 12: Sequencer versus sequence
The names are similar, but they are fundamentally different objects.
| Sequence | Sequencer |
|---|---|
Usually extends uvm_sequence |
Usually extends uvm_sequencer |
| UVM object | UVM component |
| Generates sequence items | Manages sequence-item flow |
| Contains scenario behavior | Participates in arbitration and transfer |
Started by calling start() |
Usually created as part of the agent |
Remember:
Sequence = stimulus generator
Sequencer = stimulus manager Step 13: A complete small agent connection
Here is the core architecture in one place:
class bus_agent extends uvm_agent;
bus_sequencer sequencer;
bus_driver driver;
bus_monitor monitor;
`uvm_component_utils(bus_agent)
function new(string name = "bus_agent",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
sequencer = bus_sequencer::type_id::create(
"sequencer", this);
driver = bus_driver::type_id::create(
"driver", this);
monitor = bus_monitor::type_id::create(
"monitor", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
sequencer.seq_item_export.connect(
driver.seq_item_port
);
endfunction
endclass
The resulting topology is:
uvm_test_top
|
+-- env
|
+-- agent
|
+-- sequencer
+-- driver
+-- monitor
And the stimulus connection is:
sequence
|
v
sequencer
|
v
driver
|
v
DUT Step 14: Start a sequence on the sequencer
Once the sequencer exists and is connected to the driver, the test can start a sequence on it.
task run_phase(uvm_phase phase);
basic_write_sequence seq;
phase.raise_objection(this);
seq = basic_write_sequence::type_id::create("seq");
seq.start(env.agent.sequencer);
phase.drop_objection(this);
endtask
The important relationship is:
seq.start(sequencer);
This tells the sequence where its sequence items should be managed.
The sequence does not need to know the internal implementation of the driver.
Step 15: Common sequencer mistakes
Mistake 1: Forgetting to create the sequencer
If the test tries to start a sequence on a null sequencer, stimulus cannot flow.
seq.start(env.agent.sequencer);
Verify that agent.sequencer was created during build.
Mistake 2: Forgetting the sequencer-driver connection
The components can exist in the topology while the transaction path is still disconnected.
sequencer.seq_item_export.connect(
driver.seq_item_port
);
Mistake 3: Connecting incompatible transaction types
The sequence, sequencer, and driver should agree on the sequence-item type being transferred.
Mistake 4: Putting protocol logic into the sequencer
Clock-level and pin-level behavior belongs in the driver.
Mistake 5: Assuming a sequence automatically runs
Creating a sequence does not execute it. The sequence must be started on a sequencer.
Mistake 6: Debugging the driver before checking the transaction path
If the driver receives no item, first verify the sequence, sequencer, and TLM connection.
Step 16: Debug a sequencer that appears to do nothing
Suppose your sequence prints a message saying it started, but the driver never reports receiving a transaction.
Trace the path in this order:
- Was the sequence created?
- Was
seq.start()called? - Was the correct sequencer passed to
start()? - Did the sequence enter
body()? - Did it create a sequence item?
- Did
start_item()andfinish_item()execute? - Does the sequencer exist?
- Is the sequencer connected to the driver?
- Is the driver waiting in
get_next_item()? - Did the driver receive the transaction?
A useful debug chain is:
Sequence started
|
v
body() entered
|
v
Item generated
|
v
Sequencer receives item
|
v
Driver gets item
|
v
Driver drives DUT
Step 17: A practical sequencer mental model
Think of a sequencer like a controlled intersection.
Sequence A ----\
Sequence B -----+----> [ SEQUENCER ] ----> Driver
Sequence C ----/
Each sequence can generate transaction requests. The sequencer manages which transaction proceeds toward the driver.
The driver does not need to know whether a transaction came from a normal-traffic sequence, an error sequence, or a boundary-case sequence.
It simply receives a transaction and performs its protocol-specific job.
Try it yourself
Build the stimulus path for a simple bus agent.
- Create a
bus_sequencerextendinguvm_sequencer #(bus_transaction). - Add the sequencer to a
bus_agent. - Create the sequencer using the UVM factory in
build_phase(). - Create a driver in the same agent.
- Connect
sequencer.seq_item_exporttodriver.seq_item_port. - Create a sequence that generates four transactions.
- Start the sequence using
seq.start(agent.sequencer). - Confirm that the driver receives all four items.
uvm_info messages in both
sequences and the driver so you can trace which transaction reaches
the driver first.
Key takeaways
- A sequencer manages the flow of sequence items from sequences toward a driver.
- A sequence generates scenario-level stimulus.
- A sequence item represents one transaction.
- A driver converts sequence items into DUT signal activity.
- A sequencer is a UVM component; a sequence is a UVM object.
- The sequencer and driver must be connected through their TLM interfaces.
- Multiple sequences can use the same sequencer, making stimulus management more flexible.
- Sequencer arbitration determines which competing sequence gets the next opportunity to send an item.
- Protocol timing and pin-level behavior belong in the driver, not the sequencer.
- When stimulus disappears, debug the path: sequence → sequencer → driver → DUT.