Array LiteralsΒΆ

A constant array is created using the concatenate operators, which consist of balanced braces surrounding a sequence of arguments given as expressions. It simply combines its arguments into an array. The individual arguments may be scalars or arrays, and the end result is a arrays whose length equals the sum of the lengths of each argument.

There are two forms, packed and unpacked arrays.

{4, 8, 12, 16, 20} {1*4, 2*4, 3*4, 4*4, 5*4} {4.0, 8.0, {12.0, 16.0, 20.0}}

In addition, the replicate operator can be used to specify a sequence of repeated values. The replication operator is similar to the concatenation operator, except the leading brace is preceded with an integer count and then the whole construct is surrounded with another set of braces. So {0, {2{1, 2}}} is equivalent to {0, 1, 2, 1, 2}.

Arrays come in many forms. The examples above are numeric arrays, which can consist of either integers or real numbers. One can also have arrays of bits, registers, nets, branches, instances and strings.