Uvm_config_db and the mysterious build phase group

I have various issues with the following code example.

  1. I have explicitly used the methods of uvm_config_db class in separate phases because the get method blocks and the $display statements after it are not executed.
  2. this.get_full_name() does not give me a complete path! Can someone also tell me what will my paths be?

to run


import uvm_pkg::*;
class animal extends uvm_component;
         // registration
	`uvm_component_utils(animal);
	
	string your_name;    // local variable where I want to pass my name

	function new(string name, uvm_component parent);
		super.new(name, parent);
	endfunction

        // as mentioned above if I used build_phase method it shows undefined behavior
	function void end_of_elaboration_phase(uvm_phase phase);

		super.end_of_elaboration_phase(phase);
		assert(uvm_config_db#(string)::get(null,"", "name", your_name)); 

		// in case of build_phase method the following lines don't execute
                $display("hello %s", your_name);
	        $display(this.get_full_name());    // prints the path animal_h1
	
	endfunction

endclass

class test extends uvm_test;
         // registration
	`uvm_component_utils(test)
	animal animal_h1;

	function new(string name="", uvm_component parent = null);
		super.new(name, parent);
	endfunction
	
	function void build_phase(uvm_phase phase);
		super.build_phase(phase);

                // create an instance
		animal_h1 = animal::type_id::create("animal_h1", null);

		uvm_config_db#(string)::set(null, "*", "name", "wajahat"); 

		$display(this.get_full_name());       // prints the path uvm_test_top
	endfunction

endclass

module none;

initial begin

	run_test("test");
	
end

endmodule

In reply to wajahatriaz:

Your problem is when you construct the animal component, you pass a null parent handle. The build_phase executes top-down. After executing the build_phase of test, it executes the build_phases of all its children. But since you did not pass this(which is a handle to the test instance), it never executes the build_phase of animal. With a null parent, animal becomes an orphan component which is why get_fullname only shows “animal_h1”.

Change this line to

animal_h1 = animal::type_id::create("animal_h1", this);

BTW, the uvm_config_db::get is a function call, not a blocking task.

In reply to dave_59:

Dave I also need to understand a few more things. I see that some people use uvm_root::get(), null, “*” and “” as arguments in these methods and I’m often unable to understand how these translate into. Can you tell me about them as well?

In reply to wajahatriaz:

See

https://verificationacademy.com/verification-horizons/november-2014-volume-10-issue-3/Please-Can-Someone-Make-UVM-Easier-to-Use

https://www.verilab.com/files/configdb_dvcon2014_1.pdf

In reply to dave_59:

Thanks again Dave :)

In reply to dave_59:

Dave, I agree with what you stated and it solved my problem and now I’m able to grasp it. I still have another query. As you stated that the build_phase never gets executed, but why do the other phases work? In my example, I have used end_of_elaboration_phase and it works.

In reply to wajahatriaz:

The UVM build_phase traverses the component hierarchy as uvm_components are in the process of being constructed. If they are not put into the child hierarchy, they might be skipped. By the end of build_phase, all components have been constructed and any traversal method will iterate over all components.

In reply to dave_59:

Thank you Dave.