$value$plusargs : Second argument must be a modifiable variable

Error: $value$plusargs : Second argument must be a modifiable variable.

In the below code, I intend to send the number of slaves and the required slaves I want to check.

Say I want to set 10 slaves, and I want to check in them slave 1 and 10

So to do that how can I send the same using $value$plusargs?

//TB FILE USED

`include "cs_common.sv"
`include "cs_tx.sv"
`include "cs_gen.sv"

module top_tb;

cs_gen gen=new();

initial
	begin
		$value$plusargs("total_target_slaves=%d",cs_common::total_target_slaves);	
		$value$plusargs("target_slaves=%p",cs_common::target_slaves);		
		
		$display("cs_common::target_slaves=%p",cs_common::target_slaves);
		for(int i=0;i<cs_common::target_slaves.size;i++)
			  begin
				cs_common::target_slaveQ.push_back(cs_common::target_slaves[i]);
			  end
		
		$display("cs_common::target_slaveQ=%p",cs_common::target_slaveQ);
		gen.run();
	end

endmodule


// RUN FILE USED

#compilation

vlog top_tb.sv

#elaboration

vsim top_tb -sv_seed 356489 +total_target_slaves=10 +target_slaves={1,3}

#there is nothing to add in the waveforms

simulation

run -all

//ERROR
Error: $value$plusargs : Second argument must be a modifiable variable.

In reply to Geeky_Woman:

$value$plusargs does not accept a “%p” format and cannot write to an array.

You have several other options:

  1. Put the target_slaves numbers in a file and read them one at a time using $fscanf
  2. Read the plus option
    +target_slaves=1,3
    as a single string, then split the string up individual numbers
  3. Use the UVM’s get_arg_values() method to read multiple
    +target_slave=
    switches into a queue that you can convert into

Here’s an example where you can take just one feature from the UVM and use it in your testbench without having to adopt anything else:

module top;
  import uvm_pkg::uvm_cmdline_processor;
  uvm_cmdline_processor clp = uvm_cmdline_processor::get_inst();
  string args[$];;
  int slaves[$];
  int num;
  initial begin
    num = clp.get_arg_values("+target_slave=",args);
    foreach(args[n]) slaves.push_back(args[n].atoi());
    $display("%p",args);
    $display("%p",slaves);
  end
endmodule


You can execute this with the run options
+target_slave=1 +target_slave=3