Hi,
I’m trying to understand uvm_config_db() behavior, so I added it into my simple UVM example which has been in No Problem for simulation.
But I got NULL pointer dereference. error after run simulation with uvm_config_db().
I just added one apb_master_config class.
class apb_master_config extends uvm_object;
`uvm_object_utils(apb_master_config)
virtual apb_interface apb_if;
function new (string name = "");
super.new(name);
endfunction
uvm_active_passive_enum active = UVM_ACTIVE;
endclass
and I added into my test class as the below
class apb_basic_test extends uvm_test;
`uvm_component_utils_begin(apb_basic_test)
`uvm_component_utils_end
apb_master_config m_cfg;
apb_master_environment apb_environment;//evironment handle
apb_sequence seq;//sequence handle
function new(string name="apb_basic_test", uvm_component parent);
super.new(name,parent);
`uvm_info(get_type_name(),"the objection test object has been built",UVM_LOW);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db #(apb_master_config)::set(null, "*", "apb_master_config", m_cfg);
apb_environment = apb_master_environment::type_id::create("apb_environment",this);
seq = apb_sequence::type_id::create("seq", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
`uvm_info(get_type_name(),"the connect phase of the basic_test completed", UVM_LOW)
endfunction
virtual task run_phase(uvm_phase phase);
super.run_phase(phase);
phase.raise_objection(this);//raise objection
seq.start(apb_environment.apb_agent.sequencer);
phase.drop_objection(this);//drop objection
endtask
This is Agent
class apb_master_agent extends uvm_agent;
apb_master_config m_cfg;
apb_sequencer sequencer;
apb_master_driver driver;
apb_monitor monitor;
`uvm_component_utils(apb_master_agent)
function new(string name="apb_master_agent", uvm_component parent);
super.new(name,parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db #(apb_master_config)::get(null, "*", "apb_master_config", m_cfg))
`uvm_fatal("FATAL MSG", "Configuration object is not set properly")
`uvm_info(get_type_name(), $psprintf("agent is: %s", m_cfg.active),UVM_LOW) //<== Here m_cfg make NULL pointer dereference
`uvm_info(get_type_name(), $psprintf("vif: %p", m_cfg.apb_if), UVM_LOW) //<== Here m_cfg make NULL pointer dereference
/// Monitor will Always Be Available ///
monitor=apb_monitor::type_id::create("monitor",this);
if(monitor==null)
`uvm_fatal(get_type_name(),"the monitor has not beed built");
/// Driver & Sequencer will be Implemented only in ACTIVE mode
if(m_cfg.active == UVM_ACTIVE) begin //<== Here m_cfg make NULL pointer dereference
driver=apb_master_driver::type_id::create("driver",this);
sequencer=apb_sequencer::type_id::create("sequencer", this);
if(sequencer==null)
`uvm_fatal(get_type_name(),"the sequecer has not been built");
if(driver==null)
`uvm_fatal(get_type_name(),"the driver has not been built");
`uvm_info(get_type_name(), "UVM is PASSIVE", UVM_LOW);
endfunction
If I use m_cfg like `uvm_info(get_type_name(), $psprintf(“agent is: %s”, m_cfg.active),UVM_LOW) then I got Null point Error at the starting simulation.
I think uvm_config_db setting no problem, But still I get the Null point Error about m_cfg.
Would you please help me to understand why does it make NULL point error at the starting simulation?
If I commented all about m_cfg, then there is no problem. simulation is done as well.