Can I Pass a 2D Array as a Parameter to a Procedure?

C

Chris

Hi All

I have an array of seven 32-bit std_logic registers, and I am trying to use
this array as an OUT parameter in a procedure. When I do so, Modelsim gives
me a "No feasible entries for subprogram" error.

Is it possible to pass a 2-dimensional array to a procedure, and if so, how?

Thanks,
Chris
 
C

Chris

I worded the above poorly. VHDL has no 2D arrays - I should have said an
array of arrays.
 
J

Jonathan Bromley

I worded the above poorly. VHDL has no 2D arrays - I should have said an
array of arrays.

VHDL *does* have true N-dimensional arrays, but in practice
they are less useful than you might hope.

I don't really see why this should be a problem...

subtype SLV32 is std_logic_vector(31 downto 0);
type A_SLV32 is array(natural range <>) of SLV32;
--- you need these types to be in a package so that
--- they can be imported anywhere with "use"
....
procedure twiddle(
A: in A_SLV32;
Y: out A_SLV32
) is
begin
-- confirm arrays are the same shape
assert (A'left = Y'left) and (A'right = Y'right);
for i in A'range loop
Y(i) := some_function_of(A(i));
end loop;
end;

....

variable P, Q: A_SLV32(1 to 4);
....
twiddle(P, Q);

--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
(e-mail address removed)
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
C

Chris

Hi Jonathan

Sorry for the late reply - I got shifted onto another ultra-urgent (aren't
they always) task and haven't had time to look at this till now. What you're
advising looks like what I'm doing already, but I'll take a look and see if
I can spot what I'm doing wrong.

Thanks,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top