uvm_resource_specializations
uvm_resource_specializations.svh即提供了几种常用的派生自uvm_resource的resource基类:uvm_int_rsrc、uvm_string_rsrc、uvm_obj_rsrc、uvm_bit_rsrc、uvm_byte_rsrc,以上几个resource的基类中,所有类都实现了object到resource实际类型的类型转换,除uvm_obj_rsrc外均重载了convert2string函数。
`define UVM_RESOURCE_GET_FCNS(base_type) \
static function this_subtype get_by_name(string scope, string name, bit rpterr = 1); \
this_subtype t; \
uvm_resource_base b = uvm_resource#(base_type)::get_by_name(scope, name, rpterr); \
if(!$cast(t, b)) \
`uvm_fatal("BADCAST", "cannot cast resource to resource subtype"); \
return t; \
endfunction \
\
static function this_subtype get_by_type(string scope = "", \
uvm_resource_base type_handle); \
this_subtype t; \
uvm_resource_base b = uvm_resource#(base_type)::get_by_type(scope, type_handle); \
if(!$cast(t, b)) \
`uvm_fatal("BADCAST", "cannot cast resource to resource subtype"); \
return t; \
endfunction
uvm_resource_db
配置以及获取资源
为资源工具提供了一个方便的接口。在许多情况下,创建和设置资源或获取资源等基本操作可能需要使用<uvm_resource_base>或<uvm_resource#(T)>中的接口执行多行代码。uvm_resource_db中的便利层将许多操作简化为一行代码。
class uvm_resource_db #(type T=uvm_object);
注:在SystemVerilog中不允许在静态方法中读写非静态变量
变量
typedef uvm_resource #(T) rsrc_t;
protected function new
static function rsrc_t get_by_type
static function rsrc_t get_by_name
static function rsrc_t set_default
添加新的item resource到数据库中,item没有被写过所以是默认值
r.set 给到pool
protected static function void m_show_msg
打印
msg=$typename(T):返回数据类型的子字符串
static function void set(input string scope, input string name,T val, input uvm_object accessor = null);
创建一个resource,写进val,将其写入数据库并且用name和scope做查找的参数
static function void set_anonymous
与上面类似,但是没有name
static function void set_override
与上面类似,将其设置在类型映射和名称映射中队列的开头,使其成为(当前)具有指定名称和类型的最高优先级资源
static function void set_override_type
static function void set_override_name
static function bit read_by_name(input string scope, input string name, inout T val, input uvm_object accessor = null)
用name和scope定位到资源,并且读出值,返回的比他代表是否读取成功
static function bit read_by_type
用type定位
static function bit write_by_name
用name定位
static function bit write_by_name
写val进resource 数据库 。用name和scope找到resource然后写入
static function bit write_by_type
用type找到resource、
static function void dump
打印pool中所有的资源
class uvm_resource_db_options
支持debug trace的功能, 在命令行仿真选项中+UVM_RESOURCE_DB_TRACE,每一次调用uvm_resource_db进行resource读写访问是都会打印相关信息。
变量
static local bit ready;
static local bit tracing;