UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
252 Views
Registered: ‎01-14-2008

HLS floor() bug

Jump to solution

Hi,

I think there's a bug in the hls_math library. Consider the code fragment below.

ap_fixed<10, 3, AP_TRN> a;
ap_fixed<10, 3, AP_TRN, AP_SAT_SYM> b;
int c;

c = floor(a);
c = floor(b); // compilation error

The line 'floor(b)' doesn't compile with the following error messages:

C:/Xilinx/Vivado/2018.2/include/hls_math.h:310:10: note: candidate: double hls::floor(double)
   double floor(double);
          ^~~~~
C:/Xilinx/Vivado/2018.2/include/hls_math.h:311:10: note: candidate: float hls::floor(float)
   float  floor(float);
          ^~~~~
C:/Xilinx/Vivado/2018.2/include/hls_math.h:312:10: note: candidate: half hls::floor(half)
   half   floor(half);
          ^~~~~

 

Is this in fact in the hls_math library? Or am I missing something?

Cheers

0 Kudos
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
214 Views
Registered: ‎09-05-2018

Re: HLS floor() bug

Jump to solution

Hey @dsula,

The hls_math.h library only supports the first and second template parameters. This is stated in UG902 on page 242. However, it doesn't explicitly say that the third and beyond template parameters and not supported, and I've reported to the appropriate teams that this is confusing.

The reason c = floor( a ) compiles is that AP_TRN is the default, so ap_fixed<10, 3, AP_TRN> a is understood to be the same type as ap_fixed<10,3> a. 

As a workaround, can you cast b to ap_fixed<10, 3> before calling floor()? ap_fixed<10,3> can hold values from -4 to ~3.99, so it is logically the same. The following code compiles successfully:

ap_fixed<10, 3, AP_TRN> a;
ap_fixed<10, 3, AP_TRN, AP_SAT_SYM> b;
int c;

c = floor(a);
c = floor( ap_fixed<10,3> b).to_int() // no compilation error

 

 

Nicholas Moellers

Xilinx Worldwide Technical Support
1 Reply
Xilinx Employee
Xilinx Employee
215 Views
Registered: ‎09-05-2018

Re: HLS floor() bug

Jump to solution

Hey @dsula,

The hls_math.h library only supports the first and second template parameters. This is stated in UG902 on page 242. However, it doesn't explicitly say that the third and beyond template parameters and not supported, and I've reported to the appropriate teams that this is confusing.

The reason c = floor( a ) compiles is that AP_TRN is the default, so ap_fixed<10, 3, AP_TRN> a is understood to be the same type as ap_fixed<10,3> a. 

As a workaround, can you cast b to ap_fixed<10, 3> before calling floor()? ap_fixed<10,3> can hold values from -4 to ~3.99, so it is logically the same. The following code compiles successfully:

ap_fixed<10, 3, AP_TRN> a;
ap_fixed<10, 3, AP_TRN, AP_SAT_SYM> b;
int c;

c = floor(a);
c = floor( ap_fixed<10,3> b).to_int() // no compilation error

 

 

Nicholas Moellers

Xilinx Worldwide Technical Support