( ESNUG 344 Item 1 ) --------------------------------------------- [2/23/00]

Subject: ( ESNUG 343 #11 )  Vera Really Needs Multi-Dimensional Arrays

> I'm a happy Vera user but I have 3 big complaints: ... The Vera language
> doesn't support multi-dimensional arrays.  This has huge implications on
> how one can code a testbench.
>
>     - [ Not Another Elf ]


From: Tom Symons <tsymons@level1.com>

Hi, John,

True multi-dimensional arrays in Vera would be nice, but you can get the
same result pretty easily by using an array of objects, as in:

    class second_dimension {
       bit [31:0] two[];
    }

    second_dimension one[size];

    // initialize the objects
    for (i=0; i<size; i++)
      one[i] = new;

    // ready to roll
    one[j].two[k] = value;

Note the use of the associative array in the second_dimension object.  That
way you can reuse the same object for multiple 2-D arrays of different
sizes.  Also note that you can extend the same concept for arrays of any
dimension.

Not quite as tidy as a built-in 2-D array, but hardly a huge problem to
work with.  Besides, when you are using a 2-D array, its very common
that you want more than one field associated with each element anyway,
which would have to be coded as above.

    - Tom Symons
      Level One Communications                    Sacramento, CA



 Sign up for the DeepChip newsletter.
Email
 Read what EDA tool users really think.


Feedback About Wiretaps ESNUGs SIGN UP! Downloads Trip Reports Advertise

"Relax. This is a discussion. Anything said here is just one engineer's opinion. Email in your dissenting letter and it'll be published, too."
This Web Site Is Modified Every 2-3 Days
Copyright 1991-2024 John Cooley.  All Rights Reserved.
| Contact John Cooley | Webmaster | Legal | Feedback Form |

   !!!     "It's not a BUG,
  /o o\  /  it's a FEATURE!"
 (  >  )
  \ - / 
  _] [_     (jcooley 1991)