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?

toolic
  • 57,801
  • 17
  • 75
  • 117
A J
  • 19
  • 1
  • 1
  • 2
  • 2
    In what context is the function called? We need a more complete example. –  Aug 30 '12 at 03:52
  • 2
    possible duplicate of [Width independent functions](http://stackoverflow.com/questions/22696838/width-independent-functions) (Solution Found) – Greg Apr 14 '14 at 21:28

2 Answers2

1

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

toolic
  • 57,801
  • 17
  • 75
  • 117
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.