topic Re: What fixed and float arithmetic function can be synthesis in vivado hls? in High-Level Synthesis (HLS)
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/794944#M10220
<P>Hello,</P>
<P> </P>
<P>For cos, you should be able to use the DDS ip for a fixed point implementation. Or write your own look-up table implementation.</P>
<P> </P>
<P>I don't think there is built-in fixed point IP for the other functions you mentioned, however, there is some examples of CORDIC based square root and atan here that may help:</P>
<P><A href="https://github.com/Xilinx/HLx_Examples/tree/master/Math" target="_blank">https://github.com/Xilinx/HLx_Examples/tree/master/Math</A>.</P>
<P> </P>
<P>You can also use Newton's method to implement these, but I don't know of a ready to go example anywhere. The issue is that for something like atan or sqrt, when you get close to the boundaries, fixed point solutions have a lot of error, or require a lot of iterations in order to get an accurate result. So if you need a lot of accuracy close to the boundaries it may not be much more efficient to use fixed instead of floating point. Of course it depends a lot on what your system requirements are, but this is something to consider.</P>
<P> </P>
<P>Hope this helps,</P>
<P>eschei </P>
<P> </P>
<P> </P>Tue, 19 Sep 2017 02:43:27 GMToderousmonk2017-09-19T02:43:27ZWhat fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/618956#M3820
<P>Hi, </P>
<P> Can fixed point / floating point function such as cos , acos , sqrt be synthesis in vivado hls ?</P>
<P> where can I get such information ?</P>
<P> </P>Mon, 18 May 2015 08:08:21 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/618956#M3820sanhu2015-05-18T08:08:21ZRe: What fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/619751#M3838
<PRE>#include "hls_math.h"</PRE>
<P>This should give you access to such synthesizable functions.</P>Mon, 18 May 2015 10:00:36 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/619751#M3838dahenk2015-05-18T10:00:36ZRe: What fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/622000#M3887
For details refer page 286 onward of the document: <A href="http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_1/ug902-vivado-high-level-synthesis.pdf" target="_blank">http://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_1/ug902-vivado-high-level-synthesis.pdf</A>Tue, 19 May 2015 11:55:14 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/622000#M3887debrajr2015-05-19T11:55:14ZRe: What fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/622677#M3896
<P>It listed only floating point function , no fixed point function.</P>
<P>for resource consideration, I'd like to use fixed point functions.</P>
<P>The document says fixed point function also supported by a complex way as follows :</P>
<P> </P>
<P>• Review Table 2-5 to determine if a fixed-point implementation is supported.<BR />• Update the math functions to use ap_fixed types.<BR />• Perform C simulation to validate the design still operates with the required precision.<BR />The C simulation is performed using the same bit-accurate types as the RTL<BR />implementation.<BR />• Synthesize the design.</P>
<P> </P>
<P>The first step, Table 2-5 list only <SPAN>floating point function , no fixed point function.</SPAN></P>
<P>The second step. Does it mean that I should copy the source code of floating point functions and rewrite it in fixed point ?</P>
<P> </P>
<P>here is my source code converting rgb to hsi, fixed point min/max/sqrt/acos/atan are not reported as error.</P>
<P> </P>
<P>#include "hls_math.h"<BR />#include "ap_fixed.h"</P>
<P>void rgb2hsi( ap_uint<8> r, ap_uint<8> g, ap_uint<8> b, ap_uint<8> *h, ap_uint<8> *s, ap_uint<8> *i)</P>
<P>{<BR /> ap_ufixed<16,8> rr,gg,bb;<BR /> ap_ufixed<16,8> min_val, max_val ;<BR /> ap_fixed<16,8> ss, hh, ii ;<BR /> ap_fixed<32,16> t1,t2,t3 ;<BR /> ap_ufixed<32,16> theta ;</P>
<P> rr = r ; gg = g ; bb = b ;<BR /> rr = rr>>8 ; gg = gg>>8 ; bb = bb>>8 ;<BR /> ii = (rr+gg+bb)*(ap_ufixed<16,0>)0.333333;</P>
<P> min_val = fmin( rr , gg ) ;<BR /> min_val = fmin( bb , min_val ) ;<BR /> max_val = fmax( rr , gg ) ;<BR /> max_val = fmax( bb , min_val ) ;</P>
<P> if(max_val == min_val)<BR /> {<BR /> ss = 0;<BR /> hh = -1.0;<BR /> }<BR /> else<BR /> {<BR /> // c<BR /> ss = 1 - 3 * min_val / ( rr + gg + bb ) ;</P>
<P> // h<BR /> t1 = (rr - gg + rr - bb )/2 ;<BR /> t2 = (rr-gg)*(rr-gg)+(rr-bb)*(gg-bb) ;<BR /> t3 = t1 / t2 ;<BR /> theta = atanf(t3) ; // acos not supported, use atanf instead</P>
<P> if (b > g)<BR /> {<BR /> hh = 2 - theta;<BR /> }<BR /> else<BR /> {<BR /> hh = theta;<BR /> }<BR /> }<BR /> *h = hh ;<BR /> *s = ss ;<BR /> *i = ii ;<BR />}</P>
<P> </P>Wed, 20 May 2015 04:09:29 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/622677#M3896sanhu2015-05-20T04:09:29ZRe: What fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/794905#M10215
<P>I have the same problem. I have a code using abs and pow using exp and log functions in hls_math library. I wanted to optimize it by doing a fixed point but it seems hls_math has no support of the ap_fixed<> type. any suggestions?</P>Mon, 18 Sep 2017 21:43:30 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/794905#M10215keyvanshahinrub13652017-09-18T21:43:30ZRe: What fixed and float arithmetic function can be synthesis in vivado hls?
https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/794944#M10220
<P>Hello,</P>
<P> </P>
<P>For cos, you should be able to use the DDS ip for a fixed point implementation. Or write your own look-up table implementation.</P>
<P> </P>
<P>I don't think there is built-in fixed point IP for the other functions you mentioned, however, there is some examples of CORDIC based square root and atan here that may help:</P>
<P><A href="https://github.com/Xilinx/HLx_Examples/tree/master/Math" target="_blank">https://github.com/Xilinx/HLx_Examples/tree/master/Math</A>.</P>
<P> </P>
<P>You can also use Newton's method to implement these, but I don't know of a ready to go example anywhere. The issue is that for something like atan or sqrt, when you get close to the boundaries, fixed point solutions have a lot of error, or require a lot of iterations in order to get an accurate result. So if you need a lot of accuracy close to the boundaries it may not be much more efficient to use fixed instead of floating point. Of course it depends a lot on what your system requirements are, but this is something to consider.</P>
<P> </P>
<P>Hope this helps,</P>
<P>eschei </P>
<P> </P>
<P> </P>Tue, 19 Sep 2017 02:43:27 GMThttps://forums.xilinx.com/t5/High-Level-Synthesis-HLS/What-fixed-and-float-arithmetic-function-can-be-synthesis-in/m-p/794944#M10220oderousmonk2017-09-19T02:43:27Z