IQmath
C2000 Microcontroller Workshop - Numerical Concepts 8 - 23
IQmath Provides Compatibility Between
Floating-Point and Fixed-Point
All “IQmath” operations have an equivalent floating-point operation
Compile & Run
on Fixed-Point
F2803x
Y = _IQmpy(M, X) + B;
#if MATH_TYPE == IQ_MATH
#if MATH_TYPE == FLOAT_MATH
Y = (float)M * (float)X + (float)B;
1) Develop any mathematical function
2) Select math type in IQmathLib.h
3) Compiler automatically converts to:
Floating-Point
Math Code
Fixed-Point
Math Code
Compile & Run
on Floating-Point
F2806x *
* Can also compile floating-point code on any floating-point compiler (e.g., PC, Matlab, fixed-point w/ RTS lib, etc.)
Selecting FLOAT_MATH or IQ_MATH Mode: As was highlighted in the introduction, we would
ideally like to be able to have a single source code that can execute on a floating-point or fixed-
point target device simply by recompiling the code. The "IQmath" library supports this by setting
a mode, which selects either IQ_MATH or FLOAT_MATH. This operation is performed by
simply redefining the function in a header file. For example:
#if MATH_TYPE == IQ_MATH
#define _IQmpy(M , X) _IQmpy(M , X)
#elseif MATH_TYPE == FLOAT_MATH
#define _IQmpy(M , X) (float) M * (float) X
#endif
Essentially, the programmer writes the code using the "IQmath" library functions and the code
can be compiled for floating-point or "IQmath" operations.