Reading 2D array

Discussion in 'VHDL' started by ALuPin@web.de, Nov 13, 2007.

  1. 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
     
    , Nov 13, 2007
    #1
    1. Advertising

  2. KJ Guest

    On Nov 13, 11:21 am, "" <> 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
     
    KJ, Nov 13, 2007
    #2
    1. Advertising

  3. KJ Guest

    On Nov 13, 11:21 am, "" <> 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
     
    KJ, Nov 13, 2007
    #3
  4. Andy Guest

    On Nov 13, 11:29 am, KJ <> wrote:
    > On Nov 13, 11:21 am, "" <> 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
     
    Andy, Nov 13, 2007
    #4
  5. KJ Guest

    On Nov 13, 2:02 pm, Andy <> 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
     
    KJ, Nov 13, 2007
    #5
  6. Guest

    Hi KJ and Andy,
    thank you for your clear answers.

    Best regards
    Andre
     
    , Nov 14, 2007
    #6
  7. Guest

    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
     
    , Dec 16, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denis Palas
    Replies:
    2
    Views:
    694
    Daniel Pitts
    Dec 19, 2006
  2. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    506
    David RF
    Sep 3, 2009
  3. Yvon Thoraval
    Replies:
    5
    Views:
    218
    Jason Creighton
    Sep 17, 2003
  4. Tom
    Replies:
    3
    Views:
    221
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    497
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page