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, intr_monitor.sv(34): 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?
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.
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;
`ovm_object_utils(config_class)
function new(string name = "config_class");
.....
endfunction
endclass
class env extends ovm_env;
`ovm_component_utils(env)
config_class cfg;
function new(string name = "env", ovm_component parent);
.....
endfunction
function void build();
cfg = config_class::type_id::create("cfg");
set_config_object("*","config_class",cfg,0);
endfunction
endclass: env
class intr_driver extends ovm_driver #(seq_item);
`ovm_component_utils(intr_driver)
config_class cfg;
function new(string name = "intr_driver", ovm_component parent = null);
super.new(name, parent);
endfunction
function void build();
super.build();
get_config_object("config_class",cfg,0);
endfunction
endclass: intr_driver
class intr_monitor extends ovm_monitor;
`ovm_component_utils(intr_monitor)
config_class cfg;
function new(string name = "intr_monitor", ovm_component parent = null);
super.new(name, parent);
ap=new("ovm_analysis_port",this);
endfunction
// Earlier Implementaion without casting
/* function void build();
super.build(); // Tthis impleentation has throwm error
get_config_object("config_class",cfg,0)
endfunction */
// Later implementation
function void build();
ovm_object temp;
super.build();
if(!get_config_object("config_class",temp,0)) // This worked fine
$display("Cannot get config handle");
if(!$cast(cfg,temp))
$display("Casting failed");
endfunction
endclass:intr_monitor
Please let me know why it didn’t throw any error in case of driver?
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.
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.