Just another question on setting up the parameters in uvm_config_db get and set method.
// always need 2 things
`include "uvm_macros.svh"
import uvm_pkg::*;
// sharing across 2 components
class comp1 extends uvm_component;
`uvm_component_utils(comp1)
int comp1_data = 0;
function new(input string path = "comp1", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(int)::get(this, "", "data", comp1_data)) uvm_test_top.myenv_myagent.comp1.comp1_data
`uvm_error("comp1", "Unable to share data");
endfunction
virtual task run_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info("comp1", $sformatf("Data rcvd comp1 : %0d", comp1_data), UVM_NONE);
phase.drop_objection(this);
endtask
endclass
class myagent extends uvm_agent;
`uvm_component_utils(myagent)
function new(input string path = "myagent", uvm_component c);
super.new(path, c);
endfunction
comp1 c1;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
c1 = comp1::type_id::create("comp1", this);
endfunction
endclass
class myenv extends uvm_env;
`uvm_component_utils(myenv)
int data;
function new(string path = "myenv", uvm_component parent = null);
super.new(path, parent);
endfunction
myagent a;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// declare agent here
a = myagent::type_id::create("myagent", this);
endfunction
endclass
// the test to change values
class the_test extends uvm_test;
`uvm_component_utils(the_test)
myenv the_env;
function new(string path = "the_test", uvm_component parent = null);
super.new(path, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// define component hierarchy
the_env = myenv::type_id::create("the_env", this);
endfunction
endclass
// top level
module tb (
);
int data1 = 256;
initial begin
uvm_config_db #(int)::set(null, "uvm_test_top.myenv.myagent.comp1", "data", data1);
run_test("the_test");
end
endmodule
So I wanted to see if instead of using null as the first parameter of the get function in comp1, I used ‘this’ instead and for the second parameter, I did not include in the instance name; however, in the tb part of the code, I did list out the entire hierarchy path in the second parameter of the tb module. However, this sends an error to the compiler, and I was wondering if there are other ways of writing out the parameters that would allow sharing data across different components.