can someone tell me if i want to send an object via config_db, does is matter if i new() it before or after config_db set()?
When i ran my code. i found if i do config_db set(), then do new(), then do config_db get(), will report ERROR: null pointer dereference.
But in my understanding, config_db just set and get the handle of an object, if i new() the object later than config_db set(), the handle will also point to the instance, after then do config_db get(), the another handle should point to that instance, too.
Can anyone explain what's wrong with my understanding? thanks!
Below code is for describing the problem, not exactly my code:
class my_object extends uvm_object;
int par1 = 1;
class my_sequence extends uvm_sequence;
if(!uvm_config_db#(my_object)::get(null,get_full_name(), "my_obj", my_obj))
seq_par = my_obj.par1 ; //if i new my_obj at location 2, will report error: null pointer dereference at here ~~~~~~~~~~~~~~~~~
class base_test extends uvm_test;
my_obj = new(); // location 1. if i new it before config_db set, everything is ok
uvm_config_db#(my_object)::set(null,"*", "my_obj", my_obj);
//my_obj = new(); //location 2. if i new it after config_db set, will report null pointer dereference in my_seq