Accessing sequencer from a Sequence

My environment has a Top Agent which has multiple agents ( sequencer + driver) . How do i get access to the sequencer from the sequence ?

Getting access to the Agents sequencers through the environment pointer is not recommended on most sites.Could you please suggest some different ways i could do this ?

In reply to diptishe:

You should create a base sequence which has handles to all of the sequencers required. Derive all of your sequences from this base sequence. When you create your sequence in the test, assign all of the sequencer handles prior to starting the sequence.

In sequence you will have a pointer m_sequencer(uvm_sequncer_base handle), which will point to the sequencer on which the sequence is started, using that pointer we can access the properties & methods of sequencer inside the sequence.



class ahb_sequence extends uvm_sequence#(ahb_xtn);

  task body();
    m_sequencer.lock();// m_sequencer points to the sequencer on which ahb_sequence is                   
                      //started i.e., ahb_sequencer
     ....
  endtask

endclass



Regards,
Shanthi
www.maven-silicon.com

In reply to diptishe:

My environment has a Top Agent which has multiple agents ( sequencer + driver) . How do i get access to the sequencer from the sequence ?
Getting access to the Agents sequencers through the environment pointer is not recommended on most sites.Could you please suggest some different ways i could do this ?

Could you please explain which sequencer you want to access.

In reply to chr_sue:

All the sub Agent sequencers.

In reply to diptishe:

You have to declare the handles of the sub-sequencers in the top sequencer and you can connect them in the topology because they have a well-defined position in your hierarchy.

In reply to chr_sue:

Don’t do this. You never want to extend the uvm_sequencer as it limits the reuse of your environment. As I said earlier, put the sequencer handles in a base sequence and assign the handles when the sequence is created. You can then utilize the sequencer handles as required directly in the sequence.

In reply to shanthi:

In sequence you will have a pointer m_sequencer(uvm_sequncer_base handle), which will point to the sequencer on which the sequence is started, using that pointer we can access the properties & methods of sequencer inside the sequence.


class ahb_sequence extends uvm_sequence#(ahb_xtn);
task body();
m_sequencer.lock();// m_sequencer points to the sequencer on which ahb_sequence is                   
//started i.e., ahb_sequencer
....
endtask
endclass

Regards,
Shanthi
www.maven-silicon.com

Hi Shanti,

From my understanding m_sequencer points todefault sequencer i.e uvm_sequencer_base. In order to get access to any other sequencer component we need p_sequencer and then type cast it?


class ahb_sequence extends uvm_sequence#(ahb_xtn);
  ahb_sequencer p_sequencer;

 task pre_body();
  $cast(p_sequncer, m_sequencer);
 endtask
  
  task body();
    m_sequencer.lock();// m_sequencer points to the sequencer on which ahb_sequence is                   
                      //started i.e., ahb_sequencer
     ....
  endtask
 
endclass

In reply to UVM_SV_101:

hi UVM_SV_101,

I think you might want to refer to the uvm cookbook for the sequencer/sequence relation:
https://verificationacademy.com/cookbook/sequences/api#The_m_sequencer_Handle

In reply to UVM_SV_101:

In reply to shanthi:
Hi Shanti,
From my understanding m_sequencer points to default sequencer i.e uvm_sequencer_base. In order to get access to any other sequencer component we need p_sequencer and then type cast it?


class ahb_sequence extends uvm_sequence#(ahb_xtn);
ahb_sequencer p_sequencer;
task pre_body();
$cast(p_sequncer, m_sequencer);
endtask
task body();
m_sequencer.lock();// m_sequencer points to the sequencer on which ahb_sequence is                   
//started i.e., ahb_sequencer
....
endtask
endclass

yes m_sequencer is a handle of uvm_sequencer_base present inside the uvm_sequence.

When we start the sequence,the m_sequencer inside the sequence will point to the sequencer on which the sequence is started.


ex:

class test extends uvm_test;
 ....
  task run_phase(uvm_phase phase);

    ahb_seq seq = ahb_seq::type_id::create("seq");
    seq.start(env.agt_top.ahb_agt.ahb_seqr);
    // with this the m_sequencer will point to ahb_seqri.e.,seq.m_sequencer =env.agt_top.ahb_agt.ahb_seqr
  endtask

endclass

so with m_sequencer, we can access the methods of the sequencer, but we can’t access the properties of sequencer using m_sequencer, to access the properties of sequencer inside the sequence we should declare the sequencer handle inside the sequence & cast it with m_sequencer as shown below.


class ahb_sequence extends uvm_sequence;

  ahb_sequencer seqr;
  ...
  task body();
    assert($cast(seqr,m_sequencer))
    //by casting local seqr will point to ahb_sequencer inside the agent using which we can access the properties of sequencer class
   ...
  endtask
endclass

Regards,
shanthi
www.maven-silicon.com

In reply to shanthi:

Ahh learned something new today. Thank you for the explanation.