10-22-2020 09:32 AM
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  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.
10-30-2020 05:40 AM
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:
**~ Don't forget to reply, give kudos, and accept as solution.~**
**~ Got a minute? Answer our Vitis HLS survey here! ~**
10-31-2020 07:04 AM
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.
11-02-2020 06:06 AM
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.