跳转至

输入查询内容

    本页内容

    删除接口与旧宏:编译错误及改写对照

    环境:VCS W-2024.09-SP2-8。1.2 使用 uvm-1.2,2.0 使用 uvm-ieee-2020-2.0

    实验检查观察值是否符合预期;成功复现问题不代表问题已修复。

    结果对比

    旧用法 1.2 旧写法 2.0 旧写法 2.0 改写后
    C1 · printer knobs 宽度字段 / uvm_printer_knobs 类型名删除 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C2 · uvm_transaction::begin_event/end_event 字段删除 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C3 · kill/stop 机制删除(kill/do_kill_all/stop_phase/enable_stop_interrupt/stop_request/force_stop/stop_timeout) 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C4 · uvm_event::add_callback/delete_callback 删除 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C5 · uvm_do_* 宏移入 deprecated(需 +define+UVM_ENABLE_DEPRECATED_API 或改写) 编译通过 编译失败:Error-[UM] Undefined macro 编译通过
    C6 · 无参构造函数:核对旧版 constructor 兼容宏及 factory 注册 编译通过 编译失败:Error-[TMAFTC] Too many arguments to function/task call、Error-[TMAFTC] Too many arguments to function/task call 编译通过
    C7 · uvm_resource#(T) 自管理接口删除(set/set_override/get_by_name/get_by_type/UVM_RESOURCE_GET_FCNS) 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C8 · uvm_sequence_base 新增抽象限制;uvm_sequence 在 1.2 已抽象 编译通过 编译失败:Error-[SV-ACCNBI] An abstract class cannot be instantiated 编译通过
    C9 · map 查询删除 caller 形参,核对显式实参与 override 编译通过 编译失败:Error-[TMAFTC] Too many arguments to function/task call 编译通过
    C10a · 全局仿真控制函数删除(uvm_test_done/global_stop_request/set_global_timeout/set_global_stop_timeout) 编译通过 编译失败:Error-[IND] Identifier not declared 编译通过
    C10b · reporting deprecated 方法删除(get_report_server/process_report/compose_message) 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C10c · 全局 set_config_int/object/string 删除(注意:组件方法仍可用) 编译通过 编译失败:Error-[MFNF] Member not found 编译通过
    C11 · field automation 旧钩子不再被调用,status container/scope stack 删除 编译通过 编译失败:Error-[SE] Syntax error 编译通过
    C12 · 自定义 uvm_factory 子类须补 4 个 pure virtual 编译通过 编译失败:Error-[SV-VMNI] Virtual method not implemented、Error-[SV-VMNI] Virtual method not implemented、Error-[SV-VMNI] Virtual method not implemented、Error-[SV-VMNI] Virtual method not implemented 编译通过
    C13 · uvm_print_* 宏数字后缀变体删除、签名重排 编译通过 编译失败:Error-[UM] Undefined macro 编译通过
    C14 · 自定义 user_priority_arbitration 旧 integer 签名在 VCS 2.0 不匹配 编译通过 编译失败:Error-[SV-IRT] Incompatible return types、Error-[SV-ATDNMD] Argument types do not match、Error-[SV-IRT] Incompatible return types、Error-[SV-ATDNMD] Argument types do not match 编译通过

    运行命令

    目录与环境准备;从解包根目录执行:

    uv run tools/run_compile_review.py
    

    最小源码

    compile_probe.sv

    compile_probe.sv
    `timescale 1ns/1ps
    `include "uvm_macros.svh"
    import uvm_pkg::*;
    `ifdef REVIEW_UVM20
    import uvm_compat_pkg::*;
    `endif
    
    `ifdef CASE_C5
    class compile_item extends uvm_sequence_item;
      `uvm_object_utils(compile_item)
      rand int value;
      function new(string name = "compile_item"); super.new(name); endfunction
    endclass
    class compile_sequence extends uvm_sequence#(uvm_sequence_item);
      `uvm_object_utils(compile_sequence)
      function new(string name = "compile_sequence"); super.new(name); endfunction
      task body();
        compile_item item;
    `ifdef MIGRATED
        `uvm_do(item, , , {value == 42;})
    `else
        `uvm_do_with(item, {value == 42;})
    `endif
      endtask
    endclass
    `endif
    
    `ifdef CASE_C6
    class compile_object extends uvm_object;
      `uvm_object_utils(compile_object)
    `ifdef MIGRATED
      function new(string name = "compile_object"); super.new(name); endfunction
    `else
      function new(); super.new(); endfunction
    `endif
    endclass
    `endif
    
    class probe_reg extends uvm_reg;
      function new(string name = "probe_reg"); super.new(name, 32, UVM_NO_COVERAGE); endfunction
    endclass
    
    class probe_component extends uvm_component;
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
    endclass
    
    `ifdef CASE_C12
    class compile_factory extends
    `ifdef MIGRATED
      uvm_default_factory;
    `else
      uvm_factory;
      uvm_default_factory delegate = new();
      virtual function void register(uvm_object_wrapper obj); delegate.register(obj); endfunction
      virtual function void set_inst_override_by_type(uvm_object_wrapper original_type, uvm_object_wrapper override_type, string full_inst_path);
        delegate.set_inst_override_by_type(original_type, override_type, full_inst_path);
      endfunction
      virtual function void set_inst_override_by_name(string original_type_name, string override_type_name, string full_inst_path);
        delegate.set_inst_override_by_name(original_type_name, override_type_name, full_inst_path);
      endfunction
      virtual function void set_type_override_by_type(uvm_object_wrapper original_type, uvm_object_wrapper override_type, bit replace=1);
        delegate.set_type_override_by_type(original_type, override_type, replace);
      endfunction
      virtual function void set_type_override_by_name(string original_type_name, string override_type_name, bit replace=1);
        delegate.set_type_override_by_name(original_type_name, override_type_name, replace);
      endfunction
      virtual function uvm_object create_object_by_type(uvm_object_wrapper requested_type, string parent_inst_path="", string name="");
        return delegate.create_object_by_type(requested_type, parent_inst_path, name);
      endfunction
      virtual function uvm_component create_component_by_type(uvm_object_wrapper requested_type, string parent_inst_path="", string name, uvm_component parent);
        return delegate.create_component_by_type(requested_type, parent_inst_path, name, parent);
      endfunction
      virtual function uvm_object create_object_by_name(string requested_type_name, string parent_inst_path="", string name="");
        return delegate.create_object_by_name(requested_type_name, parent_inst_path, name);
      endfunction
      virtual function uvm_component create_component_by_name(string requested_type_name, string parent_inst_path="", string name, uvm_component parent);
        return delegate.create_component_by_name(requested_type_name, parent_inst_path, name, parent);
      endfunction
      virtual function void debug_create_by_type(uvm_object_wrapper requested_type, string parent_inst_path="", string name="");
        delegate.debug_create_by_type(requested_type, parent_inst_path, name);
      endfunction
      virtual function void debug_create_by_name(string requested_type_name, string parent_inst_path="", string name="");
        delegate.debug_create_by_name(requested_type_name, parent_inst_path, name);
      endfunction
      virtual function uvm_object_wrapper find_override_by_type(uvm_object_wrapper requested_type, string full_inst_path);
        return delegate.find_override_by_type(requested_type, full_inst_path);
      endfunction
      virtual function uvm_object_wrapper find_override_by_name(string requested_type_name, string full_inst_path);
        return delegate.find_override_by_name(requested_type_name, full_inst_path);
      endfunction
      virtual function uvm_object_wrapper find_wrapper_by_name(string type_name);
        return delegate.find_wrapper_by_name(type_name);
      endfunction
      virtual function void print(int all_types=1); delegate.print(all_types); endfunction
    `endif
    endclass
    `endif
    
    `ifdef CASE_C14
    class compile_arbitrator extends uvm_sequencer#(uvm_sequence_item);
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
    `ifdef MIGRATED
      virtual function int user_priority_arbitration(int avail_sequences[$]);
    `else
      virtual function integer user_priority_arbitration(integer avail_sequences[$]);
    `endif
        return avail_sequences[$];
      endfunction
    endclass
    `endif
    
    module compile_probe;
      initial begin
    `ifdef CASE_C1
    `ifdef MIGRATED
        uvm_default_table_printer.knobs.depth = 3;
    `else
        uvm_default_table_printer.knobs.name_width = 20;
    `endif
    `endif
    `ifdef CASE_C2
        uvm_sequence_item item = new("item");
        uvm_event event_value;
    `ifdef MIGRATED
        event_value = item.get_event_pool().get("end");
    `else
        event_value = item.end_event;
    `endif
    `endif
    `ifdef CASE_C3
        probe_component component_value = new("component_value", null);
    `ifdef MIGRATED
        // Phase-based shutdown is exercised by objection_probe.
    `else
        if ($test$plusargs("CALL_LEGACY")) component_value.kill();
    `endif
    `endif
    `ifdef CASE_C4
        uvm_event event_value = new("event_value");
    `ifdef MIGRATED
        if ($test$plusargs("CALL_LEGACY")) uvm_callbacks#(uvm_event, uvm_event_callback)::add(event_value, null);
    `else
        if ($test$plusargs("CALL_LEGACY")) event_value.add_callback(null);
    `endif
    `endif
    `ifdef CASE_C7
        uvm_resource#(int) resource_value = new("resource_value", "env.*");
    `ifdef MIGRATED
    `ifdef REVIEW_UVM20
        uvm_resource_pool::get().set_scope(resource_value, "env.*");
    `else
        uvm_resource_pool::get().set(resource_value);
    `endif
    `else
        resource_value.set();
    `endif
    `endif
    `ifdef CASE_C8
    `ifdef MIGRATED
    `ifdef REVIEW_UVM20
        uvm_compat_proxy_sequence#(uvm_sequence_item) sequence_value = new("sequence_value");
    `else
        uvm_sequence_base sequence_value = new("sequence_value");
    `endif
    `else
        uvm_sequence_base sequence_value = new("sequence_value");
    `endif
    `endif
    `ifdef CASE_C9
        probe_reg register_value = new();
        uvm_reg_map map_value;
    `ifdef MIGRATED
        if ($test$plusargs("CALL_LEGACY")) map_value = register_value.get_default_map();
    `else
        if ($test$plusargs("CALL_LEGACY")) map_value = register_value.get_default_map("caller");
    `endif
    `endif
    `ifdef CASE_C10a
    `ifdef MIGRATED
        uvm_root::get().set_timeout(1000);
    `else
        set_global_timeout(1000);
    `endif
    `endif
    `ifdef CASE_C10b
        uvm_report_object reporter = new("reporter");
        uvm_report_server server;
    `ifdef MIGRATED
        server = uvm_report_server::get_server();
    `else
        server = reporter.get_report_server();
    `endif
    `endif
    `ifdef CASE_C10c
    `ifdef MIGRATED
        uvm_config_db#(uvm_bitstream_t)::set(null, "*", "value", 1);
    `else
        uvm_pkg::set_config_int("*", "value", 1);
    `endif
    `endif
    `ifdef CASE_C11
    `ifdef MIGRATED
        uvm_comparer comparer = new();
    `else
        uvm_status_container status_value = new();
    `endif
    `endif
    `ifdef CASE_C13
        int value = 1;
        uvm_printer printer = uvm_default_printer;
    `ifdef MIGRATED
        printer.print_field("value", value, 32, UVM_HEX);
    `else
        `uvm_print_int3(value, UVM_HEX, printer)
    `endif
    `endif
        $display("REVIEW|done|1");
        $finish;
      end
    endmodule
    

    全部用例 · 证据摘要

    版本适用范围