A typed-specific sequencer pointer p_sequencer tracking issue

Dear All,

I come across p_sequencer keyword, when I’m looking an example of UVM code as the following.

class sequence_1 extends uvm_sequence#(sequence_item_1);
  
  `uvm_object_utils(sequence_1)
  `uvm_declare_p_sequencer(sequencer_1)
  sequence_item_1 req;
  sequence_item_1 req1;
  sequence_item_1 q2;
  
  function new (string name = "sequence_1");
    super.new(name);
  endfunction
  
  
  
  virtual task body();
    
    begin
      p_sequencer.hi();
      repeat(5) begin
      req = sequence_item_1::type_id::create("req");
      wait_for_grant();
      req.randomize();
      send_request(req);
      //$cast(q2,req.clone());
      wait_for_item_done();
     
      req1 = sequence_item_1::type_id::create("req1");
      q2 = sequence_item_1::type_id::create("q2");
      wait_for_grant();
      req1.randomize();
      send_request(req1);
      q2.copy(req1);
      if(q2.compare(req1))
        `uvm_info("Compare","BOTH ARE THE SAME",UVM_LOW)
      else
        `uvm_info("nocompare","Different",UVM_LOW)
      
      wait_for_item_done();
      
      end
    end 
  endtask
  
endclass

As you can see that there is p_sequencer used in.

  virtual task body();
    ...
      p_sequencer.hi();

Would you please let me know Can I use “p_sequencer” such as p_sequencer.hi();, if I declare “`uvm_declare_p_sequencer(sequencer_1)”?
I can’t find anywhere the “p_sequence” declared in the source code. how can I declare and use that “p_sequencer”?

And one more thing what I’ve got a query about usage of m_sequencer and p_sequencer.
AFAIK, basically, m_sequence is used in sequence class but If i want to manipulate the property of class or method then we need p_sequencer other than m-sequencer.

I found some example but I didn’t get it exactly the usage of p_ and m_sequence and differences.

would you please help me for understanding this?

In reply to UVM_LOVE:

You should never use p_sequencer. It adds unnecessary complexity to your environment and significantly limits reuse.

You can reference m_sequencer if you need to use the config_db(), which is typically the only thing you need from a sequencer.

If you need to reference other sequencer handles in a virtual sequence, maintain sequencer handles in the virtual sequence itself.

In reply to cgales:

In reply to UVM_LOVE:
You should never use p_sequencer. It adds unnecessary complexity to your environment and significantly limits reuse.
You can reference m_sequencer if you need to use the config_db(), which is typically the only thing you need from a sequencer.
If you need to reference other sequencer handles in a virtual sequence, maintain sequencer handles in the virtual sequence itself.

Thanks for letting me know that. I will do that. this question for understading about them.

I’m starting at non-scratch enviroment. someone has implemented with bunch of p_sequence so I need to understand how does it work in the system.

In reply to UVM_LOVE:

Please see the following thread:
https://verificationacademy.com/forums/uvm/psequencer/msequencer

In reply to cgales:

In reply to UVM_LOVE:
You should never use p_sequencer. It adds unnecessary complexity to your environment and significantly limits reuse.
You can reference m_sequencer if you need to use the config_db(), which is typically the only thing you need from a sequencer.
If you need to reference other sequencer handles in a virtual sequence, maintain sequencer handles in the virtual sequence itself.

I’ve got a one more question

I thought that the sequencer call the sequences. that the sequence call sequencer by using p_sequencer. what way is the best approach? AFAIK, sequencer has the only one and multiple sequences are used in the one sequencer.

In reply to cgales:

Hi cgales/dave,

I’m not able to understand that How p_sequencer compromise the reputability?
I need help to understand that.

My impression about sequencers are that we never modify the sequencer. At most sometimes we need to get configuration to access which can be access by config db from test.

So I believe m_sequencer + config db always fulfills the requirements.
Is there any specific case where we have to use p_sequencer?

In reply to Geet:

As I stated above, you should never use p_sequencer, so there is no specific case where you have to use p_sequencer.

In reply to cgales:

Thanks, cgales.

Just one more question inline to that, How dose p_sequencer limits the re-usability?
If you can please help to elaborate more.

In reply to Geet:

As soon as you use a p_sequencer, you are restricting what sequencer your sequences can run on. By not using p_sequencer, you can run your sequences on any appropriately typed sequencer.

In reply to cgales:

In reply to Geet:
As soon as you use a p_sequencer, you are restricting what sequencer your sequences can run on. By not using p_sequencer, you can run your sequences on any appropriately typed sequencer.

Hi cgales,

In case of m_sequencer also we used to provide a path to sequencer in start method.

//From test
task run_phase(uvm_phase phase);
phase.raise_objection(this);
seq.start(env.mem_agnt.sequencer); //path to sequencer
phase.drop_objection(this);
endtask : run_phase

I’m not sure I get this 100% in re-usability term.

In reply to Geet:

Tests are commonly not reusable, because of a diiferent topologies.
WRT to p_sequencer/m_sequencer. This is an option the UVM is offering to you. My professional experience shows it is not a good solution. Dealing with virtual sequences started on a virtual sequencer or a null object is recommended instead. Virtual sequences are in most cases also not reusable.