UVM-1.1学习(二)——uvm_cmdline_processor

在由systemverilog搭建的验证环境中,我们可以使用系统函数$value$plusargs来获取仿真时的仿真参数。而在基于UVM的验证环境中,我们可以使用另一种方式来获取仿真参数:uvm_cmdline_processor。
uvm_cmdline_processor本质上是一个class,它的继承关系如下:
在这里插入图片描述
在这个类中,实现了以下两大类的功能(本文只关注第一类的功能):

  • 获取仿真参数并存储
  • 获取仿真参数来设定部分UVM变量的值(比如verbosities)

实际上,在uvm_cmdline_processor这个类里面定义了一些string队列,用于存储相关的仿真参数,这些队列如下:

protected string m_argv[$];
protected string m_plus_argv[$];
protected string m_uvm_argv[$];
  • m_argv[$]
    用于存储仿真时所有的仿真参数,其中m_argv[0]比较特殊,存储的是仿真时可执行文件的名称。
  • m_plus_argv[$]
    用于存储仿真时带’+'号的仿真参数。
  • m_uvm_argv[$]
    用于存储和UVM相关的仿真参数,判断标准是检测仿真参数是否以’+uvm’、’-uvm’、’+UVM’、’-UVM’作为前缀。

虽然知道了在这些队列中存储了相关的仿真参数,但是由于这些队列都是protected的,我们只能通过对应的函数来进行访问,这些函数的原型如下:

function void get_args (output string args[$]);
function void get_plusargs (output string args[$]);
function void get_uvm_args (output string args[$]);

另一个令人比较感兴趣的问题是,这些队列在什么时候被初始化。阅读对应的源码,可以看到这件事情发生在class的构造函数中:

  function new(string name = "");
    string s;
    string sub;
    super.new(name);
    do begin
      s = uvm_dpi_get_next_arg();
      if(s!="") begin
        m_argv.push_back(s);
        if(s[0] == "+") begin
          m_plus_argv.push_back(s);
        end 
        if(s.len() >= 4 && (s[0]=="-" || s[0]=="+")) begin
          sub = s.substr(1,3);
          sub = sub.toupper();
          if(sub == "UVM")
            m_uvm_argv.push_back(s);
        end 
      end
    end while(s!="");

细心的你可能已经发现了,对仿真参数的处理采用的是dpi+字符串的手段,而不是调用系统函数$value$plusargs。那么问题又来了,既然是在构造函数中完成队列初始化的,那么我们是不是还需要构造一个uvm_cmdline_processor类的实例?其实这一步也是不需要的,因为在源码中,已经帮我们做好了。

  static function uvm_cmdline_processor get_inst();
    if(m_inst == null)
      m_inst = new("uvm_cmdline_proc");
    return m_inst;
  endfunction

const uvm_cmdline_processor uvm_cmdline_proc = uvm_cmdline_processor::get_inst();

因此,在实际的验证环境中,我们的使用可以非常简单:

`timescale 1ns/1ps
`include "uvm_macros.svh"

import uvm_pkg::*;

program testcase();

string cmdline_argv[$];
string cmdline_plus_argv[$];
string cmdline_uvm_argv[$];

initial begin
    $display("*************************************************************");
    uvm_cmdline_proc.get_args(cmdline_argv);
    uvm_cmdline_proc.get_plusargs(cmdline_plus_argv);
    uvm_cmdline_proc.get_uvm_args(cmdline_uvm_argv);
    foreach(cmdline_argv[i])        $display("cmdline_argv[%0d]     =%s", i, cmdline_argv     [i]);
    foreach(cmdline_plus_argv[i])   $display("cmdline_plus_argv[%0d]=%s", i, cmdline_plus_argv[i]);
    foreach(cmdline_uvm_argv[i])    $display("cmdline_uvm_argv[%0d] =%s", i, cmdline_uvm_argv [i]);
    $display("*************************************************************");
    $finish();
end

endprogram

假如Makefile中的仿真参数如下:

./simv -l run_ver.log +plus_argv_test1 -plus_argv_test2 +UVM_argv_test1 -uvm_argv_test2=2

那么仿真的结果如下:

