-1

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 :)

ssgr
  • 393
  • 7
  • 21

2 Answers2

2

Do you have a copy of the 1800-2012 LRM? If you did, you would see that you have misspelled something.

dave_59
  • 39,096
  • 3
  • 24
  • 63
1

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.

sharvil111
  • 4,301
  • 1
  • 14
  • 29
  • It is indeed run-time switch. If I use with the vlog, I am getting output as **x**. Thanks for that :) – ssgr Nov 02 '15 at 03:29
  • Also can I know when do we use **+define**? – ssgr Nov 02 '15 at 03:30
  • 2
    `+define` is likely to be used to define a macro condition. For example, you have a code with `ifdef ABC`, then `+define+ABC` will define `ABC` macro. – sharvil111 Nov 02 '15 at 03:40