UVM配置之resource机制(2)

本文详细介绍了UVM中的uvm_config_db机制如何弥补uvm_resource_db的不足,通过设置与获取过程展示了其工作原理。在build_phase中设置资源,并在uvm_agent中通过uvm_config_db::get获取合适资源,遵循UVM的phase机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这部分我们将要详细介绍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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值