Home Open Vera Tutorial Arrays
Main Menu
System Verilog
Open Vera
    - Tutorial
        -- Hello World
        -- Data Types
        -- Operators
        -- Control Structures
        -- Task and Functions
        -- Arrays
        -- Associative Arrays
        -- Associative Arrays
        -- Strings
        -- Files
        -- Interfaces
        -- Virtual ports and binds
        -- Concurrency
        -- Mailboxes
        -- Regions
        -- Events
        -- Semaphores
    - Examples
    - Tools
    - Links
    - Books
    - Interview Questions
Digital Concepts
Verification Basics
Interview Questions
Computer Architechture
C and C++
AsicGuru Blog
Tags Cloud
Usefull Sites
Know Your IP/Location
Local Information India
Buy Car/Inverter Batteries
Real Estate India
Sports Accessories India
Arrays in Open Vera
Share This Articale:

Arrays in vera :

1. Fixed size arrays
2. Associative arrays
3. Dynamic arrays

Fixed size arrays :

Fixed size arrays are fast and memory efficient. In the fixed size arrays the data access time is constant irrespective of
number of elements in the array in location. Size is fixed at the time of compilation.
The fixed size arrays can have one or more dimentions

Example :
integer arr [5]; // fixed size single dimention array
integer array[5] = {0, 1, 2, 3, 4}; // single dimention arrays with initialization

Note :
- size should be specified
- indivisual bits of the arrays element can not be used directly. They need to be assigned to temporary variables

integer matrix [2][5]; // multi dimention array decleration
integer x[2][2]={{0,1},{2,3}}; // with initialization

Associative Arrays :

Associative arrays are mainly used to model the sparse memories. Associtive arrays can have only one dimention.
For associative arrays size need need not to be specified in decleratoin.

integer assoc_matrix[];

A index in the associative arrays is created only when it is assigned some value.

assoc_index () function is used to manipulate associative arrays.

Dynamic Arrays :

In the dynamic arrays the size can be defined at the run time. It is fast as fixed size arrays. Like associative arrays
dynamic arrays also does not support multiple dimentions.

integer darray [*]; // Dynamic array of integers

To change or set the size of the dynamic array at the run time new [] operator is used. To get the current size of the arrays
the function size () can be used.

new[] operator :

// Declare 2 arrays.
integer packetA[*], packetB[*];
packetA = new[100]; // Create and load packetA.

// Create packetB as a copy of packetA.
packetB = new[100] (packetA);

size() function :
The size() function returns the current size of a dynamic array.

arrsize = packetA.size();

delete () task :
Delete task deletes the elements of the arrays and makes its size as 0. Pointer or handle to the arrays still exists.


This Articles is written/submitted by puneet (Puneet Aggarwal). You can also contribute to Asicguru.com. Click here to start

Prev << Task and Functions

Next >> Associative Arrays

Sign In
Login with :-
| | |  
  • Bookmark