Jump to content

class invoke itself


Recommended Posts

Hi,

I saw a code like this:

class xxx_register extends uvm_component;

.......

xxx_register m_root;

xxx_register m_parent;

xxx_register m_children[$];

endclass

I was confused by this. How can you define/use a class in itself as "xxx_register m_root/parent/children" in xxx_register? This seems not a static function. thanks.

regards

Link to comment
Share on other sites

thanks dave. This presetation clarifies the structure and its function. I still have a question on it: how can you implement this structure in "true life"? You defined a class and in this class you use it, which seems a infinitive loop. Maybe they are in fact pointers? e.g. in my post before, I guess although m_root/parent/children is defined as class xxx_register instance, they are not an instance of xxx_register but a pointer to xxx_register. did I understand right? thanks

Link to comment
Share on other sites

Yes, m_root/parent/children are not instances of xxx_register, they are class variables that will contain handles that reference class instances of xxx_register. SystemVerilog does not have pointers like in C/C++. A pointer is an address that references a location in a uniform memory. A handle is an abstract concept that references a particular class instances. There is no way to see the value of a handle; you can only see what it references.

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...