AR# 5366


LogiCORE MAC FIR Filter, DA FIR Filter, FIR Compiler - How do I convert floating-point coefficients to fixed-point for Xilinx DA and MAC FIR filters?


Keywords: CORE Generator, CORE Generator, coef, COE, FIR, PSA, SDA, fixed point, floating point, normalize, filter

When a FIR filter is designed, the coefficient values are typically given in floating-point format. However, the Xilinx Distributed Arithmetic FIR (DA FIR), Multiply Accumulate FIR (MAC FIR) filter cores can accept only fixed-point coefficient values. Floating-point coefficient values must be normalized to fixed-point values before they can be used with Xilinx FIR filter cores. How are these values converted?

NOTE: The FIR Compiler Core can accept Floating-point coefficients, and will preform the following conversion automatically, based on the coefficient bit width.


The conversion process outlined below expects floating-point format coefficient values with a maximum value of less than "1". These are converted to signed integers in "2's" complement format.

For example:
Coefficients are 0.0174, -0.0123, 0.127, -0.0123, 0.0174

1. The first step in converting the coefficients is to determine the number of bits needed to represent the coefficients (N). Typically, this is a system-level decision and is a factor of the required Dynamic Range of the filter and the implementation costs associated with the filter. This value provides the maximum and minimum possible values for the coefficients by calculating the following equation:

Maximum value = 2^(N-1)-1
Minimum value = -2^(N-1)

NOTE: The N-1 is used because the coefficients are "2's" complement.

For example:
For 10 bits, the maximum value is 511 and the minimum value is -512.

2. The second step is to normalize the floating-point values such that the maximum possible dynamic range can be achieved from the coefficient values. This is accomplished by determining the maximum absolute value of the coefficients and dividing it into the coefficients, as in the following equation:

(coefficients) / max_of_coefficients ( absolute_value_of_coefficients (coefficients) )

For example:
Normalized values are 0.1370, -0.0969, 1, -0.0969, and 0.1370.

This normalizes ALL the coefficients to either 1 or -1, depending upon the coefficients.

3. The final step is to take the normalized values and multiply them by the maximum possible value for the coefficients as calculated in Step 1. The result is then rounded to "quantize" the values to the coefficients.

result = round (normalized_values * 2^(N-1)-1)

For example:
2's complement fixed-point values are 70, -49, 511, -49, and 70.

You can combine these steps to form the following MATLAB equation, which converts the values assuming a bit width (N) and a floating-point coefficient array (coef).

result = round (coef/max(abs(coef)) * (2^(10-1)-1))

Use the new coefficients in your COE file, ensuring that the RADIX declaration in the COE file is consistent with the number base used when you specify the coefficients.
AR# 5366
Date 08/06/2008
Status Active
Type General Article
People Also Viewed