xcl_data_pack

Description

Packs the data fields of a struct into a single scalar with a wider word width.

Thexcl_data_packattribute is used for packing all the elements of astructinto a single wide vector to reduce the memory required for the variable. This allows all members of thestructto be read and written to simultaneously. The bit alignment of the resulting new wide-word can be inferred from the declaration order of thestructfields. The first field takes the LSB of the vector, and the final element of thestructis aligned with the MSB of the vector.

Tip:Any arrays declared inside the structare completely partitioned and reshaped into a wide scalar and packed with other scalar fields.

If astructcontains arrays, those arrays can be optimized using thexcl_array_partitionattribute to partition the array. Thexcl_data_packattribute performs a similar operation as the complete partitioning of thexcl_array_partitionattribute, reshaping the elements in thestructto a single wide vector.

Astructcannot be optimized withxcl_data_packand also partitioned. Thexcl_data_packandxcl_array_partitionattributes are mutually exclusive.

You should exercise some caution when using thexcl_data_packoptimization on structs with large arrays. If an array has 4096 elements of type int, this will result in a vector (and port) of width 4096*32=131072 bits. SDx can create this RTL design, however it is very unlikely logic synthesis will be able to route this during the FPGA implementation.

Syntax

Place within the region where thestructvariable is defined:

__attribute__((xcl_data_pack(,)))

Where:

  • : is the variable to be packed.
  • : Specifies the name of resultant variable after packing. If nois specified, the inputis used.

Example 1

Packs struct array AB[17] with three 8-bit field fields (typedef struct {unsigned char R, G, B;} pixel) in functionfoo, into a new 17 element array of 24 bits.

typedef struct{ unsigned char R, G, B; } pixel; pixel AB[17] __attribute__((xcl_data_pack(AB)));

See Also