How to get the array of values as arguments in systemverilog, my requirement is I need get an array of commands of undefined size from the command line ,and how to get these arguments to an array/Queue
Eg:
+CMDS=READ,WRITE,READ_N_WRITE
: It should be taken to an array ?
According to the IEEE Std 1800-2012 (Section 21.6 "Command line input"), the
$value$plusargs
system function accepts a string, not an array. You would have to parse the string inside Verilog, which would probably be very cumbersome (refer to Section 6.16 "String data type" for string operators).Other options might be:
+CMD1=READ +CMD2=WRITE
$readmemh
, although that is limited to numeric data$fopen
$value$plusargs
does not support arrays, it does support strings. See IEEE Std 1800-2012 § 21.6 "Command line input". Parsing a string in SystemVerilog is only a little cumbersome but still very doable, especially when the separator is represented as a single character. Here is a generic string parser using a SystemVerilog queue for recoding the indexes and string methodsubstr
defined in IEEE Std 1800-2012 § 7.10 "Queue" and § 6.16.8 "Substr"Then combine it with
$value$plusargs
to parse the input:Full working example: http://www.edaplayground.com/s/6/570