Using uvm_config_db to register binded interfaces

I have following code illustrating the idea I want to achieve:

module tb();
    dut_wrap dut_wrap_1();
    dut_wrap dut_wrap_2();
    bind dut_wrap dut_val_for_bind dut_val();
endmodule 

 module dut _wrap;
   logic [1:0] my_in_port;
   logic [2:0] my_out_port;
   dut dut(.*);
endmodule

module dut(input logic [1:0] my_in_port, output logic [2:0] my_out_port);
//Do  your magic
endmodule

 module dut_val_for_bind();
   import uvm_pkg::*;
   dut_ifc dut_if();
   assign dut_wrap.my_in_port = dut_if.my_in_port;
   assign dut_if.my_out_port = dut_wrap.my_out_port;
   initial begin
      string this_inst_name = $sformatf("%m");
      uvm_config_db#(virtual dut_ifc)::set(null, this_inst_name, "DUT_IFC", dut_if);
   end
endmodule

Now, in some component elsewhere, let’s say I want to retrieve the interface by finding it via regular expression like this:

virtual dut_ifc dut_if_1;
virtual dut_ifc dut_if_2;
uvm_config_db#(virtual dut_ifc)::get(null, ".\*dut_wrap_1.\*, "DUT_IFC", dut_if_1);
uvm_config_db#(virtual dut_ifc)::get(null, ".\*dut_wrap_2.\*, "DUT_IFC", dut_if_2);

The problem is that when calling get, then UVM is not matching the regex above within the resource scope, but doing opposite considering the second argument to set as regex and trying to match it against the second argument to get.
So this UVM approach is totally make sense when the intent is top-down setting (i.e. top component setting resource via regular expression to match all the sub-components that will get with their respective scope).

In the above method, at point of interface registration you don’t have to know exactly the topology of your uvm_env and target the interface to there, since this make the env and interface pretty much coupled and if I want to make a relocatable val like I try to do above then I must overcome the obstacle of getting the interface by DUT hierarchy.
Appreciate your ideas here.

Thanks,
Eliran.

Your problem is caused by the hierarchy. The bind module does not appear on the same level as dut_wrap_1 and dut_wrap_2.

Hi,
The binded hierarchies are:
tb.dut_wrap1.dut.dut_val
tb.dut_wrap2.dut.dut_val

Not sure what is the problem with the hierarchies.
I am trying to retrieve the registration of tb.dut_wrap1.dut.dut_val.DUT_IFC by instance regex: “.dut_wrap1.” and field name “DUT_IFC”, and same with the other one.
I know it’s not working, and I also explained why it’s not working.
I just present here the idea of what I try to do and ask how can I do in different way.

Thanks,
Eliran.

I don’t understand why you are using in the get command as 2nd argument the regex. It should be simply
uvm_config_db#(virtual dut_ifc)::get(this, "", "DUT_IFC", dut_if_1);
The 1st argument ‘this’ indicates a relative path and the the empty string of the 2nd argument retrieves the interface exactly in this component where you are calling the get.

The problem is the uvm_config_db is designed to deal with UVM testbench hierarchy, not design hierarchy. It only handles regular expressions when seting, not geting.

You haven’t stated how or if you need to relate these interfaces to your testbench architecture. If there is no need, you could use a single configuration object that contains an assoative array of virtual interfaces (or just use uvm_pool)