Hi all,
I want to do a configuration class handle in an “interface”.
Lets say interaface has 2 instances and each instance will have its own configuration handle.
Lets assume my interface doesnt have knowledge of whether it is interface instance0 or interface instance1.
If I want to do uvm_config_db::get inside an interface, how can I do it?
Please note that we cant use “this” inside an interface.
As an example :
uvm_config_db#(dfi_intf_pkg::dfi_intf_cfg)::get(uvm_root::get(), “*”, “cfg”, cfg))
The above statement has issue that we cant be sure that instance 0 will get cfg handle 0 and instance 1 will get config handle 1.
If uvm_root::get() is replaced by “this”, it would have worked fine(I think so) but we cant have “this” inside an interface.
Please let me know how to do it?
Thanks ,
Suyog
1 Like
In reply to uvm_user235:
The uvm_config_db is just doing string matching to find your configuration object. The first argument to set/get is going to be replaced with cntxt.get_full_name(), and then concatenated with the inst_name, and finally the field_name
{cntxt.get_full_name(),inst_name,field_name}
So even if there was such a thing as this for an interface instance, it would not help because the cntxt argument needs to be a class with a get_full_name() method.
Your choices are to pass a unique field_name string to each interface instance, or use %m to create an inst_name argument.
import uvm_pkg::*;
interface itf;
parameter string inst_name = $sformatf("%m");
function void print;
string s;
if (uvm_config_db#(string)::get(null,inst_name,"s",s))
$display(s);
endfunction : print
endinterface : itf
module top;
itf i1();
itf i2();
initial begin
uvm_config_db#(string)::set(null,"top.i1","s","Hello");
uvm_config_db#(string)::set(null,"top.i2","s","World");
i1.print;
i2.print;
end
endmodule : top
I Have situation in which backdoor read ,write task is defined in interface , i want to collect address and data in scoreboard .
Can we set config_db inside a interface and get in scoreboard
You can certainly set uvm_config_db in a module or interface and read it in a class method. But an analysis_port is a much better form of communication.
1 Like