Using get_config_object

Hi all,

I have a class named config_class extended from ovm_object, In class_env I have set this class using set_config_object as follows
set_config_object(“*”,“config_class”,cfg,0); and in driver and monitor class I am trying to get the config_class handle using get_config_object(“config_class”,cfg,0). In driver i am able to get the config_class object but in monitor i am getting the following error, Arg. ‘value’ of ‘get_config_object’: types are not assignment compatible

Can anyone help me to solve this and tell what might be the reason for such error?

Thanks in advance,

When you have a coding error, it is very helpful if you post your entire code, preferably so that it can be compiled and the error can be reproduced.

Just based on what you have posted, I would check the variable declarations in the monitor and make sure that they are of the correct type. Remember that get_config_object() can only use a uvm_object type to return the handle and you will have to cast it to the appropriate type handle.

See the example in the UVM Cookbook.

In reply to cgales:

Hi cgales,

In order to overcome that issue I used ovm_object type to get the instance and then did casting to config_class handle, and it worked fine. But while getting same handle in driver I used config_class type so there is no need of casting and it worked fine. Can i know why? Below i am sending you snippet of my code.

class config_class extends ovm_object;

 function new(string name = "config_class");


 class env extends ovm_env;


   config_class cfg;
    function new(string name = "env", ovm_component parent);

    function void build();
     cfg = config_class::type_id::create("cfg");

 endclass: env

 class intr_driver extends ovm_driver #(seq_item);

  config_class cfg;

 function new(string name = "intr_driver", ovm_component parent = null);, parent);

 function void build();;

 endclass: intr_driver

 class intr_monitor extends ovm_monitor;


  config_class cfg;

  function new(string name = "intr_monitor", ovm_component parent = null);, parent);

// Earlier Implementaion without casting
/* function void build();;                               // Tthis impleentation has throwm error
 endfunction */

// Later implementation
function void build();
 ovm_object temp;;
 if(!get_config_object("config_class",temp,0)) // This worked fine
   $display("Cannot get config handle");

   $display("Casting failed");

Please let me know why it didn’t throw any error in case of driver?

Thank you,

In reply to mohanish:

I ran the code you posted (with edits to get it to compile), and I get the same error that you were seeing in the monitor. Are your sure your driver code is being compiled? Is it running correctly? I would not expect what you posted to work correctly.

In reply to cgales:

Yes Cgales, My driver is working fine. Its run phase is getting executed properly as it is meant to. If you want I will send you my entire code in zip format, then you can check it using makefile.