Description
The syn.directive.disaggregate
command 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.
Syntax
syn.directive.disaggregate=<location> <variable>
- <
location
> is the location (in the formatfunction[/label]
) where the variable to disaggregate is found. - <
variable
> specifies the struct variable name.
Options
This command has no options.
Example 1
The following example shows disaggregates the struct variable a
in function top
:
syn.directive.disaggregate=top a
Example 2
Disaggregated structs can be addressed in your code by the using standard
C/C++ coding style as shown below. When using the directives:
syn.directive.disaggregate=top a
syn.directive.disaggregate=top c
The code can be structured as follows.
struct SS
{
int x[N];
int y[N];
};
int top(SS *a, int b[4][6], SS &c) {
syn.directive.interface=mode=s_axilite top a->x
syn.directive.interface=mode=s_axilite top a->y
syn.directive.interface=mode=ap_memory top c.x
syn.directive.interface=mode=ap_memory top c.y
Important: Notice the different methods shown above
for accessing an element of a pointer (a) versus an element of a reference (c)
Example 3
The following example shows the Dot
struct
containing the RGB
struct as an element. If you
apply syn.directive.disaggregate
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]) {
...
}
syn.directive.disaggregate=DUT Arr
If you want to disaggregate the whole struct, Dot
and RGB
, then
you can assign the set_directive_disaggregate
as shown below.
void DUT(Dot Arr[N]) {
#pragma HLS disaggregate variable=Arr->RGB
...
}
syn.directive.disaggregate=DUT 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]) {
...
}