cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
daniel.cogan
Explorer
Explorer
464 Views
Registered: ‎07-30-2013

largest fixed point return value

What is the largest ap_fixed<> that the compiler will correctly return through a function call?

My ap_fixed<52,39> value was changed to a smaller number upon return.  I had to shift and cast to a long long int, and unshift back after the return in order to get the correct value.

Similarly a coworker tried returning a 3D array [2][2][2]  of ap_fixed<40,1>, and was getting values that didn't match the array right before the return from function call.

Just curious what the rules are involving ap_fixed as a return type.

0 Kudos
3 Replies
aoifem
Moderator
Moderator
378 Views
Registered: ‎11-21-2018

Hi @daniel.cogan 

I don't know an exact number, as I image it would change depending on your system. But if you are looking to increase the precision I would look at playing around with the quantization mode. There's more information about this in the docs: 

https://www.xilinx.com/html_docs/xilinx2020_1/vitis_doc/vitishlslibrariesreference.html

 

 

Aoife
Product Application Engineer - Xilinx Technical Support EMEA


**~ Got a minute? Answer our Vitis HLS survey here! ~**

**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
xilinxacct
Professor
Professor
346 Views
Registered: ‎10-23-2018

@daniel.cogan 

Arbitrary precision data types are provided for C and C++ and allow you to model data types of any width from 1 to 1024-bit. according to UG902

Hope that Helps
If so, Please mark as solution accepted. Kudos also welcomed.

0 Kudos
daniel.cogan
Explorer
Explorer
288 Views
Registered: ‎07-30-2013

That does.  

In terms of this question, I'm concerned with preserving integer bits within the arbitrary precision data type, as a return value in a function.  In my case, the ap_fixed<> is defined with 59 integer bits. Printing before the end of the function showed the expected large value.  Printing the return value right after the return from the function, showed a different smaller value.

Do you expect that function calls within HLS can handle the full range of arbitrary precision data types (of 1 to 1024 bits) as return values?  Does it matter if they are returned as a pointer or returned as the function return value? I have some unexplained instances in which the value did not return properly. 

However, of course when I went to make a small test project to show this behavior, I haven't been able to yet.

0 Kudos