I have various issues with the following code example.
- 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.
- 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