1
\$\begingroup\$

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?

asked Dec 31, 2015 at 11:04
\$\endgroup\$
1
  • \$\begingroup\$ Verilog for hardware implementation always ends up as fixed sized everything. You can't do dynamic memory allocation in verilog, anyway. \$\endgroup\$ Commented Dec 31, 2015 at 11:10

1 Answer 1

1
\$\begingroup\$

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.

answered Dec 31, 2015 at 11:20
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.