Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

declare

declare( 
s_arrayName 
[ x_sizeOfArray ] 
) 
=> a_newArray

Description

Creates an array with a specified number of elements. This is a syntax form. All elements of the array are initialized to unbound.

Arguments

s_arrayName

Name of the array. There must be no white space between the name of an array and the opening bracket containing the size.

x_sizeOfArray

Size of the array as an integer.

Value Returned

a_newArray

Returns the new array.

Examples

When the name of an array appears on the right side of an assignment statement, only a pointer to the array is used in the assignment; the values stored in the array are not copied. It is therefore possible for an array to be accessible by different names. Indexes are used to specify elements of an array and always start with 0; that is, the first element of an array is element 0. SKILL checks for an out of bounds array index with each array access.

declare(a[10])
a[0] = 1
a[1] = 2.0
a[2] = a[0] + a[1]

Creates an array of 10 elements. a is the name of the array, with indexes ranging from 0 to 9. Assigns the integer 1 to element 0, the float 2.0 to element 1, and the float 3.0 to element 2.

b = a 

b now also refers to the same array as a.

declare(c[10]) 

Declares another array of 10 elements.

declare(d[2]) 

Declares d as array of 2 elements.

d[0] = b

d[0] now refers to the array pointed to by b and a.

d[1] = c

d[1] is the array referred to by c.

d[0][2] 

Accesses element 2 of the array referred to by d[0]. This is the same element as a[2].

Brackets ([]) are used in this instance to represent array references and are part of the statement syntax.

Related Topics

makeVector


Return to top
 ⠀
X