set_directive_disaggregate - 2023.2 简体中文

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

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

描述

set_directive_disaggregate 命令允许您按 struct 变量所含各独立元素来对其进行解构。创建的元素数量和类型取决于结构体本身的内容。

重要: 默认情况下,作为顶层函数实参的结构体将聚合在一起,但可通过该指令或编译指示来对其进行解聚。如需了解有关如何对与串流关联的结构体进行解聚的更多信息,请参阅 AXI4-Stream 接口

语法

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

选项

此命令不含任何选项。

示例 1

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

set_directive_disaggregate top a

示例 2

解聚后的结构体可在您的代码中使用标准 C/C++ 编码样式来进行寻址,如下所示。请注意访问指针元素 (a) 与访问参考元素 (c) 的方法差异;

struct SS
{
  int x[N];
  int y[N];
};
  
int top(SS *a, int b[4][6], SS &c) {

set_directive_disaggregate top a
set_directive_interface -mode s_axilite top a->x
set_directive_interface -mode s_axilite top a->y

set_directive_disaggregate top c
set_directive_interface -mode ap_memory top c.x
set_directive_interface -mode ap_memory top c.y

示例 3

以下示例显示的 Dot 结构体内包含 RGB 结构体作为元素。如果您将 set_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]) {
... 
} 

set_directive_disaggregate DUT Arr

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

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

set_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]) { 
... 
}