System Verilog data types

What is an associative array?

An associative array is another type of array that is used to store elements in a sparse way. Let’s say you want to work with a multi-gigabyte memory that holds elements in large and distant locations i.e. 0, 3, 60, 900, 60000, 9000000 index.

At that time associative array is useful because it allocates memory for an index when you assign it so it is helpful in saving storage.

To declare an associative array:

int my_assoc_array[*]; //Here a associative array name “my_assoc_array” is defined which is “int” type

To assign value to an associative array

my_assoc_array[1]=3; //it shows, an associative array has value 3 at index 1.

What is a queue?

The queue is similar to the fixed-size array which is used for searching and sorting in a structure. They can quickly grow and shrink so it helps to user to add and remove elements.

To declare a queue:

int my_queue[$]; //Here a queue name “my_queue” is defined which is “int” type

To assign value to a queue

my_queue={3,6,9} //it shows, a queue has three values 3,6,9 respectively.

Note: There is no need to define the new[] operator for a queue because System Verilog assigns memory space for it when you create it.

So many data methods are available for adding and removing elements with queues. Users can transfer the data of a fixed or dynamic array into a queue.

Methods for Queue:

  1. insert(index, value) //It assigns a value at a specified index into the queue.
  2. push_front(value) //it assigns a value at the front into the queue.
  3. push_back(value) //it assigns a value at the back of the queue.
  4. pop_front() //it retrieves a value at the front of the queue.
  5. pop_back() //it retrieves a value at the back of the queue.
  6. delete(index) //it removes an element at a specified index into the queue.

Code:

What is string data type?

What are Enum data types?

What are structure data types?

    error: Content is protected !!
    Scroll to Top