[UVM]config_db机制(set和get函数)

uvm_config机制

在UVM中,参数的传递依赖于config_db机制以下两个函数

  • set函数是用来发送需要传递的参数
  • get函数是用来接收需要传递的参数

针对uvm验证环境,一般使用uvm_config机制来传递的资源

uvm_config_db#(T)::set(cntxt,inst_name,field_name,value);
uvm_config_db#(T)::get(cntxt,inst_name,field_name,value);

uvm_config_db

uvm_config_db#(T)::set(cntxt,inst_name,field_name,value);
uvm_config_db#(T)::get(cntxt,inst_name,field_name,value);

参数T是指传递参数的类型,可以是vulture interfacesequencer

get 函数

源码分析

static function void get(	uvm_component 	cntxt,
							string 			inst_name,
							string 			field_name,
							T 				value	)

参数解析

获取 inst_name 中 field_name 的值,使用组件 cntxt 作为起始搜索点。 inst_name 是相对于 cntxt 的显式实例名称,如果 cntxt 是配置对象适用的实例,则可能是空字符串。 field_name 是要搜索的范围内的特定字段。


set 函数

源码

static function void set(	uvm_component 	cntxt,
							string 			inst_name,
							string 			field_name,
							T 				value	)

参数解析

为 cntxt 中的 inst_name 中的 field_name 创建新的或更新现有的配置设置。

如源码所示,set函数具有四个参数:

  • cntxt和inst_name一起定义了uvm_config_db中set或get函数的作用范围完整的范围为{cntxt,“.”,inst_name},如果cntxt是null,则inst_name需要提供完整范围信息
  • field_name是目标字段