Reading 2D array

A

ALuPin@web.de

Guest
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
 
On Nov 13, 11:21 am, "ALu...@web.de" <ALu...@web.de> wrote:
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
 
On Nov 13, 11:21 am, "ALu...@web.de" <ALu...@web.de> wrote:
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
 
On Nov 13, 11:29 am, KJ <Kevin.Jenni...@Unisys.com> wrote:
On Nov 13, 11:21 am, "ALu...@web.de" <ALu...@web.de> wrote:> 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
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
 
On Nov 13, 2:02 pm, Andy <jonesa...@comcast.net> wrote:
<snip>
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
 
Hi KJ and Andy,
thank you for your clear answers.

Best regards
Andre
 
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
 

Welcome to EDABoard.com

Sponsor

Back
Top