Config_db set/get is not working properly

Hi,
can some one tell me the reason why I’m not able to access the signal in driver. When I’m using config_db set and get in test case and driver respectively

class configknobs extends uvm_componet ;
`uvm_object_utils(test_soft_rst_gear_box_confgknob)

function new(string name = "configknobs ", uvm_component parent=null);
super.new(name, parent);
endfunction : new
constraint bypass_gr_bx_c {bypass_gear_box ==0;}
constraint tx_sync_headr_c {tx_sync_header_i ==0;}

endclass : configknobs

in test case :
class testing extends configknobs;
constraint bypass_gr_box_c {bypass_gear_box ==0;}
constraint tx_sync_header_c {tx_sync_header_i ==0;}
endclass :testing

class normal_test extends uvm_test;
env env_0;
configknobs cfg;
`uvm_component_utils(normal_test)

extern function new(string name=“normal_test”,uvm_component parent=null);
extern function void build_phase(uvm_phase phase);
extern task run_phase(uvm_phase phase);
endclass : normal_test

function normal_test::new(string name=“normal_test”,uvm_component parent=null);
super.new(name,parent);
endfunction

function void normal_test::build_phase(uvm_phase phase);
super.build_phase(phase);
env_0 = env::type_id::create(“env_0”,this);
cfg = configknobs::type_id::create(“cfg”,this);
factory.set_inst_override_by_name(“testing”,“configknobs”,“");
$display(“before set:”);
uvm_config_db#(configknobs)::set(this,"uvm_test_top
”,“cfg”,cfgs);
$display(“after set:”);
endfunction

task normal_test::run_phase(uvm_phase phase);
normal_seq seq;
phase.raise_objection(this);
seq = normal_seq::type_id::create(“seq”,this);
seq.start(env_0.agnt.sqr);
phase.drop_objection(this);
endtask

driver_part:

class driver extends uvm_driver#(sequence_item);
configknobs cfg;
sequence_item item;
uvm_blocking_put_port#(local_trans) driver_put_port;

`uvm_component_utils(driver)

extern function new(string name=“driver”,uvm_component parent=null);
extern virtual function void build_phase(uvm_phase phase);
extern virtual task run_phase(uvm_phase phase);
endclass:driver

function driver::new(string name=“driver”,uvm_component parent=null);
super.new(name,parent);
endfunction:new

function void driver::build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_type_name(),“DRIVER-BUILD_PHASE”,UVM_LOW)

cfg = confgknobs::type_id::create(“cfg”,this);
driver_put_port = new(“driver_put_port”,this);
uvm_config_db#(configknobs)::get(null,“”,“gr_cfg”,gr_cfg);
endfunction : build_phase

task driver::run_phase(uvm_phase phase);
uvm_resource_db#(gear_box_confgknobs)::dump();
$display(“before get :”);
if( uvm_config_db#(gear_box_confgknobs)::get(null,“”,“gr_cfg”,gr_cfg))
$display(“BBBB”);
else $stop;
forever
begin

end
endtask:run_phase

out-put observations :
i can able to see the following statements as :
before set: → statement from test case
after set: → statement from test case
before get : ->statement from driver
here im expecting statement as BBBB
instead of that im getting into else part

can any one give me the valuable comments on the above example

-sivajsyamm

The first argument to get() and set() is the context of the call. You need to use the appropriate context to ensure that the get()/set() calls are applied correctly. Using ‘null’ in your get() call will cause things not to get applied correctly.

Please review the UVM Cookbook for the config_db.

In reply to cgales:

Hi cgales,
while using the get we can use either Null or this.
any way i tried both this is not working on both scenarios

-sivajsyamm

In reply to sivasyammj:

You need to be using ‘this’ inside your environment. The only time you would use ‘null’ is when you are outside of the UVM environment, such as you HDL testbench.

Also, you need to ensure all set() calls are done prior to any create() calls. You are calling create() for your environment before you set() the configknobs.

In reply to cgales:

i have question! with out allocation how it will understand the set/get ?

In reply to sivasyammj:

The set() and get() calls store and retrieve the information in the configuration database that is independent of your UVM environment. You use the set() function to store your objects into this database, and the get() function will query the database. These get() calls are normally made in the build(), so you should have everything set() prior to calling the sub-components create().

In reply to cgales:

if we call both set and get in body of different class there can be a chance to execute get ?
i tried this thing so that i kept my get in run_phase

In reply to sivasyammj:

You really need to read and understand the link that I posted above concerning the use of the config_db. You need to use the API in the appropriate regions (normally the build phase), as well as understand the inst_name and field_name.

After looking at your code even more, besides having the set() after the create(), you also have issues with your inst_name in your set() call (uvm_test_top is the name given to the test instance itself. You want to specify the sub-hierarchy. Try “*” at first, then scope appropriately after that works). Additionally, you are using “cfg” as the field_name in your set() call, but “gr_cfg” in your get() calls. Also, you never call set() for a type of gear_box_confgknobs, so the get() will fail.