加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

uvm_printer/uvm_printer_knobs

(2011-09-21 15:21:30)
标签:

uvm

printer

it

分类: uvm

preface:

  在uvm_compare中已经做了详细解释,这里就直接剖析这个类。本类的目的非常简单提供一个printer的工具,可以处理object各种情况下的printer需求。由于这个类可以用户自定义,从而提供同一个方法的不同实现,故也叫policy object。

  content:

    1. uvm_printer_knobs  that you use to control what and how information is printed

    2. uvm_printer_knobs是一个root类下边将简要介绍各个成员的作用

         bit header = 1;是否调用print_header打印object的头

          bit footer = 1;是否调用print_footer打印object的尾

          bit full_name = 0;<adjust_name> print the full name of an identifier or leaf name.

          bit identifier = 1;<adjust_name> should print the identifier

          bit type_name = 1;print a field's type name

          bit size = 1;print a field's size

          int depth = -1;how deep to recurse when printing objects

          bit reference = 1;print a unique reference ID for object handles

          int begin_elements = 5;Defines the number of elements at the head of a list to print

          int end_elements = 5;defines the number of elements at the end of a list

          string prefix = "";Specifies the string prepended to each output line

          int indent = 2;specifies the number of spaces to use for level indentation

          bit show_root = 0;the initial object that is printed prints the full path name

          int mcd = UVM_STDOUT;

          separator = "{}";tree printers opening and closing separators for nested objects.

          bit show_radix = 1;the radix string ('h, and so on) should be prepended

          uvm_radix_enum default_radix = UVM_HEX;default radix to use for integral values

          string dec_radix = "'d";

          string bin_radix = "'b";

          string oct_radix = "'o";

          string unsigned_radix = "'d";

          string hex_radix = "'h";

          function string get_radix_str(uvm_radix_enum radix);把radix作为string返回

          int max_width = 999;
          string truncation = "+";
          int name_width = -1;
          int type_width = -1;
          int size_width = -1;
          int value_width = -1;
          bit sprint = 1;

     3.uvm_printer是个接口,里边的许多方法都没有实现留个扩展类来具体实现如table_printer等

         3.1 function emit() Emits a string representing the contents of an object在printer中这个函数实现为空,调用将会出错,应该在扩展类中改写

         3.2 function string uvm_printer::format_row (uvm_printer_row_info row); producing custom output of a single field (row)默认什么都不做,可以在扩展类中改写

         3.3 function void uvm_printer::print_array_header (string name,
                                               int size,
                                               string arraytype="array",
                                               byte scope_separator=".");

       Prints the header of an array before each element is printed. <print_array_footer> is called to mark the completion of array printing.会在m_array_stack.push_back(1);记录他记录了一次array类型的头

         3.4 function string uvm_printer::index_string(int index, string name="");把10, a转化为a[10]

         3.5 function string uvm_printer::adjust_name(string id, byte scope_separator=".");把a[1].b[2].c这样的结构显示出来或者根据设置只把c返回来,里边的控制与show_root,m_scope.depth(),full_name, id=="..."有关

         3.6 function void print_array_footer (int size=0);让uvm知道这是一个array的结束,把m_array_stack.pop_front(),取消记录,一般这个函数什么也不打印,也可以用户定义

         3.7 function void uvm_printer::print_generic (string name,
                                          string type_name,       
                                          int size,
                                          string value,
                                          byte scope_separator=".");

             把成员名,成员类型名,成员位宽,成员值,成员间分隔符一起生成一个uvm_printer_row_info row_info;并压入uvm_printer_row_info m_rows.push_back(row_info);供以后显示用。

        3.8 function void print_array_range (int min, int max);这个函数只是打印一个普通的标志行

called after begin_elements have been printed and before end_elements have been printed

        3.9 function void uvm_printer::print_int (string name,
                                      uvm_bitstream_t value,
                                      int size,
                                      uvm_radix_enum radix=UVM_NORADIX,
                                      byte scope_separator=".",
                                      string type_name="");

          该函数把一个int类型的变量记录到一个row_info并压入m_rows

        3.10 function void uvm_printer::print_time (string name,
                                       time value,
                                       byte scope_separator=".");调用3.9实现

        3.11 function void uvm_printer::print_string (string name,
                                         string value,
                                         byte scope_separator=".");类似3.9的实现

        3.12 function void uvm_printer::print_real (string name,
                                       real value,
                                       byte scope_separator=".");类似3.9的实现

        3.13 function void uvm_printer::print_object_header (string name,
                                                uvm_object value,
                                                byte scope_separator=".");打印一个object对象的头信息基本就是名字和inst_id.很概略的。

        3.14 function void uvm_printer::print_object (string name, uvm_object value,
                                         byte scope_separator=".");

             这个函数是一个比较重要的函数功能描述比较简洁,就是打印一个object,但是打印的方法受很多控制,可以控制打印的深度等。首先调用3.13打印头,然后如果全部深度的打印那么通过cycle_check.exists来控制多个线程同时操作这个object。通过m_scope.down来记录各个object的层次关系。如果对象是一个component那么他存在着层次关系,就需要递归调用print_object的方式把每个child_object都打印出来。最后调用void'(value.sprint(this));把本object的member打印出来

        3.15 function bit uvm_printer::istop ();返回m_scope.depth() == 0看现在是不是操作的顶层

    4. class uvm_table_printer extends uvm_printer;改写了emit函数,    

        4.1   protected int m_max_name;记录了对应列的最大宽度字符数
              protected int m_max_type;
              protected int m_max_size;
              protected int m_max_value;

        4.2 function void calculate_max_widths()根据实际的宽度情况更新4.1中的值

        4.3 function string uvm_table_printer::emit();对处理的结果进行最后的打印,这个函数虽然重要,但是实现上基本就是把m_rows中的东西掉出来并打印出来,在这个过程中会调用相关函数打印一些头部尾部信息 

    5.   uvm_tree_printer extends uvm_printer;定义了一个新的控制符string newline = "\n";改写了emit函数按照树形结构打印

        5.1 function uvm_tree_printer::new();设置了一个基本的knobs信息如  knobs.size = 0;
knobs.type_name = 0;knobs.header = 0;  knobs.footer = 0;

    6.  class uvm_line_printer extends uvm_tree_printer;只是对knobs加了    newline = " ";
    knobs.indent = 0;限制

conclusion:

   uvm_printer的作用非常明白,该类嵌入在每个uvm_object中,并把每个object按文本化结构化的方法进行打印和记录。

location:

C:\Documents and Settings\zhliu\Desktop\uvm-1.0p1\src\base\uvm_printer.svh

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有