问题
In the end what I want to do is to use a streaming interface with single precision floating point arrays in Vivado Design Suite to build hardware accelerators. HLS User Guide UG902 shows that is possible to create HW accelerators (starting from C, C++, SystemC, OpenCL code) using different interfaces.
If you want to use an AXI4 streaming interface, HLS synthesizes the signals TREADY and TVALID but it doesn't synthesize the signal TLAST necessary to connect the RTL interface generated to Zynq Processing System (ARM9 cores in my case). In order to solve this problem, Xilinx gives you the possibility to use this library
#include "ap_axi_sdata.h"
Inside there is the struct - template:
#include "ap_int.h"
template<int D,int U,int TI,int TD>
struct ap_axis{
ap_int<D> data;
ap_uint<D/8> keep;
ap_uint<D/8> strb;
ap_uint<U> user;
ap_uint<1> last;
ap_uint<TI> id;
ap_uint<TD> dest;
};
I have two problems:
- If I want to use only TLAST and not the others, I try to set up U, TI and TD to zero but I get an error.
- If I want to use 'float' and not 'ap_int' and I try to change it inside the template I get another error.
Question:
is there an easy way to handle and manage streaming interface in HLS with floating point data?
回答1:
For me the simplest way to solve that, it is to declare your own struct data type, without using the library that you mentioned above. By default VivadoHLS implement the AXIS interfaces with the signals TDATA, TVALID and TREADY. If you also need TLAST and single precision single point data you should declare your own data type, which should be something like this:
struct my_data{
float data;
bool last;
};
I can give you an example about how you should use it:
void my_function(my_data input[25], my_data output[25])
{
#pragma HLS INTERFACE axis port=output
#pragma HLS INTERFACE axis port=input
#pragma HLS INTERFACE s_axilite port=return
float tmp_data;
float tmp_last;
int k=0;
for(k=0;k<25;k++)
{
tmp_data[k] = input[k].data;
tmp_last[k] = input[k].last;
}
for(k=0;k<25;k++)
{
output[k].data = tmp_data[k];
output[k].last = tmp_last[k];
}
}
If you do this, after synthesis you'll get this result:
In order to avoid errors you must pay attention to: Whenever you use the data of your stream interfaces you should be careful to manage the rest of the signals of the interface.
来源:https://stackoverflow.com/questions/38264547/axi4-streaming-interface-how-to-manage-floating-point-array-in-hls-for-generati