跳转至

输入查询内容

    本页内容

    Catcher 注册顺序与 regex/glob 匹配

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

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

    修改前后对比

    观察内容 1.2 旧写法 2.0 旧写法 1.2 改写后 2.0 改写后
    transport channel 的类型名 transport_type_name uvm_tlm_req_rsp_channel #(REQ,RSP) uvm_tlm_transport_channel #(REQ,RSP) uvm_tlm_req_rsp_channel #(REQ,RSP) uvm_tlm_transport_channel #(REQ,RSP)
    特化资源构造后已加入池(1=是) specialized_constructor_in_pool 0 1 0 1
    全局回调调用次数 global_callback_calls 1 2 1 1
    局部回调调用次数 local_callback_calls 1 1 1 1
    创建 link 前后随机状态一致(1=是) link_preserves_randstate 1 1 1 1
    正则直接匹配成功(1=是) direct_regex_match 1 1 1 1
    同一文本先正则再通配匹配成功(1=是) glob_after_regex 0 0 0 0
    get_all 向已有队列追加后的项数 get_all_appends 未记录 4 未记录 4

    运行命令

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

    uv run tools/run_uvm_review.py --case utility_probe --variants 12,20
    

    改写后运行命令

    uv run tools/run_uvm_review.py --case utility_probe --variants 12,20 --plusarg +MIGRATED --check tests/uvm_review/utility_migrated.expected.json
    

    最小源码

    utility_probe.sv

    utility_probe.sv
    `timescale 1ns/1ps
    `include "uvm_macros.svh"
    import uvm_pkg::*;
    
    class utility_catcher extends uvm_report_catcher;
      int calls;
      function new(string name="utility_catcher"); super.new(name); endfunction
      function action_e catch();
        if (get_id() == "CALLBACK_PROBE") calls++;
        return THROW;
      endfunction
    endclass
    
    module utility_probe;
      initial begin
        uvm_tlm_transport_channel#(int,int) channel_value = new("channel_value", null);
        uvm_int_rsrc resource_value = new("specialized", "scope");
        uvm_resource#(int) found;
        uvm_report_object reporter = new("reporter");
        utility_catcher shared = new(), local_value = new("local_value");
        uvm_report_catcher all_callbacks[$];
        uvm_parent_child_link link_value;
        uvm_sequence_item a = new("a"), b = new("b");
        process self_process;
        string before_state;
        int result;
        $display("REVIEW|transport_type_name|%s", channel_value.get_type_name());
        found = uvm_resource_db#(int)::get_by_name("scope", "specialized", 0);
        $display("REVIEW|specialized_constructor_in_pool|%0d", found != null);
        if ($test$plusargs("MIGRATED")) begin
          uvm_report_cb::add(reporter, local_value);
          uvm_report_cb::add(null, shared);
        end
        else begin
          uvm_report_cb::add(null, shared);
          uvm_report_cb::add(reporter, local_value);
        end
        reporter.uvm_report_info("CALLBACK_PROBE", "callback observation", UVM_NONE);
        $display("REVIEW|global_callback_calls|%0d", shared.calls);
        $display("REVIEW|local_callback_calls|%0d", local_value.calls);
    `ifdef REVIEW_UVM20
        uvm_report_cb::get_all(all_callbacks, reporter);
        uvm_report_cb::get_all(all_callbacks, reporter);
        $display("REVIEW|get_all_appends|%0d", all_callbacks.size());
    `endif
        self_process = process::self();
        before_state = self_process.get_randstate();
        link_value = uvm_parent_child_link::get_link(a,b);
        $display("REVIEW|link_preserves_randstate|%0d", before_state == self_process.get_randstate());
        // The same expression has different regex/glob meaning.
        result = uvm_re_match("a.*", "abc");
        $display("REVIEW|direct_regex_match|%0d", result == 0);
        $display("REVIEW|glob_after_regex|%0d", uvm_is_match("a.*", "abc"));
        $display("REVIEW|done|1");
        $finish;
      end
    endmodule
    

    全部用例 · 证据摘要

    版本适用范围