Description
Combines array partitioning with vertical array mapping to create a single new array with fewer elements but wider words.
The set_directive_array_reshape
command has the
following features:
- Splits the array into multiple arrays (like
set_directive_array_partition
). - Automatically recombine the arrays vertically to create a new array with wider words.
Syntax
set_directive_array_reshape [OPTIONS] <location> <array>
-
<location>
is the location (in the formatfunction[/label]
) that contains the array variable. -
<array>
is the array variable to be reshaped.
Options
-
-dim <integer>
-
Note: Relevant for multi-dimensional arrays only.Specifies which dimension of the array is to be reshaped.
- If the value is set to 0, all dimensions are partitioned with the specified options.
- Any other value partitions only that dimension. For example, if the value is set 1, only the first dimension is partitioned.
-
-factor <integer>
-
Note: Relevant for typeSpecifies the number of temporary smaller arrays to be created.
block
orcyclic
reshaping only. -
-object
-
Note: Relevant for container arrays only.Applies reshape on the objects within the container. If the option is specified, all dimensions of the objects will be reshaped, but all dimensions of the container will be kept.
-
-type (block|cyclic|complete)
-
-
block
reshaping creates smaller arrays from consecutive blocks of the original array. This effectively splits the array into N equal blocks where N is the integer defined by the-factor
option and then combines the N blocks into a single array withword-width*N
. The default iscomplete
. -
cyclic
reshaping creates smaller arrays by interleaving elements from the original array. For example, if-factor 3
is used, element 0 is assigned to the first new array, element 1 to the second new array, element 2 is assigned to the third new array, and then element 3 is assigned to the first new array again. The final array is a vertical concatenation (word concatenation, to create longer words) of the new arrays into a single array. -
complete
reshaping decomposes the array into temporary individual elements and then recombines them into an array with a wider word. For a one-dimension array this is equivalent to creating a very-wide register (if the original array was N elements of M bits, the result is a register withN*M
bits).
-
Examples
Reshapes 8-bit array AB[17] in function foo
into a new 32-bit array with five elements.
Because four is not an integer factor of 13:
- AB[17] is in the lower eight bits of the fifth element.
- The remainder of the fifth element is unused.
set_directive_array_reshape -type block -factor 4 foo AB
Partitions array AB[6][4] in function foo
, into a new array of dimension [6][2], in which dimension 2 is
twice the width.
set_directive_array_reshape -type block -factor 2 -dim 2 foo AB
Reshapes 8-bit array AB[4][2][2] in function foo
into a new single element array (a register), 4*2*2*8 (= 128)-bits
wide.
set_directive_array_reshape -type complete -dim 0 foo AB