跳转至

输入查询内容

    本页内容

    +uvm_set_config_int 宽值经 32 位字符串转换被截断

    影响范围

    通过 +uvm_set_config_int 注入宽整数时受影响;配置位于脚本或 filelist 时需让扫描器包含这些文件。

    具体差异

    目标 int 路径使用返回 int 的字符串转换,超过 32 位的配置会截断。command_probe 对相同 0x1234567801234567 实测低 64 位为 1234567801234567 / 0000000001234567。该结论针对默认 VCS 1.2 构建;旧库若启用 UVM_DO_NOT_USE_SSCANF,本来就有窄转换限制。

    修改方案

    目标版本的宽配置使用 +uvm_set_config_bitstream=uvm_test_top,wide_value,0x1234567801234567,该替代已保持完整 64 位;也可在测试中以明确类型调用 config_db::set。必须断言实际读回配置,不能只看 Applying config 日志。

    兼容措施与范围:兼容措施不修复宽值截断;使用 bitstream 配置入口或明确类型的 config_db,并检查完整读回值。

    迁移后验证

    用 0x1234567801234567 对照 int 与 bitstream 参数,断言完整 64 位读回;Applying config 日志不能代替配置值检查。

    记录本条结果M04-018 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

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

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_root.svh:879(默认 sscanf 到 uvm_bitstream_t,另有 UVM_DO_NOT_USE_SSCANF 分支)

    VCS 内置 uvm-ieee-2020-2.0uvm_root.svh:985(atoi/atohex 等)、uvm_root.svh:997(新增 bitstream 分支)

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

    src/vcs-uvm-1.2/base/uvm_root.svh
            "'h" : void'($sscanf(extval, "%h", v));
            "'x" : void'($sscanf(extval, "%h", v));
            "0x" : void'($sscanf(extval, "%h", v));
            default : void'($sscanf(split_val[2],"%d", v));  
    `endif        
          endcase
        end
        else begin
    `ifdef UVM_DO_NOT_USE_SSCANF  
          v = split_val[2].atoi();
    `else
          void'($sscanf(split_val[2],"%d", v));
    `endif
        end
        uvm_report_info("UVM_CMDLINE_PROC", {"Applying config setting from the command line: +uvm_set_config_int=", cfg}, UVM_NONE);
        uvm_config_int::set(m_uvm_top, split_val[0], split_val[1], v);
      end
      else begin
        uvm_report_info("UVM_CMDLINE_PROC", {"Applying config setting from the command line: +uvm_set_config_string=", cfg}, UVM_NONE);
    

    完整源码 · SHA256:7a3a006a2f6a7b5bbedc778d199ef5389bbe97f19358c79b12ec5d3b18e81438

    src/vcs-uvm-ieee-2020-2.0/base/uvm_root.svh
              "0b" : v = extval.atobin();
              "'o" : v = extval.atooct();
              "'d" : v = extval.atoi();
              "'h" : v = extval.atohex();
              "'x" : v = extval.atohex();
              "0x" : v = extval.atohex();
              default : v = split_val[2].atoi();
            endcase
          end
          else begin
            v = split_val[2].atoi();
          end
          uvm_report_info("UVM_CMDLINE_PROC", {"Applying config setting from the command line: +uvm_set_config_int=", cfg}, UVM_NONE);
          uvm_config_int::set(m_uvm_top, split_val[0], split_val[1], v);
        end // if (is_int)
            else if(is_bitstream) begin
          string base, extval, tmp;
              int    success ;
              bit    is_negative;
              if (split_val[2].len() > 1) begin
                byte char;
                char = split_val[2].getc(0);
                // Optional sign
                if (char == "-") begin
                  // Signed, negative
                  is_negative = 1;
                  tmp = split_val[2].substr(1, split_val[2].len()-1);
                end
                else if (char == "+") begin
                  // Signed, positive (just remove the sign)
                  tmp = split_val[2].substr(1, split_val[2].len()-1);
    

    完整源码 · SHA256:ec598230e6e36782814b52bcbe1c1b51ed22196ad1a7efe9a6600888916d72a9

    术语解释 · 兼容配置

    返回Reporting / 命令行 · 迁移清单

    版本适用范围