https://www.cnblogs.com/jiang-ic/p/10579416.html
program automatic test;
import uvm_pkg::*;
class hello_world extends uvm_test;
uvm_cmdline_processor clp;
int arg_value;
string arg;
`uvm_component_utils(hello_world);
function new (string name, uvm_component parent);
super.new(name, parent);
clp=new();
if(clp.get_arg_value("+arg_value",this.arg)) begin
this.arg_value=this.arg.atoi();
`uvm_info("test_arg", $sformatf("input value = %d", arg_value), UVM_DEBUG);
end
else begin
`uvm_info("test_arg", "no input arg_value", UVM_DEBUG);
end
if ($value$plusargs("+arg_value%0d", this.arg)) begin
`uvm_info("test_arg", $sformatf("input value = %d", arg_value), UVM_DEBUG);
end
else begin
`uvm_info("test_arg", "no input arg_value", UVM_DEBUG);
end
endfunction
endclass
initial begin
run_test("hello_world");
end
initial begin
uvm_cmdline_processor cmdline_processor = uvm_cmdline_processor::get_inst();
// give default value
string my_value = "default_value";
int rc = cmdline_processor.get_arg_value("+abc=", my_value);
// if needed, change to integer
int my_int_value = my_value.atoi();
// for a set of values in +abc
string my_value_list[$];
int rc = cmdline_process.get_values("+abd=", my_value_list);
$display("my rc: %0d", rc);
$display("my value : %0s", my_value);
$display("my value_list : %p", my_value_list);
end
endprogram
运行
vcs -full64 -sverilog -R -ntb_opts uvm-1.2 taa.sv +arg_value1231 +UVM_VERBOSITY=UVM_DEBUG +abc=111 +abd=ccc,ddd,eee
输出
数组部分获取数值失败,然后是uvm这种方法和sv提供的方法除了传入是不是格式化字符串,还有其它一点区别,要不然前两行输出是一样的。
UVM_INFO taa.sv(17) @ 0: uvm_test_top [test_arg] input value = 1231
UVM_INFO taa.sv(27) @ 0: uvm_test_top [test_arg] no input arg_value
UVM_INFO @ 0: reporter [RNTST] Running test hello_world...
my rc: 1
my value : 111
my value_list : '{}
标签:get,value,uvm,arg,test,my,UVM
From: https://www.cnblogs.com/bai2022/p/17419056.html