pragma HLS array_map

Description

Combines multiple smaller arrays into a single large array to help reduce block RAM resources.

Designers typically use thepragma HLS array_mapcommand (with the sameinstance=target) to combine multiple smaller arrays into a single larger array. This larger array can then be targeted to a single larger memory (RAM or FIFO) resource.

Each array is mapped into a block RAM or UltraRAM, when supported by the device. The basic block RAM unit provided in an FPGA is 18K. If many small arrays do not use the full 18K, a better use of the block RAM resources is to map many small arrays into a single larger array.

Tip:If a block RAM is larger than 18K, they are automatically mapped into multiple 18K units.
The ARRAY_MAP pragma supports two ways of mapping small arrays into a larger one:
  • Horizontal mapping: this corresponds to creating a new array by concatenating the original arrays. Physically, this gets implemented as a single array with more elements.
  • Vertical mapping: this corresponds to creating a new array by concatenating the original words in the array. Physically, this gets implemented as a single array with a larger bit-width.

The arrays are concatenated in the order that the pragmas are specified, starting at:

  • Target element zero for horizontal mapping, or
  • Bit zero for vertical mapping.

Syntax

Place the pragma in the C source within the boundaries of the function where the array variable is defined.

#pragma HLS array_map variable=instance=\offset=

Where:

  • variable=: A required argument that specifies the array variable to be mapped into the new target array.
  • instance=: Specifies the name of the new array to merge arrays into.
  • : Optionally specifies the array map as being eitherhorizontalorvertical.
    • Horizontal mapping is the default, and concatenates the arrays to form a new array with more elements.
    • Vertical mapping concatenates the array to form a new array with longer words.
  • offset=: Applies to horizontal type array mapping only. The offset specifies an integer value offset to apply before mapping the array into the new array. For example:
    • Element 0 of the array variable maps to elementof the new target.
    • Other elements map to,... of the new target.
    Important:If an offset is not specified, Vivado HLS calculates the required offset automatically to avoid overlapping array elements.

Example 1

Arraysarray1andarray2in functionfooare mapped into a single array, specified asarray3in the following example:

void foo (...) { int8 array1[M]; int12 array2[N]; #pragma HLS ARRAY_MAP variable=array1 instance=array3 horizontal #pragma HLS ARRAY_MAP variable=array2 instance=array3 horizontal ... loop_1: for(i=0;i

Example 2

This example provides a horizontal mapping of array A[10] and array B[15] in function foointo a single new array AB[25].
  • Element AB[0] will be the same as A[0].
  • Element AB[10] will be the same as B[0] because nooffset=option is specified.
  • The bit-width of array AB[25] will be the maximum bit-width of either A[10] or B[15].
#pragma HLS array_map variable=A instance=AB horizontal #pragma HLS array_map variable=B instance=AB horizontal

Example 3

The following example performs a vertical concatenation of arrays C and D into a new array CD, with the bit-width of C and D combined. The number of elements in CD is the maximum of the original arrays, C or D:

#pragma HLS array_map variable=C instance=CD vertical #pragma HLS array_map variable=D instance=CD vertical

See Also