Intel® High Level Design
Support for Intel® High Level Synthesis Compiler, DSP Builder, OneAPI for Intel® FPGAs, Intel® FPGA SDK for OpenCL™
677 Discussions

How to convert an ihc::hls_float <8, 23> s_tanf to an ac_int or ac_fixed?

abaxor
Beginner
940 Views

Hi,

 

I have to calculate an arctan on a CycloneV. Since HLS/ac_fixed_math.h does not include atan I use HLS/hls_float_math.h. Just now I run in trouble to convert the

ihc::hls_float <8, 23> s_tanf

variable to an

ac_int <16, false> s_tan = 0;

or better

ac_fixed <24, 8, true> s_tan = 0;

I found casting methods in hls_float.h but don't understand them.

 

Can you give me any hint on how to convert it?

 

Thanks

0 Kudos
5 Replies
aikeu
Employee
924 Views

Hi abaxor,


hls_float <8, 23> s_tanf is using IEEE 754 single-precision (binary32), 32bit to represent the data in binary value:


https://www.intel.com/content/www/us/en/docs/programmable/683349/21-4/declaring-hls-float-data-types.html

https://www.geeksforgeeks.org/ieee-standard-754-floating-point-numbers/


As for the ac_int and ac_fixed convertion, you can refer better to the below:


https://www.intel.com/content/www/us/en/docs/programmable/683349/21-4/declaring-ac-int-data-types.html

https://www.intel.com/content/www/us/en/docs/programmable/683349/21-4/declaring-ac-fixed-data-types.html


You can use any online IEEE-754 Floating Point Converter to test out the results of value you would like to convert and check if you are getting the correct output in your code based on how the value is defined with ac_int/ac_fixed.



Thanks.

Regards,

Aik Eu


0 Kudos
abaxor
Beginner
916 Views

Your answer does not help at all. As you can see from my post, I am able to declare variables because I have read the documents you mentioned. However, I need a function or method to assign the value from s_tanf to s_tan.

0 Kudos
aikeu
Employee
885 Views

Hi abaxor,


Sorry that I may not fully understand your request regarding the conversion as you mentioned. Can share with me more details on your work?

There is some tutorial/design example in the HLS directory that may help with your understanding.

<quartus_installdir>//hls\examples\tutorials\ac_datatypes\ac_fixed_constructor

Refer to this link for more info:

https://www.intel.com/content/www/us/en/docs/programmable/683680/21-3/high-level-synthesis-hls-design-examples.html



Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
875 Views

Hi abaxor,


Any feedback from the previous comment?


Thanks.

Regards,

Aik Eu


0 Kudos
aikeu
Employee
852 Views

Hi abaxor,


 We do not receive any response from you to the previous question/reply/answer that I have provided. This thread will be transitioned to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread. Thank you.


Thanks.

Regards,

Aik Eu



0 Kudos
Reply