UVM基礎之----uvm_object


uvm_void
The uvm_void class is the base class for all UVM classes.

uvm_object:
The uvm_object class is the base class for all UVM data and hierarchical classes.
uvm_object是一個uvm中data和component共同的基類,里邊集成了很多東西如recorder,reporter等,還定義了許多公用的接口。該類繼承自uvm_void

 1. 該類的屬性:
      static bit use_uvm_seeding = 1;//使能調用uvm的種子機制:
    當使能的時候,UVM-based 對象使用它們的type和full hierarchical 名字進行seeded,提高對象的隨機穩定性因為他們的名字是固定的
  The <uvm_component> class is an example of a type that has a unique  instance name.
     local string m_leaf_name;//本object的名字  
     local int m_inst_id;//本inst_id  
     static protected int m_inst_count = 0;//總共的object數  
     static uvm_status_container __m_uvm_status_container = new;//一個所有object共享的狀態容器
2. 種子機制:
    function void uvm_object::reseed ();//use_uvm_seeding使能情況下根據類型和層次化名字生成一個隨機的種子,即使用uvm的種子機制

3. 對象身份方法:
     1.    function void uvm_object::set_name (string name); //設置leaf_name
     2.   function string uvm_object::get_name ();//返回leaf_name(由new設置或者通過set_name更改)
     3.   function string uvm_object::get_full_name ();//調用2
          1. 返回對象的全部層次名, The default implementation is the same as get_name, as uvm_objects do not inherently possess hierarchy.
          2. 如果對象具有層次,比如uvm_components,將會重載默認的那個實現
          3. Other objects might be associated with component hierarchy but are not themselves components.  For example, uvm_sequence #(REQ,RSP) classes are typically associated with a uvm_sequencer #(REQ,RSP).  In this case, it is useful to override get_full_name to return the sequencer’s full name concatenated with the sequence’s name.  This provides the sequence a full context, which is useful when debugging.

     4.   function int uvm_object::get_inst_id();//返回inst_id
     5.  function int uvm_object::get_inst_count(); //返回inst_count
     6.  function uvm_object_wrapper uvm_object::get_object_type();//在factory中查找type_name並返回對應的實例
        1. get_object_type同get_type是相同的
     7.  function uvm_object_wrapper uvm_object::get_type();//返回本類型所對應的uvm_object_wrapper
        1. 某些object派生的對象都對應一個wrapper來實現對某個對象的create,register到工廠等操作,本函數就是要返回對應的wrapper
        2. 返回對象的type-proxy(類型-代理wrapper). uvm_factory's的type-based 覆蓋和創建方法
        3.  The default implementation of this method produces an error and returns null.  To enable use of this method, a user’s subtype must implement a version that returns the subtype’s wrapper.
        4.  This function is implemented by the `uvm_*_utils macros, if employed.(下面例子中的標紅部分由uvm_*utils實現)  
       舉個例子:
          class cmd extends uvm_object;
           typedef uvm_object_registry #(cmd) type_id;
           static function type_id get_type();
           return type_id::get();
           endfunction
         endclass
     8. virtual function string get_type_name (); //這個函數返回對象的類型名稱,這是通常的類型標識符
         1.  It is used for various debugging functions in the library, and it is used by the factory for creating objects.
         2. This function must be defined in every derived class.
4.創建機制:
        1.  virtual function uvm_object create ( string name ="" )
             1.  Every class deriving from uvm_object, directly or indirectly, must implement the create method.
        2.  virtual function uvm_object clone ();// 克隆方法創建並返回這個對象的精確復制。
5. print方法:
  1 .function void uvm_object::print(uvm_printer printer=null);//調用sprint打印本object  
      1. 如果printer沒有提供將會使用uvm_default_printer。
      2.  See also uvm_line_printer, uvm_tree_printer, and uvm_table_printer for details on the pre-defined printer “policies,” or formatters, provided by the UVM.
      3. 自定義打印和sprint 操作, 派生類必須覆蓋do_print方法和使用提供的打印機政策類格式輸出。
      4.  $fwrite(printer.knobs.mcd,sprint(printer));//主要是調用fwrite函數,打印sprint返回的string
  2. function string uvm_object::sprint(uvm_printer printer=null); //調用do_print(printer)打印(主要目的是返回一個string,而不是為了打印)
      1. The printer policy will manage all string concatenations and provide the string to sprint to return to the caller.
      2. 注意在printer.istop, not at top-level, must be recursing into sub-object調用do_print方法
   3.調用printer.emit()實現格式化
 3.  virtual function void do_print (     uvm_printer      printer     )
   1.  The do_print method is the user-definable hook called by print and sprint that allows users to customize what gets printed or sprinted beyond the field information provided by the `uvm_field_* macros, Utility and Field Macros for Components and Objects.
      2. printer是policy對象,控制輸出的格式和內容
      3.   To ensure correct print and sprint operation, and to ensure a consistent output format, the printer must be used by all do_print implementations.  That is, instead of using $display or string concatenations directly, a do_print implementation must call through the printer’s API to add information to be printed or sprinted.
      3. 使用printer提供的api打印
      class mytype extends uvm_object;
  data_obj data;
  int f1;
  virtual function void do_print (uvm_printer printer);
    super.do_print(printer);
    printer.print_int("f1", f1, $bits(f1), DEC);
    printer.print_object("data", data);
  endfunction
   4. convert2string()//This virtual function is a user-definable hook, called directly by the user, that allows users to provide object information in the form of a string.
       
