MalkAce Posted January 3, 2011 Report Share Posted January 3, 2011 I face a problem which I believe is not so rare. I pass the string variable name to member objects (of other class) in new function of my data class. When I use create() method to create the objects of my data, only the default value of name (upper_object) is passed down into the object. I've realized this is due to the implementation of create_object() method where we call new() without any arguments and then explicitly call set_name() method to set the name variable. Q. Is there any specific need to call the new method without any argument when we have already access to the name string in create_object method ? class lower_object; rand int data ; string name; function new(string name=""); this.name=name; endfunction: new endclass: my_object class upper_object extends uvm_object; lower_object lowerO; function new(string name="upper_object"); super.new(name); lowerO=new(name);//This always gets the value 'upper_object' endfunction: new endclass: upper_object module Top; upper_object upperO; initial begin upperO=upper_object::type_id::create("TestStream1"); // what create_object does is: //upperO=new; //No argument passed //upperO.set_name(name); end endmodule: Top I would be glad to see a change in implementation coming along this line in the future, but would like to know what is the best way to get this thing going for now. Presently I override the set_name() function of upper_object to assign name field of member lowerO with the updated value. Thanks, Malkesh Quote Link to comment Share on other sites More sharing options...
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.