Accessing sequencer from a Sequence

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