Hi All,
When I use the virtual interface for each class, I declared multiple time like as the below. it seems very inconvenience. Is there any way just one time declare
virtual my_interface vintf;
and
uvm_config_db#(virtual my_interface)::get(this, "", "vintf_my_interface", vintf)
to handle into the multiple class?
I just thought that they can move into my_pkg, so I declare it at once. but It’s not possible. because “virtual my_interface vintf” and uvm_config_db#(virtual my_interface)::get(this, “”, “vintf_my_interface”, vintf) are should be in a class right?
`include "uvm_macros.svh"
import uvm_pkg::*;
class my_driver extends uvm_driver;
int c;
`uvm_component_utils(my_driver)
virtual my_interface vintf;
function new(string name = "", uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
if(! uvm_config_db#(virtual my_interface)::get(this, "", "vintf_my_interface", vintf))
`uvm_error("", "!!uvm_config_db get fail!!!!");
endfunction
task run_phase(uvm_phase phase);
vintf.a = 6;
vintf.b = 7;
//c = vintf.c;
//$display(" %d, %d, %d",vintf.a, vintf.b, c);
$display(" %d, %d, %d",vintf.a, vintf.b, vintf.c);
endtask
endclass
class my_env extends uvm_env;
`uvm_component_utils(my_env)
virtual my_interface vintf;
my_driver p_driver;
function new (string name ="", uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
p_driver = my_driver::type_id::create("p_driver", this);
if(! uvm_config_db#(virtual my_interface)::get(this, "", "vintf_my_interface", vintf))
`uvm_error("", "!!uvm_config_db get fail!!!!");
endfunction
task run_phase(uvm_phase phase);
vintf.a = 8;
vintf.b = 9;
//c = vintf.c;
//$display(" %d, %d, %d",vintf.a, vintf.b, c);
$display(" %d, %d, %d",vintf.a, vintf.b, vintf.c);
endtask
endclass