Why p sequencer

I have seen people suggesting try to avoid p sequencer but can anybody tell how can we run two agents without using p sequencer?

In reply to Raja VA:

I have seen people suggesting try to avoid p sequencer but can anybody tell how can we run two agents without using p sequencer?

what is p_sequencer ?
Every sequence have m_sequencer handle which is type of uvm_base_sequencer. The real sequencer which is connected to the driver is extend from uvm_base_sequnece and parameterized with sequence item type which used to communication with driver. To access this actual sequencer (uvm_base_sequnece parameterized with sequence item type) within the sequence we need to type cast m_sequencer to actual sequencer which is called p_sequencer(widely used name, can be named anything you like). p_sequencer is used to access the environment component detail inside the sequence as sequence won’t have access to component detail/configuration etc.

so p_sequencer has nothing to related with running 2 sequence of different agent.

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

To run the sequence of 2 or more different agent you don’t need to define p_sequencer, just create the instate of 2 sequence and run them on agent specific sequencer inside the test case.

Generally people create the virtual sequencer and virtual sequence. virtual sequence is container of different sequences and Virtual sequencer is container of different agent’s sequencer.

How to create virtual sequencer ?
Create virtual sequencer which have different agent’s sequencer handle.
Create the instant of virtual sequencer inside the top level environment(which instantiate both the agent) and connect the sequencers handle define inside virtual sequencer with actual agent’s sequencer.


/// virtual sequence declaration
  class my_virtual_sequencer extends uvm_sequencer;
    `uvm_component_utils (my_virtual_sequencer)
 
    function new (string name = "my_virtual_sequencer", uvm_component parent);
      super.new (name, parent);
    endfunction
 
    // Declare handles to agent sequencers 
    apb_sequencer      apb_seqr;
    ahb_sequencer      ahb_seqr;
  endclass


  class my_env extends uvm_env;
    ...
 
    my_virtual_sequencer   virt_seqr;
 
    virtual function void build_phase (uvm_phase phase);
      ...
      virt_seqr= my_virtual_sequencer::type_id::create ("virt_seqr", this);
      ...
    endfunction
 
    // Connect virtual sequencer handles to actual sequencers
    virtual function void connect_phase (uvm_phase phase);
      ...
      virt_seqr.apb_seqr   = m_apb_agent.apb_seqr;
      virt_seqr.ahb_seqr   = m_ahb_agent.ahb_seqr;
      ...
    endfunction
  endclass

In reply to Rahul Patel:

I would make the sequencer handles part of the virtual sequence instead of creating a virtual sequencer. This makes porting of virtual sequences between environments even easier and eliminates the need to create a virtual sequencer. You would then run the virtual sequence with a null pointer.

In reply to cgales:

In reply to Rahul Patel:
I would make the sequencer handles part of the virtual sequence instead of creating a virtual sequencer. This makes porting of virtual sequences between environments even easier and eliminates the need to create a virtual sequencer. You would then run the virtual sequence with a null pointer.

Agree.

In reply to Rahulkumar:

Hi Rahul,

I would like to understand your statement “p_sequencer is used to access the environment component detail inside the sequence as sequence won’t have access to component detail/configuration etc.”

Could you give me an example where I can differentiate the difference between m_sequencer and p_sequencer? what kind of error I will get If I use p_sequencer instead of m_sequencer or vice versa.?

Thank you so much .

In reply to Prashant Soni:

Have a look at UVM Tutorial for Candy Lovers – 3. Transactions and Sequences – ClueLogic and find the second mention of “uvm_declare_p_sequencer”. Say you have extended uvm_sequencer to create a new class, my_vsqr, with the new property, my_sqr. m_sequencer is the base class and can not directly access my_sqr. You could $cast m_sequencer to a temporary handle.

p_sequencer is this new type and can directly access my_sqr. The $cast has already been done for you in the `uvm_declare_p_sequencer() macro.