跳转至

输入查询内容

    本页内容

    uvm_resource_pool 重构:set 系列改名 set_scope/set_override,新增 get_scope/delete 等 API

    影响范围

    直接调用 resource_pool::set/set_override 并传入特殊 override 掩码时需修改;同时核对 scope 与查询侧。

    具体差异

    1.2 的 set(rsrc, override) 在 2.0 保留但标注 @uvm-compat,内部委托给 set_scope/set_override;三个 override 方法新增可选 scope 参数(向后兼容)。新增 get_scope(rsrc, output scope)delete(rsrc)(1.2 无删除资源手段)。new() 从 local 变为 public,且 uvm_resource_pool::get() 改为返回 coreservice 持有的 pool(2.0 :153-158),用户可通过 uvm_coreservice_t::set_resource_pool() 整体替换资源池(1.2 的 uvm_coreservice.svh 无任何 resource 接口)。

    修改方案

    rp.set(rsrc) / 默认双置顶 rp.set_override(rsrc) 可继续使用。注意 2.0 rp.set(rsrc, override) 只检查 override 是否非零,旧 name-only/type-only 掩码会变为双置顶,须显式改用对应的单侧 override API。需要删除资源时使用新 delete()

    兼容措施与范围:主库保留 pool.set 和默认双置顶的 set_override 用法;旧单侧 override 掩码不能据此视为等价,须改用 set_name_override/set_type_override。

    迁移后验证

    同一资源分别用 name/type 查询,确认仅预期的索引优先级改变;显式 set_name_override/set_type_override 保留单侧意图。

    记录本条结果M05-005 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

    有扫描规则,覆盖部分可识别写法。脚本检查名称、参数和部分 FLAG 表达式,并对少数直接声明关联使用点;未做完整类型解析或预处理,行为结果仍需验证。

    • S15 · 启发式:resource 单侧 override 掩码与入池前 precedence 需核对。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules S15
    

    核对命中对象及生效分支后,在条目清单记录修改与验证证据;扫描规则记录用于整理命中位置。

    扫描器下载、输入范围与报告说明

    源码与标准依据

    核查方式:源码与实测核对。实测仅覆盖本条所列场景。

    VCS 内置 UVM-1.2uvm_resource.svh:657(class)、uvm_resource.svh:666local function new())、uvm_resource.svh:714(set)、uvm_resource.svh:768(set_override 仅 1 参)、uvm_resource.svh:779(set_name_override)、uvm_resource.svh:789(set_type_override)、uvm_resource.svh:1356(dump 仅 audit 参)

    VCS 内置 uvm-ieee-2020-2.0uvm_resource_pool.svh:122(class)、uvm_resource_pool.svh:144function new() 公开)、uvm_resource_pool.svh:195(set 保留为 @uvm-compat)、uvm_resource_pool.svh:208(set_scope)、uvm_resource_pool.svh:277uvm_resource_pool.svh:298uvm_resource_pool.svh:319(set_override/set_name_override/set_type_override,均新增 string scope="<not provided>" 参数)、uvm_resource_pool.svh:333(get_scope,新增)、uvm_resource_pool.svh:387(delete,新增)、uvm_resource_pool.svh:982(set_default_precedence,新增)、uvm_resource_pool.svh:1214(dump 新增 uvm_printer printer = null 参数)、uvm_resource_pool.svh:617(sort_by_precedence_q,新增)、uvm_resource_pool.svh:559(get_highest_precedence 改为 static,1.2 在 uvm_resource_pool.svh:933 为实例方法)

    标准依据:IEEE 1800.2-2020 §C.2.4.3.1–C.2.4.3.6、§C.2.4.5.4–C.2.4.5.6

    标为“源码标注”或未注明原文核对的条款仅作定位;具体库行为以源码和实测为准。

    引用代码(高亮为引用行);上方行号链接可直接定位。

    src/vcs-uvm-1.2/base/uvm_resource.svh
    //
    //----------------------------------------------------------------------
    
    class uvm_resource_pool;
    
      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();
      endfunction
    
    
      // Function: get
      //
      // Returns the singleton handle to the resource pool
    
      static function uvm_resource_pool get();
        if(rp == null)
          rp = new();
        return rp;
      endfunction
    
    
      // Function: spell_check
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // <set_override>, <set_name_override>, or <set_type_override>
      // functions.
      //
      function void set (uvm_resource_base rsrc, 
                         uvm_resource_types::override_t override = 0);
    
        uvm_resource_types::rsrc_q_t rq;
        string name;
        uvm_resource_base type_handle;
    
        // If resource handle is ~null~ then there is nothing to do.
        if(rsrc == null)
          return;
    
        // insert into the name map.  Resources with empty names are
        // anonymous resources and are not entered into the name map
        name = rsrc.get_name();
        if(name != "") begin
          if(rtab.exists(name))
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // The resource provided as an argument will be entered into the pool
      // and will override both by name and type.
    
      function void set_override(uvm_resource_base rsrc);
        set(rsrc, (uvm_resource_types::NAME_OVERRIDE |
                   uvm_resource_types::TYPE_OVERRIDE));
      endfunction
    
    
      // Function: set_name_override
      //
      // The resource provided as an argument will entered into the pool
      // using normal precedence in the type map and will override the name.
    
      function void set_name_override(uvm_resource_base rsrc);
        set(rsrc, uvm_resource_types::NAME_OVERRIDE);
      endfunction
    
    
      // Function: set_type_override
      //
      // The resource provided as an argument will be entered into the pool
      // using normal precedence in the name map and will override the type.
    
      function void set_type_override(uvm_resource_base rsrc);
        set(rsrc, uvm_resource_types::TYPE_OVERRIDE);
      endfunction
    
    
      // function - push_get_record
      //
      // Insert a new record into the get history list.
    
      function void push_get_record(string name, string scope,
                                      uvm_resource_base rsrc);
        get_t impt;
    
        // if auditing is turned off then there is no reason
        // to save a get record
        if(!uvm_resource_options::is_auditing())
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // is used to initiate the printing. If the ~audit~ bit is set then
      // the audit trail is dumped for each resource.
    
      function void dump(bit audit = 0);
    
        uvm_resource_types::rsrc_q_t rq;
        string name;
    
        `uvm_info("UVM/RESOURCE/DUMP","\n=== resource pool ===",UVM_NONE)
    
        foreach (rtab[name]) begin
          rq = rtab[name];
          print_resources(rq, audit);
        end
    
        `uvm_info("UVM/RESOURCE/DUMP","=== end of resource pool ===",UVM_NONE)
    
      endfunction
    

    完整源码 · SHA256:6dd457f7586da01b713fb94bdb5472e7fdb3e741219398f87f341c21f5a0f8af

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
    //----------------------------------------------------------------------
    
    // @uvm-ieee 1800.2-2020 auto C.2.4.1
    class uvm_resource_pool;
    
    `ifndef UVM_DISABLE_RESOURCE_POOL_SHARED_QUEUE
      typedef uvm_resource_types::rsrc_shared_q_t table_q_t;
     `define M__TABLE_Q(QUEUE_NAME) QUEUE_NAME``.value
     `define M__TABLE_GET(QUEUE_NAME, ITER) QUEUE_NAME``.value[ITER]
     `define M__TABLE_NAME "uvm_shared#(uvm_resource_base[$])"
    
    `else
      typedef uvm_resource_types::rsrc_q_t table_q_t;
     `define M__TABLE_Q(QUEUE_NAME) QUEUE_NAME
     `define M__TABLE_GET(QUEUE_NAME, ITER) QUEUE_NAME``.get(ITER)
     `define M__TABLE_NAME "uvm_queue#(uvm_resource_base)"
    
    `endif // !`ifdef UVM_DISABLE_RESOURCE_POOL_SHARED_QUEUE
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      get_t get_record [$];  // history of gets
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.2.1
      function new();
      endfunction
    
    
      // Function -- NODOCS -- get
      //
      // Returns the singleton handle to the resource pool
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.2.2
      static function uvm_resource_pool get();
        uvm_resource_pool t_rp;
        uvm_coreservice_t cs = uvm_coreservice_t::get();
        t_rp = cs.get_resource_pool();
        return t_rp;
      endfunction
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      //
    
      //@uvm-compat provided for compatibility with 1.2
      function void set (uvm_resource_base rsrc, 
                         uvm_resource_types::override_t override = 0);
    
        // If resource handle is ~null~ then there is nothing to do.
        if (rsrc == null) return ;
        if (override) 
            set_override(rsrc, rsrc.get_scope()) ;
        else
            set_scope(rsrc, rsrc.get_scope()) ; 
    
      endfunction
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.1
      function void set_scope (uvm_resource_base rsrc, string scope); 
    
        table_q_t rq;
        string name;
        uvm_resource_base type_handle;
        uvm_resource_base r;
        int unsigned i;
    
        // If resource handle is ~null~ then there is nothing to do.
        if(rsrc == null) begin
          uvm_report_warning("NULLRASRC", "attempting to set scope of a null resource");
          return;
        end
    
        // Insert into the name map.  Resources with empty names are
        // anonymous resources and are not entered into the name map
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // is added to make the routine backward compatible
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.2
      function void set_override(uvm_resource_base rsrc, string scope="<not provided>");
         string s ;
         if (rsrc == null) begin
            uvm_report_warning("NULLRASRC", "attempting to change the search priority of a null resource");
            return;
         end
         if (scope == "<not provided>") s = rsrc.get_scope();
         else s = scope ;
         set_scope(rsrc, s);
         set_priority(rsrc, uvm_resource_types::PRI_HIGH);
      endfunction
    
    
      // Function -- NODOCS -- set_name_override
      //
      // The resource provided as an argument will entered into the pool
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // is added to make the routine backward compatible
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.3
      function void set_name_override(uvm_resource_base rsrc, string scope="<not provided>");
        string s ;
        if (rsrc == null) begin
            uvm_report_warning("NULLRASRC", "attempting to change the search priority of a null resource");
            return;
        end
        if (scope == "<not provided>") s = rsrc.get_scope();
        else s = scope ;
        set_scope(rsrc, s);
        set_priority_name(rsrc, uvm_resource_types::PRI_HIGH);
      endfunction
    
    
      // Function -- NODOCS -- set_type_override
      //
      // The resource provided as an argument will be entered into the pool
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // is added to make the routine backward compatible
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.4
      function void set_type_override(uvm_resource_base rsrc, string scope="<not provided>");
        string s ;
        if (rsrc == null) begin
            uvm_report_warning("NULLRASRC", "attempting to change the search priority of a null resource");
            return;
        end
        if (scope == "<not provided>") s = rsrc.get_scope();
        else s = scope ;
        set_scope(rsrc, s);
        set_priority_type(rsrc, uvm_resource_types::PRI_HIGH);
      endfunction
    
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.5
      virtual function bit get_scope(uvm_resource_base rsrc,
                                     output string scope);
    
        table_q_t rq;
        string name;
        uvm_resource_base r, type_handle;
        int unsigned i;
    
        // If resource handle is ~null~ then there is nothing to do.
        if(rsrc == null) 
          return 0;
    
        // Search the resouce in the name map.  Resources with empty names are
        // anonymous resources and are not entered into the name map
        name = rsrc.get_name();
        if((name != "") && rtab.exists(name)) begin
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // @uvm-ieee 1800.2-2020 auto C.2.4.3.6
      virtual function void delete ( uvm_resource_base rsrc );
        string name;
        table_q_t rq;
        uvm_resource_base type_handle;
        int    iter;
    
        if (rsrc != null) begin
    
          name = rsrc.get_name();
          if(name != "") begin
            if(rtab.exists(name)) begin
              rq = rtab[name];
              iter = 0;
    
              while (iter < `M__TABLE_Q(rq).size()) begin
                if (`M__TABLE_GET(rq, iter) == rsrc) begin
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // precedence will be the one that is returned.
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.4.2
      static function uvm_resource_base get_highest_precedence(ref uvm_resource_types::rsrc_q_t q);
    
        uvm_resource_base rsrc;
        uvm_resource_base r;
        int unsigned i;
        int unsigned prec;
        int unsigned c_prec;
    
        if(q.size() == 0)
          return null;
    
        // get the first resources in the queue
        rsrc = q.get(0);
        prec = (rsrc != null) ? rsrc.precedence: 0;
    
        // start searching from the second resource
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      //
      // Sorts a list of resources of resources in a standard SV
      // queue instead of a uvm_queue.
      static function void sort_by_precedence_q(ref uvm_resource_types::rsrc_sv_q_t q);
        uvm_resource_types::rsrc_sv_q_t all[int];
        uvm_resource_base r;
        int unsigned prec;
    
        for(int i=0; i<q.size(); ++i) begin
          r = q[i];
          prec = (r != null) ? r.precedence: 0;
          all[prec].push_back(r);
        end
        q.delete();
        foreach(all[iter]) begin
          q = {q, all[iter]};
        end
      endfunction // sort_by_precedence_q    
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
        end
    
        rq = ttab[type_handle];
        set_priority_queue(rsrc, rq, pri);
      endfunction
    
    
      // Function -- NODOCS -- set_priority_name
      //
      // Change the priority of the ~rsrc~ based on the value of ~pri~, the
      // priority enum argument.  This function changes the priority only in
      // the name map, leaving the type map untouched.
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.5.2
      function void set_priority_name(uvm_resource_base rsrc,
                                      uvm_resource_types::priority_e pri);
    
        string name;
        string msg;
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // @uvm-ieee 1800.2-2020 auto C.2.4.5.4
      static function void set_default_precedence( int unsigned precedence);
        uvm_coreservice_t cs = uvm_coreservice_t::get();
        cs.set_resource_pool_default_precedence(precedence);
      endfunction
    
    
      static function int unsigned get_default_precedence();
        uvm_coreservice_t cs = uvm_coreservice_t::get();
        return cs.get_resource_pool_default_precedence(); 
      endfunction
    
    
      // @uvm-ieee 1800.2-2020 auto C.2.4.5.6
      virtual function void set_precedence(uvm_resource_base r,
                                           int unsigned p=uvm_resource_pool::get_default_precedence());
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_pool.svh
      // is used to initiate the printing. If the ~audit~ bit is set then
      // the audit trail is dumped for each resource.
    
      function void dump(bit audit = 0, uvm_printer printer = null);
    
        string name;
        static uvm_tree_printer m_printer;
    
        if (m_printer == null) begin
          m_printer = new();
          m_printer.set_type_name_enabled(1);
        end
    
    
        if (printer == null)
          printer = m_printer;
    
        printer.flush();
        printer.push_element("uvm_resource_pool",
    

    完整源码 · SHA256:e617ba32a3b09e84913a841080b708ccbb69943976d2e48f3a92c72bf5c99806

    术语解释 · 兼容配置

    返回Config DB / Resource DB · 迁移清单

    版本适用范围