Plusargs in SystemVerilog:

Plus args are command-line switches supported by the simulator. Usually, they are application-specific. As per SystemVerilog LRM arguments beginning with the ‘+’ character will be available using the $test$plusargs and $value$plusargs PLI APIs. Plus args are very useful in controlling many things in your environment like controlling your debug mode or setting a value like the debug_level in your environment, set a value to select/deselect a particular field in your environment in your simulation.

What is the Syntax :

  1. $test$plusargs (string)
  2. $value$plusargs (string, variable)

This is a system function that searches the list of plusargs. For this system in build function, If a string is found the function returns the value 1’b1. If no strong is found matching, the function returns the value 1’b0, and the variable provided is not modified.

Let’s take an example, How should we use these functions in our environment to have control.

initial begin
  if ($test$plusargs("USER_TEST")) begin
    $display("Configuring User Test"); 
    //Execute some code for this mode
  end
end

Once you compile and later run the simulator with command-line argument: +USER_TEST , the output will be

Configuring User Test

Similarly, if you want to read values from the command line into variables the second system function will be handy

For Example

initial begin
  string testname;
  if ($value$plusargs("TEST=%s",testname)) begin 
    $display(" Running TEST= %s.",testname); 
  end 
end

Once you compile and pass some argument to the simulator as: +TEST=AXI_TEST , the output would be

Running TEST=AXI_TEST

About the author

The Art of Verification

Hi, I’m Hardik, and welcome to The Art of Verification.

I’m a Verification Engineer who loves to crack complex designs and here to help others commit to mastering Verification Skills through self-learning, System Verilog, UVM, and most important to develop that thought process that every verification engineer should have.

I’ve made it my mission to give back and serve others beyond myself.

I will NEVER settle for less than I can be, do, give, or create.

View all posts