跳转至

输入查询内容

    本页内容

    registry 延迟注册与初始化实现

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

    影响范围

    直接依赖 registry 的静态注册时机,或自行绕过标准初始化入口。普通 type_id::create/type_name 读取可保留;公开 coreservice 的替换要求见 M01-014,类型名变量用法见 M09-006,新增抽象注册能力见 M09-012

    具体差异

    2.0 通过 uvm_deferred_init 队列在 uvm_init() 中注册(base/uvm_globals.svh:422),而 coreservice 首次 get() 会自动触发初始化,不能据此断言普通 factory.print() 会看不到注册项。自定义 coreservice/静态初始化代码仍需核对调用顺序。新增 uvm_abstract_component_registry/uvm_abstract_object_registry 支持抽象类注册;未 override 而创建时报 UVM/ABST_RGTRY/CREATE_ABSTRACT_*,这与直接 new 抽象类的编译失败不同。新增 type_id::set_type_alias("别名")。 registry.type_name 的成员形态变化统一见 M09-006

    修改方案

    普通 type_name 读取与 type_id::create 可保留;自定义初始化不要绕过 uvm_init 的 deferred 注册。若通过抽象 registry 创建对象,先设置具体派生类 override,再检查返回非空和实际类型;整体替换 coreservice 的时机按 M01-014 核对。

    兼容措施与范围:现有入口无需兼容开关;这不表示两版行为相同,仍按本条条件和验证方法核对。

    迁移后验证

    初始化后查询注册项并 create 具体对象;对抽象类型提供具体 override,检查返回非空和实际类型。类型名读取的编译验证见 M09-006

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

    已有实测与复现

    补充查阅

    扫描定位与记录结果

    无对应规则。当前脚本没有针对本条的直接检测规则。

    按“影响范围”检视实际代码与配置,再执行本条验证方法;扫描零命中不能排除此项。

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_registry.svh:71const static string type_name = Tname;,uvm_object_registry 同见于 uvm_registry.svh:213),get() 在静态初始化即向 factory 注册

    VCS 内置 uvm-ieee-2020-2.0uvm_registry.svh:68static function string type_name())、uvm_registry.svh:290(uvm_abstract_component_registry)、uvm_registry.svh:411(uvm_abstract_object_registry)、uvm_registry.svh:155set_type_alias

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

    src/vcs-uvm-1.2/base/uvm_registry.svh
      endfunction
    
    
      const static string type_name = Tname;
    
      // Function: get_type_name
      //
      // Returns the value given by the string parameter, ~Tname~. This method
      // overrides the method in <uvm_object_wrapper>.
    
      virtual function string get_type_name();
        return type_name;
      endfunction
    
      local static this_type me = get();
    
    
      // Function: get
      //
    

    src/vcs-uvm-1.2/base/uvm_registry.svh
        return obj;
      endfunction
    
      const static string type_name = Tname;
    
      // Function: get_type_name
      //
      // Returns the value given by the string parameter, ~Tname~. This method
      // overrides the method in <uvm_object_wrapper>.
    
      virtual function string get_type_name();
        return type_name;
      endfunction
    
      local static this_type me = get();
    
      // Function: get
      //
      // Returns the singleton instance of this type. Type-based factory operation
    

    完整源码 · SHA256:fc5105829c7c96095d9c4d7c43d4dd5b63cf7667ae7b1c4440e4df23b73989c0

    src/vcs-uvm-ieee-2020-2.0/base/uvm_registry.svh
      endfunction
    
    
       static function string type_name();
         return common_type::type_name();
       endfunction : type_name
    
      // Function -- NODOCS -- get_type_name
      //
      // Returns the value given by the string parameter, ~Tname~. This method
      // overrides the method in <uvm_object_wrapper>.
    
      // @uvm-ieee 1800.2-2020 auto 8.2.3.2.2
      virtual function string get_type_name();
         common_type common = common_type::get();
         return common.get_type_name();
      endfunction
    
      // @uvm-ieee 1800.2-2020 manual 8.2.4.2.3
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_registry.svh
      // then the alias is deferred until registration occurs.
      //
      // @uvm-contrib This API is being considered for potential contribution to 1800.2
      static function bit set_type_alias(string alias_name);
         common_type::set_type_alias( alias_name );
         return 1;
      endfunction
    
    endclass
    
    
    // Class: uvm_object_registry#(T,Tname)
    // Implementation of uvm_object_registry#(T,Tname), as defined by section
    // 8.2.4.1 of 1800.2-2020.
    
    // @uvm-ieee 1800.2-2020 auto 8.2.4.1
    class uvm_object_registry #(type T=uvm_object, string Tname="<unknown>")
                                            extends uvm_object_wrapper;
      typedef uvm_object_registry #(T,Tname) this_type;
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_registry.svh
    // 8.2.5.1.1 of 1800.2-2020.
    
    // @uvm-ieee 1800.2-2020 auto 8.2.5.1.1
    class uvm_abstract_component_registry #(type T=uvm_component, string Tname="<unknown>")
                                               extends uvm_object_wrapper;
      typedef uvm_abstract_component_registry #(T,Tname) this_type;
      typedef uvm_registry_common#( this_type, uvm_registry_component_creator, T, Tname ) common_type;
    
      // Function -- NODOCS -- create_component
      //
      // Creates a component of type T having the provided ~name~ and ~parent~.
      // This is an override of the method in <uvm_object_wrapper>. It is
      // called by the factory after determining the type of object to create.
      // You should not call this method directly. Call <create> instead.
    
      // @uvm-ieee 1800.2-2020 auto 8.2.5.1.2
      virtual function uvm_component create_component (string name,
                                                       uvm_component parent);
        `uvm_error(
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_registry.svh
    // 8.2.5.2.1 of 1800.2-2020.
    
    // @uvm-ieee 1800.2-2020 auto 8.2.5.2.1
    class uvm_abstract_object_registry #(type T=uvm_object, string Tname="<unknown>")
                                            extends uvm_object_wrapper;
      typedef uvm_abstract_object_registry #(T,Tname) this_type;
      typedef uvm_registry_common#( this_type, uvm_registry_object_creator, T, Tname ) common_type;
    
      // Function -- NODOCS -- create_object
      //
      // Creates an object of type ~T~ and returns it as a handle to a
      // <uvm_object>. This is an override of the method in <uvm_object_wrapper>.
      // It is called by the factory after determining the type of object to create.
      // You should not call this method directly. Call <create> instead.
    
      // @uvm-ieee 1800.2-2020 auto 8.2.5.2.2
      virtual function uvm_object create_object(string name="");
        `uvm_error(
          "UVM/ABST_RGTRY/CREATE_ABSTRACT_OBJ",
    

    完整源码 · SHA256:0cf5c58a30662e9b35e3b35ae2a9929f841b6508afbe377e87e51140247b31c6

    术语解释 · 兼容配置

    自定义 coreservice(M01-014) · 注册宏的 type_name 改为函数形式(M09-006) · 新增 abstract 注册宏族(M09-012)

    返回Object / Factory · 迁移清单

    版本适用范围