plusargs in verilog

plusargs are command-line switches supported by the simulator. As per SystemVerilog LRM arguments beginning with the + character will be available using the $test$plusargs and $value$plusargs PLI APIs.

1
2
3
$test$plusargs (user_string)

$value$plusargs (user_string, variable)

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// tb.v
module tb;
int a;
initial begin
if($test$plusargs("RUNSIM")) begin
$display("There is RUNSIM plusargs");
end else begin
$display("There is NO $test$plusargs");
end
if($value$plusargs("SEED=%d",a)) begin
$display("SEED=%d",a);
end else begin
$display("There is NO $value$plusargs");
end
end
endmodule
  • compile

    1
    2
    $ vlib work
    $ vlog -sv tb.v
  • simulate (QuestaSim)

    • without plusargs

      1
      $ vsim work.tb -c -do "run; exit"
      1
      2
      3
      4
      5
      6
      7
      8
      9
      # //
      # Loading sv_std.std
      # Loading work.tb(fast)
      # run
      # There is NO $test$plusargs
      # There is NO $value$plusargs
      # exit
      # End time: 13:04:23 on Jun 04,2022, Elapsed time: 0:00:01
      # Errors: 0, Warnings: 0
    • with plusargs

      1
      $ vsim work.tb -c -do "run; exit" +SEED=31 +RUNSIM

      +SEED=31 +RUNSIM

      1
      2
      3
      4
      5
      6
      7
      8
      9
      # //
      # Loading sv_std.std
      # Loading work.tb(fast)
      # run
      # There is RUNSIM plusargs
      # SEED= 31
      # exit
      # End time: 13:04:55 on Jun 04,2022, Elapsed time: 0:00:01
      # Errors: 0, Warnings: 0

reference

systemverilog-command-line-input URL: https://www.chipverify.com/systemverilog/systemverilog-command-line-input

PLUSARGS IN SYSTEMVERILOG URL:https://www.theartofverification.com/plusargs-in-systemverilog/