跳转至

输入查询内容

    本页内容

    新增 uvm_policy / uvm_copier / uvm_field_op 与 do_execute_op / set_local 钩子

    新增功能:目标库新增的 API 和可选替代接口;已有用法的迁移要求列在用户接口与行为中。

    具体差异

    纯新增能力:uvm_policy 为所有策略类基类(扩展挂接 set_extension/get_extension);uvm_field_op 描述字段操作并由 do_execute_op 分发——自定义字段自动化行为应 override do_execute_op 而非旧钩子;pack/unpack 新增 longint 流变体。set_int_local/set_string_local/set_object_local 保留但改经 uvm_field_op 实现。

    修改方案

    无(存量代码可不动);新代码建议直接使用新钩子。

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

    已有实测与复现

    补充查阅

    扫描定位与记录结果

    无对应规则。当前脚本没有针对本条的直接检测规则。

    本条处理级别为“可选采用”,按修改方案评估;缺少扫描规则本身不增加迁移改造要求。

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

    源码与标准依据

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

    VCS 内置 UVM-1.2:无对应(1.2 uvm_object.svh:565 仅有 pack/pack_bytes/pack_ints)

    VCS 内置 uvm-ieee-2020-2.0uvm_policy.svh:31(uvm_policy:extension 机制、active object 栈)、uvm_copier.svh:40(uvm_copier:copy_object uvm_copier.svh:76set_recursion_policy uvm_copier.svh:127)、uvm_field_op.svh:30(uvm_field_op:set() uvm_field_op.svh:57)、uvm_object.svh:718do_execute_op)、uvm_object.svh:723set_local)、uvm_object.svh:571/uvm_object.svh:668(新增 pack_longints/unpack_longints)、uvm_component.svh:1553(组件级 do_execute_op,UVM_PRINT 时按 print_enabled 打印子组件)

    标准依据:IEEE 1800.2-2020 §16.1(uvm_policy)、§16.6(uvm_copier)、§5.7(uvm_field_op)、§13.1.2.3(组件 do_execute_op)、§5.3.11.1(unpack_longints)

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

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

    src/vcs-uvm-ieee-2020-2.0/base/uvm_policy.svh
    // Implementation as per Section 16.1 UVM Policy
    //------------------------------------------------------------------------------
    // @uvm-ieee 1800.2-2020 auto 16.1.1
    virtual class uvm_policy extends uvm_object;
    
    
    typedef enum {
            NEVER,
            STARTED,
            FINISHED
    } recursion_state_e;
    
    
    local uvm_object  m_extensions[uvm_object_wrapper];
    local uvm_object m_policy_stack[$];
    

    完整源码 · SHA256:b66da283b0aabcd291a30fe3c11fd0d3c07925b710fbc840b8c8f7f5a652751b

    src/vcs-uvm-ieee-2020-2.0/base/uvm_copier.svh
    // 16.6 of 1800.2-2020
    
    // @uvm-ieee 1800.2-2020 auto 16.6.1
    class uvm_copier extends uvm_policy;
       // @uvm-ieee 1800.2-2020 auto 16.6.2.2
       `uvm_object_utils(uvm_copier)
      // Variable -- NODOCS -- policy
      //
      // Determines whether comparison is UVM_DEEP, UVM_REFERENCE, or UVM_SHALLOW.
    
        uvm_recursion_policy_enum policy = UVM_DEFAULT_POLICY;
    
    
       // @uvm-ieee 1800.2-2020 auto 16.6.2.1
       function new(string name="uvm_copier") ; 
        super.new(name);
       endfunction
    
       // Implementation only.
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_copier.svh
      // ~rhs.get_type_name()~).
    
      // @uvm-ieee 1800.2-2020 auto 16.6.4.1
      virtual function void copy_object (
                                           uvm_object lhs,
                                           uvm_object rhs);
    
        uvm_field_op field_op;
        if (get_recursion_policy() == UVM_REFERENCE) begin
          `uvm_error("UVM_COPY_POLICY","Attempting to make a copy of a object which is a reference")
          return;
        end
    
        if (rhs == null || lhs == null) begin
          `uvm_error("UVM_COPY_NULL_OBJ","Attempting to make a copy of a object with null src/target")
          return;
        end
    
        push_active_object(lhs);
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_copier.svh
    endfunction
    
    // @uvm-ieee 1800.2-2020 auto 16.6.3
    virtual function void set_recursion_policy (uvm_recursion_policy_enum policy);
        this.policy = policy;
    endfunction
    
    // @uvm-ieee 1800.2-2020 auto 16.6.3
    virtual function uvm_recursion_policy_enum get_recursion_policy();
          return policy;
    endfunction
    
    // Function: get_num_copies
    //
    // Returns the number of times the ~rhs~ has been copied to a unique ~lhs~ 
    //
    // @uvm-contrib This API is being considered for potential contribution to 1800.2
    function int unsigned get_num_copies(uvm_object rhs);
      if (m_recur_states.exists(rhs))
    

    完整源码 · SHA256:573e1df554d7871680577394c3d8197cfef2b206181391d526a2dc2df726dbee

    src/vcs-uvm-ieee-2020-2.0/base/uvm_field_op.svh
    //------------------------------------------------------------------------------
    
    // @uvm-ieee 1800.2-2020 auto 5.7.1
    class uvm_field_op extends uvm_object;
    
       `uvm_object_utils(uvm_field_op)
    
       local uvm_policy m_policy;
       local bit m_user_hook;
       local uvm_object m_object;
       // Bit m_is_set is set when the set() method is called and acts 
       // like a state variable. It is cleared when flush is called.
       local bit m_is_set;
       local  uvm_field_flag_t m_op_type;
    
    
       // Function -- new 
       // 
       // Creates a policy with the specified instance name. If name is not provided, then the policy instance is
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_field_op.svh
       // @uvm-ieee 1800.2-2020 auto 5.7.2.2
       virtual function void set( uvm_field_flag_t op_type, uvm_policy policy = null, uvm_object rhs = null);
         string matching_ops[$];
         if (op_type & UVM_COPY)
           matching_ops.push_back("UVM_COPY");
         if (op_type & UVM_COMPARE)
           matching_ops.push_back("UVM_COMPARE");
         if (op_type & UVM_PRINT)
           matching_ops.push_back("UVM_PRINT");
         if (op_type & UVM_RECORD)
           matching_ops.push_back("UVM_RECORD");
         if (op_type & UVM_PACK)
           matching_ops.push_back("UVM_PACK");
         if (op_type & UVM_UNPACK)
           matching_ops.push_back("UVM_UNPACK");
         if (op_type & UVM_SET)
           matching_ops.push_back("UVM_SET");
    

    完整源码 · SHA256:d6c2d1741c91fa780a7e2552b555fefa2cc287c39fb19cbc727ee6a6ba5e39d7

    src/vcs-uvm-ieee-2020-2.0/base/uvm_object.svh
                                     input uvm_packer packer=null);
    
      // @uvm-ieee 1800.2-2020 auto 5.3.10.1
      extern function int pack_longints (ref longint unsigned longintstream[],
                                         input uvm_packer packer=null);
    
    
      // Function -- NODOCS -- do_pack
      //
      // The ~do_pack~ method is the user-definable hook called by the <pack> methods.
      // A derived class should override this method to include its fields in a pack
      // operation.
      //
      // The ~packer~ argument is the policy object for packing. The policy object
      // should be used to pack objects. 
      //
      // A typical example of an object packing itself is as follows
      //
      //|  class mysubtype extends mysupertype;
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_object.svh
                                       input uvm_packer packer=null);
    
      // @uvm-ieee 1800.2-2020 auto 5.3.11.1
      extern function int unpack_longints (ref   longint unsigned longintstream[],
                                           input uvm_packer packer=null);
    
    
    
      // Function -- NODOCS -- do_unpack
      //
      // The ~do_unpack~ method is the user-definable hook called by the <unpack>
      // method. A derived class should override this method to include its fields
      // in an unpack operation.
      //
      // The ~packer~ argument is the policy object for both packing and unpacking.
      // It must be the same packer used to pack the object into bits. Also,
      // do_unpack must unpack fields in the same order in which they were packed.
      // See <uvm_packer> for more information.
      //
    

    src/vcs-uvm-ieee-2020-2.0/base/uvm_object.svh
      extern virtual function void do_unpack (uvm_packer packer);
    
      // @uvm-ieee 1800.2-2020 auto 5.3.13
      extern virtual function void do_execute_op ( uvm_field_op op);
    
      // Group -- NODOCS -- Configuration
    
      // @uvm-ieee 1800.2-2020 auto 5.3.12
      extern virtual function void  set_local(uvm_resource_base rsrc) ;
    
      //---------------------------------------------------------------------------
      //                 **** Internal Methods and Properties ***
      //                           Do not use directly
      //---------------------------------------------------------------------------
    
      extern local function void m_pack        (inout uvm_packer packer);
      extern local function void m_unpack_pre  (inout uvm_packer packer);
      extern local function int m_unpack_post (uvm_packer packer);
      extern virtual function void m_unsupported_set_local(uvm_resource_base rsrc);
    
      // The print_matches bit causes an informative message to be printed
      // when a field is set using one of the set methods.
    
      local string m_leaf_name;
    

    完整源码 · SHA256:53c99f38f1ce6cb3c6a215858b84938d18eb858f9396d3dba281a32addb3c9c9

    src/vcs-uvm-ieee-2020-2.0/base/uvm_component.svh
      bit print_enabled = 1;
    
      // @uvm-ieee 1800.2-2020 auto 13.1.2.3
      extern virtual function void do_execute_op( uvm_field_op op );
    
      // Type: config_mode_t
      // Value type for storing config_mode_e values
      //
      // |  typedef bit [1:0] config_mode_t;
      //
      // @uvm-contrib
      typedef bit [1:0] config_mode_t;
    
      // Type: config_mode_e
      // Enumeration for controlling component config settings.
      //
      // CONFIG_STRICT - Strictly adhere to the LRM
      // CONFIG_HIGHEST_PRECEDENCE - Only apply resources with highest precedence for each 
      //                             field name / type handle pair
    

    完整源码 · SHA256:a35015c7b14dbf63f2e47a4d202e49555159bb91c263255a1421e3cfdf9e63f2

    术语解释 · 兼容配置

    返回Object / Factory · 迁移清单

    版本适用范围