1

How can I call a function inside a module in verilog, with the function having parameters, and define the parameters to it?

For a trivial instance:

function automatic void inv();
  parameter W = 1;
  input logic [W:0] in;
  output logic [W:0] out;

  out = ~in;

endfunction

How would I call this and define W in the call?

2
  • 2
    In what context is the function called? We need a more complete example. Commented Aug 30, 2012 at 3:52
  • 2
    possible duplicate of Width independent functions (Solution Found) Commented Apr 14, 2014 at 21:28

2 Answers 2

1

You cannot override a parameter value when calling a function. There is no syntax for this specified in the IEEE Std (1800-2009).

Sign up to request clarification or add additional context in comments.

Comments

1

As stated parameters are constant and cannot be changed after design elaboration. The dimensions are part of the data type so they also must be constant during design elaboration. If all your function calls are outside procedural contexts you might be able to get away with passing in a constant as an argument. I don't recommend doing this.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.