在HLS中,有如下语句 ap_int offset=(trr+row*2)SIZE+(tcc+col2)+(ti+tii)SIZESIZE; vivado HLS综合时警告显示该语句为关键路径,时钟周期超出,解决方法如下
ap_int Reg(ap_int in){
#pragma HLS INTERFACE register port=return
#pragma HLS INLINE off
#pragma HLS PIPELINE
return in;
}
定义上述函数,以插入寄存器 然后将该语句改写为
ap_int r=Reg((ap_int)(trr+row*2));
ap_int c=Reg((ap_int)(tcc+2*col));
ap_int s=Reg((ap_int)(SIZE*SIZE));
ap_int x_y=Reg((ap_int)(r*SIZE+c));
ap_int n_d=Reg((ap_int)(ti+tii)*s);
ap_int offset=x_y+n_d;
综合后警告消失 再看看vivado HLS是如何schedule的
第一张图表明r,c,s同时计算,第二张图表明x_y,n_d同时计算,而offset最后计算,从而实现了将许多操作分配到不同的时钟周期,提高了系统时钟频率。