我正在使用 Vitis HLS 编写一些代码。代码如下:
#include "algo.h"
void find_peaks(ap_uint<14> input[NDATA], bool *peak, ap_uint<14> *start_time, ap_uint<14> *end_time, ap_uint<14> *peak_time, ap_uint<14> *peak_value, ap_uint<14> *sum_value){
ap_uint<14> local_start_time = 0;
ap_uint<14> local_end_time = 0;
ap_uint<14> local_peak_time = 0;
ap_uint<14> local_peak_value = 0;
ap_uint<14> local_sum_value = 0;
ap_uint<14> width = 0;
bool prev_peak = false;
for (ap_uint<14> i = 0; i<NDATA; i++){
prev_peak = *peak;
*peak = input[i]>20;
local_start_time = (*peak && !prev_peak)? i:local_start_time;
local_end_time = *peak? i:local_end_time;
local_peak_time = (*peak && (input[i]>local_peak_value))? i:local_peak_time;
local_peak_value = (*peak && (input[i]>local_peak_value))? input[i]:local_peak_value;
local_sum_value += *peak ? input[i]:ap_uint<14>(0);
width = local_end_time - local_start_time;
*start_time = (!*peak && prev_peak && (width>3))? local_start_time: *start_time ;
*end_time = (!*peak && prev_peak && (width>3))? local_end_time: *end_time ;
*peak_time = (!*peak && prev_peak && (width>3))? local_peak_time: *peak_time ;
*peak_value = (!*peak && prev_peak && (width>3))? local_peak_value: *peak_value ;
*sum_value = (!*peak && prev_peak && (width>3))? local_sum_value: *sum_value ;
}
}
在NDATA
输入文件中定义为 64 的位置。这可以正常工作并且可以正常合成。当我尝试使用#pragma
s 来优化它时,问题就开始了。主要要求之一是将代码流水线化。我尝试使用以下两个:
#pragma HLS pipeline II=1 style=flp
可以理解的是,这不能单独工作,考虑到它无法足够快地读取输入,我使用了推荐的修复方法,即使用将输入拆分为单独的寄存器
#pragma HLS ARRAY_PARTITION variable=input complete
这就是问题所在:Vitis 无法合成它,而是给出以下错误:
ERROR: [HLS 214-247] in function 'find_peaks(ap_uint<14>*, bool*, ap_uint<14>*, ap_uint<14>*, ap_uint<14>*, ap_uint<14>*, ap_uint<14>*) (.12)': Cannot apply array transformation pragma/directive because of pointer selection. (src/algo.cpp:21:22)
我还没有在任何地方找到任何文档。有谁知道是什么原因造成的,或者我该如何解决?