I am trying to learn how to use $value$plusarg. I have picked up the following code from somewhere.
module test;
integer i, r;
initial begin
r = $value$plusarg("myint=%d", i);
$display("Value is %0d", i);
end
endmodule
When I tried to run it, I am getting the warning as:
System task or function '$value$plusarg' is not defined.
I have used Modelsim. The commands I have used are as follows:
vlog test_genvar.v +define+myint="22"
vsim work.test
run -all
I am not sure if the problem is with the code or the commands I have used. Thanks in advance :)
Very silly mistake. The system task name is $value$plusargs
and not $value$plusarg
(missing 's'..!!!).
Moreover, you may use $test$plusargs
to detect/test whether the given switch is available at run-time or not. Like as follows:
if($test$plusargs("myint"))
begin
$value$plusargs("myint=%d",i);
end
One more thing, I am using VCS, and to provide these kind of switches, I use simply "./simv +myint=5" (of course simv is my compiled-executable file). So, no need of +define+myint=5
, directly +myint=5
should work.
Also, these are run-time switches and not compile time. So, I think they should be with vsim
command and not vlog
, but I am not sure about this. Not big deal, I guess.
Your code is available here at EDAPlayground, simulated with VCS. Just for reference.