有可能遍历我传递给系统verilog任务或函数的所有参数,例如c中的argv和Perl中的@ARGV?因为我不知道将要传递多少参数。
test("name2", 1,2,3); // might pass more argument than this
task test(string signal, int tog1, int tog2, int tog3);
$display("The value are: %s, %d and %d", signal, tog1, tog3) ; //any way to just iterate through this?
endtask
SystemVerilog没有此功能。在编译时检查任务和函数调用参数是否匹配原型。
我能想到的两种选择:
首先argv
和@ARGV
迭代传递给程序的参数,而不是函数。 Verilog与plusargs
实现了类似的功能。换句话说,您可以传递以+
开头的参数并使用plusargs
函数来扫描它们。例如,如果您将模拟图像称为此
%> simv +HELLO
在Vreilog中,您可以使用以下内容
initial begin
if ($test$plusargs("HELLO")) $display("Hello argument found.");
...
end
该标准定义了2个功能:
$test$plusargs ( string )
$value$plusargs ( user_string, variable )
其次,c
不允许你遍历函数参数,除非你使用varargs
和variadic
函数。 perl
允许它,将args视为一个数组。 verilog
没有任何语言功能。
但是,verilog定义了一组pli
函数,用于与c
的互操作性。 vpi
接口具有允许您遍历任务和功能的参数的功能(在'c'中)。