跳转至

输入查询内容

    本页内容

    sequence_library 的选择边界与类型名

    影响范围

    USER 模式自定义选择或运行中缩减候选数量时核对本条,观察实际返回索引。

    具体差异

    uvm_sequence_library 本体保留(属 Accellera 扩展而非标准正文)。get_type_name() 返回值不变;UVM_SEQ_LIB_USER 模式下子类现在可读写 counter。默认 select_sequence 还删除了返回前的越界回绕:连续选择后缩小 max,1.2 先归零再返回,2.0 可能先返回旧的越界 counter 再归零。library_probe 的 max 从 3 降到 0,返回值为 0 / 3。

    修改方案

    动态缩减候选集的 USER 模式须检查索引范围;tests/uvm_review/library_migrated.sv 派生带选择前边界检查的 select_sequence,在相同场景两库均返回 0。固定候选集的普通用法无需因此改写。

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

    已知限制KI-011

    迁移后验证

    先积累选择计数,再缩小 max,检查每次索引都在新范围内;候选为空的处理按实际调用契约另测。

    记录本条结果M06-017 · 状态与证据

    已有实测与复现

    补充查阅

    扫描定位与记录结果

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

    • S20 · 启发式:sequence library 动态缩减 max 可能先返回越界索引。
    uv run tools/uvm_migration_scan.py <SoC代码目录> --rules S20
    

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

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

    源码与标准依据

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

    VCS 内置 UVM-1.2uvm_sequence_library.svh:243local int unsigned m_counter

    VCS 内置 uvm-ieee-2020-2.0uvm_sequence_library.svh:289/uvm_sequence_library.svh:455(新增 get_sequence(int unsigned idx) 返回 uvm_object_wrapper)、uvm_sequence_library.svh:71(类型名改用 `uvm_type_name_decl)、:188select_sequence 计数器改为 protected counter,子类可访问)

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

    src/vcs-uvm-1.2/seq/uvm_sequence_library.svh
       // default implementation returns 0, incrementing on successive calls,
       // wrapping back to 0 when reaching ~max~.
       //
       local int unsigned m_counter = 0;
       extern virtual function int unsigned select_sequence(int unsigned max);
    
    
    
       //-----------------------------
       // Group: Sequence registration
       //-----------------------------
    
       // Function: add_typewide_sequence
       //
       // Registers the provided sequence type with this sequence library
       // type. The sequence type will be available for selection by all instances
       // of this class. Sequence types already registered are silently ignored.
       //
       extern static function void add_typewide_sequence(uvm_object_wrapper seq_type);
    

    完整源码 · SHA256:ff9568806676b8ad4a24792a961d08807759de4e23c8baac0bf09539b99707a4

    src/vcs-uvm-ieee-2020-2.0/seq/uvm_sequence_library.svh
      `uvm_object_param_utils(uvm_sequence_library#(REQ,RSP))
      `uvm_type_name_decl("uvm_sequence_library #(REQ,RSP)")
    
       // @uvm-ieee 1800.2-2020 auto 14.4.2
       // @uvm-ieee 1800.2-2020 auto 14.4.3
       extern function new(string name="");
    
    
       //--------------------------
       // Group -- NODOCS -- Sequence selection
       //--------------------------
    
       // Variable -- NODOCS -- selection_mode
       //
       // Specifies the mode used to select sequences for execution
       //
       // If you do not have access to an instance of the library,
    

    src/vcs-uvm-ieee-2020-2.0/seq/uvm_sequence_library.svh
       extern virtual function void get_sequences(ref uvm_object_wrapper seq_types[$]);
    
       // @uvm-ieee 1800.2-2020 auto 14.4.4.10
       extern virtual function uvm_object_wrapper get_sequence(int unsigned idx);
    
    
       // Function -- NODOCS -- init_sequence_library
       //
       // All subtypes of this class must call init_sequence_library in its
       // constructor.
       extern function void init_sequence_library();
    
       // Macro -- NODOCS -- uvm_sequence_library_utils
       //
       // All subtypes of this class must invoke the `uvm_sequence_library_utils
       // macro.
       //
       //| class my_seq_lib extends uvm_sequence_library #(my_item);
       //|   `uvm_object_utils(my_seq_lib)
    

    src/vcs-uvm-ieee-2020-2.0/seq/uvm_sequence_library.svh
    // get_sequence
    // ------------
    
    function uvm_object_wrapper uvm_sequence_library::get_sequence(int unsigned idx);
      if(idx < sequences.size())
        return sequences[idx];
      else begin
        `uvm_error("SEQ_LIB/GET_SEQ", $sformatf("idx %0d > number of sequences in library", idx))
        return null;
      end
    
    endfunction
    
    // select_sequence
    // ---------------
    
    function int unsigned uvm_sequence_library::select_sequence(int unsigned max);
      select_sequence = counter;
      counter++;
    

    完整源码 · SHA256:8c4179d56e5de5a869c43cd13e28ef6fb68d5f447da5c5eb85fa6994717d7907

    术语解释 · 兼容配置

    返回Sequence / Sequencer · 迁移清单

    版本适用范围