跳转至

输入查询内容

    本页内容

    删除无效的打印宽度配置,使用 printer 访问器

    影响范围

    声明旧 knobs 类型、访问被删宽度字段或定制输出截断的代码受影响;先区分保留与删除成员。

    具体差异

    uvm_printer_knobs 类型名消失,改名 m_uvm_printer_knobs 且无 typedef 别名;两个派生 typedef 删除。宽度字段 max_width / truncation / name_width / type_width / size_width / value_width / sprint 在 1.2 中已标注 "Deprecated knobs, hereafter ignored",2.0 中彻底删除——读写这些字段直接编译报错。knobs 成员本身保留(uvm_printer.svh:58,@uvm-compat),其中 header/footer/full_name 也标注 @uvm-compat:778);identifier/type_name/size/depth/reference/begin_elements/... 等字段仍在但已降级为内部实现,正式 API 是 set_/get_ 访问器。

    修改方案

    删除旧 knobs 类型引用,改通过 printer 访问器配置。已被 1.2 忽略的宽度赋值可直接删除;只有确有输出截断需求时才另行实现。保留字段按实际 printer 类型选访问器:mcd/prefix/show_radix/default_radix 对应 set_file/set_line_prefix/set_radix_enabled/set_default_radixset_indentset_separators 需核对具体 printer 子类,不能对任意基类句柄照搬。

    这类宽度赋值在 1.2 就已被忽略,迁移时直接删除:

    uvm_default_table_printer.knobs.name_width = 20;
    

    对于仍有意义的深度配置,目标写法可改为公开访问器:

    1
    2
    3
    4
    // Old configuration
    printer.knobs.depth = 3;
    // Target configuration
    printer.set_max_depth(3);
    

    printer 是实际打印对象。不要为了通过编译而把 name_width 替换成 depth,两者含义不同;前者没有等价的宽度替代。

    兼容措施与范围:主库保留 printer.knobs 的部分成员;已删除的宽度字段及 uvm_printer_knobs 类型没有恢复方案。保留字段可继续使用,删除项按正文调整。

    迁移后验证

    编译原打印配置;生成包含长名字、宽值和嵌套对象的输出,检查列宽及 golden。不要给已删除且旧版已忽略的字段添加无效替代。

    记录本条结果M02-003 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

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

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_printer.svh:416class uvm_printer_knobs)、uvm_printer.svh:620–626(宽度字段)、uvm_printer.svh:631–632(typedef uvm_table_printer_knobs / uvm_tree_printer_knobs)

    VCS 内置 uvm-ieee-2020-2.0uvm_printer.svh:617class m_uvm_printer_knobs,NODOCS 内部类)

    标准依据:IEEE 1800.2-2020 §16.2.5(printer 配置 accessor)

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

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

    src/vcs-uvm-1.2/base/uvm_printer.svh
    //
    //------------------------------------------------------------------------------
    
    class uvm_printer_knobs;
    
      // Variable: header
      //
      // Indicates whether the <uvm_printer::format_header> function should be called when
      // printing an object.
    
      bit header = 1;
    
    
      // Variable: footer
      //
      // Indicates whether the <uvm_printer::format_footer> function should be called when
      // printing an object. 
    
      bit footer = 1;
    

    src/vcs-uvm-1.2/base/uvm_printer.svh
      endfunction
    
      // Deprecated knobs, hereafter ignored
      int max_width = 999;
      string truncation = "+"; 
      int name_width = -1;
      int type_width = -1;
      int size_width = -1;
      int value_width = -1;
      bit sprint = 1;
    
    endclass
    
    
    typedef uvm_printer_knobs uvm_table_printer_knobs;
    typedef uvm_printer_knobs uvm_tree_printer_knobs;
    
    
    //------------------------------------------------------------------------------
    // IMPLEMENTATION
    //------------------------------------------------------------------------------
    
    // emit
    // ----
    
    function string uvm_printer::emit (); 
      `uvm_error("NO_OVERRIDE","emit() method not overridden in printer subtype")
      return "";
    endfunction
    

    完整源码 · SHA256:3a007c7a488ef1943aa1bfce8bb945eaa32c3023170f6c35ce6358f5f6f5a378

    src/vcs-uvm-ieee-2020-2.0/base/uvm_printer.svh
    //
    //------------------------------------------------------------------------------
    
    class m_uvm_printer_knobs;
    
      // Variable -- NODOCS -- identifier
      //
      // Indicates whether <uvm_printer::adjust_name> should print the identifier. This is useful
      // in cases where you just want the values of an object, but no identifiers.
    
      bit identifier = 1;
    
    
      // Variable -- NODOCS -- type_name
      //
      // Controls whether to print a field's type name.
    
      bit type_name = 1;
    

    完整源码 · SHA256:960f0c18aee9036a3261b2108183dc85b3cf572d1912605325c6b595f4b9aaef

    术语解释 · 兼容配置

    返回Comparer / Printer / Packer / Recorder · 迁移清单

    版本适用范围