pragma HLS disaggregate - 2023.2 English

Vitis High-Level Synthesis User Guide (UG1399)

Document ID
Release Date
2023.2 English


The DISAGGREGATE pragma lets you deconstruct a struct variable into its individual elements. The number and type of elements created are determined by the contents of the struct itself.

Important: Structs used as arguments to the top-level function are aggregated by default, but can be disaggregated with this directive or pragma. Refer to AXI4-Stream Interfaces for important information about disaggregating structs associated with streams.


Place the pragma in the C source within the boundaries of the region, function, or loop.

#pragma HLS disaggregate variable=<variable>



  • variable=<variable>: Specifies the struct variable to disaggregate.

Example 1

The following example shows the struct variable a in function top will be disaggregated:

#pragma HLS disaggregate variable=a

Example 2

Disaggregated structs can be addressed in your code by the using standard C/C++ coding style as shown below. Notice the different methods for accessing the pointer element (a) versus the reference element (c);

struct SS
  int x[N];
  int y[N];
int top(SS *a, int b[4][6], SS &c) {
#pragma HLS disaggregate variable = a
#pragma HLS interface s_axilite port = a->x
#pragma HLS interface s_axilite port = a->y
// Following is now supported
#pragma HLS disaggregate variable = c
#pragma HLS interface ap_memory port = c.x
#pragma HLS interface ap_memory port = c.y

Example 3

The following example shows the Dot struct containing the RGB struct as an element. If you apply the DISAGGREGATE pragma to variable Arr, then only the top-level Dot struct is disaggregated.

struct Pixel { 
char R; 
char G; 
char B; 

struct Dot { 
Pixel RGB; 
unsigned Size; 

#define N 1086 
void DUT(Dot Arr[N]) {
#pragma HLS disaggregate variable=Arr

If you want to disaggregate the whole struct, Dot and RGB, then you can assign the DISAGGREGATE pragma as shown below.

void DUT(Dot Arr[N]) { 
#pragma HLS disaggregate variable=Arr->RGB 
The results in this case will be:
void DUT(char Arr_RGB_R[N], char Arr_RGB_G[N], char Arr_RGB_B[N], unsigned Arr_Size[N]) { 
#pragma HLS disaggregate variable=Arr->RGB