Interface must be assigned a matching interface or virtual interface

I have a ‘parametrised’ module(lets say mod) that has a ‘parametrised’ interface (lets say intf) inside it . I do the following in my top module:
initial
begin
uvm_config_db #(virtual intf)::set(null, “uvm_test_top”, “vif”, test_mod.test_intf);
run_test();
$finish;
end

test_mod is an instance of type mod (instantiated in top module). test_intf is an instance of type intf instantiated inside module mod. I tried to use permit_unmatched_virtual_intf flag with vsim command but I still get the error “interface must be assigned a matching interface or virtual interface”.

I changed the above line to:

uvm_config_db #(virtual intf#(LINK_SPEED(4’h2))::set(null, “uvm_test_top”, “vif”, test_mod.test_intf);

Where LINK_SPEED is the parameter. Now this gives me the next error(“[NOVIF] virtual interface must be set for: uvm_test_top.vif”) in uvm_test class where I do the following in the build phase:

if(!uvm_config_db#( virtual intf)::get(this, “”, “vif”, hook))
`uvm_fatal(“NOVIF”,{“virtual interface must be set for: “,get_full_name(),”.vif”});

hook is declared as : virtual intf hook. If I try to parametrise the hook declaration and the above statement, I go back to the original error. Can somebody help ?

You will need to ensure that any references to the virtual interface type use the same parameter values for the virtual interface handles to match - i.e.

In the testbench:

uvm_config_db #(virtual intf #(4’h2)::set(null, “uvm_test_top”, “vif”, test_mod.test_intf);

And in the test:

if(!uvm_config_db#( virtual intf #(4’h2)::get(this, “”, “vif”, hook))
`uvm_fatal(“NOVIF”,{“virtual interface must be set for: “,get_full_name(),”.vif”});

intf and intf #(4’h2) are two different types, doing a get() in uvm_config_db for an intf will not return anything because it was an intf #(4’h2) that was set()

In reply to mperyer:

@mperyer - thats what I mentioned in my post. If I try to parameterize, like you just mentioned :

if(!uvm_config_db#( virtual intf #(4’h2)::get(this, “”, “vif”, hook))
`uvm_fatal(“NOVIF”,{“virtual interface must be set for: “,get_full_name(),”.vif”});

I get the error "interface must be assigned a matching interface or virtual interface " in the above statement. Also, it doesn’t matter whether I declare hook as virtual intf hook OR virtual intf#(4’h2) hook. Do you also know why ‘permit_unmatched_virtual_intf’ flag might not work ?

The permit_unmatched_virtual_intf flag allows Questa to elaborate so that you can run code, it does not mean that it will allow interface types to be unmatched at run time. Very often it gives you a chance to find out where the error is coming from.

The message you are getting is an error message because the uvm_config_db get() call is failing. There various reasons why this might be.

  1. What is the type of hook? Have you declared it as a virtual interface handle?
  2. What is the type of test_mod.test_intf? Is it consistent with the virtual intf #(4’h2)?

What happens if you dump the content of uvm_config_db:

uvm_config_db #(int)::dump();

This should list all the entries in the uvm_config_db and their types - this may yield a clue.

In reply to mperyer:

To clarify what Mark wrote, the -permit_unmatched_virtual_intf flag allows Questa to elaborate so that you can simulate when you have a virtual interface reference in your code with no matching interface instantiated in your design AND you are not executing that particular portion of code. This is only useful when you have a package for a particular interface with classes that reference interfaces, but you do not plan to use them. Questa cannot generate the proper machine code to execute virtual interface references unless there is an actual interface instantiated with the same set of parameters that your virtual interface declaration uses. So that switch will not help you here.

You need to have matching interface parameters in 4 places:

  1. where you instantiate the interface connected to your DUT. MATCH inst();
  2. the uvm_config_db#(virtual MATCH)set()
  3. the uvm_config_db#(virtual MATCH)get()
  4. where you store the virtual interface handle. virtual MATCH vitf_h;

MATCH should be “intf #(4’h2)” in all 4 places.

In reply to dave_59:

@dave_59, mperyer - Thanks for the info. It works now. I added intf #(4’h2) in place of intf everywhere.

@mperyer - I used the dump function. It prints something like this:

=== resource pool ===

vif [/^uvm_test_top..*$/] : ?

-

vif [/^uvm_test_top$/] : ?

-

=== end of resource pool ===

Can you tell me what does “?” stand for in the resource pool printout? And why 2 statements are printed when I am writing in the config database only once ?