xcl_data_pack
Description
Packs the data fields of a struct into a single scalar with a wider word width.
Thexcl_data_pack
attribute is used for packing all the elements of astruct
into a single wide vector to reduce the memory required for the variable. This allows all members of thestruct
to be read and written to simultaneously. The bit alignment of the resulting new wide-word can be inferred from the declaration order of thestruct
fields. The first field takes the LSB of the vector, and the final element of thestruct
is aligned with the MSB of the vector.
struct
are completely partitioned and reshaped into a wide scalar and packed with other scalar fields.
If astruct
contains arrays, those arrays can be optimized using thexcl_array_partition
attribute to partition the array. Thexcl_data_pack
attribute performs a similar operation as the complete partitioning of thexcl_array_partition
attribute, reshaping the elements in thestruct
to a single wide vector.
Astruct
cannot be optimized withxcl_data_pack
and also partitioned. Thexcl_data_pack
andxcl_array_partition
attributes are mutually exclusive.
You should exercise some caution when using thexcl_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.
Syntax
Place within the region where thestruct
variable is defined:
__attribute__((xcl_data_pack(
Where:
: is the variable to be packed. : Specifies the name of resultant variable after packing. If no is specified, the input is 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
- pragma HLS data_pack
- SDAccel Environment Optimization Guide(UG1207)