uvm config_db/config文件

446 阅读1分钟

config文件:

`ifndef xxx_CFG_SV
`define xxx_CFG_SV
class xxx_cfg extends uvm_object;
	`uvm_object_utils(layer_agent_cfg)

	bit is_active = 1;
  //virtual rst_if vif;
	//string REPORT_TAG = "XXX_CFG"
	function new(string name="xxx_cfg");
		super.new(name);
	endfunction
endclass
`endif

传递config class

env中set

xxx_cfg cfg;  //声明
//build_phase
cfg = xxx_cfg::type_id::create("cfg");
cfg.is_active = 1;

uvm_config_db#(xxx_cfg)::set(this, "agt*","cfg",cfg);
//uvm_config_db#(xxx_cfg)::set(this, "agt*.*","cfg",cfg);  //报错,不要使用

agent中get

//agent build_phase
if(!uvm_config_db#(xxx_cfg)::get(this,"","cfg",cfg))
		`uvm_error(get_type_name(),"do not get config")
if(cfg.is_active == 1) begin