Verilog-A: pass an array without predefined size as input to a function

verilog

It seems fairly easy to pass to a function array if its size is already known:

analog function integer ArrayIsZeros;
input [7:0] array;
integer array [7:0] ;

But then the function becomes specific for arrays with 8. Is there any way to make it more universal, for any array with size not predefined?

Best Answer

You can do parameterised functions:

localparam WIDTH = 8; //Or module parameter
function integer ArrayIsZeros;
input [WIDTH-1:0] array;
integer array [WIDTH-1:0];
begin
...
end
endfunction

But this is only useful if you are using the function for one data width in the module. Basically you can use the module parameters to parameterise the width of the function, but you couldn't use the same function with two different widths in the same module.