跳转至

输入查询内容

    本页内容

    通过 get_objection() 获取 task phase 的 objection

    影响范围

    直接访问 phase_done,或对 function phase 请求 objection。

    具体差异

    两侧对 function phase(build/connect 等)都返回 null 并在 raise/drop 时经 m_report_null_objection 报错,此点一致。差异在于:① 2.0 惰性创建,get_objection() 的副作用时点改变(phase_done 字段 1.2 在 add 后即非 null,2.0 首次调用前为 null);② run phase 返回值从 test_done 单例变为普通 objection(见条目 3)。依赖 phase.phase_done 字段直接判空/取名的代码行为改变。

    修改方案

    get_objection() 代替直接访问 phase_done 字段;不要假设其非空。

    只做 raise/drop 的 task phase 代码直接使用传入的 phase.raise_objection(this) / phase.drop_objection(this),无需手工访问对象。

    确需读取 objection 句柄时,obj 声明为 uvm_objection

    1
    2
    3
    4
    // UVM 1.2 dependency on eager initialization
    obj = phase.phase_done;
    // UVM 2.0: use the accessor, which may create the objection
    obj = phase.get_objection();
    

    两行是替换关系。返回 null 时先确认传入的是实际 task phase 节点;build/connect 等 function phase 不提供该对象,不要自行 new 一个 objection 冒充 phase 的控制对象。

    兼容措施与范围:现有入口无需兼容开关;这不表示两版行为相同,仍按本条条件和验证方法核对。

    迁移后验证

    检查实际 task phase 的 get_objection 非空;function phase 按接口限制处理,不使用未初始化 phase_done 判断运行阶段。

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

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

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

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_phase.svh:357get_objection(); return this.phase_done;);phase_doneadd() 时创建(uvm_phase.svh:885–892

    VCS 内置 uvm-ieee-2020-2.0uvm_phase.svh:567–580(非 UVM_PHASE_NODE 或 imp 非 uvm_task_phase 时返回 null;否则惰性创建 {name}_objection

    标准依据:IEEE 1800.2-2020 §9.3.1.7(仅 task-based phase 节点提供 objection 接口,其余类型调用 raise/drop/get_objection_count 应报错)

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

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

    src/vcs-uvm-1.2/base/uvm_phase.svh
      //
      // Return the <uvm_objection> that gates the termination of the phase.
      //
      function uvm_objection get_objection(); return this.phase_done; endfunction
    
      // Function: raise_objection
      //
      // Raise an objection to ending this phase
      // Provides components with greater control over the phase flow for
      // processes which are not implicit objectors to the phase.
      //
      //|   while(1) begin
      //|     some_phase.raise_objection(this);
      //|     ...
      //|     some_phase.drop_objection(this);
      //|   end 
      //|   ...
      //
      (* uvm_fgp_lock = "uvm_objection" *)
    

    src/vcs-uvm-1.2/base/uvm_phase.svh
        begin_node = new_node;
        end_node = new_node;
    
        // The phase_done objection is only required
        // 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;
    

    完整源码 · SHA256:35d4b96b111219dd92ea544929952a1d7bbeb3ce29153c705a75c934551f050e

    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 · 迁移清单

    版本适用范围