Jump to content

derived sequencer and derived sequence. Confusion how to get sequencer handle


Recommended Posts

hi experts,

Please help me figure out this.

Also please pardon the syntax. Just trying to write the logic here.

1) i have class my_seqr derived from uvm_sequencer;

class my_seqr extends uvm_sequencer;

2) class my_sequence_item derived from uvm_sequence_item;

Now in agent i have created the sequencer using create method.

class my_agent extends uvm_agent;

my_seqr seqr;

seqr = my_seqr::type_id::create("seqr") // ignore syntax please

The problem is, inside my_sequence_item i want to point to "seqr" object. How can i do this.

example:

class my_sequence_item extends uvm_sequence_item;

my_seqr local_seqr;

now i want local_seqr to point to seqr in agent class.

I know m_sequencer handle to uvm_sequencer is there in UVM, but that is for uvm_sequencer class and not for my_seqr derived class.

To be honest one of my friends did this:

$cast( local_seqr, m_sequencer) and it works, but i dont understand how local_seqr derived class sequencer handle can be pointed to m_sequencer handle which is base class handle and pointing to base uvm_sequencer in uvm.

Am i missing something in how m_sequencer works ?

Please help.

much thanks.

Link to comment
Share on other sites

Use the `uvm_declare_p_sequencer macro in your sequence. It will generate a handle to your sequencer with the type you want.

If you also need to have access to the sequencer in your sequence items, simple provide this handle (p_sequencer) to them from the sequence that generates them.

Link to comment
Share on other sites

thanks dudi,

In my above post i mentioned that $cast as listed also works. Can you please explain me how ?

""$cast( local_seqr, m_sequencer) and it works, but i dont understand how local_seqr derived class sequencer handle can be pointed to m_sequencer handle which is base class handle and pointing to base uvm_sequencer in uvm.""

Link to comment
Share on other sites

i know polymorphism, but perhaps you didn't get my question :(

base class handle can point to derived class handle but not vice versa (with one exception)

$cast(local_seqr, m_sequencer) here its derived class handle pointing to parent m_sequencer handle.

may be i am missing another basic thing.

Link to comment
Share on other sites

Since the actual type of the sequencer is my_seqr (derived from uvm_sequencer), and m_sequencer is a handle of type uvm_sequencer, you can use the dynamic cast ($cast) to produce a handle of the derived class type from the handle of the parent class type.

Maybe I'm not explaining it well, or maybe we don't not fully understand each other... Perhaps someone else can provide a better explanation.

Good luck!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...