UVM源码阅读(7)——uvm_resource_specializations+uvm_resource_db

本文介绍了UVM中的uvm_resource_specializations.svh中的资源派生类,如uvm_int_rsrc等,以及uvm_resource_db提供的资源配置、获取和管理的便利接口。uvm_resource_db允许简化操作并支持调试追踪功能。
摘要由CSDN通过智能技术生成

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;

static function void turn_on_tracing

static function void turn_off_tracing

static function bit is_tracing

tatic local function void init

  • 15
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值