5

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
  • 3
    The $value$plusarg is not the cause of your error. Parameters can only take constant expressions, i.e. operation on constant values or other parameters. You passed a real READ_FREQ which is a variable and causes this error. However, you can check project-veripage.com/plusarg.php for $value$plusarg usage Commented Apr 3, 2017 at 12:02
  • Your simulator should support $value$plusargs; it was added in IEEE1364-2001 so all simulators from 2005 and onward should support it. Check the lines above. real READ_FREQ is missing a ; Commented Apr 3, 2017 at 17:22

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.