跳转至

输入查询内容

    本页内容

    重写 recorder、stream、database 方法时同步句柄类型

    影响范围

    派生 recorder/stream/database 虚方法,或调用被移除的内部句柄接口。

    具体差异

    recorder/stream/database 全族 handle 相关方法与回调由 integer 改为 int(get_handle、get_recorder_from_handle、get_stream_from_handle、begin_tr/end_tr/link_tr/free_tr 等,文本后端同改)。uvm_tr_stream::m_get_handle()(1.2 留给厂商 override 的钩子)被删除——Synopsys 自家 verdi/vcs 后端已同步改造,用户若 override 过该方法需删除。recorder 新增 set/get_recursion_policy、set/get_id_enabled、set/get_default_radix、flush()、object_recorded();record_object 对 null 直接记录。

    VCS 两侧在未定义 UVM_VERDI_NO_PORT_RECORDING 时都声明 pure virtual 的 port_begin_recording_cb/port_end_recording_cb;直接派生 uvm_tr_database 时须实现真实端口录制,不能用空回调冒充后端。已有实现可继续按目标签名核对。两侧 begin 的输出句柄均为 ref int,end 的输入句柄均为 int,不能由本条标题推断所有 VCS 回调都改过类型。TLM2 begin/end 的 delay 从 uvm_tlm_time 名称变为 uvm_time,旧名称主库 typedef 见 M08-007get_object_id() 在未定义 UVM_VCS_RECORD 时也为延续的 VCS 虚方法。源码:src/vcs-uvm-1.2/base/uvm_tr_database.svh:289-342src/vcs-uvm-ieee-2020-2.0/src/base/uvm_tr_database.svh:233-285。此处证据范围为扩展声明核对,不包含任意自定义后端的实测。

    修改方案

    普通 integer 变量存储 int 句柄无需因 64 位仿真而修改,两种整数都为 32 位四态。覆盖虚方法时须匹配目标版签名(参见 M06-007 的 VCS 类型检查);删除已失去调用入口的 m_get_handle override。

    兼容措施与范围:兼容措施不恢复 m_get_handle 钩子或旧虚方法签名;普通句柄变量可保留,override 按目标接口修改。

    迁移后验证

    编译所有 override;建立、结束和释放一条记录,检查句柄有效性及 stream/database 关联。

    记录本条结果M02-012 · 状态与证据

    补充查阅

    扫描定位与记录结果

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

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

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

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

    源码与标准依据

    核查方式:源码核对。未单独进行 VCS 行为实测。

    VCS 内置 UVM-1.2uvm_tr_stream.svh:407function integer get_handle())、uvm_tr_stream.svh:431(virtual m_get_handle)

    VCS 内置 uvm-ieee-2020-2.0uvm_tr_stream.svh:327function int get_handle()

    标准依据:IEEE 1800.2-2020 §16.4.5/§7.2.6

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

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

    src/vcs-uvm-1.2/base/uvm_tr_stream.svh
       // A value of ~0~ indicates that the recorder has been ~freed~,
       // and no longer has a valid ID.
       //
       function integer get_handle();
          if (!is_open() && !is_closed()) begin
            return 0;
          end
          else begin
             integer handle = get_inst_id();
    
             // Check for the weird case where our handle changed.
             if (m_ids_by_stream.exists(this) && m_ids_by_stream[this] != handle)
               m_streams_by_id.delete(m_ids_by_stream[this]);
    
             m_streams_by_id[handle] = this;
             m_ids_by_stream[this] = handle;
    
             return handle;
          end
    

    src/vcs-uvm-1.2/base/uvm_tr_stream.svh
       //
       // This is an implementation detail of the UVM library, which allows
       // for vendors to (optionally) put vendor-specific methods into the library.
       virtual function integer m_get_handle();
          return get_handle();
       endfunction : m_get_handle
    
       // Function: get_stream_from_handle
       // Static accessor, returns a stream reference for a given unique id.
       //
       // If no stream exists with the given ~id~, or if the
       // stream with that ~id~ has been freed, then ~null~ is
       // returned.
       //
       static function uvm_tr_stream get_stream_from_handle(integer id);
          if (id == 0)
            return null;
    
          if ($isunknown(id) || !m_streams_by_id.exists(id))
    

    完整源码 · SHA256:4e373501ca2bc9af44d4f168043d2ce07725ff3115a3966455b51529e48839d5

    src/vcs-uvm-ieee-2020-2.0/base/uvm_tr_stream.svh
       // @uvm-ieee 1800.2-2020 auto 7.2.6.1
       function int get_handle();
          if (!is_open() && !is_closed()) begin
            return 0;
          end
          else begin
             int handle = get_inst_id();
    
             // Check for the weird case where our handle changed.
             if (m_ids_by_stream.exists(this) && m_ids_by_stream[this] != handle)
               m_streams_by_id.delete(m_ids_by_stream[this]);
    
             m_streams_by_id[handle] = this;
             m_ids_by_stream[this] = handle;
    
             return handle;
          end
    

    完整源码 · SHA256:9eebb1f40671f6c3d62666b8fd4f1e35b8a541d2a2c888c9a85a76bdd81d6af5

    src/vcs-uvm-1.2/base/uvm_tr_database.svh
       // Backend implementation of <establish_link>
       pure virtual protected function void do_establish_link(uvm_link_base link);
    
       // Modified by Verdi
    `ifndef UVM_VERDI_NO_PORT_RECORDING
       pure virtual function void port_begin_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             time begin_time = 0,
                                             time end_time = 0,
                                             bit has_response = 0,
                                             uvm_object rsp = null,
                                             bit has_return_value = 0,
                                             bit return_value = 0,
                                             ref int r_tr_h1,
                                             ref int r_tr_h2);
       pure virtual function void port_end_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             int tr_h1,
                                             int tr_h2,
                                             time begin_time = 0,
                                             time end_time = 0,
                                             bit has_response = 0,
                                             uvm_object rsp = null,
                                             bit has_return_value = 0,
                                             bit return_value = 0);
      virtual function void tlm2_begin_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             uvm_tlm_time delay,
                                             bit is_nonblocking,
                                             int begin_phase,
                                             ref int tr_h);
        return;
      endfunction
    
      virtual function void tlm2_end_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             uvm_tlm_time delay,
                                             int tr_h,
                                             bit is_nonblocking,
                                             int end_phase,
                                             int sync);
        return;
      endfunction
    `endif
       // End
    
    `ifndef UVM_VCS_RECORD
    // 9001130255
      virtual function string get_object_id (uvm_object obj);
         return obj.get_type_name();
      endfunction
    `endif
    // End
    

    完整源码 · SHA256:cb9ff1f3a3cc018c80015b8394d0223370811c17f835f7c98b8e36345db2f393

    src/vcs-uvm-ieee-2020-2.0/base/uvm_tr_database.svh
       // @uvm-ieee 1800.2-2020 auto 7.1.6.4
       pure virtual protected function void do_establish_link(uvm_link_base link);
    
       // Modified by Verdi
    `ifndef UVM_VERDI_NO_PORT_RECORDING
       pure virtual function void port_begin_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             time begin_time = 0,
                                             time end_time = 0,
                                             bit has_response = 0,
                                             uvm_object rsp = null,
                                             bit has_return_value = 0,
                                             bit return_value = 0,
                                             ref int r_tr_h1,
                                             ref int r_tr_h2);
       pure virtual function void port_end_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             int tr_h1,
                                             int tr_h2,
                                             time begin_time = 0,
                                             time end_time = 0,
                                             bit has_response = 0,
                                             uvm_object rsp = null,
                                             bit has_return_value = 0,
                                             bit return_value = 0);
      virtual function void tlm2_begin_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             uvm_time delay,
                                             bit is_nonblocking,
                                             int begin_phase,
                                             ref int tr_h);
        return;
      endfunction
    
      virtual function void tlm2_end_recording_cb (uvm_port_component_base port_comp,
                                             string func_name,
                                             uvm_object req,
                                             uvm_time delay,
                                             int tr_h,
                                             bit is_nonblocking,
                                             int end_phase,
                                             int sync);
        return;
      endfunction
    `endif
       // End
    
    `ifndef UVM_VCS_RECORD
    // 9001130255
      virtual function string get_object_id (uvm_object obj);
         return obj.get_type_name();
      endfunction
    `endif
    

    完整源码 · SHA256:ffddac284b5a12a50304eb521edb3d3678eb328fa1662918cc4f119b5f6f8c2f

    术语解释 · 兼容配置

    自定义 sequence 仲裁函数改用 int 签名(M06-007) · uvm_tlm_time 更名 uvm_time(M08-007)

    返回Comparer / Printer / Packer / Recorder · 迁移清单

    版本适用范围