The UVM sequence is a core component of the Universal Verification Methodology (UVM) and plays a crucial role in generating and delivering stimulus to the DUT (Device Under Test). As a user-defined class extending the uvm_sequence base class, the UVM sequence defines the behavior of transactions and interacts with the sequencer to generate stimuli in a controlled and organized manner. A UVM sequence is a transaction generator. It defines the flow of transactions that are sent to the driver via the sequencer. Sequences can call other sequences, enabling hierarchical and modular test creation.
A user-defined sequence class is extended from uvm_sequence. It should be parameterized with request(REQ) and response(RSP) sequence_item types. Response is optional. uvm_sequence is inherited by uvm_object.
uvm_sequence base class:
virtual class uvm_seqence #( type REQ = uvm_sequence_item, type RSP = REQ) extends uvm_sequence_base

UVM Sequence Anatomy: The body Method
The body method is the heart of a UVM sequence. It contains the procedural code that defines the flow and behavior of the sequence. The body method is automatically executed when the sequence starts.
Key Points About the body Method:
- Automatic Execution: When a sequence is started, the UVM framework automatically calls its
bodymethod. - Transaction Generation: The
bodymethod is where transactions are created, randomized, and sent to the sequencer. - Control Flow: Loops, conditionals, and synchronization constructs can be used to control the behavior of the sequence.
Example: Implementing a Simple UVM Sequence
Let’s consider a scenario where we need to drive an APB transaction to the DUT. Below is a step-by-step example of how to create and use a UVM sequence with the body method.
class pt_sequence extends uvm_sequence#(p_transaction);
`uvm_object_utils(pt_sequence)
p_transaction req;
function new(string name = "pt_sequence");
super.new(name);
endfunction
virtual task body();
req=p_transaction::type_id::create("req");
for (int i=4;i<21;i=i+4) begin
start_item(req);
req.paddr= i;
req.pwdata = i+4;
req.pwrite = 1;
finish_item(req);
end
for (int i=4;i<21;i=i+4) begin
start_item(req);
req.paddr= i;
// req.pwdata = i+4;
req.pwrite = 0;
finish_item(req);
end
endtask
endclass
Explanation of the body Method
- Transaction Creation:
Thebodymethod creates an instance of theapb_transactionclass (req) in a loop. - Sequencer Communication:
start_item(trans)initiates a handshake with the sequencer, notifying it that a new transaction is ready.finish_item(trans)finalizes the transaction and sends it to the sequencer.
- Control Flow:
The loop ensures that 5 transactions are created and sent sequentially.
Key Takeaways:
- The
bodymethod is automatically executed when a sequence is started. - Use
start_itemandfinish_itemto send transactions to the sequencer. - Leverage randomization and constraints to generate diverse stimuli.