UVM源码阅读(6)——uvm_resource

本文介绍了在UVM(UniversalVerificationMethodology)中用于资源管理的关键概念,如typedefs、enums、优先级设置、访问记录和审计功能。uvm_resource_base和uvm_resource_option类提供了基础结构和选项管理,而uvm_resource_pool则负责资源的注册、查找和排序。
摘要由CSDN通过智能技术生成

class uvm_resource_types

用来提供typedef和enmu。

  // types uses for setting overrides
  typedef bit[1:0] override_t;
  typedef enum override_t { TYPE_OVERRIDE = 2'b01,
                            NAME_OVERRIDE = 2'b10 } override_e;

  // general purpose queue of resourcex
  typedef uvm_queue#(uvm_resource_base) rsrc_q_t;

  // enum for setting resource search priority
  typedef enum { PRI_HIGH, PRI_LOW } priority_e;

  // 资源的访问记录。通过访问对象,为每个资源存储一组。每次读/写都会更新
  typedef struct
  {
    time read_time;
    time write_time;
    int unsigned read_count;
    int unsigned write_count;
  } access_t;

class uvm_resource_option

       提供用于管理资源设施选项的命名空间。这个类中唯一允许的是静态本地数据成员和用于操作和检索数据成员值的静态函数。静态本地数据成员表示控制资源设施行为的选项和设置。

变量

static local bit auditing = 1;
//可以选择开、关。关闭可以节省性能,但没有审计追踪信息?

function

turn_on_auditing  //打开
turn_off_auditing //关闭
is_auditing       //返回auditing配置值

virtual class uvm_resource_base extends uvm_object

资源的非参数化基类。支持用于范围匹配的接口,以及用于打印资源和用于打印访问者列表的虚拟函数

  protected string scope; //范围
  protected bit modified;
  protected bit read_only;
  local bit m_is_regex_name;
  uvm_resource_types::access_t access[string];
  int unsigned precedence; //优先
  static int unsigned default_precedence = 1000;

function new

pure virtual function get_type_handle

返回handle。在uvm_resource中使用,返回this_type(静态变量),整个仿真过程仅此一个,如果this type = null > this_type new

function set_read_only

  如果设置read_only=1,uvm_resource 中write会有error

function set_read_write

function bit is_read_only

task wait_modified

function set_scope(string s)

  需要使用uvm_dpi中的uvm_regex

function string get_scope

function bit match_scope(string s)

    匹配 scope和s

pure virtual function bit set_priority(uvm_resource_types::priority_e pri)

function string convert2string()    

本class中仅返回“?”,资源专业化应覆盖此函数,以生成资源值的正确字符串表示形式。(为什么不是virtual function)

 function do_print

打印 name/scope/convert2string

function record_read_access(uvm_object accessor=null)

  记录读取访问

  1. 判断uvm_resource_option中auditing是否enable,否则return

  2.如果有accessor,则用accessor的full name 做数据库条目, 否则empty

  3.如果access(uvm_resource_types中的结构体)中不存在新的访问者记录,请创建该记录

  4.更新 accessor record

functrecord_write_access(uvm_object accessor=null)

  1. 判断uvm_resource_option中auditing是否enable,是继续

  2.和read类似

virtual function print_accessors

  打印accessor record信息

function init_access_record(inout uvm_resource_types::access_t access_record)

  初始化新的access_record

virtual function bit has_regex_name()

  返回m_is_rehex_name。function new中看是否有模糊配置,有则为1

class get_t

  get_t的实例作为每个get的记录存储在历史列表中。失败的获取以rsrc设置为null表示。这是资源审计跟踪功能的一部分。

  string name;
  string scope;
  uvm_resource_base rsrc;
  time t;

class uvm_resource_pool

变量

  static bit m_has_wildcard_names;
  static local uvm_resource_pool rp = get();
  uvm_resource_types::rsrc_q_t rtab [string];
  uvm_resource_types::rsrc_q_t ttab [uvm_resource_base];
  get_t get_record [$];  // history of gets

local function new

static function uvm_resource_pool get()

  如果rp是null new,否则返回现有rp

function bit spell_check(string s)

  如果rtab中有s返回1

function set (uvm_resource_base rsrc, uvm_resource_types::override_t override = 0);

  创建一个resources 并且set 进resource pool;

  rsrc非空,则继续

  插入name_map;查看rtab中是否有rsrc的name,有取出为rq,否则new

  如果override,将rsrc push_front 进rq;否则push_back

  更新rtab[name]为rp;

  插入type_map: 和name类似

function set_override(uvm_resource_base rsrc)

  调用set,override使用name|type

function set_name_override(uvm_resource_base rsrc)

  调用set

function set_type_override(uvm_resource_base rsrc)

  调用set

function push_get_record(string name,string scope, uvm_resource_base rsrc)

   使用get_t impt

  记录get history,get_record队列

function dump_get_records

  打印 get_records

function lookup_name

  在数据库中根据name找资源。

  查找rtab中是否有name,有输出对队列q

function get_highest_precedence

  遍历资源的队列q,并返回具有最高优先级的rsrc

function sort_by_precedence(ref uvm_resource_types::rsrc_q_t q)

  按照precedence给q重排序

function get_by_name

  lookup_name之后,q非空,拿到最高优先级的rsrc

function lookup_type

  参考之前

function get_by_type

  参考之前

function lookup_regex_names

  资源的名字可以是正则表达式。the resource name may be a regular expression.

function lookup_regex

function lookup_scope

  找到对特定作用域可见的所有资源,与之前function相同,返回q

local function set_priority_queue

  更改资源搜索搜索的优先级,将q中的rsrc配置优先级,如果high,push到q front,如果low,push到q back

function set_priority_type

  根据rsrc 的type handle查找ttab的q,调用set_priority_queue排序

function set_priority_name

  与上类似

function set_priority

  both name type

function find_unused_resources

  找到至少有一次写入而没有读取的所有资源

function print_resources

 打印rq 

function dump

  调用print_resources,打印rtab

class uvm_resource #(type T=int) extends uvm_resource_base

对资源数据库进行读取和写入

变量

  typedef uvm_resource#(T) this_type;

  // singleton handle that represents the type of this resource
  static this_type my_type = get_type();

  // Can't be rand since things like rand strings are not legal.
  protected T val;

function new

function string convert2string()

static function this_type get_type()

  返回this_type静态指针

function get_type_handle

function set

  将resource 放进pool

function set_override

  set 覆盖

function get_by_name

function get_by_type

function write

  非read_only 并且 参数t和蚕食val不一致,调用record_write_access,accessor record

function read

  调用record_read_access

function set_priority

  改变priority

static function get_highest_precedence

static global resource pool handle

const uvm_resource_pool uvm_resources = uvm_resource_pool::get();

注:const是用于声明常量的关键字。它用于将一个变量或信号标记为只读,禁止对其进行更改

  • 25
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Table of Contents Articles Introduction 0 Cookbook/Introduction 0 Cookbook/Acknowledgements 1 Testbench Architecture 2 Testbench 2 Testbench/Build 9 Testbench/Blocklevel 19 Testbench/IntegrationLevel 29 Component 39 Agent 42 Phasing 48 Factory 53 UsingFactoryOverrides 56 SystemVerilogPackages 62 Connections to DUT Interfaces 65 Connections 65 SVCreationOrder 71 Connect/SystemVerilogTechniques 73 ParameterizedTests 75 Connect/Virtual Interface 78 Config/VirtInterfaceConfigDb 86 Connect/VirtInterfacePackage 90 Connect/VirtInterfaceConfigPkg 93 Connect/TwoKingdomsFactory 97 DualTop 103 VirtInterfaceFunctionCallChain 106 BusFunctionalModels 108 ProtocolModules 111 Connect/AbstractConcrete 115 Connect/AbstractConcreteConfigDB 118 Configuring a Test Environment 126 Configuration 126 Resources/config db 131 Config/Params Package 134 Config/ConfiguringSequences 139 ResourceAccessForSequences 142 MacroCostBenefit 145 Analysis Components & Techniques 146 Analysis 146 AnalysisPort 149 AnalysisConnections 152 MonitorComponent 158 Predictors 161 Scoreboards 163 MetricAnalyzers 170 PostRunPhases 172 Matlab/Integration 175 End Of Test Mechanisms 183 EndOfTest 183 Objections 185 Sequences 188 Sequences 188 Sequences/Items 193 Transaction/Methods 195 Sequences/API 200 Connect/Sequencer 204 Driver/Sequence API 206 Sequences/Generation 213 Sequences/Overrides 221 Sequences/Virtual 223 Sequences/VirtualSequencer 231 Sequences/Hierarchy 237 Sequences/SequenceLibrary 242 Driver/Use Models 246 Driver/Unidirectional 247 Driver/Bidirectional 250 Driver/Pipelined 255 Sequences/Arbitration 267 Sequences/Priority 276 Sequences/LockGrab 277 Sequences/Slave 284 Stimulus/Signal Wait 290 Stimulus/Interrupts 294 Sequences/Stopping 301 Sequences/Layering 302 Register Abstraction Layer 308 Registers 308 Registers/Specification 315 Registers/Adapter 317 Registers/Integrating 321 Registers/Integration 327 Registers/RegisterModelOverview 332 Registers/ModelStructure 334 Registers/QuirkyRegisters 344 Registers/ModelCoverage 349 Registers/BackdoorAccess 354 Registers/Generation 357 Registers/StimulusAbstraction 358 Registers/MemoryStimulus 370 Registers/SequenceExamples 375 Registers/BuiltInSequences 382 Registers/Configuration 386 Registers/Scoreboarding 389 Registers/FunctionalCoverage 395 Testbench Acceleration through Co-Emulation 401 Emulation 401 Emulation/SeparateTopLevels 404 Emulation/SplitTransactors 410 Emulation/BackPointers 415 Emulation/DefiningAPI 419 Emulation/Example 422 Emulation/Example/APBDriver 430 Emulation/Example/SPIAgent 435 Emulation/Example/TopLevel 441 Debug of SV and UVM 444 BuiltInDebug 444 Reporting/Verbosity 455 UVM/CommandLineProcessor 460 UVM Connect - SV-SystemC interoperability 464 UvmConnect 464 UvmConnect/Connections 466 UvmConnect/Conversion 468 UvmConnect/CommandAPI 472 UVM Express - step by step improvement 476 UvmExpress 476 UvmExpress/DUT 481 UvmExpress/BFM 485 UvmExpress/WritingBfmTests 490 UvmExpress/FunctionalCoverage 498 UvmExpress/ConstrainedRandom 503 Appendix - Deployment 516 OVM2UVM 516 OVM2UVM/DeprecatedCode 527 OVM2UVM/SequenceLibrary 528 OVM2UVM/Phasing 530 OVM2UVM/ConvertPhaseMethods 535 UVC/UvmVerificationComponent 537 Package/Organization 548 Appendix - Coding Guidelines 555 SV/Guidelines 555 UVM/Guidelines 569 Appendix - Glossary of Terms 579 Doc/Glossary 579
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值