6. Recording方法:
   1.function void uvm_object::record (uvm_recorder recorder=null);//調用do_record做記錄
      1. A simulator’s recording mechanism is vendor-specific.  By providing access via a common interface, the uvm_recorder policy provides vendor-independent access to a simulator’s recording capabilities.
   2.function void uvm_object::do_record (uvm_recorder recorder);//null      

7. Copy方法:
    1.function void uvm_object::copy (uvm_object rhs);  
    2 .function void uvm_object::do_copy (uvm_object rhs); //null
8. Compare方法:
  1.  function bit  uvm_object::compare (uvm_object rhs,            
                                   uvm_comparer comparer=null); //調用比較策略器進行比較
        1. The optional comparer argument specifies the comparison policy.  It allows you to control some aspects of the comparison operation.  It also stores the results of the comparison, such as field-by-field miscompare information and the total number of miscompares.  If a compare policy is not provided, then the global uvm_default_comparer policy is used.  See uvm_comparer for more information.
  2.  function bit  uvm_object::do_compare (uvm_object rhs,      
                                      uvm_comparer comparer);//被1調用
          class mytype extends uvm_object;
      ...
      int f1;
      virtual function bit do_compare (uvm_object rhs,uvm_comparer comparer);
        mytype rhs_;
        do_compare = super.do_compare(rhs,comparer);
        $cast(rhs_,rhs);
        do_compare &= comparer.compare_field_int("f1", f1, rhs_.f1);
      endfunction
 
A derived class implementation must call super.do_compare() to ensure its base class’ properties, if any, are included in the comparison.  Also, the rhs argument is provided as a generic uvm_object.  Thus, you must $cast it to the type of this object before comparing.
 
The actual comparison should be implemented using the uvm_comparer object rather than direct field-by-field comparison.  This enables users of your class to customize how comparisons are performed and how much miscompare information is collected.  See uvm_comparer for more details.

9.Pack方法:
10. Unpack方法:

11.configuration方法:
  1.function void  uvm_object::set_int_local (string      field_name,
                                          uvm_bitstream_t value, 
                                          bit         recurse=1); //保存一個整數
 
  2.function void  uvm_object::set_object_local (string     field_name,
                                             uvm_object value,    
                                             bit        clone=1,  
                                             bit        recurse=1); //保存一個object
 
   3.function void  uvm_object::set_string_local (string field_name,
                                             string value,   
                                             bit    recurse=1);//保存string

1. These methods provide write access to integral, string, and uvm_object-based properties indexed by a field_name string.
2. Although the object designer implements these methods to provide outside access to one or more properties, they are intended for internal use (e.g., for command-line debugging and auto-configuration) and should not be called directly by the user.








免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM