syn.directive.disaggregate - 2025.2 简体中文 - UG1399

Vitis 高层次综合用户指南 (UG1399)

Document ID
UG1399
Release Date
2026-01-22
Version
2025.2 简体中文

描述

syn.directive.disaggregate 命令允许您按 struct 变量所含各独立元素来对其进行解构。struct 本身的内容用于判定元素的数量和类型。

重要: 默认情况下,作为顶层函数实参的结构体将聚合在一起,但可通过该指令或编译指示来对其进行解聚。

语法

syn.directive.disaggregate=<location> <variable>
  • <location> 对应可在其中找到要解聚的变量的位置(格式为 function[/label])。
  • <variable> 则用于指定结构体变量名称。

选项

此命令不含任何选项。

示例 1

以下示例显示的是如何对 top 函数中的结构体变量 a 进行解聚:

syn.directive.disaggregate=top a

示例 2

您可以使用标准的 C/C++ 语言编码风格对解聚的结构体进行寻址。使用这些指令时的代码如下所示。
syn.directive.disaggregate=top a
syn.directive.disaggregate=top c

代码结构如下。

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
重要: 请注意,访问指针元素 (a) 与访问参考元素 (c) 的方法存在差异,如上所示

示例 3

以下示例显示的 Dot 结构体内包含 RGB 结构体作为元素。如果您将 syn.directive.disaggregate 应用于 Arr 变量,则仅对顶层 Dot 结构体进行解聚。

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

如果您要将整个结构体(包括 DotRGB)进行解聚,则可按如下所示对 set_directive_disaggregate 进行赋值。

void DUT(Dot Arr[N]) { 
#pragma HLS disaggregate variable=Arr->RGB 
... 
} 

syn.directive.disaggregate=DUT Arr->RGB
以下代码展示了操作结果。
void DUT(char Arr_RGB_R[N], char Arr_RGB_G[N], char Arr_RGB_B[N], unsigned Arr_Size[N]) { 
... 
}