Null Object Access

Hi,

I am getting an error - Null Object Access when I am trying to assign the virtual interface in the driver component for the verification of APB Protocol.

class apb_driver extends uvm_driver #(apb_seq_item);
	`uvm_component_utils(apb_driver)
	
	virtual apb_interface apb_intf;
	apb_agent_config apb_agent_cfg;
	apb_seq_item apb_seq_item_h;
	
	function new(string name = "apb_driver", uvm_component parent = null);
	    super.new(name,parent);
	endfunction
	
	virtual function void build_phase(uvm_phase phase);
            apb_agent_cfg =  apb_agent_config :: type_id :: create("apb_agent_cfg",this);
      
            if (!uvm_config_db#(apb_agent_config)::get(this, "", "apb_agent_cfg", apb_agent_cfg)) begin
                `uvm_fatal("APB/DRV/NOCONFIG", "No config specified for driver ")
            end		
	endfunction
	
	virtual function void connect_phase(uvm_phase phase);
	    apb_intf = apb_agent_cfg.apb_intf;
	endfunction
	
	virtual task run_phase(uvm_phase phase);
...
...

The error is at the line

apb_intf = apb_agent_cfg.apb_intf;

Can someone please point out how to resolve the error?

In reply to prithvinkumble:

Here you declared virtual interface.but it doesn’t not points to any physical interface. you need to get ‘apb_if’ from top module where it is set by using uvm_config_db.

In reply to prithvinkumble:

When you called
uvm_config_db#(apb_agent_config)::get()
, it is possible you set() it with null handle. Then apb_agent_cfg would be null.

BTW, there is no need to call apb_agent_config::create() if you are required to get it out of the umm_config_db anyways.