How Can I Use $Value$Plusargs?

How Can I Use $Value$Plusargs?

I'd like to use $value$plusargs as in the below code:

module top();
...
reg data;
real READ_FREQ

initial begin
if (!$value$plusargs("READ_FREQ=%0F", READ_FREQ))
 READ_FREQ = 197;
end

parameter wclk = 300;
parameter rclk = READ_FREQ;

always #(rclk/2.0) i_rclk = ~i_rclk;

...
endmodule

But, when I compile the code, I get this error:

irun: *E,VLGERR: An error occurred during parsing.  Review the log file for errors with the code *E and fix those identified problems to proceed.  Exiting with code (status 1).

irun(64): 12.10-p001: (c) Copyright 1995-2012 Cadence Design Systems, Inc.
file: ./top.v
parameter       rclk      = READ_FREQ;
                                         |
ncvlog: *E,NOTPAR (./top.v,197|41): Illegal operand for constant expression [4(IEEE)].

How can I use $value$plusargs?

2

1 Answer

You cannot assign a run-time variable to a parameter. Parameters can only be assigned during compile (default values) and elaboration (override values). $value$plusargs is executed at run-time, it also cannot assign a parameter.

You haven't demonstrated where you need to use rclk other than the period value of i_rclk. You could modify your code to the following to get a the intended effect.

real READ_FREQ;

initial begin
  if (!$value$plusargs("READ_FREQ=%0F", READ_FREQ)) begin
    READ_FREQ = 197;
  end
  forever #(READ_FREQ/2.0) i_rclk = ~i_rclk;
end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.