0% found this document useful (0 votes)
118 views

M - Sequence and P - Sequencer in UVM

Uvm sequencer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

M - Sequence and P - Sequencer in UVM

Uvm sequencer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Key Points Summarized for

m_sequencer & p_sequencer:


m_sequencer:
• Generic sequencer pointer of type uvm_sequencer_base.

• Always exists for a uvm_sequence and is initialized when the sequence is started.

• Acts as a base class handle pointing to the sequencer.

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).

• Will not exist if the uvm_declare_p_sequencer macro is not used.

• Defined as a handle of a user-defined sequencer class.

m_sequencer and p_sequencer in


UVM
Aspect m_sequencer p_sequencer

Type Handle of base class type Handle of user-defined sequencer type


uvm_sequencer_base (parent class of (child class).
uvm_sequencer).

Declaration Automatically declared inside Not present by default; must be


uvm_sequence_item class, which is manually declared using the
extended by user-defined sequence uvm_declare_p_sequencer macro within
item classes. It is always present in the the sequence.
UVM testbench.

Initialization Initialized when the sequence is Declared using the


started. The start method calls uvm_declare_p_sequencer(sequencer)
set_sequencer, which statically casts macro, which dynamically casts
the user-specific sequencer handle to m_sequencer to p_sequencer.
m_sequencer.

Usage Provides a generic interface to the Allows access to type-specific features


sequencer, suitable for all sequencers. and methods of the user-defined
sequencer.

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).

Hierarchy uvm_sequence extends from Defined as a handle of a user-defined


uvm_sequence_item and ultimately from sequencer class.
uvm_object. Sequencer classes have
uvm_sequencer_base as their
grandparent and extend from
uvm_component.

Casting When a sequence starts, the user- The uvm_declare_p_sequencer macro


defined sequencer object is assigned to expands to a function that
the m_sequencer handle using static dynamically casts m_sequencer back to
casting. p_sequencer.

Example Code Base Class: base b; + User-defined Using


Sequencer: child child1; + Internal uvm_declare_p_sequencer(sequencer)
Casting: b = child1; and within a sequence declares
$cast(child2, b); p_sequencer and enables access to
specific properties and methods of the
user-defined sequencer.

UVM Source Code start method in uvm_sequence_base uvm_declare_p_sequencer macro


calls set_sequencer. + set_sequencer in defines p_sequencer and includes
uvm_sequence_item assigns m_sequencer dynamic casting.
and calls m_set_p_sequencer.

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).

Type Safety Typically of a generic uvm_sequencer Provides type-safe access to the


type or a specific sequencer type. specific sequencer class, allowing
access to custom methods and
properties.

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.

Additional Examples and Details:


Example usage of m_sequencer in a driver:

class my_driver extends uvm_driver #(my_transaction);


`uvm_component_utils(my_driver)

uvm_sequencer #(my_transaction) m_sequencer;

function void connect_phase(uvm_phase phase);


super.connect_phase(phase);
if (!uvm_config_db#(uvm_sequencer #(my_transaction))::get(this, "", "sequencer",
m_sequencer))
`uvm_fatal("NOSEQUENCER", "No sequencer specified for this driver")
seq_item_port.connect(m_sequencer.seq_item_export);
endfunction

// ... other driver code ...


endclass

Example usage of p_sequencer in a sequence:

class my_sequence extends uvm_sequence #(my_transaction);


`uvm_object_utils(my_sequence)
`uvm_declare_p_sequencer(my_sequencer)

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

You might also like