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

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

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

If a struct contains arrays, those arrays can be optimized using the xcl_array_partition attribute to partition the array. The xcl_data_pack attribute performs a similar operation as the complete partitioning of the xcl_array_partition attribute, reshaping the elements in the struct to a single wide vector.

A struct cannot be optimized with xcl_data_pack and also partitioned. The xcl_data_pack and xcl_array_partition attributes are mutually exclusive.

You should exercise some caution when using the xcl_data_pack optimization 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.


Place within the region where the struct variable is defined:

__attribute__((xcl_data_pack(<variable>, <name>)))


  • <variable>: is the variable to be packed.
  • <name>: Specifies the name of resultant variable after packing. If no <name> is specified, the input <variable> is used.

Example 1

Packs struct array AB[17] with three 8-bit field fields (typedef struct {unsigned char R, G, B;} pixel) in function foo, 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