Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Level 1
Level 1
Hello everyone!
How can one declare a float16 variable in HIGHTEC / AURIX Studio? It's weird that I couldn't find it in Platform_Types, because this datatype is used in SPU when the input datatype is set to IfxSpu_RM_InputDataFormat_realHalfFloat or IfxSpu_RM_InputDataFormat_complexHalfFloat? I have also seen assembly instructions for working with half floats.
Perhaps additional options need to be specified for gcc HIGHTEC (I tried -mfp16-format, no success).
Regards, Gennadiy
2 Replies
Level 1
Level 1
Infineon support:
Float16 is not natively supported by the TriCore.
These Input Data Type values: IfxSpu_RM_InputDataFormat_realHalfFloat and IfxSpu_RM_InputDataFormat_complexHalfFloat are somehow used to specify the size of the data that will need to be stored and used. The space that is needed to be reserved in the memory.
For processing, this data will then need to be converted to float32. This can be done by any of the way you want.
However, the TriCore Instruction Set supports the conversion with the following instruction:
hptof d1, d2
Level 6
Level 6
50 likes received 50 solutions authored 100 sign-ins
Float16 support has beein introduced in v6.0r1 of the TASKING TriCore tools. The user guide includes the following details about this data type:

1.1.1. Half Precision Floating-Point

The TASKING C compiler supports half precision (16-bit) floating-point via the _Float16 type using the
binary16 interchange format. The binary16 interchange format is defined in IEEE Std 754-2008 IEEE
Standard for Floating-Point Arithmetic. The _Float16 type is defined in ISO/IEC TS 18661-3 Draft
Technical Specification – December 4, 2014 WG14 N1896.

The _Float16 type with binary16 format can represent normalized values in the range of 2-14 to 65504.
There are 11 bits of significant precision, approximately 3 decimal digits. Also subnormal values are
supported, as defined by FLT16_HAS_SUBNORM in float.h.

The _Float16 type is a storage format only. For purposes of arithmetic and other operations, _Float16
values in C expressions are automatically promoted to float.

Note that all conversions from and to _Float16 involve an intermediate conversion to float. Because
of rounding, this can sometimes produce a different result than a direct conversion.

When you specify C compiler option --fp-model=-soft, the C compiler generates hardware floating-point
instructions for conversions between _Float16 and float for AURIX TC3xx only.

Language-level support for the _Float16 data type is independent of whether the C compiler generates
code using hardware floating-point instructions or not. In cases where hardware support is not specified
or not available for the selected core, the C compiler implements conversions between _Float16 and
float values as run-time library calls.These run-time functions are called __f_ftohp and __f_hptof.

_Float16 __f_ftohp( float f ); // single precision to half precision
float __f_hptof( _Float16 f ); // half precision to single precision

Best regards,
Ulrich Kloidt

TASKING tools support