Get Virtual Interface In uvm_test

Hello everyone,

I am a newbie in uvm. I am trying to reach interface signals in uvm_test. In below you can see what did I do for that but I get the following error. Can anyone help me to solve this problem?

Thanks.


module testbench;
    v_interface if0(clk, reset);
    
    initial begin
        uvm_config_dn#(virtual interface)::set(uvm_root::get(),"uvm_test_top_env.agt0", "vif", if0);
    end
endmodule


class test extends uvm_test;

    virtual v_interface if0;

    virtual function void build_phase(uvm_phase phase);
        uvm_config_db#(virtual interface)::get(this, "", "vif", if0);
    endfunction

endclass


The ERROR I get: uninitialized virtual interface object.

In reply to Ankelih:

Please note ‘interface’ is a keyword.

In reply to chr_sue:

I used it as example. I will edit post.

In reply to Ankelih:

There are many typos in the code that you have shown. When debugging issues with uvm_config_db, every character counts.

You are doing the set() to the context “uvm_test_top_env.agt0”, but the get() is from the context “uvm_test_top”.

In the set(), the null string replaces
uvm_root::get()

In the get(), “uvm_test_top.” replaces
this
.

You probably want:

uvm_config_db#(virtual v_interface)::set(null,"uvm_test_top", "vif", if0);

In reply to dave_59:

Thank you very much. I solve my problem with your suggestion. The last thing I want to ask is about uvm_root::get(). How does it work?