syn.directive.array_reshape - 2023.1 English

Vitis Unified IDE and Common Command-Line Reference Manual (UG1553)

Document ID
UG1553
Release Date
2023-07-17
Version
2023.1 English

Description

Important: syn.directive.array_partition and syn.directive.array_reshape are not supported for M_AXI Interfaces on the top-level function. Instead you can use the hls::vector data types as described in Vector Data Types.

syn.directive.array_reshape combines array partitioning with vertical array mapping to create a single new array with fewer elements but wider words.

The syn.directive.array_reshape command has the following features:

  • Splits the array into multiple arrays (like syn.directive.array_partition).
  • Automatically recombine the arrays vertically to create a new array with wider words.

Syntax

syn.directive.array_reshape=[OPTIONS] <location> <array>
  • <location> is the location (in the format function[/label]) that contains the array variable.
  • <array> is the array variable to be reshaped.

Options

dim=<integer>
Specifies which dimension of the array is to be partitioned.
  • The dimension is relevant for multidimensional arrays only.
  • If a value of 0 is used, all dimensions are partitioned with the specified options.
  • Any other value partitions only that dimension. For example, if a value 1 is used, only the first dimension is partitioned.
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 with word-width*N. The default is complete.
  • 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 with N*M bits). This is the default.
factor=<integer>
Used for block or cyclic partitioning only, this option specifies the number of smaller arrays that are to be created.
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.

Example 1

Reshapes 8-bit array AB[17] in function func into a new 32-bit array with five elements.

Because four is not an integer factor of 17:

  • Index 17 of the array, AB[17], is in the lower eight bits of the reshaped fifth element.
  • The upper eight bits of the fifth element are unused.
syn.directive.array_reshape=type=block factor=4 func AB

Partitions array AB[6][4] in function func, into a new array of dimension [6][2], in which dimension 2 is twice the width.

syn.directive.array_reshape=type=block factor=2 dim=2 func AB

Reshapes 8-bit array AB[4][2][2] in function func into a new single element array (a register), 4*2*2*8 (= 128)-bits wide.

syn.directive.array_reshape=type=complete dim=0 func AB

Example 2

Reshaped arrays can be addressed in your code by the new structure of the array, as shown in the following code example. When using the following directive:
syn.directive.array_reshape=top b type=complete dim=0

The code can be structured as follows:

struct SS
{
  int x[N];
  int y[N];
};
  
int top(SS *a, int b[4][6], SS &c) {...}

And the array interface defined as:
syn.directive.interface=mode=ap_memory top b[0]