In UVM, I want to create two objects as below in a build_phase. Both have same name argument but parent argument is different. What will happen? Is it allowed to do?
It is allowed, but very unusual. When creating any hierarchy, siblings cannot have the same name. This is just like files and directory names.
The UVM has no way of knowing if the class variable holding the handle to the component has the same identifier name as the strings passed to the constructor. It also has no way of knowing if the class variables have the same hierarchy as the hierarchy passed to constructor. For debugging, it is best to keep them the same.
It appears that the obj_b has the same leaf level name as obj_a, but they are placed in a different hierarchy. In that sense, they are not really siblings. So in my opinion, this should be perfectly legal, but may not adhere strictly to paradigms of object oriented design.
I think you are talking about different string name argument in constructor new and while creating component using create.
I am talking about providing different parent argument(second argument in create method call) in two different components while string name argument(first argument in create method call) is same for both objects.
I think was are saying the same thing. But I’ll add that SystemVerilog has no built-in concept of owner relationships. A class object has no knowledge of which object created it unless the user defines a database structure that contains that information, which is what uvm_component does.