• UVM基础之-------uvm report机制的使用


    后面的例子我会继续补充:

    1. 因为uvm默认定义的message格式比较长,非常不利于debug过程中的分析使用,一般情况下,开始使用uvm,都要利用uvm_report_server重新定义message输出的格式。下面给出一个例子:用于将name和ID限定在同一个width。

    class my_report_server extends uvm_report_server;
      int name_width = 20;
      int id_width   = 20;
     
      function string pad(string s, int width);
        if ( s.len() == width )
          return s;
     
        // s is short. Pad at the end.
        if ( s.len() < width )
          return {s, {(width - s.len()){" "}}};
        else                  
            // s is too long. truncate.
          return s.substr(s.len()-width, s.len()-1);
      endfunction
     
      function string compose_message(
        uvm_severity severity,
        string name,
        string id,
        string message,
        string filename,
        int    line
      );
      // Make the width be exactly name_width
      // and id_width.
     
    name = pad(name, name_width);
        id   = pad(id,     id_width);
     
        return super.compose_message(
         severity, name, id, message, filename, line);
        endfunction
      endclass

    前面文章中讲过,uvm_report_server类在整个环境中是一个单态类,所以在uvm_test层用set_server将继承的类替换原来的uvm_report_server类就可以了
    class test extends uvm_test;
     
      // Make my report server.
      begin
        my_report_server my_report_server_inst;
        my_report_server_inst = new();
     
        // Configure.
        my_report_server_inst.name_width = 28;
        my_report_server_inst.id_width   = 20;
     
        // Set.
        uvm_report_server::set_server(
          my_report_server_inst);
      end


    2. 使用catcher对一些message执行CATCH或者THROW的操作:
    class my_report_catcher
      extends uvm_report_catcher;
     
      string            id;
      string            filename;
      string            name;
      string            message;
      int               line;
      int               verbosity;
      uvm_severity      severity;
      uvm_report_object client;
     
    function new(string name = "my_report_catcher");
        super.new(name);
      endfunction
     
      function action_e catch();
        uvm_severity_type usv;
     
        id              = get_id();
        filename        = get_fname();
        line            = get_line();
        severity        = get_severity();
        verbosity       = get_verbosity();
        message         = get_message();
     
        client          = get_client();
        name            = client.get_full_name();
     
        usv = uvm_severity_type'(severity);
     
        // Process this message.
        // Decide THROW or CATCH.
        ...
        return THROW;
      endfunction
    endclass

    class test extends uvm_test;
      ...
      my_report_catcher my_report_catcher_inst;
      my_report_catcher_inst =
        new("my_report_catcher_inst");
      uvm_report_cb::add(null,
        my_report_catcher_inst, UVM_APPEND);

    3. 通过ID实现对message的精细控制,这部分内容在前面代码中有介绍,这里不展开在说的还有另一方面原因,我们在debug的时候通常希望log尽量的完全,因此不推荐使用ID去过滤message,也不推荐将log根据ID打印到不同的file当中,因为这两种做法,一种限制的log的完整性,有可能缺失我们需要的关键的信息,而另一种则是因为message的打印一般是按照时间顺序进行,将log打印到不同的file,将破坏这种前后时间关系,不利于进行debug。因此比较推荐的方式是,尽量将所有的message打印到一个文件,然后通过脚本,从这个文件中根据ID提取你需要debug信息。

    这里面有个原则,是别人跟我说的,我觉得非常有道理:当你在debug一个问题的时候,trace的很长世间才找到问题发生的点(TB 或者DUT的原因),你要在这个问题发生点加上一行打印,帮助你以后去debug。这就是message的意义所在。

    4. 由于使用在环境中使用的uvc越来越多,不可避免的就是log的数量将打印的非常多,如何使用uvm控制和管理log的输出,这也是一个比较值得研究的问题。




  • 相关阅读:
    分布式搜索引擎Elasticsearch的查询与过滤
    剖析Elasticsearch集群系列第一篇 Elasticsearch的存储模型和读写操作
    分布式缓存 cachecloud
    npm是什么NPM的全称是Node Package Manager
    Grafana监控可视化环境搭建
    github ssl验证跳过
    Linux分区扩容
    手把手教你把Vim改装成一个IDE编程环境(图文)
    根据条件批量删除document
    奇智网络聊天机器人
  • 原文地址:https://www.cnblogs.com/bob62/p/3879179.html
Copyright © 2020-2023  润新知