跳转至

输入查询内容

    本页内容

    配置类型与克隆、部分正向 FLAG 及显式操作对照

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

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

    结果对比

    观察内容 UVM 1.2 UVM 2.0 UVM 2.0 + 旧 field 行为开关
    宽整数配置查询命中(1=是) wide_found 1 1 1
    宽整数配置值(十六进制) wide_value 1234567801234567 1234567801234567 1234567801234567
    使用不匹配的 int 类型仍查到配置(1=是) wrong_int_type_found 0 0 0
    存入的对象副本与原对象隔离(1=是) stored_clone_isolated 1 1 1
    各使用者取得的克隆互不影响(1=是) consumer_clones_isolated 1 1 1
    直接通过 config_db 传递同一对象句柄(1=是) direct_db_shares_handle 1 1 1
    只有 UVM_COPY 的 compare 结果(0=检出不匹配) partial_compare 0 1 0
    显式完整 FLAG 的 compare 结果(0=检出不匹配) explicit_compare 0 0 0
    显式 FLAG 仍禁止 copy(1=是) explicit_copy_excluded 1 1 1

    运行命令

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

    uv run tools/run_uvm_review.py --case guidance_probe
    

    最小源码

    guidance_probe.sv

    guidance_probe.sv
    `timescale 1ns/1ps
    `include "uvm_macros.svh"
    import uvm_pkg::*;
    
    class guidance_config extends uvm_object;
      int value;
      `uvm_object_utils_begin(guidance_config)
        `uvm_field_int(value, UVM_ALL_ON)
      `uvm_object_utils_end
      function new(string name="guidance_config"); super.new(name); endfunction
    endclass
    
    class guidance_reader extends uvm_component;
      function new(string name, uvm_component parent); super.new(name, parent); endfunction
    endclass
    
    class partial_flag_packet extends uvm_object;
      int value;
      `uvm_object_utils_begin(partial_flag_packet)
        `uvm_field_int(value, UVM_COPY)
      `uvm_object_utils_end
      function new(string name="partial_flag_packet"); super.new(name); endfunction
    endclass
    
    class explicit_flag_packet extends uvm_object;
      int value;
      `uvm_object_utils_begin(explicit_flag_packet)
        `uvm_field_int(value, UVM_ALL_ON | UVM_NOCOPY)
      `uvm_object_utils_end
      function new(string name="explicit_flag_packet"); super.new(name); endfunction
    endclass
    
    module guidance_probe;
      initial begin
        guidance_reader reader = new("reader", null);
        guidance_config original = new(), saved, first, second;
        uvm_object stored, first_object, second_object;
        uvm_bitstream_t wide;
        int narrow;
        bit found;
        partial_flag_packet partial_a = new(), partial_b = new();
        explicit_flag_packet explicit_a = new(), explicit_b = new();
        #1;
        original.value = 42;
    `ifdef REVIEW_UVM20
        uvm_root::get().set_config_int("reader", "wide", 64'h1234567801234567);
        uvm_root::get().set_config_object("reader", "cfg", original, 1);
    `else
        uvm_pkg::set_config_int("reader", "wide", 64'h1234567801234567);
        uvm_pkg::set_config_object("reader", "cfg", original, 1);
    `endif
        found = uvm_config_db#(uvm_bitstream_t)::get(reader, "", "wide", wide);
        $display("REVIEW|wide_found|%0d", found);
        $display("REVIEW|wide_value|%016h", wide[63:0]);
        $display("REVIEW|wrong_int_type_found|%0d", uvm_config_db#(int)::get(reader, "", "wide", narrow));
        original.value = 99;
        found = uvm_config_db#(uvm_object)::get(reader, "", "cfg", stored);
        if (!found || !$cast(saved, stored)) `uvm_fatal("GUIDANCE", "Missing object configuration")
        $display("REVIEW|stored_clone_isolated|%0d", saved != original && saved.value == 42);
        if (!reader.get_config_object("cfg", first_object, 1) ||
            !reader.get_config_object("cfg", second_object, 1) ||
            !$cast(first, first_object) || !$cast(second, second_object))
          `uvm_fatal("GUIDANCE", "Missing consumer configuration")
        first.value = 7;
        $display("REVIEW|consumer_clones_isolated|%0d", first != second && second.value == 42 && saved.value == 42);
        uvm_config_db#(uvm_object)::set(null, "reader", "shared", original);
        original.value = 123;
        found = uvm_config_db#(uvm_object)::get(reader, "", "shared", stored);
        $display("REVIEW|direct_db_shares_handle|%0d", found && stored == original);
        partial_a.value = 1; partial_b.value = 2;
        explicit_a.value = 1; explicit_b.value = 2;
        $display("REVIEW|partial_compare|%0d", partial_a.compare(partial_b));
        $display("REVIEW|explicit_compare|%0d", explicit_a.compare(explicit_b));
        explicit_a.copy(explicit_b);
        $display("REVIEW|explicit_copy_excluded|%0d", explicit_a.value == 1);
        $display("REVIEW|done|1");
        $finish;
      end
    endmodule
    

    全部用例 · 证据摘要

    版本适用范围