跳转至

输入查询内容

    本页内容

    禁用自动字段配置:旧开关改为组件方法

    影响范围

    依赖 disable_apply_cfg_settings、旧禁止自动配置开关,或定制字段自动赋值。

    具体差异

    自动配置仍默认开启,改由 set_local(resource) 和 UVM_SET 操作赋值。默认 CONFIG_CHECK_NAMES 先通过 UVM_CHECK_FIELDS 枚举字段名再查询资源;CONFIG_STRICT 扩大查询范围,仍需字段操作完成赋值,不会发现任意未注册 SV 成员。VCS 1.2 的 disable_apply_cfg_settings 及对应 plusarg 被删除,目标版可在用户组件基类 override use_automatic_config 返回 0。

    修改方案

    检索 disable_apply_cfg_settings/UVM_DISABLE_APPLY_CFG_SETTINGS 使用点并改 override;如脚本依赖 +UVM_DISABLE_APPLY_CFG_SETTINGS 需删除。

    旧构建依赖 +UVM_DISABLE_APPLY_CFG_SETTINGS 时,目标库不会再按这个参数关闭自动字段赋值。在需要禁用的用户组件基类中加入:

    1
    2
    3
    virtual function bit use_automatic_config();
      return 0;
    endfunction
    

    随后删除无效旧参数。此方法只影响继承该基类的组件;第三方 VIP 和其他基类需分别核对。显式 uvm_config_db::get() 仍可用于读取配置。

    兼容措施与范围:旧自动配置开关不再生效;用 use_automatic_config 控制,并验证字段赋值。

    迁移后验证

    对同一字段设置非默认配置,分别开启/关闭 use_automatic_config,断言 build 后实际字段值;未注册字段不能因 CONFIG_STRICT 就预期自动赋值。

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

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

    • D5 · 文本匹配:disable_apply_cfg_settings / +UVM_DISABLE_APPLY_CFG_SETTINGS(VCS 1.2 私有开关删除)。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules D5
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_component.svh:3527(apply_config_settings);uvm_root.svh:272–276disable_apply_cfg_settings,由 +define+UVM_DISABLE_APPLY_CFG_SETTINGS+UVM_DISABLE_APPLY_CFG_SETTINGS plusarg 控制)

    VCS 内置 uvm-ieee-2020-2.0uvm_component.svh:1561–1580config_mode_e:CONFIG_STRICT/CONFIG_HIGHEST_PRECEDENCE/CONFIG_CHECK_NAMES,默认 CONFIG_CHECK_NAMES)、uvm_component.svh:1589/uvm_component.svh:3382apply_config_settings_mode())、uvm_component.svh:917/uvm_component.svh:3388use_automatic_config(),默认返回 1)、uvm_component.svh:3930–3931(build() 内自动调用);默认宏 uvm_global_defines.svh:42

    标准依据:IEEE 1800.2-2020 §13.1.5.1(apply_config_settings)、§13.1.5.2(use_automatic_config)

    标为“源码标注”或未注明原文核对的条款仅作定位;具体库行为以源码和实测为准。

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

    src/vcs-uvm-1.2/base/uvm_component.svh
    // apply_config_settings
    // ---------------------
    
    function void uvm_component::apply_config_settings (bit verbose=0);
    
      uvm_resource_pool rp = uvm_resource_pool::get();
      uvm_queue#(uvm_resource_base) rq;
      uvm_resource_base r;
      string name;
      string search_name;
      int unsigned i;
      int unsigned j;
    
      // populate an internal 'field_array' with list of
      // fields declared with `uvm_field macros (checking
      // that there aren't any duplicates along the way)
      __m_uvm_field_automation (null, UVM_CHECK_FIELDS, "");
    
      // if no declared fields, nothing to do. 
    

    完整源码 · SHA256:a64354e981dcf241513831f16466d6bea6dea05c561ffe3a3ae02dd7bcce99fc

    src/vcs-uvm-1.2/base/uvm_root.svh
       //variable to disable uvm_component::apply_config_settings();
    `ifdef UVM_DISABLE_APPLY_CFG_SETTINGS 
       bit disable_apply_cfg_settings =1; 
    `else 
       string trace_args[$];
       uvm_cmdline_processor clp_inst = uvm_cmdline_processor::get_inst(); 
       bit disable_apply_cfg_settings =
            clp_inst.get_arg_matches("+UVM_DISABLE_APPLY_CFG_SETTINGS",trace_args) ? 1:0; 
    `endif
    
       // internal function not to be used
       // get the initialized singleton instance of uvm_root
       static function uvm_root m_uvm_get_root();
          if (m_inst == null) begin
         m_inst = new();
         void'(uvm_domain::get_common_domain());
         m_inst.m_domain = uvm_domain::get_uvm_domain();
          end
    

    完整源码 · SHA256:7a3a006a2f6a7b5bbedc778d199ef5389bbe97f19358c79b12ec5d3b18e81438

    src/vcs-uvm-ieee-2020-2.0/base/uvm_component.svh
      // otherwise, returns 0.
      //
      // @uvm-ieee 1800.2-2020 auto 13.1.5.2
      extern virtual function bit use_automatic_config();
    
      // Function: print_config
      //
      // Print_config prints all configuration information for this
      // component, as set by previous calls to <uvm_config_db::set()> and exports to
      // the resources pool.  The settings are printed in the order of
      // their precedence.
      //
      // If ~recurse~ is set, then configuration information for all
      // children and below are printed as well.
      //
      // if ~audit~ is set then the audit trail for each resource is printed
      // along with the resource name and value
      //
      // @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_component.svh
      // |  typedef bit [1:0] config_mode_t;
      //
      // @uvm-contrib
      typedef bit [1:0] config_mode_t;
    
      // Type: config_mode_e
      // Enumeration for controlling component config settings.
      //
      // CONFIG_STRICT - Strictly adhere to the LRM
      // CONFIG_HIGHEST_PRECEDENCE - Only apply resources with highest precedence for each 
      //                             field name / type handle pair
      // CONFIG_CHECK_NAMES - Only apply settings for fields names responding to UVM_CHECK_FIELDS op
      //
      // @uvm-contrib
      typedef enum config_mode_t {CONFIG_STRICT=2'b00,
                                  CONFIG_HIGHEST_PRECEDENCE=2'b01,
                                  CONFIG_CHECK_NAMES=2'b10} config_mode_e;
    
      // Variable: CONFIG_DEFAULT
      // Default configuration mode used by apply_config_settings_mode.
      //
      // @uvm-contrib
      localparam config_mode_t CONFIG_DEFAULT = `UVM_COMPONENT_CONFIG_MODE_DEFAULT;
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_component.svh
      // mode.
      //
      // @uvm-contrib
      extern virtual function config_mode_t apply_config_settings_mode();
    
    
      // Variable -- NODOCS -- tr_database
      //
      // Specifies the <uvm_tr_database> object to use for <begin_tr>
      // and other methods in the <Recording Interface>.  
      // Default is <uvm_coreservice_t::get_default_tr_database>.
      uvm_tr_database tr_database;
    
      // @uvm-ieee 1800.2-2020 auto 13.1.7.12
      extern virtual function uvm_tr_database get_tr_database();
    
      // @uvm-ieee 1800.2-2020 auto 13.1.7.11
      extern virtual function void set_tr_database(uvm_tr_database db);
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_component.svh
    // apply_config_settings_mode
    // ---------------
    function uvm_component::config_mode_t uvm_component::apply_config_settings_mode();
      return CONFIG_DEFAULT;
    endfunction : apply_config_settings_mode
    
    // use_automatic_config
    // --------------------
    function bit uvm_component::use_automatic_config();
      return 1;
    endfunction 
    
    // check_config_usage
    // ------------------
    
    function void uvm_component::check_config_usage ( bit recurse=1 );
      uvm_resource_pool rp = uvm_resource_pool::get();
      uvm_queue#(uvm_resource_base) rq;
    
      rq = rp.find_unused_resources();
    
      if(rq.size() == 0)
        return;
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_component.svh
    // contains default behavior for build_phase()
    function void uvm_component::build();
      m_build_done = 1;
      if (use_automatic_config())
        apply_config_settings(get_print_config_matches());
    endfunction
    
    // These are the old style phase names for backward compatibility. 
    function void uvm_component::connect();             return; endfunction
    function void uvm_component::start_of_simulation(); return; endfunction
    function void uvm_component::end_of_elaboration();  return; endfunction
    task          uvm_component::run();                 return; endtask
    function void uvm_component::extract();             return; endfunction
    function void uvm_component::check();               return; endfunction
    function void uvm_component::report();              return; endfunction
    

    完整源码 · SHA256:a35015c7b14dbf63f2e47a4d202e49555159bb91c263255a1421e3cfdf9e63f2

    src/vcs-uvm-ieee-2020-2.0/macros/uvm_global_defines.svh
    //
    // @uvm-contrib
    `ifndef UVM_COMPONENT_CONFIG_MODE_DEFAULT
     `define UVM_COMPONENT_CONFIG_MODE_DEFAULT CONFIG_CHECK_NAMES
    `endif
    
    // MACRO -- NODOCS -- `UVM_MAX_STREAMBITS
    //
    // Defines the maximum bit vector size for integral types. 
    // Used to set uvm_bitstream_t
    
    `ifndef UVM_MAX_STREAMBITS
     `define UVM_MAX_STREAMBITS 4096
    `endif
    
    
    // MACRO -- NODOCS -- `UVM_PACKER_MAX_BYTES
    //
    // Defines the maximum bytes to allocate for packing an object using
    

    完整源码 · SHA256:94d6c90ed614d104d6a77413d381e41e1c7b1f74136cf0562c9d6b7aa126acb9

    术语解释 · 兼容配置

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

    版本适用范围