Systemverilog has two system functions for retriving the arguments (aka plusargs) from the command line, these are $test$plusargs and $value$plusargs.
$test$plusargs(string)
This system function receives a string as input argument, then search through the plusargs in the command line. If the prefix of any of the plusargs is matched with the provided string of the system function, this function return non-zero value. Usually, we will use this function as an expression in the consditional statement if-else as below example:
$value$plusargs(“PLUSARGS=format string”, var)
Similar to $test$plusargs, but the plusargs now comes with a value, and we can assign that value to a variable as below example.
string format for plusargs
We can use below format string when get the value from plusargs
%d
decimal conversion
%o
octal conversion
%h,%x
hexadecimal conversion
%b
binary conversion
%e
real exponential conversion
%f
real decimal conversion
%g
real decimal or exponential conversion
%s
string (no conversion)
UVM built-in functions those help
Some uvm functions those make handling test plusargs easier
Plusargs for enum variable
Assuming we have a enum type sha_mode_e, and the plusargs input value is stored in a string. Instead of using switch-case to match the string to each enum name constant, we can use uvm_enum_wrapper#(<enum type>)::from_name() function to cast the plusarg string to the enum variable.
uvm_cmdline_processor sigleton class
This uvm class supports many functions that handle the plusargs. There is a global variable of uvm_cmdline_processor class called uvm_cmdline_proc and can be used to access command line information.
Let’s check some examples below.
plusarg containing a list of values
In this example we will use the uvm_cmdline_proc.get_arg_value() function to get the argument as a string. Then use the uvm_split_string() to split this string to entries based on the sepapartor.
multiple plusargs with the same name, but different values
Assuming we need a plusarg with this format to configure one aes encryption operation : +AES_OPR_CFG=<AES_MODE>,<KEY_LEN>.
We also need to have multiple aes encryption operations in 1 test, each receiving plusarg will corresponding to 1 operation.
In this example, we will use the uvm_cmdline_proc.get_arg_values() function instead of uvm_cmdline_proc.get_arg_value().
Finding more information
Systemverilog LRM, section 21.6 Command line input