シミュレーターにコマンドライン引数を渡して、条件分岐などを行う方法。システムタスク $test$plusargs(string)、$value$plusargs(user_string, variable) を使う。
文字列の指定
simv +FOO のように渡す場合。
if ($test$plusargs("FOO")) begin | |
$display("FOO"); | |
end |
$test$plusargs は前方一致で判断するので、+FOO でも +FOOO、+FOOOO などでも上記条件は成立する。
任意の値の指定
simv +FOO=100 のように渡す場合。
integer foo; | |
if ($value$plusargs("FOO=%d", foo)) begin | |
$display("FOO = %0d", foo); | |
end |
%d 部分は、受け取りたい(変換したい)型に合せて指定する。
[table]
format string,説明
%d,decimal conversion
%o,octal conversion
%h,hexadecimal conversion
%b,binary conversion
%e,real exponential conversion
%f,real decimal conversion
%g,real decimal or exponential conversion
%s,string
[/table]