preet723 Posted May 24, 2012 Report Share Posted May 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
dudi Posted May 24, 2012 Report Share Posted May 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
preet723 Posted May 24, 2012 Author Report Share Posted May 24, 2012 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."" Quote Link to comment Share on other sites More sharing options...
dudi Posted May 24, 2012 Report Share Posted May 24, 2012 This is a very basic principle in OOP, called polymorphism. Perhaps you should search for a brief tutorial of SystemVerilog Quote Link to comment Share on other sites More sharing options...
preet723 Posted May 24, 2012 Author Report Share Posted May 24, 2012 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. Quote Link to comment Share on other sites More sharing options...
dudi Posted May 24, 2012 Report Share Posted May 24, 2012 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! Quote Link to comment Share on other sites More sharing options...
dave_59 Posted May 25, 2012 Report Share Posted May 25, 2012 Maybe this will help: http://verificationacademy.com/forum/verification-methodology-discussion-forum/uvm-forum/22389-psequencer-msequencer Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.