M - Sequence and P - Sequencer in UVM
M - Sequence and P - Sequencer in UVM
• Always exists for a uvm_sequence and is initialized when the sequence is started.
p_sequencer:
• Type-specific sequencer pointer, created by using the uvm_declare_p_sequencer macro.
• Allows access to additional features added to the specific sequencer (e.g., pointers to other
sequencers).
1
Aspect m_sequencer p_sequencer
Existence Always exists for a uvm_sequence and is Will not exist if the
initialized when the sequence is uvm_declare_p_sequencer macro is not
started. used.
Functionality Acts as a generic pointer to the base Allows access to additional features
class of all sequencers added to the specific sequencer (e.g.,
(uvm_sequencer_base). pointers to other sequencers).
Key Takeaway The difference between m_sequencer Allows sequences to interact with the
and p_sequencer boils down to static sequencer in a more detailed and
and dynamic casting between a base specific way.
class (uvm_sequencer_base) and an
extended user-defined sequencer
class.
Member Variable Typically found in UVM drivers. Typically found in sequence classes.
Location
Connection Phase Connected to the sequencer during the Automatically set up by UVM when the
connection phase using sequence is started on a sequencer.
seq_item_port.connect(sequencer.seq_i
tem_export).
2
Aspect m_sequencer p_sequencer
Purpose Used for communication between the Used for sequences to access
driver and sequencer. sequencer-specific functionality.
Scope Specific to the driver instance. Provides access to the sequencer from
within any sequence running on that
sequencer.
Generic vs Specific Provides a generic interface suitable Allows access to type-specific features
Access for all sequencers. and methods of the user-defined
sequencer.
Initialization Initialized via the start method of the Initialized via the
Method sequence which calls set_sequencer. uvm_declare_p_sequencer(sequencer)
macro within a sequence.
task body();
// Use p_sequencer to access sequencer-specific methods or variables
p_sequencer.some_sequencer_specific_method();
// ... sequence logic ...
endtask
3
// ... other sequence code ...
endclass