# Null Object Access

**URL:** <https://verificationacademy.com/forums/t/null-object-access/32854>\
**Category:** UVM\
**Tags:** Null-Object-Access, UVM\
**Created:** [February 14, 2017, 3:01am UTC](https://verificationacademy.com/forums/t/null-object-access/32854 "2017-02-14T03:01:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prithvinkumble](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/59ef9b/32.png) [@prithvinkumble](https://verificationacademy.com/forums/u/prithvinkumble)\
**Post date:** [February 14, 2017, 3:01am UTC](https://verificationacademy.com/forums/t/null-object-access/32854/1 "2017-02-14T03:01:06Z")

</div>

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.

```auto
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

```auto
apb_intf = apb_agent_cfg.apb_intf;

```

Can someone please point out how to resolve the error?

---

<div class="post-metadata">

**Author:** ![hussi410](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/c5a1d2/32.png) [@hussi410](https://verificationacademy.com/forums/u/hussi410)\
**Post date:** [February 14, 2017, 6:14am UTC](https://verificationacademy.com/forums/t/null-object-access/32854/2 "2017-02-14T06:14:05Z")

</div>

_In reply to [prithvinkumble](https://verificationacademy.com/forums/t/null-object-access/32854):_

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.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [February 14, 2017, 6:23am UTC](https://verificationacademy.com/forums/t/null-object-access/32854/3 "2017-02-14T06:23:34Z")

</div>

_In reply to [prithvinkumble](https://verificationacademy.com/forums/t/null-object-access/32854/2):_

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.
