Start a sequence in another sequence using p_sequencer

Hi,

I am working on nested sequences by creating a child sequence in a top sequence(my_sequence) and starting the child sequence using p_sequencer as follows:

class my_sequence extends uvm_sequence #(my_transaction);
  `uvm_object_utils(my_sequence)
  `uvm_declare_p_sequencer(my_sequencer)
  function new(string name = "");
    super.new(name);
  endfunction
  task body;
    child_sequence cseq;
    cseq = child_sequence::type_id::create("cseq");
//    if(! cseq.randomize())
//      `uvm_error("", "Randomization of child sequence failed")
//      cseq.start(m_sequencer, this);
    cseq.start(p_sequencer, this);
  endtask 
endclass : my_sequence

I declared the p_sequencer using uvm_declare_p_sequencer macro but I get the following error saying that my_sequencer should be a valid type:
**Parsing included file ‘my_sequence.svh’.

Error-[SE] Syntax error
Following verilog source has syntax error :
token ‘my_sequencer’ should be a valid type. Please declare it
virtual if it is an Interface.
“my_sequence.svh”, 4 (expanding macro): token is ‘;’
`uvm_declare_p_sequencer(my_sequencer)
^

#0, uvm_declare_p_sequencer(SEQUENCER=my_sequencer) : “/apps/vcsmx/etc/uvm-1.2/src/macros/uvm_sequence_defines.svh”:448
full expansion of macro (uvm_declare_p_sequencer), error at line 1
=>my_sequencer p_sequencer;
virtual function void m_set_p_sequencer();
super.m_set_p_sequencer();
…**
This code works fine if I use m_sequencer, I have one agent in my environment. I am starting the top sequence(my_sequence)in the test class run_phase using the following statement:

seq.start(my_env_h.my_agent_h.my_sequencer_h);

Can you please help!!

In reply to v.siri:

Are you sure that your sequencer class compile before the sequence class? Try using typedef for forward class declaration.

typedef class my_sequencer;
class my_sequence extends uvm_sequence #(my_transaction);
//...

In reply to sharvil111:

Hi,

I tried using typedef. Thanks!!