In reply to bachan21:
Several comments:
- You should always check the return value of the get() call.
- Your component names passed in create() are what is used during the get() call. They should match the names in the set() call.
- You should always set() prior to create().
- Don’t use a ‘.’ in the set() call hierarchy.
`include "uvm_macros.svh"
import uvm_pkg::*;
class env extends uvm_env;
`uvm_component_utils(env)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
int value;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if (!uvm_config_db#(int) :: get(this,"","value",value))
`uvm_fatal("ERRGET", "Can't get a valid value");
`uvm_info(get_name(), $sformatf("VALUE = %d", value), UVM_NONE)
endfunction
endclass //env
class test extends uvm_test;
`uvm_component_utils(test)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction //new()
env E1,E2;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
//Setting value = 10 for env1 E1
uvm_config_db#(int)::set(this,"E1","value",10);
//Setting value = 20 for env2 E2
uvm_config_db#(int)::set(this,"E2","value",20);
E1 = env::type_id::create("E1",this);
E2 = env::type_id::create("E2",this);
endfunction
endclass //agent2 extends uvm_agent
module tb;
initial begin
run_test("test");
end
endmodule