跳转至

输入查询内容

    本页内容

    自定义 coreservice:新增虚方法与初始化时机

    影响范围

    自行派生或整体替换 coreservice 的环境需检查初始化顺序;普通服务调用按实际依赖核对。

    具体差异

    coreservice 新增策略、资源池、hopper、种子等 pure virtual 接口。set(cs) 只是直接替换静态句柄,不执行 deferred registry/global 初始化;不能将它当成完整初始化流程。uvm_init(cs) 接收自定义实例,并执行初始化;库已初始化后再传不同实例会告警且忽略(src/vcs-uvm-ieee-2020-2.0/base/uvm_globals.svh:369)。

    修改方案

    自定义 coreservice 补齐目标签名。只有库尚未初始化时,uvm_init(custom_cs) 才能安装;不能把“用户 initial 第一行”视为满足此前提。默认 VCS Verdi 集成在 src/vcs-uvm-ieee-2020-2.0/base/uvm_globals.svh:629 / :643 的静态变量初始化调用 root getter,实测 initial 中安装被忽略;仅关闭 UVM_NO_VERDI_RECORD 对应集成后,本探针安装成功。关闭录制不是通用迁移要求,有 Verdi 需求时优先通过现有 coreservice 的服务访问器定制单项能力,整体替换须单独设计初始化与已有引用的迁移。

    需要保留自己的 coreservice 时,先决定是否可以继承 uvm_default_coreservice_t 并只覆盖业务所需服务。直接继承抽象 uvm_coreservice_t 的实现还须补齐下面的目标方法族;原 factory/report/root 等接口继续保留:

    服务 目标方法签名
    phase 上限 void set_phase_max_ready_to_end(int max) / int get_phase_max_ready_to_end()
    printer void set_default_printer(uvm_printer printer) / uvm_printer get_default_printer()
    packer void set_default_packer(uvm_packer packer) / uvm_packer get_default_packer()
    comparer void set_default_comparer(uvm_comparer comparer) / uvm_comparer get_default_comparer()
    copier void set_default_copier(uvm_copier copier) / uvm_copier get_default_copier()
    全局 seed int unsigned get_global_seed()
    seeding 控制 void set_uvm_seeding(bit enable) / bit get_uvm_seeding()
    resource pool void set_resource_pool(uvm_resource_pool pool) / uvm_resource_pool get_resource_pool()
    默认 precedence void set_resource_pool_default_precedence(int unsigned precedence) / int unsigned get_resource_pool_default_precedence()
    phase hopper uvm_phase_hopper get_phase_hopper()

    以上均是 function,派生类以 virtual function 实现对应返回类型及形参;getter/setter 使用同一份状态,不要返回临时新对象。目标默认实现可作为各服务的行为参照。

    如果只需要替换一种策略,优先在现有 coreservice 上调用对应 setter,例如 uvm_coreservice_t::get().set_default_comparer(cmp)。真正安装全新实例必须满足 uvm_init(custom_cs) 尚未执行过初始化的前提;uvm_coreservice_t::set(custom_cs) 仅替换句柄,不补做 deferred 注册,也不迁移已有引用。

    本机默认 Verdi 集成在用户 initial 前已触发 UVM 初始化,已有探针确认 initial 中调用 uvm_init(custom_cs) 会被忽略。关闭该集成的探针结果仅用于说明初始化时机,不是有 Verdi 需求时的通用改法。原 UVM_CORESERVICE_TYPE 选择也不能机械换成用户 initial 中的安装调用。

    兼容措施与范围:兼容开关不恢复旧 coreservice 初始化契约;自定义服务须满足安装时机,Verdi 集成另验。

    已知限制KI-012

    迁移后验证

    在真实录制配置下断言 get 返回自定义 service,并检查自定义资源池/policy 生效;关闭 Verdi 的探针对照不能代替实际集成验证。

    记录本条结果M01-014 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

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

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_coreservice.svh:31–35UVM_CORESERVICE_TYPE 宏选择实现类)、uvm_coreservice.svh:93(inst 直接 new)

    VCS 内置 uvm-ieee-2020-2.0uvm_coreservice.svh:120get_global_seed)、uvm_coreservice.svh:124–127set/get_default_copier)、uvm_coreservice.svh:132get/set_uvm_seeding)、uvm_coreservice.svh:153get_phase_hopper)、uvm_coreservice.svh:165(新增静态 uvm_coreservice_t::set(cs))、uvm_coreservice.svh:158–160(get() 空实例时先 uvm_init(null)

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

    src/vcs-uvm-1.2/base/uvm_coreservice.svh
    typedef class uvm_tr_database;
    typedef class uvm_text_tr_database;
    
    `ifndef UVM_CORESERVICE_TYPE
    `define UVM_CORESERVICE_TYPE uvm_default_coreservice_t
    `endif
    
    typedef class `UVM_CORESERVICE_TYPE;
    
    //----------------------------------------------------------------------
    // Class: uvm_coreservice_t
    //
    // The singleton instance of uvm_coreservice_t provides a common point for all central 
    // uvm services such as uvm_factory, uvm_report_server, ...
    // The service class provides a static <::get> which returns an instance adhering to uvm_coreservice_t
    // the rest of the set_<facility> get_<facility> pairs provide access to the internal uvm services
    //
    // Custom implementations of uvm_coreservice_t can be included in uvm_pkg::*
    // and can selected via the define UVM_CORESERVICE_TYPE. They cannot reside in another package.
    

    src/vcs-uvm-1.2/base/uvm_coreservice.svh
        // returns the uvm_root instance
        pure virtual function uvm_root get_root();
    
        local static `UVM_CORESERVICE_TYPE inst;
        // Function: get
        //
        // Returns an instance providing the uvm_coreservice_t interface.
        // The actual type of the instance is determined by the define `UVM_CORESERVICE_TYPE.
        //
        //| `define UVM_CORESERVICE_TYPE uvm_blocking_coreservice
        //| class uvm_blocking_coreservice extends uvm_default_coreservice_t;
        //|    virtual function void set_factory(uvm_factory f);
        //|       `uvm_error("FACTORY","you are not allowed to override the factory")
        //|    endfunction
        //| endclass
        //|
        static function uvm_coreservice_t get();
            if(inst==null)
                inst=new;
    

    完整源码 · SHA256:737ad718740c07ada40c0cc668bc562ba63c346da55724df0f7cc7a479cd7668

    src/vcs-uvm-ieee-2020-2.0/base/uvm_coreservice.svh
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.17
        pure virtual function uvm_comparer get_default_comparer();
    
        pure virtual function int unsigned get_global_seed();
    
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.18
        pure virtual function void set_default_copier(uvm_copier copier);
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.19
        pure virtual function uvm_copier get_default_copier();
    
    
    
            // @uvm-ieee 1800.2-2020 auto F.4.1.4.25
            pure virtual function bit get_uvm_seeding();
    
            // @uvm-ieee 1800.2-2020 auto F.4.1.4.26
            pure virtual function void set_uvm_seeding(bit enable);
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.21
        pure virtual function void set_resource_pool (uvm_resource_pool pool);
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.22
        pure virtual function uvm_resource_pool get_resource_pool();
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.4.23
        pure virtual function void set_resource_pool_default_precedence(int unsigned precedence);
    
        pure virtual function int unsigned get_resource_pool_default_precedence();
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_coreservice.svh
            // Returns the <uvm_phase_hopper> (singleton) instance for this environment
            //
            // @uvm-contrib For potential contribution to 1800.2
            pure virtual function uvm_phase_hopper get_phase_hopper();
    
        local static uvm_coreservice_t inst;
    
        // @uvm-ieee 1800.2-2020 auto F.4.1.3
        static function uvm_coreservice_t get();
            if(inst==null)
                uvm_init(null);
    
            return inst;
        endfunction // get
    
        static function void set(uvm_coreservice_t cs);
            inst=cs;
        endfunction
    endclass
    
    // Class: uvm_default_coreservice_t
    // Implementation of the uvm_default_coreservice_t as defined in
    // section F.4.2.1 of 1800.2-2020.
    //
    //| class uvm_default_coreservice_t extends uvm_coreservice_t
    //
    
    // @uvm-ieee 1800.2-2020 auto F.4.2.1
    class uvm_default_coreservice_t extends uvm_coreservice_t;
        local uvm_factory factory;
    

    完整源码 · SHA256:f7cad9269dafa30402c6ffe86a99dc8c0fedf1e02e8faff9ec4e6f6e7b083202

    src/vcs-uvm-ieee-2020-2.0/base/uvm_globals.svh
    // @uvm-contrib This API represents a potential contribution to IEEE 1800.2
    
    // @uvm-ieee 1800.2-2020 auto F.3.1.3
    function void uvm_init(uvm_coreservice_t cs=null);
      uvm_default_coreservice_t dcs;
    
      if(get_core_state()!=UVM_CORE_UNINITIALIZED) begin
        if (get_core_state() == UVM_CORE_PRE_INIT) begin
          // If we're in this state, something very strange has happened.
          // We've called uvm_init, and it is actively assigning the
          // core service, but the core service isn't actually set yet.
          // This means that either the library messed something up, or
          // we have a race occurring between two threads.  Either way, 
          // this is non-recoverable.  We're going to setup using the default
          // core service, and immediately fatal out.
          dcs = new();
          uvm_coreservice_t::set(dcs);
          `uvm_fatal("UVM/INIT/MULTI", "Non-recoverable race during uvm_init")
        end
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_globals.svh
    `ifdef VCS
    
    function void verdi_set_report_verbosity_level_hier(int verbosity);
      static uvm_root top = uvm_root::get();
    
      top.set_report_verbosity_level_hier(verbosity);
    endfunction
    
    function void verdi_set_verbosity(logic [115199:0] options_bv,bit first=0);
      // _ALL_ can be used for ids
      // +uvm_set_verbosity=<comp>,<id>,<verbosity>,<phase|time>,<offset>
      // +uvm_set_verbosity=uvm_test_top.env0.agent1.*,_ALL_,UVM_FULL,time,800
    
      string args[$];
      string options;
      uvm_component list[$];
      static uvm_cmdline_processor clp = uvm_cmdline_processor::get_inst();
      static uvm_root top = uvm_root::get();
    
      begin
        if (first)
            return;
        args.delete();
        options = uvm_bits_to_string(options_bv);
        uvm_string_split(options, ",", args);
    
        begin
          setting_comp = args[0];
          setting_id = args[1];
          void'(clp.m_convert_verb(args[2],setting_verbosity));
          setting_phase = args[3];
          setting_offset = 0;
          if(args.size() == 5) begin
    

    完整源码 · SHA256:7c9321d117c5e3391f81792b730837a5bca47d3539152d98412ae3c75594fe2f

    术语解释 · 兼容配置

    返回Object / Factory · 迁移清单

    版本适用范围