这部分我们将要详细介绍uvm_config_db机制时如何解决uvm_resource_db机制带来的弊端的
首先我们来看看uvm_config_db是如何工作的,
两个核心方法set和get
package UVM_cmd;
import uvm_pkg::*'
`include "uvm_macros.svh"
class unit_agent extends uvm_agent;
int A=10;
int i;
local int b;
uvm_resource#(int) re;
uvm_resource_types::rsrc_q_t rq;
uvm_resource_pool rp;
`uvm_component_utils(unit_agent)
function new(string name);
super.new(name);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
re=uvm_resource#(int)::get_type();
rp=uvm_resource_pool::get();
rq=rp.lookup_name("abcd","A",re);
`uvm_info("INT",$sformatf("before the config the a is %d",A),UVM_LOW)
if(!uvm_config_db#(int)::get(this,"",“A”,A))
`uvm_error("error","the read is error")
else
`uvm_info("INT",$sformatf("after the config the a is %d",A),UVM_LOW)
`uvm_in