# "NULL pointer dereference" Error!

**URL:** <https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117>\
**Category:** OVM\
**Tags:** OVM\
**Created:** [November 22, 2010, 8:25am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117 "2010-11-22T08:25:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxchit](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/z/85e7bf/32.png) [@zxchit](https://verificationacademy.com/forums/u/zxchit)\
**Post date:** [November 22, 2010, 8:25am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117/1 "2010-11-22T08:25:54Z")

</div>

Hi, all  
I met an issue as following, can anyone help me?

OVM\_INFO @ 0.00 ns: ovm\_test\_top [ovm\_test\_top] Starting loop 0, equidistant traffic on LL and BE ports, sweep traffic on GT ports  
SDI/Verilog Transaction Recording Facility Version 09.20-s011

Error! NULL pointer dereference  
File: …/ovc/mtl/ip\_fusion\_2055\_2034\_mtl\_monitor\_class.sv, line = 56, pos = 43  
Scope: ip\_fusion\_2055\_2034lib.$unit\_0x36acc8fa::ip\_fusion\_2055\_2034\_mtl\_monitor\_c#(128,10,32,16,7,8)@15665\_3.run  
Time: 0 FS + 20

…/ovc/mtl/ip\_fusion\_2055\_2034\_mtl\_monitor\_class.sv:56 @(posedge bus\_if\_wrap.bus\_if.clk);  
ncsim\> if { $env(abv) == “ABV\_ON” } {

> ```
> assertion -summary -directive assert -redirect assertion.log
> assertion -summary -directive assert
> 
> ```
> 
> }  
> ncsim\> exit  
> TOOL: irun 09.20-s011: Exiting on Nov 22, 2010 at 16:08:19 CST (total: 00:00:50)

Parts of monitor class code is as following, and lines with red color is line 56:

virtual class ip\_fusion\_2055\_2034\_mtl\_monitor\_c #(int d\_w = 32,  
int id\_w = 8,  
int addr\_w= 32,  
int str\_w = 8,  
int bs\_w = 8,  
int lns\_w = 8) extends ip\_fusion\_2055\_2034\_base\_monitor\_c;  
// local variables  
local int d\_w\_log;  
int wdc;  
int rdc;  
int account, account\_peak;  
int bw;  
bit peak\_en;  
int pend;  
real clk\_per;  
ip\_fusion\_2055\_2034\_mtl\_if\_wrap\_c #(.d\_w ( d\_w ),  
.id\_w ( id\_w ),  
.addr\_w( addr\_w),  
.str\_w ( str\_w ),  
.bs\_w ( bs\_w ),  
.lns\_w ( lns\_w )) bus\_if\_wrap;

