Erroneous generated FIR Filter Coefficient File for Xilinx (.coe)
40 次查看(过去 30 天)
显示 更早的评论
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,
回答(1 个)
Raghava S N
2024-2-15
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!