function int get_arg_matches (string match,ref string args[$])
获取与字符串match的内容匹配的参数,结果存储在args字符串队列中;
functionint get_arg_value (string match, ref string value)
获取与字符串match匹配的参数值,如“+incdir+”后面的信息,仅获取第一个参数;
functionint get_arg_values (string match, ref string values[$])
获取与字符串match匹配的参数值,如“+incdir+”后面的信息,获取所有参数值
example:
initial begin
string arg_values[$];
string str_arg_value;
int num;
uvm_cmdline_processor clp;
clp = uvm_cmdline_processor::get_inst();
void'(clp.get_arg_values("+foo",arg_values));
for(int ii=0;ii<arg_values.size;ii++)
$display("arg_values[%0d],%s",ii,arg_values[ii]);
clp.get_arg_value("seq_num =",str_arg_value);
num = str_arg_value.atoi(); //string transfer to integer
end
run-time option \
seq_num=200
uvm_cmdline_processor 可以接收多个相同的plusargs,而$test$plusargs和$value$plusargs不能。
$test$plusargs和$value$plusargs作为进行Verilog和SystemVerilog仿真运行时调用的系统函数,可以在仿真命令直接进行赋值.
$test$plusargs
当仿真运行时,$test$plusargs会在sim 命令行中搜索指定的字符,若找到相应字符,函数返回“1”,否则返回“0”;
module top ;
reg[255:0] testname;
initial begin
if($test$plusargs("TAISHAN"))
$display("****************TAISHAN is selected******************");
end
endmodule
sim option: simv +TAISHAN
$value$plusargs
$value$plusargs用於(sim-options)中的参数值传递给指定的信号或者字符,若在sim options找到相应字符,函数返回“1”,否则返回“0”。
其语法格式如下:
Integer = $value$plusargs(“string”,signalname);
其中string = ”plusarg_format” + ”format_string”, ”plusarg_format” 指定了用户定义的要进行传递的值,”format_string”指定了要传递的值的格式(类似$display中定义的%s、%h、etc.),并且string中 ”plusarg_format” 和 ”format_string” 格式应该为”plusarg_format”(=/+)”format_string”。如果转换后的位宽和传递的值不一致,则按照如下规则转换:
plusarg位宽与sigalname的关系 |
Signalname值 |
< |
plusarg左补零 |
> |
plusarg截位 |
plusarg为负数 |
按照正数处理 |
不匹配 |
若为指定默认值,则reg类型为x |
int stop_clk;
string test_name;
real freq;
if($value$plusargs("FINISH=%0d",stop_clk))begin
repeat(stop_clk) @(posedge clk);
end
if($value$plusargs("TEST_NAME=%s",test_name))begin
$display("run test %0s",test_name);
end
if($value$plusargs("FREQ=%0f",freq))begin
$display("freq: %0f",freq);
end
若使用的运行命令如下:
<sim-options> +FINISH=10000 +TESTNAME=this_test +FREQ=5.6666
上例的运行结果为:
stop_clk : 10000
testname:this_test
freq:5.6666