I was investigating your problem in some more detail.
Replacing the argument ‘this’ with ‘null’ should result in a bad reference fatal error.
Could you provide your example on EDAPlayground, please.
When you call run_test(), UVM creates a single instance of your test as uvm_test_top. The UVM scheduler only knows of this one top-level instance and calls all of the phases on this top-level module and child components.
If you create() another component outside of this hierarchy, UVM can’t just restart these phases on an new top-level.
Why are you trying to create a component outside of the uvm_test_top hierarchy? Is there a problem you are trying to solve?
I was curious to try a code with parent component as null so that it becomes a child of uvm_root .
I understand that typically there is only one top-level instance i.e uvm_test_top .
However components created with parent argument as null before calling run_test ,
are a top level component too i.e There are 2 top-level instances
uvm_test_top and the the component created before run_test .
Your suggestion on “UVM can’t just restart these phases on an new top-level” is a start .
Given that build_phase operates depth-first the instance_name decides the exact order of calling build_phase .
Changing the instance_name to “zase_h” ensures that build_phase() does execute .
My understanding for now is that Lexicographical ordering impacts the Output .
As “z” occurs after “u” , build_phase() executes
whereas as “b” occurs before “u” , the scheduler has moved past “u” by then , so it doesn’t execute .
To have a deeper understanding I might need to debug the source code
You are correct. The uvm_root maintains a list of children. “uvm_test_top” is one of these that is created by run_test(). You can also create other top level instances at the testbench, or as you are doing, in the build_phase(). However, the list of children in uvm_root is iterated over by name, so if you create an instance that is named alphabetically before the current instance, the build_phase() won’t be called.
Additionally, the follow on phases will be called on all of the top level instances, so in your case where you create a component that is alphabetically before ‘uvm_test_top’, the connect_phase() will be called even though the build_phase() wasn’t.