set_directive_array_reshape - 2022.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
UG1399
Release Date
2022-12-07
Version
2022.2 English

Description

Important: Array_Partition and Array_Reshape pragmas and directives 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.

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 format function[/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. The default is 1.
-factor <integer>
Note: Relevant for type block or cyclic reshaping only.
Specifies the number of temporary smaller arrays 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.
-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.

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.
set_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.

set_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.

set_directive_array_reshape -type complete -dim 0 func AB

Example 2

Partitioned arrays can be addressed in your code by the new structure of the array, as shown in the following code example;

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

set_directive_array_reshape top b -type complete -dim 0
set_directive_interface -mode ap_memory top b[0]