Hi dave,
I having one more question on config_db and resource_db…
I saw the link which you previously shared,and i understood the concept of database.
Here i am try the code of config_db and resource_db.
In a config_db always last parent is wins it works fine,But
In a resource_db last write is wins but in my code top(first value) is wins…Why??
Thanks in advance… :)
Here i will share both codes:
1----->(Config_db)-- it works fine
`include "uvm.sv"
import uvm_pkg :: *;
class agent extends uvm_agent;
`uvm_component_utils (agent)
int a;
function new (string name = "agent", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
uvm_config_db #(int)::get(this, "", "a", a);
`uvm_info ("agent-get", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
task run_phase (uvm_phase phase);
endtask
endclass
class envi extends uvm_env;
`uvm_component_utils (envi)
int a;
agent agnt;
function new (string name = "envi", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
agnt = agent::type_id::create("agnt", this);
a = 60;
uvm_config_db #(int)::set(null, "*", "a", a);
`uvm_info ("env-set", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
task run_phase (uvm_phase phase);
endtask
endclass
class my_test_1 extends uvm_test;
`uvm_component_utils (my_test_1)
int a;
envi env;
function new (string name = "my_test_1", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
env = envi::type_id::create("env", this);
a = 50;
uvm_config_db #(int)::set(null, "*", "a", a);
`uvm_info ("test-set", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
task run_phase (uvm_phase phase);
phase.raise_objection(this);
#50;
phase.drop_objection(this);
endtask
endclass
module top();
initial begin
run_test("my_test_1");
end
endmodule
output::
UVM_INFO @ 0: reporter [RNTST] Running test my_test_1…
UVM_INFO config_db.sv(57) @ 0: uvm_test_top [test-set] a=50
UVM_INFO config_db.sv(36) @ 0: uvm_test_top.env [env-set] a=60
UVM_INFO config_db.sv(15) @ 0: uvm_test_top.env.agnt [agent-get] a=60
2---->Resource_db(here top value is wins!!..How??)
class agent extends uvm_agent;
`uvm_component_utils (agent)
int a;
function new (string name = "agent", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
uvm_resource_db #(int)::read_by_name("*", "a", a,this);
`uvm_info ("agnt-get", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
endclass
class env extends uvm_env;
`uvm_component_utils (env)
int a;
agent agnt;
function new (string name = "env", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
agnt = agent::type_id::create("agnt", this);
a = 60;
uvm_resource_db #(int)::set("*", "a", a, this);
`uvm_info ("env-set", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
endclass
class my_test_1 extends uvm_test;
`uvm_component_utils (my_test_1)
int a;
env envi;
function new (string name = "my_test_1", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase (uvm_phase phase);
super.build_phase (phase);
envi = env::type_id::create("envi", this);
a = 50;
uvm_resource_db #(int)::set("*", "a", a,this);
`uvm_info ("test-set", $sformatf("a=%0d", a), UVM_MEDIUM)
endfunction
task run_phase (uvm_phase phase);
phase.raise_objection(this);
#50;
phase.drop_objection(this);
endtask
endclass
module top();
initial begin
run_test("my_test_1");
end
endmodule
output::
UVM_INFO @ 0: reporter [RNTST] Running test my_test_1…
UVM_INFO resource_db.sv(43) @ 0: uvm_test_top [test-set] a=50
UVM_INFO resource_db.sv(27) @ 0: uvm_test_top.envi [env-set] a=60
UVM_INFO resource_db.sv(11) @ 0: uvm_test_top.envi.agnt [agnt-get] a=50