03-17-2017 06:35 PM
Hi, I am writing a code where I got the data as an int array like : int input;
now I need to process each bytes in one int parameter, that is saying that one int has to be divided into 4 char parameters. And after processing this I need to combine the 4 together.
I found that in HLS this is not allowed:
How should I handle this?
Thanks in advance.
03-17-2017 06:43 PM
>> I found that in HLS this is not allowed:
can you describe what error you see? This is fairly benign c++ code.
03-18-2017 03:31 AM
I too would like to know what error you see; I use that sort of code all the time. The only possible error I can see is if "input" is an AXI Stream; HLS demands pure sequential access (ie you read every element exactly once, in sequence) for AXI Streams and in your example you read each element of "input" four times.
The easy alternative, at least in C++, is to convert to the ap_int types:
ap_int<32> input; ap_uint<8> a1, a2, a3, a4; a1 = input(31,24); a2 = input(23,16); a3 = input(15,8); a4 = input(7,0);
03-18-2017 05:35 PM
a1 = input[i](31,24);
a1 = input(31,24);
would be not work.
03-19-2017 10:45 PM
You can also try like this if you do not want to use ap_uint/ap_int:
unsigned int tmpInt;
tmpInt = input[i];
a1 = tmpInt & 0xFF;
a2 = (tmpInt >> 8 ) & 0xFF;
a3 = (tmpInt >> 16) & 0xFF;
a4 = (tmpInt >> 24) & 0xFF;