UVM基礎之---Command-line Processor

提供一個廠商獨立的通用接口命令行參數,支持分類:
  1. 基本參數和值:get_args,get_args_matches
  2. 工具信息:get_tool_name(),get_tool_version()
  3. 支持從命令行設置各類UVM變量如冗長和配置設置積分和字符串類型:  +uvm_set_config_int, +uvm_set_config_string

類:uvm_cmdline_processor:
這個類在模擬過程當中提供一個命令參數接口,這個類應該是當成一個單例類使用,但這不是必須的。一個全局變量 uvm_cmdline_proc在初始化的時候建立,用於訪問命令行提供的 信息。也支持從命令行配置各類各樣的UVM變量。

下面簡單的分析下這個類的實現機制:首先這個類繼承自uvm_report_object,是一個單態類。

  protected string m_argv[$]; 
  protected string m_plus_argv[$];
  protected string m_uvm_argv[$]; 
 
首先是基本的參數操做:
  get_args(output string args[$]) 命令行的全部用於控制仿真狀態的參數作成一個隊列並返回。
  get_plusargs(output string args[$]) :返回一個隊列,包含全部用於啓動仿真的附加參數。
  get_uvm_args(output string args[$]) : 使用一個隊列返回全部uvm參數。
  get_arg_matches(string match, ref string args[$]) :這個函數加載全部匹配match string的參數到一個隊列,並返回匹配的個數。若是表達式包含//擴展正則表達式,下面是一個例子:
 //| string myargs[$]
  //| initial begin
  //|    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.

  function int get_arg_matches (string match, ref string args[$]);
   `ifndef UVM_CMDLINE_NO_DPI
    chandle exp_h = null;
    int len = match.len();   //檢查match的長度
    args.delete();
    if((match.len() > 2) && (match[0] == "/") && (match[match.len()-1] == "/")) begin//若是長度大於2 且包含//
       match = match.substr(1,match.len()-2);//提取須要match的表達式
       exp_h = uvm_dpi_regcomp(match);//使用dpi匹配知足表達式,
       if(exp_h == nullbegin
         uvm_report_error("UVM_CMDLINE_PROC", {"Unable to compile the regular expression: ", match}, UVM_NONE);
         return 0;
       end
    end
    foreach (m_argv[i]) begin
      if(exp_h != nullbegin
        if(!uvm_dpi_regexec(exp_h, m_argv[i]))
           args.push_back(m_argv[i]);
      end
      else if((m_argv[i].len() >= len) && (m_argv[i].substr(0,len - 1) == match))
        args.push_back(m_argv[i]);
    end
    if(exp_h != null)
      uvm_dpi_regfree(exp_h);
    `endif
    return args.size();
  endfunction 


get_arg_value(string match,ref string value):從args裏面找到第一個知足match的參數,並返回對應的值
get_arg_values(string match, ref srring values[$]) : 從args裏面找到全部知足match的參數,並返回一個值得隊列。返回參數是匹配的個數。
 
     function   new ( string  name =  "" ); 用於收集命令行傳來的參數,並保存到對應的隊列裏面
    string s;
    string sub;
    int doInit=1;
    super.new(name);
    do begin
      s = uvm_dpi_get_next_arg(doInit);
      doInit=0;
      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!=""); 

命令行調試:
  1.  +UVM_DUMP_CMDLINE_ARGS,容許用戶dump全部的命令行參數發給report機制,在uvm_root裏面實現
    2.  +UVM_TESTNAME= 指定須要從工廠裏面建立的test,若是指定不少,則使用第一個。在uvm_root實現,經過run_test調用
  3. +UVM_VERBOSITY= 指定message的冗餘程度,在uvm_root實現,經過uvm_root:new()調用
    4.  +uvm_set_verbosity 容許用戶在特定的phase對特定的message的冗餘度進行調整
    // ~+uvm_set_verbosity=<comp>,<id>,<verbosity>,<phase>~ and
    // ~+uvm_set_verbosity=<comp>,<id>,<verbosity>,time,<time>~ 

    +uvm_set_verbosity=uvm_test_top.env0.agent1.*,_ALL_,UVM_FULL,time,800

    5. +uvm_set_action:指定對應的message的動做
    +uvm_set_action=uvm_test_top.env0.*,_ALL_,UVM_ERROR,UVM_NO_ACTION
    6. +uvm_set_severity : 指定對應message的嚴重等級:
    7. +UVM_TIMEOUT= 
    8. +UVM_MAX_QUIT_COUNT 用於指定當出現幾個ERROR就退出仿真
    9. +UVM_PHASE_TRACE
   10. +UVM_OBJECTION_TRACE
   11. +UVM_RESOURCE_DB_TRACE
   12. +UVM_CONFIG_DB_TRACE
    13. 工廠替換參數:  
   // Variable: +uvm_set_inst_override  
    // Variable: +uvm_set_type_override   
    // ~+uvm_set_inst_override=<req_type>,<override_type>,<full_inst_path>~ and
    // ~+uvm_set_type_override=<req_type>,<override_type>[,<replace>]~
 //| <sim command> +uvm_set_type_override=eth_packet,short_eth_packet
   14. 設置變量參數:
    // Variable: +uvm_set_config_int  
    // Variable: +uvm_set_config_string
    // ~+uvm_set_config_int=<comp>,<field>,<value>~ and
    // ~+uvm_set_config_string=<comp>,<field>,<value>~




相關文章
相關標籤/搜索