Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Arrays and Queues

Presented by : Dileep C P,
Nishant S,
Sharmila E K
Content
 Fixed size arrays
 Packed and Unpacked arrays
 Dynamic arrays
 Associative arrays
 Queues
Packed and Un-packed Arrays
 Packed array - the dimensions declared before the data identifier name.
 Unpacked array - the dimensions declared after the data identifier name.
 Packed arrays can be of single bit data types (reg, logic, bit), enumerated types, and
recursively packed arrays and packed structures.
 One dimensional packed array is referred to as a vector
• Vector: A vector is a multi-bit data object of reg/logic/bit declared by specifying a range
• Scalar: Scalar is 1-bit data object of reg/logic/bit declared without specifying a range
Packed arrays
 A mechanism for subdividing a vector into sub-fields, which can be conveniently
accessed as array elements.
 A packed array is guaranteed to be represented as a contiguous set of bits.
Un-packed arrays
 Unpacked arrays can be of any data type.
 Unpacked arrays shall be declared by specifying the element ranges after the identifier
name.
 An unpacked array may or may not be so represented as a contiguous set of bits.
Multi dimensional array
• Multi dimensional array is still a set of contagious bits but are also segmented into
smaller groups.
Dynamic arrays
 A dynamic array is one dimension of an unpacked array whose size can be set or
changed at run-time. Dynamic array is Declared using an empty word subscript [ ].
 The space for a dynamic array doesn’t exist until the array is explicitly created at run-
time, space is allocated when new[number] is called.
 The number indicates the number of space/elements to be allocated.
 Dynamic array methods

new[ ]    –> allocates the storage.


size( )    –> returns the current size of a dynamic array.
delete( ) –> empties the array, resulting in a zero-sized
array.
Cont.
Associative arrays
 Associative array Stores entries in a sparse matrix.
 Associative arrays allocate the storage only when it is used, unless like in the dynamic
array we need to allocate memory before using it.
 In associative array index expression is not restricted to integral expressions but can be of
any type.
 An associative array implements a lookup table of the elements of its declared type. The
data type to be used as an index serves as the lookup key and imposes an ordering.
Cont.
Example
Queues
 Syntax
<type_name> <variable_name> [$]
 Flexible memory
 Bounded Queue
<type_name> <variable_name> [$:<max_length>]

 Queue Declaration
 Queue Initialization
Built-In Methods
 Push and Pop

3
Thank you

You might also like