Erroneous generated FIR Filter Coefficient File for Xilinx (.coe)

38 visualizaciones (últimos 30 días)
Anastasios
Anastasios el 5 de Feb. de 2024
Comentada: Anastasios el 21 de Feb. de 2024
I am utilizing the Filter Designer Tool to create an output file that will contain the Coefficients at the Xilinx .ceo format.
I tried two different approaches. One with and one without scaling the coefficients factors.
When I select the generation of the output .ceo file the generated file contains the coefficient factors without a fractional part.
Below it is shown some output of it since the platform cannot upload a simple txt file:
; XILINX CORE Generator(tm)Distributed Arithmetic FIR filter coefficient (.COE) File
; Generated by MATLAB(R) 9.14 and DSP System Toolbox 9.16.
; Generated on: 05-Feb-2024 17:59:17
Radix = 16;
Coefficient_Width = 24;
CoefData = 00103c,
0061e1,
00874f,
00e890,
01673d....
When I select numerator word length 24 and a fractional length of 0 bits in order to scale the coefficients to integers the tool does not work as the output is as shown below:
; XILINX CORE Generator(tm)Distributed Arithmetic FIR filter coefficient (.COE) File
; Generated by MATLAB(R) 9.14 and DSP System Toolbox 9.16.
; Generated on: 05-Feb-2024 18:02:55
Radix = 16;
Coefficient_Width = 24;
CoefData = 000000,
000000,
000000,
000000,
000000,
  2 comentarios
Anastasios
Anastasios el 5 de Feb. de 2024
I figured out from the Datasheet of the Xilinx Fir Filter IP Block that the radix 2 or 16 allow only integer values without fractional part.
So the question is how we are scaling the coefficients so that they have no fractional part in the Filter Designer Tool?

Iniciar sesión para comentar.

Respuestas (1)

Raghava S N
Raghava S N el 15 de Feb. de 2024
Hi Anastasios,
The filter coefficients are normalized to the input range and scaled by the Numerator range, which is seen in the Filter Coefficients snapshot you have shared.
With your first snapshot as reference, the filter coefficients are normalized in the Input range, i.e. [-8388608 8388608). This is then scaled by the “Numerator” range, i.e. [-6.25e-02 6.25e-02).
To verify this, you can run hex2dec on any positive value from the COE file and divide it by 8388608. Then multiply this by 6.25e-02. The result of this operation will be the same value displayed in the “Filter Coefficients” Tab in the Filter Designer App.
Concretely, MATLAB uses “coewrite” to create .COE files. By design, “coewrite” fails if you try to export single-precision, double-precision, or floating-point filters as .coe files. Do refer this link for more details on “coewrite” - https://www.mathworks.com/help/dsp/ref/coewrite.html#:~:text=You%20cannot%20export%20single%2Dprecision%2C%20double%2Dprecision%2C%20or%20floating%2Dpoint%20filters%20as%20.coe%20files%2C%20nor%20multiple%2Dsection%20filters
You essentially set the “Filter arithmetic” field in the quantization panel in the Filter Designer App to “Fixed-point” for this reason, so that the filter coefficients can be exported to a .COE file. Hence, there is no need to set “Numerator frac. Length” to 0 in the “Coefficients” tab of the quantization panel.
  1 comentario
Anastasios
Anastasios el 21 de Feb. de 2024
Hi Raghava and thank you for your reply.
What do you mean with the terms normalized and scaled?
The coefficients generated are real numbers (fixed point rational) which when multiplied by a scale factor shall become an integer number with no fractional part, if I want to use coefficients with no fractional part.
The scale factor is what I need to be able to interpret the data after filtering.
It should be just a number that when mulltiplied by the coefficients will result integer coefficients in binary format.
I cannot understand this point then "This is then scaled by the “Numerator” range, i.e. [-6.25e-02 6.25e-02)."

Iniciar sesión para comentar.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by