跳转至

输入查询内容

    本页内容

    自定义 resource_converter 已删除

    影响范围

    注册自定义 resource_converter 并依赖其打印格式。

    具体差异

    资源值转字符串的 policy 机制连同编译宏一起移除。2.0 的 convert2stringuvm_resource_base 经纯虚 m_value_type_name()/m_value_as_string() 实现(uvm_resource_base.svh:431-437uvm_resource.svh:72-78)。仅当 1.2 环境显式 +define+UVM_USE_RESOURCE_CONVERTER 并注册过自定义转换器时受影响。 旧开关默认关闭;仅使用仿真器原生 %p 打印而未注册 converter 的代码无需改写。

    修改方案

    改用派生资源类重写 m_value_as_string()/convert2string();未启用过该宏则无需改动。

    兼容措施与范围:旧 converter 类与开关不再提供;需要原打印效果时,将格式逻辑移入派生资源。

    迁移后验证

    将格式化逻辑迁入派生资源后打印代表值,核对输出和审计使用方;仅删除宏不能保留转换效果。

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

    补充查阅

    扫描定位与记录结果

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

    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules D10
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_resource_converter.svh:31(m_uvm_resource_converter 及 default/convert2string/sprint 转换器);uvm_resource.svh:1395–1419m_get_converter/m_set_converterifdef UVM_USE_RESOURCE_CONVERTER);uvm_macros.svh:49–51(默认关闭,注释说明该机制从未被 Accellera 正式认可) ;补充:src/vcs-uvm-1.2/deprecated/uvm_resource_converter.svh

    VCS 内置 uvm-ieee-2020-2.0:无(全库 grep 无 UVM_USE_RESOURCE_CONVERTER / uvm_resource_converter

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

    src/vcs-uvm-1.2/deprecated/uvm_resource_converter.svh
    // convertion from resource value to string.
    //
    //------------------------------------------------------------------------------
    class m_uvm_resource_converter #(type T=int);
    
       // Function- convert2string
       // Convert a value of type ~T~ to a string that can be displayed.
       //
       // By default, returns the name of the type
       //
       virtual function string convert2string(T val);
            return {"(", `uvm_typename(val), ") ?"};
       endfunction
    endclass
    
    //----------------------------------------------------------------------
    //
    // CLASS- uvm_resource_default_converter
    // Define a default resource value converter using '%p'.
    

    完整源码 · SHA256:891596c43eb1b24aaabd32924fb56670eb1ed43340d4fb2db886b02ce5e9b8aa

    src/vcs-uvm-1.2/base/uvm_resource.svh
      // Can't be rand since things like rand strings are not legal.
      protected T val;
    
    `ifdef UVM_USE_RESOURCE_CONVERTER
    
      // Singleton used to convert this resource to a string
      local static m_uvm_resource_converter#(T) m_r2s;
    
      // Function- m_get_converter
      // Get the conversion policy class that specifies how to convert the value
      // of a resource of this type to a string
      //
      static function m_uvm_resource_converter#(T) m_get_converter();
        if (m_r2s==null) m_r2s = new();
        return m_r2s;
      endfunction
    
    
      // Function- m_set_converter
      // Specify how to convert the value of a resource of this type to a string
      //
      // If not specified (or set to ~null~),
      // a default converter that display the name of the resource type is used.
      // Default conversion policies are specified for the built-in type.
      //
      static function void m_set_converter(m_uvm_resource_converter#(T) r2s);
        m_r2s = r2s;
      endfunction
    

    完整源码 · SHA256:6dd457f7586da01b713fb94bdb5472e7fdb3e741219398f87f341c21f5a0f8af

    src/vcs-uvm-1.2/uvm_macros.svh
    `ifdef VCS
    // `ifndef UVM_DISABLE_RESOURCE_CONVERTER
    
    //UVM_USE_RESOURCE_CONVERTER enables UVM-1.1d to print resources output to match uvm-1.1c. VCS2014.03 or later does not need resource_converter object.
    // As per agreement in Committee at time of UVM-1.1d, from UVM-1.2 onwards the default is to disable resource converter and allow simulators to deal with %p natively. If a user wishes to enable resource converter then they need to compile using +define+UVM_USE_RESOURCE_CONVERTER. The resource converter was never officially sanctioned by Accellera and is placed in the deprecated directory which may be removed in future version. 
    // `define UVM_USE_RESOURCE_CONVERTER
    
    // `endif
    `ifndef UVM_VCS_NO_DTL
    `define UVM_VCS_DTL
    `endif
    `ifndef UVM_VCS_NO_FGP
    `define UVM_VCS_FGP
    `endif
    `else
    `define UVM_VCS_GLOBAL_DECLARATIONS
    `define UVM_VCS_DECLARATIONS
    `define UVM_VCS_CHECK(if_expr) if_expr
    `define UVM_VCS_CLP_TF
    

    完整源码 · SHA256:cdf2c414fc9ae4bb2453842e5a1c1172596c5d19e34abeb4c7745a2773f98070

    术语解释 · 兼容配置

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

    版本适用范围