syn.directive.disaggregate - 2023.2 简体中文

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

Document ID
UG1399
Release Date
2023-12-18
Version
2023.2 简体中文

描述

syn.directive.disaggregate 命令允许您按 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]) { 
... 
}