跳转至

输入查询内容

    本页内容

    新增 uvm_phase_hopper 类,phase 执行引擎从 uvm_phase 迁出

    内部实现:文件组织、内部数据结构与实现钩子的变化。直接依赖内部接口时查阅,普通 API 的使用不需要重审这些源码。

    影响范围

    定制 phase traverse/execute,或依赖旧 phase 内部执行入口。

    具体差异

    uvm_phase 内部的调度/执行逻辑整体迁入 uvm_phase_hopper(经 uvm_coreservice_t::get_phase_hopper() 获取)。uvm_task_phase/uvm_topdown_phase/uvm_bottomup_phasetraverse 相应改调 hopper.traverse_on/execute_on(如 uvm_task_phase.svh:86-114)。默认行为不变:traverse_on 默认仍调 imp.traverse(),用户自定义 phase 的 traverse/execute 重写继续生效;高级用户可通过扩展 hopper 改变 phase 遍历/执行方式。普通用户无感知。

    修改方案

    无(仅当曾依赖 uvm_phase::m_run_phases 等 internal 接口时需改走 hopper)。

    兼容措施与范围:本条是新增能力或实现说明,无需恢复旧接口;按使用条件核对行为。

    迁移后验证

    记录自定义 domain 中各节点执行顺序和次数;验证所用 traverse/execute override 仍被调用,不能仅以基础 L2 顺序代替自定义调度。

    记录核销:在无规则及补充检查中记录实际依赖与证据。

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

    • D17 · 启发式:直接依赖 UVM 内部表、执行入口或状态字段。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules D17
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_phase.svh:613static task m_run_phases(),实现 uvm_phase.svh:2202)、execute_phase() 实现 uvm_phase.svh:1303(均为 local/internal)

    VCS 内置 uvm-ieee-2020-2.0uvm_phase_hopper.svh:44(新类,744 行整文件新增),单例访问 get_global_hopper() uvm_phase_hopper.svh:60,调度主循环 run_phases() uvm_phase_hopper.svh:169execute_phase() uvm_phase_hopper.svh:197(实现 uvm_phase_hopper.svh:413),扩展钩子 traverse_on() uvm_phase_hopper.svh:237 / execute_on() uvm_phase_hopper.svh:251

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

    src/vcs-uvm-1.2/base/uvm_phase.svh
      //---------------------------------
      local static mailbox #(uvm_phase) m_phase_hopper = new();
    
      extern static task m_run_phases();
      extern local task  execute_phase();
      extern local function void m_terminate_phase();
      extern local function void m_print_termination_state();
      extern local task wait_for_self_and_siblings_to_drop();
      extern function void kill();
      extern function void kill_successors();
    
      // TBD add more useful debug
      //---------------------------------
      protected static bit m_phase_trace;
      local static bit m_use_ovm_run_semantic;
    
    
      function string convert2string();
      //return $sformatf("PHASE %s = %p",get_name(),this);
    

    src/vcs-uvm-1.2/base/uvm_phase.svh
    // execute_phase
    // -------------
    
    task uvm_phase::execute_phase();
    
      uvm_task_phase task_phase;
      uvm_root top;
      uvm_phase_state_change state_chg;
      uvm_coreservice_t cs;
    
      cs = uvm_coreservice_t::get();
      top = cs.get_root();
    
      // If we got here by jumping forward, we must wait for
      // all its predecessor nodes to be marked DONE.
      // (the next conditional speeds this up)
      // Also, this helps us fast-forward through terminal (end) nodes
      foreach (m_predecessors[pred])
        wait (pred.m_state == UVM_PHASE_DONE);
    

    src/vcs-uvm-1.2/base/uvm_phase.svh
    // This task contains the top-level process that owns all the phase
    // processes.  By hosting the phase processes here we avoid problems
    // associated with phase processes related as parents/children
    task uvm_phase::m_run_phases();
      uvm_root top;
      uvm_coreservice_t cs;
      cs = uvm_coreservice_t::get();
      top = cs.get_root();
    
      // initiate by starting first phase in common domain
      begin
        uvm_phase ph = uvm_domain::get_common_domain();
        void'(m_phase_hopper.try_put(ph));
      end
    
      forever begin
        uvm_phase phase;
        m_phase_hopper.get(phase);
        fork
    

    完整源码 · SHA256:35d4b96b111219dd92ea544929952a1d7bbeb3ce29153c705a75c934551f050e

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase_hopper.svh
    //
    //
    // @uvm-contrib For potential contribution to the 1800.2 standard
    class uvm_phase_hopper extends uvm_object;
    
      `uvm_object_utils(uvm_phase_hopper)
    
      // Function: new
      // Creates a new uvm_phase_hopper instance with ~name~.
      //
      extern function new(string name="uvm_phase_hopper");
    
      // Group: Singleton Accessors
    
      // Function: get_global_hopper
      // Returns the global phase hopper.
      //
      // This method is provided as a wrapper function to conveniently retrieve the
      // phase hopper via the <uvm_coreservice_t::get_phase_hopper> method.
      extern static function uvm_phase_hopper get_global_hopper();
    
      // Group: Queue API
    
      // Function: try_put
      // Attempts to add a new phase to the hopper.
      //
      // If the phase is successfully added to the internal queue, then
      // <raise_objection> is called for ~phase~, and '1' is returned.
      // If the phase can not be added to the internal queue, then no 
      // objection is raised and '0' is returned.
      //
      // NOTE - By default the internal queue has no maximum depth, and
      // as such this method shall always succeed.
      extern virtual function bit try_put(uvm_phase phase);
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase_hopper.svh
      //
      // Note that the UVM core state shall transition to UVM_CORE_POST_RUN
      // when ~run_phases~ returns.
      extern virtual task run_phases();
    
      // Task: process_phase
      // Processes a phase.
      //
      // The process_phase task transitions a phase from the SCHEDULED
      // to the DONE state.  
      //
      // It calls the following tasks in order:
      // - sync_phase
      // - start_phase
      // - execute_phase
      // - end_phase
      // - cleanup_phase
      // - finish_phase
      // 
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase_hopper.svh
      // Task: execute_phase
      // Performs actions associated with transitioning phase state to the UVM_PHASE_EXECUTING state.
      extern protected virtual task execute_phase(uvm_phase phase);
    
      // Task: end_phase
      // Performs actions associated with transitioning phase state to the UVM_PHASE_ENDED state.
      extern protected virtual task end_phase(uvm_phase phase);
    
      // Task: cleanup_phase
      // Performs actions associated with transitioning phase state to the UVM_PHASE_CLEANUP or UVM_PHASE_JUMPING state.
      extern protected virtual task cleanup_phase(uvm_phase phase);
    
      // Task: finish_phase
      // Performs actions associated with transitioning phase state to the UVM_PHASE_DONE state.
      extern protected virtual task finish_phase(uvm_phase phase);
    
      // Task: wait_for_waiters
      // Delays execution to allow waiters on phase state changes to react.
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase_hopper.svh
      //
      // If ~comp~ is null, then the default implementation shall pass
      // <uvm_root::get> to the traverse method.
      extern virtual function void traverse_on(uvm_phase imp,
                                               uvm_component comp,
                                               uvm_phase node,
                                               uvm_phase_state state);
    
      // Function: execute_on
      // Calls ~execute~ on ~imp~, passing in ~comp~, and ~node~.
      //
      // Similar the ~traverse_on~, the ~execute_on~ function is a hook
      // that allows the phase hopper to witness, and potentially change
      // how a phase executes on a component.
      //
      // By default, the ~execute_on~ method calls <uvm_phase::execute>
      // for ~imp~ on ~comp~.
      extern virtual function void execute_on(uvm_phase imp,
                                              uvm_component comp,
                                              uvm_phase node);
    
      /// Implementation Artifacts
    
      local uvm_phase m_queue[$]; // Internal storage
      local uvm_objection m_objection; // Tracks when all phases are complete
    
    endclass // uvm_phase_hopper
    
    /// Implementation
    
    function uvm_phase_hopper::new(string name = "uvm_phase_hopper");
      super.new(name);
      m_objection = new("phase_hopper_objection");
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_phase_hopper.svh
    endtask : start_phase
    
    // Inside the executing stage
    task uvm_phase_hopper::execute_phase(uvm_phase phase);
      uvm_phase_state prev_state;
      prev_state = phase.get_state();
      phase.set_state(UVM_PHASE_EXECUTING);
    
      // Only nodes traverse_on
      if (phase.get_phase_type() != UVM_PHASE_NODE) begin
        wait_for_waiters(phase, prev_state);
        return;
      end
      else begin
        uvm_root top;
        uvm_phase imp;
        uvm_task_phase task_phase;
        top = uvm_root::get();
        imp = phase.get_imp();
    

    完整源码 · SHA256:802b00060165c3f929bda389fde4c8d805103bb463d17a02b4d0d2f047116a61

    术语解释 · 兼容配置

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

    版本适用范围