FPGA Center



ARRAY

Array is a series of sub-elements which are all the same type. Each element has an index number in an array within a certain range. A one-dimensional array has one index and  a multi-dimensional array has an index number which is equal to the size of the array.

type type_name is array (range) of element_name
type type_name is array (type range <>) of element_name

DETAILED EXPLANATION

Arrays can be constraint or unconstraint with respect to their range. The number of elements in unconstraint arrays is uncertain. Fort his type of arrays, the size of the object is defined in the declaration part of that object. (Example 2)

In the STANDARD Package,there are two types of pre-defined arrays called string and bit_vector.

Sub-elements of the strings are characters. Their index numbers are expressed as positive numbers. (1,2,3ÔÇŽetc.)

Bit_vectors are consist of elements of type bit. Their indexes are the natural numbers. (0,1,2...etc.)

It is possible to assign a value to each elements independently. Fort his, there are some methods used like concetanation, aggregate  or slice

NOTE:

EXAMPLE 1

type Real_Matrix is array (1 to 10) of REAL;   -- an array which has 10 elements of real type
type BYTE is array (0 to 7) of BIT;                   -- an array which has 8 elements of bit type

--A 8x2 dimensional array (DATA_BUS) which has elements of  bit type:

type X is (LOW, HIGH); --X is defined as enumaration type
type DATA_BUS is array (0 to 7, X) of BIT;

EXAMPLE 2

-- An unconstraint array called Real_Matrix:

type Real_Matrix is array (POSITIVE range <>) of Real;
variable Real_Matrix_Object : Real_Matrix (1 to 8); --The size of the object is constraint to 8 now.

--An unconstraint array which consists of elements of thype Log_4:

type Log_4_Vector is array (NATURAL range <>, POSITIVE range<>) of Log_4;
variable L4_Object : Log_4_Vector (0 to 7, 1 to 2);

As you can see from the example, although the Real_Matrix array is not constraint first,  it is used by limiting the size of the Real_Matrix_Object to 8. Likewise, the array of Log_4_Vector which  is not constraint is used as limited with a name of  L4_Object.

                                                                                                           

    

                                                                                                                                    

 

                                                                                                                                                                                                                                                                   

Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.