```
`ovm_component_param_utils_begin(ip_fusion_2055_2034_mtl_monitor_c #(d_w,id_w,addr_w,str_w,bs_w,lns_w))
  `ovm_field_int (account, OVM_ALL_ON)
  `ovm_field_int (account_peak, OVM_ALL_ON)
  `ovm_field_int (pend, OVM_ALL_ON)
  `ovm_field_int (bw, OVM_ALL_ON)
  `ovm_field_int (peak_en, OVM_ALL_ON)
  `ovm_field_object(bus_if_wrap, OVM_ALL_ON)
`ovm_component_utils_end
// Constructor
function new(string name, ovm_component parent);
    int j = d_w / 8;
    super.new(name, parent);
    wdc = 0;
    rdc = 0;
    d_w_log = 0;
    bw = 0;
    peak_en = 1'b0;
    while (j > 1) begin
        d_w_log++;
        j >>= 1;
    end
endfunction : new
// run function
virtual task run();
    pend = 0;
    account = 0;
    account_peak = 0;
    fork
        begin

```

@(posedge bus\_if\_wrap.bus\_if.clk); clk\_per = $realtime;  
@(posedge bus\_if\_wrap.bus\_if.clk);  
clk\_per = $realtime - clk\_per;  
end  
forever begin  
@(posedge bus\_if\_wrap.bus\_if.clk);  
if (bus\_if\_wrap.bus\_if.cmd\_valid && bus\_if\_wrap.bus\_if.cmd\_accept) begin  
if (pend == 0) begin  
void’(get\_config\_int(“bw”, bw));  
void’(get\_config\_int(“peak\_en”, peak\_en));  
end  
pend += (bus\_if\_wrap.bus\_if.cmd\_block\_size + 1) \* (bus\_if\_wrap.bus\_if.cmd\_lines + 1);  
end  
if (bus\_if\_wrap.bus\_if.rd\_valid) begin  
pend–;  
account = (account \> 100) ? account - 100 : 0;  
end  
if (bus\_if\_wrap.bus\_if.wr\_accept) begin  
pend–;  
account = (account \> 100) ? account - 100 : 0;  
end  
if (pend \> 0 && !account[31])  
account += bw;  
else if (pend == 0)  
account = 0;  
account\_peak = peak\_en && (account \> account\_peak) ? account : account\_peak;  
end  
super.run();  
join  
endtask : run

---

<div class="post-metadata">

**Author:** ![Vaibhav\_Tekale](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/vaibhav_tekale/32/2015_2.png) [@Vaibhav\_Tekale](https://verificationacademy.com/forums/u/Vaibhav_Tekale)\
**Post date:** [November 22, 2010, 10:32am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117/2 "2010-11-22T10:32:35Z")

</div>

Hi,

Can you please make sure that you are passing “bus\_if\_wrap” class instance using set\_config\_object(“\*”,“bus\_if\_wrap”, bus\_if\_wrap, **0** ); from testbench file.

Here “0” will pass the handle.

Hope this will resolve the issue.

Thanks,  
Vaibhav

---

<div class="post-metadata">

**Author:** ![zxchit](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/z/85e7bf/32.png) [@zxchit](https://verificationacademy.com/forums/u/zxchit)\
**Post date:** [November 24, 2010, 7:43am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117/3 "2010-11-24T07:43:52Z")

</div>

Hi, Vaibhav Tekale,

Thanks for you reply. But I have done this in testbench like this:

* * *

```
initial begin

  // connect virtual interface to IF Agent(s)
  set_config_object("*.if_agent0" , "bus_if_wrap", if_interface0_wrapper, 0);
  set_config_object("*.if_agent1" , "bus_if_wrap", if_interface1_wrapper, 0);
  set_config_object("*.if_agent2" , "bus_if_wrap", if_interface2_wrapper, 0);
  set_config_object("*.if_agent3" , "bus_if_wrap", if_interface3_wrapper, 0);
  set_config_object("*.if_agent4" , "bus_if_wrap", if_interface4_wrapper, 0);
  set_config_object("*.if_agent5" , "bus_if_wrap", if_interface5_wrapper, 0);
  set_config_object("*.if_agent6" , "bus_if_wrap", if_interface6_wrapper, 0);
 
  // connect virtual interface to QU Agent(s)
  set_config_object("*.qu_agent0_0" , "bus_if_wrap", qu_interface0_0_wrapper, 0);
  set_config_object("*.qu_agent1_0" , "bus_if_wrap", qu_interface1_0_wrapper, 0);
  set_config_object("*.qu_agent2_0" , "bus_if_wrap", qu_interface2_0_wrapper, 0);
  set_config_object("*.qu_agent3_0" , "bus_if_wrap", qu_interface3_0_wrapper, 0);
  set_config_object("*.qu_agent4_0" , "bus_if_wrap", qu_interface4_0_wrapper, 0);
  set_config_object("*.qu_agent5_0" , "bus_if_wrap", qu_interface5_0_wrapper, 0);
  set_config_object("*.qu_agent6_0" , "bus_if_wrap", qu_interface6_0_wrapper, 0);

  // Start the test... 
  run_test();

```

end

* * *

The issue is still exist :(

> Hi,  
> Can you please make sure that you are passing “bus\_if\_wrap” class instance using set\_config\_object(“\*”,“bus\_if\_wrap”, bus\_if\_wrap, **0** ); from testbench file.  
> Here “0” will pass the handle.  
> Hope this will resolve the issue.  
> Thanks,  
> Vaibhav

---

<div class="post-metadata">

**Author:** ![Vaibhav\_Tekale](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/vaibhav_tekale/32/2015_2.png) [@Vaibhav\_Tekale](https://verificationacademy.com/forums/u/Vaibhav_Tekale)\
**Post date:** [November 24, 2010, 8:46am UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117/4 "2010-11-24T08:46:42Z")

</div>

Can you please try using get\_config\_object method in the respective agents.

Also, can you please make sure that you are calling the super.build() method in agent, and also you have done the factory registration for all components.

Regards,  
Vaibhav

---

<div class="post-metadata">

**Author:** ![venkateshragala](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/fbc32d/32.png) [@venkateshragala](https://verificationacademy.com/forums/u/venkateshragala)\
**Post date:** [November 24, 2010, 7:45pm UTC](https://verificationacademy.com/forums/t/null-pointer-dereference-error/27117/5 "2010-11-24T19:45:51Z")

</div>

Also Make sure that you connect to the interface handle that you’re getting from the get\_config, So that there will be connection between the interface that you’re using in your agent and the physical interface which you connect @ tb\_top.

Hope this helps.

-Venky

> Can you please try using get\_config\_object method in the respective agents.  
> Also, can you please make sure that you are calling the super.build() method in agent, and also you have done the factory registration for all components.  
> Regards,  
> Vaibhav
