( 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
|
|