Fixed-point implementations are also provided for the following math
All fixed-point math functions support ap_[u]fixed and ap_[u]int data
types with following bit-width specification,
I<=33 and W-I<=32
I<=32 and W-I<=32
Important: Fixed-point math functions from the
hls_math library do not support the
ap_[u]fixed template parameters Q,O, and N, for quantization
mode, overflow mode, and the number of saturation bits, respectively. The
quantization and overflow modes are only effective when an ap_[u]fixed variable is
on the left hand of assignment or being initialized, but not during the
The fixed-point type provides a slightly-less accurate version of the
function value, but a smaller and faster RTL implementation.
The methodology for implementing a math function with a fixed-point
data types is:
- Determine if a fixed-point implementation is supported.
- Update the math functions to use
- Perform C simulation to validate the design still operates with
the required precision. The C simulation is performed using the same
bit-accurate types as the RTL implementation.
- Synthesize the design.
For example, a fixed-point implementation of the function
sin is specified by using fixed-point types with the
math function as follows:
ap_fixed<32,2> my_input, my_output;
my_input = 24.675;
my_output = sin(my_input);
When using fixed-point math functions, the result type must have the
same width and integer bits as the input.