cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Explorer
1,391 Views
Registered: ‎10-16-2018

## FIR filter amplitude

Hi,

I used FIR filter for my system, and I imported the coeffecients form matlab using FDA tool.

In matlab (FDA tool), I set the stop band to - 80 dB and the pass band to 0 dB, as indicated in the first attached picture.

But when openning the the coeffeceint file in Vivado by FIR IP block and checking the frequency response of the filter, the situation was different. In fact, the pass band is 125 dB ! and stop band is 50 dB ! I think these are wrong values. How to modify these values in order to be the same of FDA matlab tool ?

Thanks.

1 Solution

Accepted Solutions
Voyager
1,315 Views
Registered: ‎08-16-2018

That's something you can (should) play with. If you select for your coefficients 'Quantize Only' in Quantization, you can have, for example, 16-bit coeffs with 8 fractional bits. If you increase your coeff size to 24 bits, the fractional part can be up to 16 bits. So your coeffs will always be at least 8 bits wide (the integer part).

Now, your data can be, for example, 32-bit wide and 32 fractional bits. That's good enough for many applications.

What happens is (I just realized that) your data is always scaled up because of the coefficients having and integer part of 8 bits min. So you need to scale down the values either before or after (better) the filter.

With regards to precision, 16-bit coeffs and 32-bit data is good enough. When using integer arithmetics there is always this trade-off, it's something you need to play with and choose a solution is good enough for you.

7 Replies
Voyager
1,378 Views
Registered: ‎08-16-2018

Are you using FIR Compiler 7.2?

One thing you can try is to copy-paste the coefficient vector. If too long, simplify your filter to have less coefficients, just to see where the difference comes from.

My first suspicion is about coefficient representation. In the implementation tab, in 'Data Path Options' you specify the datawidth (default 16) and number of fractional bits (default 0). This means your coefficients are integer 0 - 65535 and maybe your coefficients are real numbers 0.0 - 1.0 and artificially multiplied by 65536 (96 dB). Check that.

Explorer
1,369 Views
Registered: ‎10-16-2018

Hi @johnvivm ,

Kindly, see the attched two pictures of implemenatation tab settings. I didn't understand why I have to set the output data with to 16 bits ! That 's mean severely I have to truncate my output. Since the full precision is 38 bits of the fir compileer output.

Voyager
1,368 Views
Registered: ‎08-16-2018

Also, with your FDAtool your passband is around 56-57 kHz, while in your FIR it's slightly shifted to 0.58 - 0.59 and looks narrower and there are less side lobes, looks like a much lower order response, is it really the same thing?

Explorer
1,364 Views
Registered: ‎10-16-2018

Hi @johnvivm ,

About the passband frequency. It is the same in FDA tool (55.5 - 57 KHz) and in Xilinx FIR compiler we have normalized values, so it is calculated as follow :

0.578 * 192000(Fs)/ 2 = 55.5 kHz,

0.594 * 192000 / 2 = 57 kHz,

Thanks,

Voyager
1,316 Views
Registered: ‎08-16-2018

That's something you can (should) play with. If you select for your coefficients 'Quantize Only' in Quantization, you can have, for example, 16-bit coeffs with 8 fractional bits. If you increase your coeff size to 24 bits, the fractional part can be up to 16 bits. So your coeffs will always be at least 8 bits wide (the integer part).

Now, your data can be, for example, 32-bit wide and 32 fractional bits. That's good enough for many applications.

What happens is (I just realized that) your data is always scaled up because of the coefficients having and integer part of 8 bits min. So you need to scale down the values either before or after (better) the filter.

With regards to precision, 16-bit coeffs and 32-bit data is good enough. When using integer arithmetics there is always this trade-off, it's something you need to play with and choose a solution is good enough for you.

Explorer
1,115 Views
Registered: ‎10-16-2018

Hi @johnvivm ,

@johnvivm wrote:

What happens is (I just realized that) your data is always scaled up because of the coefficients having and integer part of 8 bits min. So you need to scale down the values either before or after (better) the filter.

How to "scale down the values" ?

Thanks.

Voyager
1,085 Views
Registered: ‎08-16-2018

"scale down" is a technicism for "divide" to look more clever than a schoolboy.

The most economic way of scaling down is dividing by 2,4,8, etc. by shifting (or simply not using) the lowest bits.

For example when you assign:

`v2 <= v1(15 downto 3);`

you are scaling down by 8