0% found this document useful (0 votes)
4 views5 pages

VLSI

The document discusses fixed size arrays, including single-dimensional, two-dimensional, and three-dimensional arrays, with examples of their declarations and initializations. It explains how to assign values to arrays and provides a module example demonstrating array manipulation using loops. The arrays are initialized to zero by default and can be displayed using specific display functions.

Uploaded by

Abhi Abhiss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

VLSI

The document discusses fixed size arrays, including single-dimensional, two-dimensional, and three-dimensional arrays, with examples of their declarations and initializations. It explains how to assign values to arrays and provides a module example demonstrating array manipulation using loops. The arrays are initialized to zero by default and can be displayed using specific display functions.

Uploaded by

Abhi Abhiss
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Fixed size array

In fixed size array, array size will be constant throughout the simulation, Once the
array is declared no need to create it. By default, the array will be initialized with
value ‘o’.

Single dimensional array


Int array1 [6]; //Compact declaration
Declaration
Int array2 [5:0]; // Verbose declaration
Declaration

Multidimensional array
Multidimensional arrays are also known as an array of arrays
int arr[2][3];
This array has total 2*3 = 6 elements.

Two-Dimensional Array
Int arr[2][3];
This array has total 2*3 = 6 elements.

Three-Dimensional Array
int arr[2][2][2];
This array has total 2*2*2 = 8 elements.
Two-Dimensional array declaration
int array3 [2:0][3:0];
The data in a two-dimensional array is stored in a tabular form as shown
in the below diagram.

Array assignment
array1 = ‘(0,1,2,3,4,5};
array2 ‘(0,1,2,3,4,5};
array3 = ‘{ ‘{0,1,2,3}, ‘{4,5,6,7}, ‘{8,9,10,11}}
;
Fixed Size Array Example
This example shows array declaration and array manipulation using for
and foreach loop.
Module fixedsize_array; //declaration of array’s
int array1[6]; //single dimension array
int array2[5:0]; //single dimension array
int array3[2:0][3:0]; //multi dimension array
int array4[4:0]; initial begin //array initialization
array1 = ‘{0,1,2,3,4,5};
array2 = ‘(0,1,2,3,4,5};
array3 = ‘{‘(0,1,2,3}, ‘(4,5,6,7}, ‘(8,9,10,11 }}; //displaying array elements
$display(“-------displaying array1-------“);
foreach(array1[i])
$display(“\t array1[%0d] = %0d”,I,array1[i]);
$display(“-- --displaying array2-------“);
for(int i=0;i<6;i++)
$display(“\t array2[%0d] = %0d”,I,array2[i]);
$display(“-- --displaying $display(“ array3-------“);
foreach(array3[I,j])
$display(“\t array3[%0d][%0d] = %0d”,I,j,array3[i][j]); -displaying uninitialized
array4-------“);
for(int i=0;i<5;i++)
$display(“\t array4[%0d] = %0d”,I,array4[i]);
end endmodule

You might also like