*************************************************************
cmdline_argv[0]     =./simv
cmdline_argv[1]     =-l
cmdline_argv[2]     =run_ver.log
cmdline_argv[3]     =+plus_argv_test1
cmdline_argv[4]     =-plus_argv_test2
cmdline_argv[5]     =+UVM_argv_test1
cmdline_argv[6]     =-uvm_argv_test2=2
cmdline_plus_argv[0]=+plus_argv_test1
cmdline_plus_argv[1]=+UVM_argv_test1
cmdline_uvm_argv[0] =+UVM_argv_test1
cmdline_uvm_argv[1] =-uvm_argv_test2=2
*************************************************************

事实上,uvm还提供了更丰富的函数库:

  function int get_arg_matches (string match, ref string args[$]);

  //|    void'(uvm_cmdline_proc.get_arg_matches("+foo",myargs)); //matches +foo, +foobar
  //|                                                            //doesn't match +barfoo
  //|    void'(uvm_cmdline_proc.get_arg_matches("/foo/",myargs)); //matches +foo, +foobar,
  //|                                                             //foo.sv, barfoo, etc.
  //|    void'(uvm_cmdline_proc.get_arg_matches("/^foo.*\.sv",myargs)); //matches foo.sv
  //|                                                                   //and foo123.sv,
  //|                                                                   //not barfoo.sv.

get_arg_matches允许我们搜索并返回满足条件的仿真参数。match是搜索条件,args[$]是满足搜索条件的仿真参数,function返回的int值则是满足搜索条件的仿真参数个数。由于使用了dpi接口,match甚至于还支持正则表达式。

  function int get_arg_value (string match, ref string value);
  function int get_arg_values (string match, ref string values[$]);
  
  // For example if '+foo=1,yes,on +foo=5,no,off' was provided on the command
  // line and the following code was executed:
  //|    void'(uvm_cmdline_proc.get_arg_values("+foo=",foo_values));
  // The foo_values queue would contain two entries.  These entries are shown
  // here:
  //   0 - "1,yes,on"
  //   1 - "5,no,off"

get_arg_value和get_arg_values函数允许我们搜索以match字符串为开头的仿真参数。两个函数的区别在于一个只返回搜索到的第一个值,一个返回搜索到的所有满足条件的值。

  function string get_tool_name ();
  function string  get_tool_version ();

get_tool_name和get_tool_version函数允许我们获取仿真工具的名称和版本,实际上,这部分的实现已经通过dpi交还给了EDA vender。

  • 3
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: uvm-1.1a.tar.gz是一个库文件,它是Universal Verification Methodology(UVM)的开源版本,旨在帮助硬件验证工程师实现更高效、更准确的系统级验证工作。该版本的发布包括完整的UVM框架和示例代码,它们可以被应用于各种验证环境中。其中包含了基于SystemVerilog的类库、通用模型、事务级建模器和随机验证,同时也包括了DPI、OVM等不同验证中间件框架的支持。该版本提供了更多的互操作性和可扩展性,让用户能够快速开发和部署大规模验证工作。UVM已经成为ASIC和FPGA验证领域的事实标准,可以在不同的平台和工具上进行移植。因为它的开源特性和流行度,UVM支持社区持续创新和最佳实践的分享,不断提高Verilog验证技术的水平和效率。 ### 回答2: uvm-1.1a.tar.gz是一种开源的验证方法学框架,为现代芯片验证提供了一种完整而灵活的解决方案。它提供了一套可重用的Class Library,包括了各种验证组件,如监控,分析器,交通形成器和交通收集器,并提供了一种现代的验证方法学,包括创建可重用的测试用例和环境。UVM框架是基于SystemVerilog语言的,是目前工业界最常用的验证环境之一。该框架可以帮助芯片设计者和验证工程师更有效地制定验证计划和执行测试,缩短开发周期,提高产品质量和可重复性。同时,UVM也在学术界和研究机构中广泛应用,为芯片验证方法学的研究和发展提供了有力的支持和平台。总之,uvm-1.1a.tar.gz是一个非常有用的开源验证方法学框架,为芯片验证提供了强大的支持和帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值