跳转至

输入查询内容

    本页内容

    resource 审计表搬迁与读写实现

    内部实现:文件组织、内部数据结构与实现钩子的变化。直接依赖内部接口时查阅,普通 API 的使用不需要重审这些源码。

    影响范围

    调试代码直接读取 rsrc.access 内部审计表。普通 read/write、record_read_access、print_accessors 调用可保留;新增 do_read/do_write 扩展按需采用。

    具体差异

    审计数据从 rsrc.access 移至 rsrc.dbg.access,直接访问 access 成员的调试代码编译失败;record_read_access 等公开方法保留、行为等价(仍受 uvm_resource_options::is_auditing() 控制)。read/write 主体逻辑下沉为可重写的 do_read/do_write 钩子,供用户定制资源读写行为。uvm_resource_options(turn_on/off_auditing、is_auditing)两版 API 不变。

    修改方案

    rsrc.access[...]rsrc.dbg.access[...];需要定制读写副作用时重写 do_read/do_write 而非修改库。

    兼容措施与范围:旧 rsrc.access 成员不再提供;审计方法保留,直接数据访问改走 rsrc.dbg.access。

    迁移后验证

    执行一次读写,检查审计记录、访问者和回调次数;确认调试服务记录与实际资源值一致。

    记录核销:在无规则及补充检查中记录实际依赖与证据。

    补充查阅

    扫描定位与记录结果

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

    • D17 · 启发式:直接依赖 UVM 内部表、执行入口或状态字段。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules D17
    

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

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

    源码与标准依据

    核查方式:源码核对。未单独进行 VCS 行为实测。

    VCS 内置 UVM-1.2uvm_resource.svh:205(公开成员 access[string])、uvm_resource.svh:480(record_read_access)、uvm_resource.svh:545(print_accessors)、uvm_resource.svh:1601uvm_resource.svh:1619(read/write 内联审计)

    VCS 内置 uvm-ieee-2020-2.0uvm_resource_base.svh:200(新类 uvm_resource_debug)、uvm_resource_base.svh:338uvm_resource_debug dbg)、uvm_resource_base.svh:483uvm_resource_base.svh:496uvm_resource_base.svh:510(record_*_access/print_accessors 委托 dbg);uvm_resource.svh:150uvm_resource.svh:183(do_read/do_write,@uvm-contrib

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

    src/vcs-uvm-1.2/base/uvm_resource.svh
      protected bit modified;
      protected bit read_only;
    
      uvm_resource_types::access_t access[string];
    
      // variable: precedence
      //
      // This variable is used to associate a precedence that a resource
      // has with respect to other resources which match the same scope
      // and name. Resources are set to the <default_precedence> initially,
      // and may be set to a higher or lower precedence as desired.
    
      int unsigned precedence;
    
      // variable: default_precedence
      //
      // The default precedence for an resource that has been created.
      // When two resources have the same precedence, the first resource
      // found has precedence.
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // function: record_read_access
    
      function void record_read_access(uvm_object accessor = null);
    
        string str;
        uvm_resource_types::access_t access_record;
    
        // If an accessor object is supplied then get the accessor record.
        // Otherwise create a new access record.  In either case populate
        // the access record with information about this access.  Check
        // first to make sure that auditing is turned on.
    
        if(!uvm_resource_options::is_auditing())
          return;
    
        // If an accessor is supplied, then use its name
        // as the database entry for the accessor record.
        // Otherwise, use "<empty>" as the database entry.
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      //
      // Dump the access records for this resource
      //
      virtual function void print_accessors();
    
        string str;
        uvm_component comp;
        uvm_resource_types::access_t access_record;
        string qs[$];
    
        if(access.num() == 0)
          return;
    
        foreach (access[i]) begin
          str = i;
          access_record = access[str];
          qs.push_back($sformatf("%s reads: %0d @ %0t  writes: %0d @ %0t\n",str,
                   access_record.read_count,
                   access_record.read_time,
    

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // object is supplied then also update the accessor record for this
      // resource.
    
      function T read(uvm_object accessor = null);
        record_read_access(accessor);
        return val;
      endfunction
    
      // Function: write
      // Modify the object stored in this resource container.  If the
      // resource is read-only then issue an error message and return
      // without modifying the object in the container.  If the resource is
      // not read-only and an ~accessor~ object has been supplied then also
      // update the accessor record.  Lastly, replace the object value in
      // the container with the value supplied as the argument, ~t~, and
      // release any processes blocked on
      // <uvm_resource_base::wait_modified>.  If the value to be written is
      // the same as the value already present in the resource then the
      // write is not done.  That also means that the accessor record is not
      // updated and the modified bit is not set.
    
      function void write(T t, uvm_object accessor = null);
    
        if(is_read_only()) begin
          uvm_report_error("resource", $sformatf("resource %s is read only -- cannot modify", get_name()));
          return;
        end
    
        // Set the modified bit and record the transaction only if the value
        // has actually changed.
        if(val == t)
          return;
    
        record_write_access(accessor);
    
        // set the value and set the dirty bit
        val = t;
    

    完整源码 · SHA256:6dd457f7586da01b713fb94bdb5472e7fdb3e741219398f87f341c21f5a0f8af

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_base.svh
    // in the parameterized uvm_resource class.
    //
    // @uvm-accellera The details of this API are specific to the Accellera implementation and are not being considered for contribution to 1800.2
    class uvm_resource_debug extends uvm_object ;
    
      uvm_resource_types::access_t access[string];
    
      `uvm_object_utils(uvm_resource_debug)
    
      function new(string name = "");
        super.new(name);
      endfunction
    
      // Function: record_read_access
      //
      // Record the read access information for this resource for debug purposes.
      // This information is used by <print_accessors> function.
      //
      // @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_base.svh
      protected bit read_only;
    
      // instance of delegate class for supporting resource debug
      uvm_resource_debug dbg ;
    
      protected string scope;
    
      //@uvm-compat provided for compatibility with 1.2
      int unsigned precedence;
      //@uvm-compat provided for compatibility with 1.2
      static int unsigned default_precedence = 1000;
    
      // @uvm-ieee 1800.2-2020 auto C.2.3.2.1
      function new(string name = "",string s = "<not provided>"); //string argument added for compatibility
        super.new(name);
        modified = 0;
        read_only = 0;
        // begin lines provided for compatibility with 1.2
        if (s == "<not provided>") scope = s; //don't call glob_to_re unless legacy usage
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource_base.svh
      //
      // @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
    
      function void record_read_access(uvm_object accessor = null);
         if (dbg==null) dbg = uvm_resource_debug::type_id::create("dbg") ; 
         dbg.record_read_access(accessor);
      endfunction
    
      // Function: record_write_access
      //
      // Delegates to the <uvm_resource_debug::record_write_access function to 
      // record write access information for this resource for debug purposes,
      // information used by <print_accessors> function.
      //
      // @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
    
      function void record_write_access(uvm_object accessor = null);
         if (dbg==null) dbg = uvm_resource_debug::type_id::create("dbg") ; 
         dbg.record_write_access(accessor);
      endfunction
    
      // Function: print_accessors
      //
      // Delegates to the <uvm_resource_debug::print_access function to 
      // print the read/write access history of the resource, using the accessor 
      // argument <accessor> which is passed to the <uvm_resource#(T)::read> 
      // and <uvm_resource#(T)::write> 
      //
      // @uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
    
      virtual function void print_accessors();
         // if dbg is null, we never called record_xxx_access and so there is nothing to print
         if (dbg != null) dbg.print_accessors();
      endfunction
    
      function void init_access_record (inout uvm_resource_types::access_t access_record);
         if (dbg==null) dbg = uvm_resource_debug::type_id::create("dbg") ; 
         dbg.init_access_record(access_record);
      endfunction
    
      //@uvm-compat provided for compatibility with 1.2
      function void set_scope(string s);
        scope = uvm_glob_to_re(s);
      endfunction
    
      function void m_set_scope(string s); 
    

    完整源码 · SHA256:1c28e6cc95c0ae5c636a1a6c81b65d5d9feab621c22d71b932791147f1c69e85

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource.svh
      // Accellera implementation and is not being considered for contribution to 1800.2
    
      //@uvm-contrib For potential contribution to 1800.2
      virtual function T do_read(uvm_object accessor);
        if (uvm_resource_options::is_auditing()) begin
           record_read_access(accessor);
        end
        return val;
      endfunction : do_read    
    
      // Function: write
      //
      //| function void write(T t, uvm_object accessor = null);
      //
      // This function is the implementation of the uvm_resource#(T)::write 
      // method detailed in IEEE1800.2-2020 section C.2.5.4.2
      //
      // The Accellera implementation passes ~t~ and ~accessor~ to <do_write>.
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_resource.svh
      // Accellera implementation and is not being considered for contribution to 1800.2
    
      //@uvm-contrib For potential contribution to 1800.2
      virtual function void do_write(T t, uvm_object accessor);
        if(is_read_only()) begin
          uvm_report_error("resource", $sformatf("resource %s is read only -- cannot modify", get_name()));
          return;
        end
    
        // Set the modified bit and record the transaction only if the value
        // has actually changed.
        if(val == t)
          return;
    
        if (uvm_resource_options::is_auditing()) begin
           record_write_access(accessor);
        end
    
        // set the value and set the dirty bit
    

    完整源码 · SHA256:7ea343e2caccbe066149268c978931c0190db327ec6940dffc17dfff00d5fc90

    术语解释 · 兼容配置

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

    版本适用范围