跳转至

输入查询内容

    本页内容

    旧 test_done 不再保持 run 存活

    影响范围

    test 或 component 用 uvm_test_done_objection::get() 保持 run phase 存活时需要修改。已经通过实际 run_phase(uvm_phase phase) 的 phase 句柄 raise/drop 的代码,不需要因为本条再换一套 objection。

    具体差异

    旧行为——uvm_test_done_objection::get() 就是 run phase 的 objection,对它 raise/drop 直接门控 run phase 结束;新行为——该单例与 phase 机制完全脱钩,对其 raise/drop 编译通过但不产生任何 phase 控制效果。因此 test 可能编译通过,而 run phase 因无有效 objection 直接结束。

    修改方案

    检查 uvm_test_done 相关结束控制,保留 raise/drop 的配对、计数与收尾条件,改用实际 run_phase(uvm_phase phase) 参数调用 phase.raise_objection(this) / phase.drop_objection(this)phase.get_objection() 返回 objection 对象,不是 phase 句柄;sequence 中需要由调用方传入 phase,或确认 get_starting_phase() 返回了所需的非空 phase。

    旧写法(片段放在 component 的 run_phase 中):

    1
    2
    3
    4
    5
    6
    task run_phase(uvm_phase phase);
      uvm_test_done_objection::get().raise_objection(this);
      #10;
      completed = 1;
      uvm_test_done_objection::get().drop_objection(this);
    endtask
    

    修改后保持业务流程,用实际 phase 控制结束:

    1
    2
    3
    4
    5
    6
    task run_phase(uvm_phase phase);
      phase.raise_objection(this);
      #10;
      completed = 1;
      phase.drop_objection(this);
    endtask
    

    完整示例的 completed 为 test 成员,并在 report_phase 输出。真实环境把延时部分替换成激励完成与检查器排空的握手,raise/drop 应成对管理。

    兼容措施与范围:主库保留类与 get() 等符号,允许继续编译引用;旧对象不再保持 run 存活,stop 方法也未恢复,结束控制仍需改为实际 phase objection。

    迁移后验证

    report_phase 检查 completed==1;示例的对应输出名为 run_completed。环境级验证还应检查实际事务数、激励完成标志和 scoreboard 排空状态。

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

    已有实测与复现

    观察量 1.2 旧写法 2.0 旧写法 修改后,两版
    run 中的 completed 是否被置 1 否,run 提前结束

    补充查阅

    扫描定位与记录结果

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

    • S2 · 文本匹配:uvm_test_done_objection 孤儿化(raise/drop 不再门控 run phase)。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules S2
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_phase.svh:889(run phase 节点的 phase_done 直接挂 uvm_test_done_objection::get() 单例);uvm_objection.svh:1124(类定义,含 raise/drop/all_dropped 重写)

    VCS 内置 uvm-ieee-2020-2.0uvm_objection.svh:1171–1244//@uvm-compat for compatibility with 1.2,仅保留 new/qualify/get_type/get_type_name/create/get);uvm_phase.svh:567–580get_objection() 惰性创建普通 uvm_objection,全库不再引用 uvm_test_done_objection

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

    src/vcs-uvm-1.2/base/uvm_phase.svh
        // for task-based nodes
        if ($cast(tp, phase)) begin
           if (new_node.get_name() == "run") begin
             new_node.phase_done = uvm_test_done_objection::get();
           end
           else begin
             new_node.phase_done = uvm_objection::type_id::create({phase.get_name(), "_objection"});
           end
        end
    
      end
      // We are inserting an existing schedule
      else begin
        begin_node = phase;
        end_node   = phase.m_end_node;
        phase.m_parent = this;
      end
    
      // If 'with_phase' is us, then insert node in parallel
    

    完整源码 · SHA256:35d4b96b111219dd92ea544929952a1d7bbeb3ce29153c705a75c934551f050e

    src/vcs-uvm-1.2/base/uvm_objection.svh
    // Provides built-in end-of-test coordination
    //------------------------------------------------------------------------------
    
    class uvm_test_done_objection extends uvm_objection;
    
       protected static uvm_test_done_objection m_inst;
      protected bit m_forced;
    
      // For communicating all objections dropped and end of phasing
      local  bit m_executing_stop_processes;
      local  int m_n_stop_threads;
    
    
      // Function- new DEPRECATED
      //
      // Creates the singleton test_done objection. Users must not call
      // this method directly.
    
      function new(string name="uvm_test_done");
    

    完整源码 · SHA256:c80371feb8fa0c455538bb8b274463a0daac8dbb8cca67259e370ad041b4a6f3

    src/vcs-uvm-ieee-2020-2.0/base/uvm_objection.svh
    endclass
    
    
    //@uvm-compat for compatibility with 1.2
    class uvm_test_done_objection extends uvm_objection;
    
       protected static uvm_test_done_objection m_inst;
      protected bit m_forced;
    
      // For communicating all objections dropped and end of phasing
      local  bit m_executing_stop_processes;
      local  int m_n_stop_threads;
    
    
      // Function- new DEPRECATED
      //
      // Creates the singleton test_done objection. Users must not call
      // this method directly.
    
      //@uvm-compat for compatibility with 1.2
      function new(string name="uvm_test_done");
        super.new(name);
      endfunction
    
    
      // Function- qualify DEPRECATED
      //
      // Checks that the given ~object~ is derived from either <uvm_component> or
      // <uvm_sequence_base>.
    
      //@uvm-compat for compatibility with 1.2
      virtual function void qualify(uvm_object obj=null,
                                    bit is_raise,
                                    string description);
        uvm_component c;
        uvm_sequence_base s;
        string nm = is_raise ? "raise_objection" : "drop_objection";
        string desc = description == "" ? "" : {" (\"", description, "\")"};
        if(! ($cast(c,obj) || $cast(s,obj))) begin
          uvm_report_error("TEST_DONE_NOHIER", {"A non-hierarchical object, '",
            obj.get_full_name(), "' (", obj.get_type_name(),") was used in a call ",
            "to uvm_test_done.", nm,"(). For this objection, a sequence ",
            "or component is required.", desc });
        end
      endfunction
    
      // Below are basic data operations needed for all uvm_objects
      // for factory registration, printing, comparing, etc.
    
      typedef uvm_object_registry#(uvm_test_done_objection,"uvm_test_done") type_id;
      //@uvm-compat for compatibility with 1.2
      static function type_id get_type();
        return type_id::get();
      endfunction
    
      //@uvm-compat for compatibility with 1.2
      function uvm_object create (string name="");
        uvm_test_done_objection tmp = new(name);
        return tmp;
      endfunction
    
      //@uvm-compat for compatibility with 1.2
      virtual function string get_type_name ();
        return "uvm_test_done";
      endfunction
    
      //@uvm-compat for compatibility with 1.2
      static function uvm_test_done_objection get();
        if(m_inst == null)
          m_inst = uvm_test_done_objection::type_id::create("run");
        return m_inst;
      endfunction
    
    endclass
    

    完整源码 · SHA256:4f431c3f91aafce1a407ee0d169f4b7c4a0a5c4885e25c8a4b5cb039f64a7e22

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase.svh
      endfunction
    
    
      // @uvm-ieee 1800.2-2020 auto 9.3.1.7.1
      function uvm_objection get_objection();
         uvm_phase imp;
         uvm_task_phase tp;
         imp = get_imp();
         // Only nodes with a non-null uvm_task_phase imp have objections
         if ((get_phase_type() != UVM_PHASE_NODE) || (imp == null) || !$cast(tp, imp)) begin
        return null;
         end
         if (phase_done == null) begin
           phase_done = uvm_objection::type_id::create({get_name(), "_objection"});
         end
    
         return phase_done;
      endfunction // get_objection
    

    完整源码 · SHA256:a788b22ff02a9ff8e6eab4a18c55794dcae9777ddfa19695bffa88bf14b83181

    术语解释 · 兼容配置

    返回Phase / Objection / Event · 迁移清单

    版本适用范围