跳转至

输入查询内容

    本页内容

    事务开始/结束事件改用 get_event_pool()

    影响范围

    直接访问 transaction 的 events、begin_event 或 end_event 字段。

    具体差异

    1.2 中 eventsbegin_eventend_event 均为公开字段,driver/sequence 常写 item.end_event.wait_on()。2.0 中 events 变为 local,两个事件句柄字段删除,事件仍按 "begin"/"end" 键在池中触发(uvm_transaction.svh:764/:795),只能通过新 API get_event_pool() 访问。

    修改方案

    item.begin_eventitem.get_event_pool().get("begin")item.end_event 同理。

    tr 为已有的 uvm_transaction 或派生对象。只修改获取事件的方式,保留后续等待逻辑:

    1
    2
    3
    4
    // UVM 1.2
    uvm_event finished = tr.end_event;
    // UVM 2.0
    uvm_event finished = tr.get_event_pool().get("end");
    

    开始事件同理,将 tr.begin_event 改为 tr.get_event_pool().get("begin")。两段是替换关系,不要在同一作用域重复声明。触发仍由事务的 begin_tr/end_tr 流程负责。

    兼容措施与范围:旧 begin_event/end_event 字段不再提供;使用主库 event pool 获取事件,并验证触发与等待时机。

    迁移后验证

    编译全部访问点;用实际 begin_tr/end_tr 触发事件,确认原等待方能在同一事务边界恢复,避免只验证句柄非空。

    记录本条结果M01-001 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

    • C2 · 启发式:uvm_transaction::begin_event/end_event 字段删除。 匹配 begin_event/end_event,包括类内省略接收者的继承成员;仍需区分同名用户字段,events 池的直接访问未完整覆盖。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules C2
    

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

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

    源码与标准依据

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

    1. 事件池从公开字段改为通过方法取得

    VCS 内置 UVM-1.2events 是公开字段:uvm_transaction.svh:409

    VCS 内置 uvm-ieee-2020-2.0events 改为 local:uvm_transaction.svh:433get_event_pool() 返回同一个池:uvm_transaction.svh:508–510

    2. begin/end 事件仍可按池中的键取得

    VCS 内置 UVM-1.2:原公开句柄由池中的 begin/end 事件赋值:uvm_transaction.svh:487–488

    VCS 内置 uvm-ieee-2020-2.0:目标在触发时从池中取得事件。begin 分支:uvm_transaction.svh:762–766;end 分支:uvm_transaction.svh:793–797。这说明改用池访问后仍能等待相应事件;字段删除范围见完整引用。

    补充定位

    VCS 内置 UVM-1.2uvm_transaction.svh:409const uvm_event_pool events)、uvm_transaction.svh:422(begin_event)、uvm_transaction.svh:443(end_event)

    VCS 内置 uvm-ieee-2020-2.0uvm_transaction.svh:433const local uvm_event_pool events)、uvm_transaction.svh:358/uvm_transaction.svh:508(新增 get_event_pool()

    标准依据:IEEE 1800.2-2020 §5.4.2.4(begin_tr 触发 event pool 中 "begin" 事件)、§5.4.2.13(get_event_pool)

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

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

    src/vcs-uvm-1.2/base/uvm_transaction.svh
      // The event pool instance for this transaction. This pool is used to track
      // various milestones: by default, begin, accept, and end
    
      const uvm_event_pool events = new;
    
    
      // Variable: begin_event
      //
      // A ~uvm_event#(uvm_object)~ that is triggered when this transaction's actual execution on the
      // bus begins, typically as a result of a driver calling <uvm_component::begin_tr>. 
      // Processes that wait on this event will block until the transaction has
      // begun. 
      //
      // For more information, see the general discussion for <uvm_transaction>.
      // See <uvm_event#(T)> for details on the event API.
      //
      uvm_event#(uvm_object) begin_event;
    
      // Variable: end_event
      //
      // A ~uvm_event#(uvm_object)~ that is triggered when this transaction's actual execution on
      // the bus ends, typically as a result of a driver calling <uvm_component::end_tr>. 
      // Processes that wait on this event will block until the transaction has
      // ended. 
      //
      // For more information, see the general discussion for <uvm_transaction>.
      // See <uvm_event#(T)> for details on the event API.
      //
      //| virtual task my_sequence::body();
      //|  ...
      //|  start_item(item);    \ 
      //|  item.randomize();     } `uvm_do(item)
    

    src/vcs-uvm-1.2/base/uvm_transaction.svh
      //|  item.end_event.wait_on();
      //|  ...
      // 
      uvm_event#(uvm_object) end_event;
    
      //----------------------------------------------------------------------------
      //
      // Internal methods properties; do not use directly
      //
      //----------------------------------------------------------------------------
    
      //Override data control methods for internal properties
      extern virtual function void do_print  (uvm_printer printer);
      extern virtual function void do_record (uvm_recorder recorder);
      extern virtual function void do_copy   (uvm_object rhs);
    
    
      extern protected function integer m_begin_tr (time    begin_time=0, 
                                                    integer parent_handle=0);
    

    src/vcs-uvm-1.2/base/uvm_transaction.svh
      super.new(name);
      this.initiator = initiator;
      m_transaction_id = -1;
      begin_event = events.get("begin");
      end_event = events.get("end");
    
    endfunction // uvm_transaction
    
    
    // set_transaction_id
    function void uvm_transaction::set_transaction_id(integer id);
        m_transaction_id = id;
    endfunction
    
    // get_transaction_id
    function integer uvm_transaction::get_transaction_id();
        return (m_transaction_id);
    endfunction
    

    完整源码 · SHA256:9441e0432d30f53bd3583ca4392481e067469ced06ea0204e3eca7b224691eab

    src/vcs-uvm-ieee-2020-2.0/base/uvm_transaction.svh
      // specialization of <uvm_pool#(KEY,T)>, e.g. a ~uvm_pool#(uvm_event)~.
    
      // @uvm-ieee 1800.2-2020 auto 5.4.2.13
      extern function uvm_event_pool get_event_pool ();
    
    
      // Function -- NODOCS -- set_initiator
      //
      // Sets initiator as the initiator of this transaction. 
      //
      // The initiator can be the component that produces the transaction. It can
      // also be the component that started the transaction. This or any other
      // usage is up to the transaction designer.
    
      // @uvm-ieee 1800.2-2020 auto 5.4.2.14
      extern function void set_initiator (uvm_component initiator);
    
    
      // Function -- NODOCS -- get_initiator
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_transaction.svh
      // The event pool instance for this transaction. This pool is used to track
      // various milestones: by default, begin, accept, and end
    
      const local uvm_event_pool events = new("events");
    
    
      //----------------------------------------------------------------------------
      //
      // Internal methods properties; do not use directly
      //
      //----------------------------------------------------------------------------
    
      //Override data control methods for internal properties
      extern virtual function void do_print  (uvm_printer printer);
      extern virtual function void do_record (uvm_recorder recorder);
      extern virtual function void do_copy   (uvm_object rhs);
    
    
      extern protected function int m_begin_tr (time    begin_time=0, 
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_transaction.svh
    // get_event_pool
    // --------------
    
    function uvm_event_pool uvm_transaction::get_event_pool();
      return events;
    endfunction
    
    
    // is_active
    // ---------
    
    function bit uvm_transaction::is_active();
      return (end_time == -1);
    endfunction
    
    
    // get_begin_time
    // --------------
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_transaction.svh
       do_begin_tr(); //execute callback before event trigger
    
       begin
          uvm_event#(uvm_object) begin_event ;
          begin_event = events.get("begin");
          begin_event.trigger();
       end
    
    endfunction
    
    
    // end_tr
    // ------
    
    function void uvm_transaction::end_tr (time end_time=0, bit free_handle=1);
       this.end_time = (end_time == 0) ? $realtime : end_time;
    
       do_end_tr(); // Callback prior to actual ending of transaction
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_transaction.svh
       tr_recorder = null;
    
       begin
          uvm_event#(uvm_object) end_event ;
          end_event = events.get("end") ;
          end_event.trigger();
       end
    endfunction
    

    完整源码 · SHA256:e4443fd2af49a710de04d3be0b2eb80c39106fb0e3abb1f9054dfadbd002fe70

    术语解释 · 兼容配置

    返回Object / Factory · 迁移清单

    版本适用范围