跳转至

输入查询内容

    本页内容

    注册宏的 type_name 改为函数形式

    影响范围

    把 type_name 当可写变量、重复声明它,或跨库改成函数调用。 包括 comparator/pair 工具类的 type_name 变量上下文及类型名匹配。

    具体差异

    utils/phase 宏生成的 type_name 由静态数据成员变为无参静态函数,registry 的 type_name 也同步改变。普通 T::type_nameT::type_id::type_name 读取在两版 VCS 中可用,因为 SV 允许省略无参函数调用括号。不能仅凭省略括号判断编译断点;重复声明同名成员或要求变量的上下文需另行核对。 comparator/pair 工具类同样改用 uvm_type_name_decl:uvm_in_order_comparator、uvm_algorithmic_comparator、uvm_class_pair、uvm_built_in_pair 的类型名字符串与 get_type_name() 返回值保持,两版均未因此新增 factory 注册。

    修改方案

    普通读取可保留;新目标代码可显式写 T::type_name()。重复声明或要求变量的用法单独核对,跨版本代码不能把旧常量机械改成函数调用。 需要可写字符串、ref 实参或缓存类型名时,先复制到自有 string 变量;不要仅因 type_name 的实现变化给 comparator/pair 补 factory 注册。registry 初始化另见 M01-006,抽象组件注册见 M10-003predictor 的旧可写成员及 flush 见 M07-012

    兼容措施与范围:普通 type_name 读取可保留;兼容措施不恢复静态变量形态,要求可写或 ref 的位置须使用自有变量。

    迁移后验证

    两库分别编译普通读取及实际特殊上下文,核对返回名;只对受影响用法改写,不能把旧常量无条件调用。 comparator/pair 还应对照实际类型字符串,确认名称匹配结果。

    记录本条结果M09-006 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

    • C27 · 启发式:type_name 被当作可写变量。 排除自有变量、形参及普通下标读取;受影响成员写入和注册宏与同名声明冲突仍提示,未解析完整类型系统。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules C27
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_object_defines.svh:434m_uvm_get_type_name_funcconst static string type_name = "T";);phase 侧 uvm_phase_defines.svh:46 ;补充:uvm_in_order_comparator.svh:82uvm_in_order_comparator.svh:217uvm_in_order_comparator.svh:249uvm_algorithmic_comparator.svh:72uvm_pair.svh:43uvm_pair.svh:121

    VCS 内置 uvm-ieee-2020-2.0uvm_object_defines.svh:530uvm_type_name_declstatic function string type_name(););phase 侧 uvm_phase_defines.svh:48 ;补充:uvm_in_order_comparator.svh:84uvm_in_order_comparator.svh:213uvm_in_order_comparator.svh:240uvm_algorithmic_comparator.svh:80uvm_pair.svh:43uvm_pair.svh:116

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

    src/vcs-uvm-1.2/macros/uvm_object_defines.svh
    // m_uvm_get_type_name_func
    // ----------------------
    
    `define m_uvm_get_type_name_func(T) \
       const static string type_name = `"T`"; \
       virtual function string get_type_name (); \
         return type_name; \
       endfunction 
    
    
    // m_uvm_object_registry_internal
    // ------------------------------
    
    //This is needed due to an issue in of passing down strings
    //created by args to lower level macros.
    `define m_uvm_object_registry_internal(T,S) \
       typedef uvm_object_registry#(T,`"S`") type_id; \
       static function type_id get_type(); \
         return type_id::get(); \
    

    完整源码 · SHA256:fad4b0a983286e771a025f28de582e35b21fd1dc49d8fcc5c1b2be9f4ebe99d1

    src/vcs-uvm-1.2/macros/uvm_phase_defines.svh
                  comp_.``PHASE``_phase(phase); \
              endtask \
              local static PREFIX``PHASE``_phase m_inst; \
              static const string type_name = `"PREFIX``PHASE``_phase`"; \
              static function PREFIX``PHASE``_phase get(); \
                if(m_inst == null) begin \
                  m_inst = new; \
                end \
                return m_inst; \
              endfunction \
              protected function new(string name=`"PHASE`"); \
                super.new(name); \
              endfunction \
              virtual function string get_type_name(); \
                return type_name; \
              endfunction \
            endclass \
            //PREFIX``PHASE``_phase PREFIX``PHASE``_ph = PREFIX``PHASE``_phase::get();
    

    完整源码 · SHA256:ef309c4a45ea4f33256f1c5a8a7ab05e5705aac9640f56829e39b5034c621b56

    src/vcs-uvm-1.2/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_comparator #(T,comp_type,convert,pair_type) this_type;
      `uvm_component_param_utils(this_type)
    
      const static string type_name = 
        "uvm_in_order_comparator #(T,comp_type,convert,pair_type)";
    
      // Port: before_export
      //
      // The export to which one stream of data is written. The port must be
      // connected to an analysis port that will provide such data. 
    
      uvm_analysis_export #(T) before_export;
    
    
      // Port: after_export
      //
      // The export to which the other stream of data is written. The port must be
      // connected to an analysis port that will provide such data. 
    

    src/vcs-uvm-1.2/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_built_in_comparator #(T) this_type;
      `uvm_component_param_utils(this_type)
    
      const static string type_name = "uvm_in_order_built_in_comparator #(T)";
    
      function new(string name, uvm_component parent);
        super.new(name, parent);
      endfunction
    
      virtual function string get_type_name ();
        return type_name;
      endfunction
    
    endclass
    
    
    //------------------------------------------------------------------------------
    //
    // CLASS: uvm_in_order_class_comparator #(T)
    

    src/vcs-uvm-1.2/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_class_comparator #(T) this_type;
      `uvm_component_param_utils(this_type)
    
      const static string type_name = "uvm_in_order_class_comparator #(T)";
    
      function new( string name  , uvm_component parent);
        super.new( name, parent );
      endfunction
    
      virtual function string get_type_name ();
        return type_name;
      endfunction
    
    endclass
    

    完整源码 · SHA256:a5f8d43d835d05bb432e02259b662a311d4d3ab51bfc25301948458f5691e716

    src/vcs-uvm-1.2/comps/uvm_algorithmic_comparator.svh
                                        type AFTER=int,
                                        type TRANSFORMER=int) extends uvm_component;
    
      const static string type_name = "uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)";
    
      typedef uvm_algorithmic_comparator #( BEFORE , 
                                            AFTER , 
                                            TRANSFORMER ) this_type;
    
      `uvm_component_param_utils(this_type)
    
    
      // Port: before_export
      //
      // The export to which a data stream of type BEFORE is sent via a connected
      // analysis port. Publishers (monitors) can send in an ordered stream of
      // transactions against which the transformed BEFORE transactions will
      // (be compared.
    

    完整源码 · SHA256:6d348ad863a30c2c2b6862661af112724faa1808be4e5ab4a6354afe0cc430e0

    src/vcs-uvm-1.2/comps/uvm_pair.svh
      `uvm_object_param_utils(this_type)
    
      const static string type_name = "uvm_class_pair #(T1,T2)";
    
    // Variable: T1 first
    //
    // The handle to the first object in the pair
    
      T1 first;
    
    // Variable: T2 second
    //
    // The handle to the second object in the pair
    
      T2 second;
    
      // Function: new
      //
    

    src/vcs-uvm-1.2/comps/uvm_pair.svh
      `uvm_object_param_utils(this_type)
    
      const static string type_name = "uvm_built_in_pair #(T1,T2)";
    
    // Variable: T1 first
    //
    // The first value in the pair
    
      T1 first;
    
    // Variable: T2 second
    //
    // The second value in the pair
    
      T2 second;
    
      // Function: new
      //
    

    完整源码 · SHA256:23ab6d6c1115d22ea185cdb759b7d7f9ccd2c0635ca91d2dd01d7b32d879c303

    src/vcs-uvm-ieee-2020-2.0/macros/uvm_object_defines.svh
    // ~type_name~, and implements the virtual
    // <uvm_object::get_type_name> method.
    //
     `define uvm_type_name_decl(TNAME_STRING) \
         static function string type_name(); \
           return TNAME_STRING; \
         endfunction : type_name \
         virtual function string get_type_name(); \
           return TNAME_STRING; \
         endfunction : get_type_name
    
    
    // m_uvm_object_registry_internal
    // ------------------------------
    
    //This is needed due to an issue in of passing down strings
    //created by args to lower level macros.
    `define m_uvm_object_registry_internal(T,S) \
       typedef uvm_object_registry#(T,`"S`") type_id; \
    

    完整源码 · SHA256:072baece05e653f6811936de05739a8ff55c02651d89a9278f39cca11372a260

    src/vcs-uvm-ieee-2020-2.0/macros/uvm_phase_defines.svh
                  comp_.``PHASE``_phase(phase); \
              endtask \
              local static PREFIX``PHASE``_phase m_inst; \
              `uvm_type_name_decl(`"PREFIX``PHASE``_phase`") \
              static function PREFIX``PHASE``_phase get(); \
                if(m_inst == null) begin \
                  m_inst = new; \
                end \
                return m_inst; \
              endfunction \
              protected function new(string name=`"PHASE`"); \
                super.new(name); \
              endfunction \
            endclass \
            //PREFIX``PHASE``_phase PREFIX``PHASE``_ph = PREFIX``PHASE``_phase::get();
    
    `define m_uvm_topdown_phase(PHASE,COMP,PREFIX) \
            class PREFIX``PHASE``_phase extends uvm_topdown_phase; \
              virtual function void exec_func(uvm_component comp, uvm_phase phase); \
    

    完整源码 · SHA256:616851b0ae13604220523b98f8450555a0617b95a4da17d088fdda02e2fb7308

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_comparator #(T,comp_type,convert,pair_type) this_type;
      `uvm_component_param_utils(this_type)
      `uvm_type_name_decl("uvm_in_order_comparator #(T,comp_type,convert,pair_type)")
    
      // Port --NODOCS-- before_export
      //
      // The export to which one stream of data is written. The port must be
      // connected to an analysis port that will provide such data. 
    
      uvm_analysis_export #(T) before_export;
    
    
      // Port --NODOCS-- after_export
      //
      // The export to which the other stream of data is written. The port must be
      // connected to an analysis port that will provide such data. 
    
      uvm_analysis_export #(T) after_export;
    

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_built_in_comparator #(T) this_type;
      `uvm_component_param_utils(this_type)
      `uvm_type_name_decl("uvm_in_order_built_in_comparator #(T)")
    
      function new(string name, uvm_component parent);
        super.new(name, parent);
      endfunction
    
    endclass
    
    
    //------------------------------------------------------------------------------
    //
    // CLASS --NODOCS-- uvm_in_order_class_comparator #(T)
    //
    // This class uses the uvm_class_* comparison, converter, and pair classes.
    // Use this class for comparing user-defined objects of type T, which must
    // provide compare() and convert2string() method.
    

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_in_order_comparator.svh
      typedef uvm_in_order_class_comparator #(T) this_type;
      `uvm_component_param_utils(this_type)
      `uvm_type_name_decl("uvm_in_order_class_comparator #(T)")
    
      function new( string name  , uvm_component parent);
        super.new( name, parent );
      endfunction
    
    endclass
    

    完整源码 · SHA256:480605ae12aca5814512a3f3ab1a74c73fc6c05d1a9ebae6e121cbd882ef0817

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_algorithmic_comparator.svh
                                            TRANSFORMER ) this_type;
    
      `uvm_component_param_utils(this_type)
      `uvm_type_name_decl("uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)")
    
      // Port --NODOCS-- before_export
      //
      // The export to which a data stream of type BEFORE is sent via a connected
      // analysis port. Publishers (monitors) can send in an ordered stream of
      // transactions against which the transformed BEFORE transactions will
      // (be compared.
    
      uvm_analysis_imp #(BEFORE, this_type) before_export;
    
    
      // Port --NODOCS-- after_export
      //
      // The export to which a data stream of type AFTER is sent via a connected
      // analysis port. Publishers (monitors) can send in an ordered stream of
    

    完整源码 · SHA256:87cea1e947ffb95389c38d55db0d9da905ffaf47ddb98f0b45a072eff8f58e84

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_pair.svh
      typedef uvm_class_pair #(T1, T2 ) this_type;
    
      `uvm_object_param_utils(this_type)
      `uvm_type_name_decl("uvm_class_pair #(T1,T2)")
    
    // Variable -- NODOCS -- T1 first
    //
    // The handle to the first object in the pair
    
      T1 first;
    
    // Variable -- NODOCS -- T2 second
    //
    // The handle to the second object in the pair
    
      T2 second;
    
      // Function -- NODOCS -- new
      //
    

    src/vcs-uvm-ieee-2020-2.0/comps/uvm_pair.svh
      typedef uvm_built_in_pair #(T1,T2) this_type;
    
      `uvm_object_param_utils(this_type)
      `uvm_type_name_decl("uvm_built_in_pair #(T1,T2)")
    
    // Variable -- NODOCS -- T1 first
    //
    // The first value in the pair
    
      T1 first;
    
    // Variable -- NODOCS -- T2 second
    //
    // The second value in the pair
    
      T2 second;
    
      // Function -- NODOCS -- new
      //
    

    完整源码 · SHA256:3e7f202d4ead38913b2ea5a328f0c35034ee3c42e7f31447f558664c4391fe00

    术语解释 · 兼容配置

    registry 延迟注册与初始化实现(M01-006) · uvm_reg_predictor(M07-012) · 抽象组件的工厂注册与 type_name 使用(M10-003)

    返回Field Automation / 版本宏 · 迁移清单

    版本适用范围