chenyong Posted January 8, 2013 Report Share Posted January 8, 2013 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 Quote Link to comment Share on other sites More sharing options...
dave_59 Posted January 8, 2013 Report Share Posted January 8, 2013 This is how you build a linked data structure. See http://www.slideshare.net/geeksrik/trees-data-structures-in-cjava. This seems to be redundant as uvm_component already these class members. Quote Link to comment Share on other sites More sharing options...
chenyong Posted January 8, 2013 Author Report Share Posted January 8, 2013 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 Quote Link to comment Share on other sites More sharing options...
dave_59 Posted January 8, 2013 Report Share Posted January 8, 2013 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. Quote Link to comment Share on other sites More sharing options...
chenyong Posted January 8, 2013 Author Report Share Posted January 8, 2013 thanks for your kind reply. 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.