FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
6424 Discussions

FIR Compiler II fractional signed fractional binary (integer bits output width)

Honored Contributor II

Hi all! 


I'm using FIR Compiler II for some time, and now I have a question about it. 


My point is to have a unity gain after filter for a purpose of temperature filtering, so I use test constant input to calculate filter gain and delete filter output by that gain. 

I choose signed fractional binary format. 


So, I'm using lowpass FIR (20 coeffs moving average (each coeff = 0.05)), input data type is signed fractional binary (24 fractional, 8 integer, 32 total) and coefficient data type signed fractional binary (1 bit).  

Filter generates Output Full Bit Width 39 bit, Output Full Fractional Bit Width 25 bit, so that means that integer part consists of 14 bit. 


I tested filter with a constant input (0x01880000 equals 24.5 Celsius) and received output, which first 14 bits were: 00000011110101 (245 dec). But that means that filter gain is 10 (dec), when I'm expected to see 20 (dec). 


It's not a problem to use that coefficient, but I can't understand why filter behaves like that. I tested another lowpass FIR (101 coeffs, and coeffs were not equal), input data type was still signed fractional binary (24 fractional) and coefficient data type signed fractional binary (12 bit), and filter generated output with 16 bit integer width, and its coefficient gain was much closer to the amount of coefficients (about 101). 


So my question is, why in my first test (20 coeffs moving average) filter gain is a half of the coefficints amount, and in second test it was about the amount of filter coefficients?
0 Kudos
1 Reply
Honored Contributor II

Hi vanoDNK! 


I'm your mirror copy from future! 


The answer is something like that: 


If the Fractional bit width of coefficients is 1, when you see in the fixed point value of fir compiler II "1", it is actually 0.5 (decimal), if you select the coefficient fractional bit width as 2 bits, then the fixed point value became "3" (decimal), and it is actually 0.75 (0.5 + 0.25). So the filter output gain tend to be a sum of coeffs with the rsie of coeff bit width number. And if you select Fractional bit width of coeffs as "1", than filter output gain will be only a half of number of coeffs (true if all coeffs are equal as for moving average filter).
0 Kudos