突发访问全局存储器 - 2022.1 简体中文

Vitis 统一软件平台文档 应用加速开发 (UG1393)

Document ID
UG1393
Release Date
2022-05-25
Version
2022.1 简体中文

从内核访问全局存储体会产生巨大的时延,因此应在突发内完成全局存储器传输。如需了解有关突发传输的更多信息,请参阅 Vitis HLS 用户指南(UG1399) 中的 AXI 突发传输

提示: Vitis HLS 中的Synthesis Summary(综合汇总)报告包含有关内核中的突发传输的详细信息。但是,要复查此报告,您需要启动该工具。

要推断突发,建议采用以下循环流水打拍编码样式。

hls::stream<datatype_t> str;

INPUT_READ: for(int i=0; i<INPUT_SIZE; i++) {
  #pragma HLS PIPELINE
  str.write(inp[i]); // Reading from Input interface
}

在代码示例中,经流水打拍的 for 循环用于从输入存储器接口中读取数据,并将数据写入内部 hls::stream 变量。以上编码样式旨在从突发中的全局存储体读取数据。

这种编码样式建议用于在独立函数内部实现以上示例中的 for 循环操作,并应用 dataflow 最优化,如 数据流最优化 中所述。以下示例代码显示了其效果,它允许编译器在读取、执行和写入函数间建立数据流:

top_function(datatype_t * m_in, // Memory data Input
  datatype_t * m_out, // Memory data Output
  int inp1,     // Other Input
  int inp2) {   // Other Input
#pragma HLS DATAFLOW

hls::stream<datatype_t> in_var1;   // Internal stream to transfer
hls::stream<datatype_t> out_var1;  // data through the dataflow region

read_function(m_in, inp1, in_var1); // Read function contains pipelined for loop 
                           // to infer burst

execute_function(in_var1, out_var1, inp1, inp2); // Core compute function

write_function(out_var1, m_out); // Write function contains pipelined for loop 
                                 // to infer burst
}