05-18-2015 01:08 AM
Can fixed point / floating point function such as cos , acos , sqrt be synthesis in vivado hls ?
where can I get such information ?
05-18-2015 03:00 AM
This should give you access to such synthesizable functions.
05-19-2015 04:55 AM
05-19-2015 09:09 PM
It listed only floating point function , no fixed point function.
for resource consideration, I'd like to use fixed point functions.
The document says fixed point function also supported by a complex way as follows :
• Review Table 2-5 to determine if a fixed-point implementation is supported.
• Update the math functions to use ap_fixed types.
• Perform C simulation to validate the design still operates with the required precision.
The C simulation is performed using the same bit-accurate types as the RTL
• Synthesize the design.
The first step, Table 2-5 list only floating point function , no fixed point function.
The second step. Does it mean that I should copy the source code of floating point functions and rewrite it in fixed point ?
here is my source code converting rgb to hsi, fixed point min/max/sqrt/acos/atan are not reported as error.
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)
ap_ufixed<16,8> min_val, max_val ;
ap_fixed<16,8> ss, hh, ii ;
ap_fixed<32,16> t1,t2,t3 ;
ap_ufixed<32,16> theta ;
rr = r ; gg = g ; bb = b ;
rr = rr>>8 ; gg = gg>>8 ; bb = bb>>8 ;
ii = (rr+gg+bb)*(ap_ufixed<16,0>)0.333333;
min_val = fmin( rr , gg ) ;
min_val = fmin( bb , min_val ) ;
max_val = fmax( rr , gg ) ;
max_val = fmax( bb , min_val ) ;
if(max_val == min_val)
ss = 0;
hh = -1.0;
ss = 1 - 3 * min_val / ( rr + gg + bb ) ;
t1 = (rr - gg + rr - bb )/2 ;
t2 = (rr-gg)*(rr-gg)+(rr-bb)*(gg-bb) ;
t3 = t1 / t2 ;
theta = atanf(t3) ; // acos not supported, use atanf instead
if (b > g)
hh = 2 - theta;
hh = theta;
*h = hh ;
*s = ss ;
*i = ii ;
09-18-2017 02:43 PM
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?
09-18-2017 07:43 PM
For cos, you should be able to use the DDS ip for a fixed point implementation. Or write your own look-up table implementation.
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:
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.
Hope this helps,