基本指针 - 2023.2 简体中文

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

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

如以下代码示例所示,顶层接口上具有基本指针的函数不会对 Vitis HLS 产生影响。指针可综合为简单的有线接口或使用握手的接口协议。

提示: 仅限只读或只写指针才能综合为 FIFO 接口。
#include "pointer_basic.h"

void pointer_basic (dio_t *d) {
 static dio_t acc = 0;

 acc += *d;
 *d  = acc;
}

每个函数调用仅对接口上的指针执行一次读取或写入。以下代码示例中显示了测试激励文件。

#include "pointer_basic.h"

int main () {
 dio_t d;
 int i, retval=0;
 FILE *fp;

 // Save the results to a file
 fp=fopen(result.dat,w);
 printf( Din Dout\n, i, d);

 // Create input data
 // Call the function to operate on the data
 for (i=0;i<4;i++) {
    d = i;
    pointer_basic(&d);
    fprintf(fp, %d \n, d);
    printf(  %d   %d\n, i, d);
 }
 fclose(fp);

 // Compare the results file with the golden results
 retval = system(diff --brief -w result.dat result.golden.dat);
 if (retval != 0) {
    printf(Test failed!!!\n); 
    retval=1;
 } else {
    printf(Test passed!\n);
 }

 // Return 0 if the test
 return retval;
}

C 和 RTL 仿真通过以下简单数据集验证运算是否正确(尽管并未列出所有可能的情况):

Din Dout
  0   0
  1   1
  2   3
  3   6
Test passed!