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?
-
\$\begingroup\$ Verilog for hardware implementation always ends up as fixed sized everything. You can't do dynamic memory allocation in verilog, anyway. \$\endgroup\$pjc50– pjc502015年12月31日 11:10:19 +00:00Commented Dec 31, 2015 at 11:10
1 Answer 1
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.