taijusti / sleep_apnea

0 stars 0 forks source link

apply workaround so that we can send floats without having to convert to fixed point #31

Open taijusti opened 9 years ago

taijusti commented 9 years ago

currently to transmit a float, we convert float -> fixed -> int32_t when we receive the value, we convert int32_t -> fixed -> float. this is because Vivado HLS doesn't correctly support unions with float and int. this is bad because: a) results in precision lost every time we convert between float/fixed b) wasted DSPs + LUTs for the conversion

there is a workaround: https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Vivado-HLS-2013-1-workaround-for-unsupported-pointer/td-p/330235

basically, we need to make it something like this void unicast_send(float f, hls::stream & out) {

pragma HLS INLINE

transmit_t temp;
temp.f = f;
out.write(temp);

}

void unicast_recv(float &f, hls::stream & in) {

pragma HLS INLINE

transmit_t temp;
temp.ui = in.read();
f = temp.f;

}