# Type casting error in get\_config\_object

**URL:** <https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603>\
**Category:** OVM\
**Tags:** Type-casting-error-in-get\_config\_object, OVM\
**Created:** [October 12, 2017, 1:20pm UTC](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603 "2017-10-12T13:20:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vimalambigai](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/d6d6ee/32.png) [@vimalambigai](https://verificationacademy.com/forums/u/vimalambigai)\
**Post date:** [October 12, 2017, 1:20pm UTC](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603/1 "2017-10-12T13:20:24Z")

</div>

Hi,  
I am new to OVM and I am trying to pass an interface from top to the environment through set\_config\_object and get\_config\_object.  
Below is my code and I am getting the error:  
OVM\_INFO @ 0.001ns: ovm\_test\_top.m\_env\_h[0].mon\_h[0] [mon\_h[0]] Connect Phase …

# OVM\_ERROR @ 0.001ns: ovm\_test\_top.m\_env\_h[0].mon\_h[0] [mon\_h[0]] Cannot cast to vif container in dpe mon

# \*\* Fatal: (vsim-131) \*/monitor.sv(25): Null instance encountered when dereferencing ‘vif\_mon’

Kindly help me out in this issue. Any help would be very useful to me since I am stuck here.  
Thanks in advance,  
Vimala

```verilog
interface mon_if();
  logic a;
  logic b;
    modport master(input a,output b);
  modport slave(input a,input b);
endinterface

class my_virtual_container #(type VIF = int) extends ovm_object;
    `ovm_object_param_utils(my_virtual_container #(VIF))
    VIF vif_h;
Endclass

module top();
    mon_if mon_if_top;
  typedef my_virtual_container #(virtual mon_if) container;
  container vif_top;
    vif_top = container::type_id::create(vif_top);
    initial
    begin
      vif_top.vif_h = mon_if_top;
      set_config_object("*","virtual_handle_t",vif_top.vif_h,.clone(0));
    end
   endmodule

class monitor #(type MON_IF_MP=int, type MON_IF) extends ovm_monitor;
  MON_IF_MP mon_if_mp_h;
  ovm_object tmp;
   typedef my_virtual_container #(MON_IF) container_mon;
  container_mon vif_mon;
    task run();
  get_config_object("virtual_handle_t",tmp);
    assert($cast(vif_mon,tmp))
     else ovm_report_error(get_name(),"Cannot cast to vif container in dpe mon"); 
  endtask
    mon_if_mp_h = vif_mon.vif_h;
endclass

class checker extends ovm_scoreboard;
    monitor #((virtual mon_if.slave),virtual mon_if);
    endclass

```

---

<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:** [November 1, 2017, 5:55am UTC](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603/2 "2017-11-01T05:55:07Z")

</div>

_In reply to [vimalambigai](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603):_

You will get a better error message if you use   
$cast without the   
assert. get\_config\_object returns true if it was set, and you can test   
via\_mon to see if it is still null.

---

<div class="post-metadata">

**Author:** ![vimalambigai](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/v/d6d6ee/32.png) [@vimalambigai](https://verificationacademy.com/forums/u/vimalambigai)\
**Post date:** [November 2, 2017, 4:45am UTC](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603/3 "2017-11-02T04:45:35Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/type-casting-error-in-get-config-object/33603/2):_

Thanks Dave for the response.

I got the issue fixed. The issue was in the parameter list where I was creating my monitor. I missed a parameter there and when I corrected that my issue got fixed.

Anyways your response will be a good hint for further debug.

Thank you.
