Reading 2D array

A

ALuPin

Hi,

I am trying to read a two-dimensional array which looks like the
following:



SUBTYPE std_logic_cluster16 IS std_logic_vector(15 DOWNTO 0);
TYPE std_logic_cluster5 IS ARRAY(4 DOWNTO 0) OF std_logic_cluster16;


SIGNAL test_array : std_logic_cluster5;

SIGNAL test : std_logic;


BEGIN

test <= test_array(2,2);

When trying to synthesize my design I get the following error
messages:

Precision Synthesis:
"Index name prefix does not denote a 2-dimensional array"

Synplify Synthesis:
"Indexing operation does not match dimensionality of array"

Does synthesis not support 2D-arrays ?

Rgds
Andre
 
K

KJ

Hi,

I am trying to read a two-dimensional array which looks like the
following:

SUBTYPE std_logic_cluster16 IS std_logic_vector(15 DOWNTO 0);
TYPE std_logic_cluster5 IS ARRAY(4 DOWNTO 0) OF std_logic_cluster16;

Just a comment, a vector of vectors is not the same thing as a 2d
array.
SIGNAL test_array : std_logic_cluster5;

SIGNAL test : std_logic;

BEGIN

test <= test_array(2,2);
Correct syntax for the data types that you defined would be...
test <= test_array(2)(2);

If you really want a 2d array, you would do the following...
type sulv2d is array(natural range<>, natural range<>) of
std_ulogic;
signal test_array : sulv2d(4 downto 0, 15 downto 0);
...
test <= test_array(2,2);
Does synthesis not support 2D-arrays ?
Yes (but it might depend on which synthesis tool), but you must also
use the correct syntax.

KJ
 
K

KJ

Hi,

I am trying to read a two-dimensional array which looks like the
following:

SUBTYPE std_logic_cluster16 IS std_logic_vector(15 DOWNTO 0);
TYPE std_logic_cluster5 IS ARRAY(4 DOWNTO 0) OF std_logic_cluster16;
Just a comment, a vector of vectors is not the same thing as a 2d
array.
SIGNAL test_array : std_logic_cluster5;

SIGNAL test : std_logic;

BEGIN

test <= test_array(2,2);

Correct syntax for the types as you defined them would be
test <= test_array(2)(2);

If you really want a true 2d array, you would do the following:
type slv2d is array(natural range<>, natural range<>) of std_logic;
signal test_array: slv2d(4 downto 0, 15 downto 0);
...
test <= test_array(2,2);

That's why knowing that a vector of vectors is not the same as a 2d
array is important.

KJ
 
A

Andy

Just a comment, a vector of vectors is not the same thing as a 2d
array.



Correct syntax for the types as you defined them would be
test <= test_array(2)(2);

If you really want a true 2d array, you would do the following:
type slv2d is array(natural range<>, natural range<>) of std_logic;
signal test_array: slv2d(4 downto 0, 15 downto 0);
...
test <= test_array(2,2);

That's why knowing that a vector of vectors is not the same as a 2d
array is important.

KJ

Other differences include how you can access parts of the structure.

With a two dimensional array, you can only access the entire array, or
a single element of it.

With an array of arrays, you can access:
test_array(3 downto 2)
test_array(1)(5 downto 3)
test_array(0)(0)

but not:
test_array(test_array'range)(5 downto 3)
test_array(3 downto 2)(5 downto 3)
test_array(3 downto 2)(0)

For these reasons, and because some synthesis tools may not support
two dimensional arrays, I almost always use arrays of arrays.

Andy
 
K

KJ

For these reasons, and because some synthesis tools may not support
two dimensional arrays, I almost always use arrays of arrays.
Interestingly enough, one case where I used a true 2d array was one
where I really wanted an array of arrays but both dimensions had to be
parameterizable so I couldn't have that intermediate subtype of since
the range was not a constant. By providing the appropriate to/from
functions I could then convert the 2d array to/from the array of
arrays.

Generally though, arrays of arrays are more useful than 2d arrays for
all the reasons you mentioned.

KJ
 
D

dimhatzo

Hi.How can I have the same 2d array we are talking about in my ENTITY
PORT(not as a signal in my architecture)?

Thanks in advance

Antony
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top