I have the following class:
class cfg_c extends uvm_object;
string m_foo;
`uvm_object_utils_begin(my_pkg::cfg_c)
`uvm_field_string(m_foo, UVM_ALL_ON)
`uvm_object_utils_end
function new(string name="cfg");
super.new(name);
endfunction : new
endclass : cfg_c
The cfg_c class declares a config string called m_foo, which is assigned in the config_db by the testbench top as follows:
module tb_top;
...
function pre_run_test();
uvm_config_db #(string)::set(null, "*", "m_foo", "Hello world.");
endfunciton : pre_run_test
...
endmodule tb_top
My test class is able to access that config string, but the cfg class is not. When do UVM object classes assign their config string/int/object variables?
class base_test extends uvm_test;
string m_foo;
my_pkg::cfg_c cfg;
`uvm_component_utils_begin(my_pkg::env_c)
`uvm_field_string(m_foo, UVM_ALL_ON)
`uvm_compoennt_utils_end
function new(string name="env", uvm_component parent);
super.new(name);
endfunction : new
virtual function void build_phase(uvm_phase phase);
this.cfg = my_pkg::cfg_c::type_id::create("cfg");
$display("test.m_foo = '%s'", this.m_foo);
$display("test.cfg.m_foo = '%s'", this.cfg.m_foo);
endfunction : build_phase
...
endclass : base_test
The first display statement prints "Hello world." to stdout. The second display statement shows an empty string. What am I missing?