DSPRelated.com
Forums

FIR filter verification

Started by Sharan123 October 5, 2015
Hello All,

My area of expertise is verification of functions and have theoretical
exposure to DSP.

To get started with some practical exercises, I have started working on a
simple filter.

Basically, I have designed a moving average filter with co-efficient - 0.2
0.2 0.2 0.2 0.2
I have used two stimulus' currently to do a sanity check if the
implementation is working.

Firstly, I have passed an impulse input to the filer. This gives me
co-efficient as the output, which is what I expected.
Next, I have passed a sine wave and indeed get delayed sine wave as the
output.

I am interested in a more formal & rigorous verification of the filter and
of course, I would like to do this with minimum number of tests. But to be
frank, I am not able to see how to get started with this.

I am sharing some of the thoughts I have in mind but don't know how to go
about this.

I know I can sweep sine waveforms of different frequencies as input to the
filter and see the output. Beyond a point in frequency, the sine should be
attenuated. But is this the most efficient way to test an FIR filter? Even
if this was a good method, how can I verify (by not looking at waveform)
that output is okay? Would measuring SNR help here to have a formal method
to validate the filter response?

Can I take frequency response of impulse input and see where the power
lies? Would this help in anyway to validate the filter behavior?

I need some guidance please ...
---------------------------------------
Posted through http://www.DSPRelated.com
On Monday, October 5, 2015 at 9:31:06 AM UTC-4, Sharan123 wrote:
> Hello All, > > My area of expertise is verification of functions and have theoretical > exposure to DSP. > > To get started with some practical exercises, I have started working on a > simple filter. > > Basically, I have designed a moving average filter with co-efficient - 0.2 > 0.2 0.2 0.2 0.2 > I have used two stimulus' currently to do a sanity check if the > implementation is working. > > Firstly, I have passed an impulse input to the filer. This gives me > co-efficient as the output, which is what I expected. > Next, I have passed a sine wave and indeed get delayed sine wave as the > output. > > I am interested in a more formal & rigorous verification of the filter and > of course, I would like to do this with minimum number of tests. But to be > frank, I am not able to see how to get started with this. > > I am sharing some of the thoughts I have in mind but don't know how to go > about this. > > I know I can sweep sine waveforms of different frequencies as input to the > filter and see the output. Beyond a point in frequency, the sine should be > attenuated. But is this the most efficient way to test an FIR filter? Even > if this was a good method, how can I verify (by not looking at waveform) > that output is okay? Would measuring SNR help here to have a formal method > to validate the filter response? > > Can I take frequency response of impulse input and see where the power > lies? Would this help in anyway to validate the filter behavior? > > I need some guidance please ... > --------------------------------------- > Posted through http://www.DSPRelated.com
You want to validate your coefficients, your FIR filter code (assuming that's what you are using, could be IIR filter code with coefficients properly loaded), or both? Dirk
On Mon, 05 Oct 2015 08:30:59 -0500, Sharan123 wrote:

> Hello All, > > My area of expertise is verification of functions and have theoretical > exposure to DSP. > > To get started with some practical exercises, I have started working on > a simple filter. > > Basically, I have designed a moving average filter with co-efficient - > 0.2 0.2 0.2 0.2 0.2 I have used two stimulus' currently to do a sanity > check if the implementation is working. > > Firstly, I have passed an impulse input to the filer. This gives me > co-efficient as the output, which is what I expected. > Next, I have passed a sine wave and indeed get delayed sine wave as the > output. > > I am interested in a more formal & rigorous verification of the filter > and of course, I would like to do this with minimum number of tests. But > to be frank, I am not able to see how to get started with this. > > I am sharing some of the thoughts I have in mind but don't know how to > go about this. > > I know I can sweep sine waveforms of different frequencies as input to > the filter and see the output. Beyond a point in frequency, the sine > should be attenuated. But is this the most efficient way to test an FIR > filter? Even if this was a good method, how can I verify (by not looking > at waveform) that output is okay? Would measuring SNR help here to have > a formal method to validate the filter response? > > Can I take frequency response of impulse input and see where the power > lies? Would this help in anyway to validate the filter behavior?
The one thing missing from your question, which boggles my mind a bit since you're talking about testing, is the specified behavior of the filter. Shouldn't testing be making sure that the filter behaves as specified? So -- how is the filter specified? Some things that I would look for to verify filter software would be, in order: * That it has the correct impulse response. * That it responds correctly to more complex inputs -- giving it a step may or may not be enough here. * That it either does not exhibit nonlinearities when excited with a worst-case input, or that the nonlinearities it does exhibit are specified and desirable. * That it does not unduly load the processor (assuming that it must work in real time). This should probably be tested both when it is working entirely in its linear range and when nonlinearities are being encountered, particularly if the filter code deals with nonlinearities using conditionals. * That it does not exhibit more than specified quantization anomalies (or noise, if you want to spec it that way). Strictly speaking this comes under nonlinear behavior, but most people separate the two. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
> > * That it either does not exhibit nonlinearities when excited with a > worst-case input, or that the nonlinearities it does exhibit are > specified and desirable. >
this is an important and can be complicated issue. specify and test the filter to see what inputs will create an internal overflow Mark
On Mon, 05 Oct 2015 11:40:31 -0700, makolber wrote:


>> * That it either does not exhibit nonlinearities when excited with a >> worst-case input, or that the nonlinearities it does exhibit are >> specified and desirable. >> >> > this is an important and can be complicated issue. > > specify and test the filter to see what inputs will create an internal > overflow
Yes! It is! Particularly if it's an IIR rather than a FIR filter -- FIR filters tend to be about an order of magnitude more straightforward to analyze and verify in this regard than IIR filters. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
> >Basically, I have designed a moving average filter with co-efficient -
0.2
>0.2 0.2 0.2 0.2 >I have used two stimulus' currently to do a sanity check if the >implementation is working. >
you said it correctly, you want to verify implementation rather than concept. I wouldn't worry about impulse response, nonlinearity, frequency response etc. that is all to do with verification of concept and is waste of time at implementation. All you need some random data as input and a simple fir mathematical model that is proven (Matlab) and check output of your design Vs model output. Kaz --------------------------------------- Posted through http://www.DSPRelated.com
On Mon, 05 Oct 2015 15:30:57 -0500, kaz wrote:


>>Basically, I have designed a moving average filter with co-efficient - > 0.2 >>0.2 0.2 0.2 0.2 I have used two stimulus' currently to do a sanity check >>if the implementation is working. >> >> > you said it correctly, you want to verify implementation rather than > concept. > I wouldn't worry about impulse response, nonlinearity, frequency > response etc. that is all to do with verification of concept and is > waste of time at implementation. All you need some random data as input > and a simple fir mathematical model that is proven (Matlab) and check > output of your design Vs model output.
To that it's probably a good idea to add an input stimulus purposely designed to cause overflow (if the filter is designed to allow it) to make sure that it is handled correctly. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Mon, 05 Oct 2015 15:43:20 -0500, Tim Wescott
<seemywebsite@myfooter.really> wrote:

>On Mon, 05 Oct 2015 15:30:57 -0500, kaz wrote: > > >>>Basically, I have designed a moving average filter with co-efficient - >> 0.2 >>>0.2 0.2 0.2 0.2 I have used two stimulus' currently to do a sanity check >>>if the implementation is working. >>> >>> >> you said it correctly, you want to verify implementation rather than >> concept. >> I wouldn't worry about impulse response, nonlinearity, frequency >> response etc. that is all to do with verification of concept and is >> waste of time at implementation. All you need some random data as input >> and a simple fir mathematical model that is proven (Matlab) and check >> output of your design Vs model output. > >To that it's probably a good idea to add an input stimulus purposely >designed to cause overflow (if the filter is designed to allow it) to >make sure that it is handled correctly. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com
For exampe, a string of input samples at max value can help reveal overflow issues, likewise a string of input samples at min value. For filters with coefficients with differing signs, a string of max-valued input samples with signs arranged to yield the largest possible output can also be revealing. etc., etc... Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Tim Wescott  <seemywebsite@myfooter.really> wrote:

>To that it's probably a good idea to add an input stimulus purposely >designed to cause overflow (if the filter is designed to allow it) to >make sure that it is handled correctly.
I agree. Whenever possible, I will generate a curve over the entire dynamic range -- that is, sweep the magnitude of the test signal applied to the inputs from "below noise" to "above saturation", and graph the RMS error (expressed in dBc) vs. input level (expressed in dB). Such a graph should have a wide region where the dBc error is satisfactorily low, corresponding the operating region, and will have degraded (higher) dBc error at both low and high input levels, corresponding to quantization and saturation/overflow errors respectively. Good test signals are sinusoids, and also lowpass-filtered white noise. Steve
On 10/5/15 5:16 PM, Eric Jacobsen wrote:
> On Mon, 05 Oct 2015 15:43:20 -0500, Tim Wescott > <seemywebsite@myfooter.really> wrote: > >> On Mon, 05 Oct 2015 15:30:57 -0500, kaz wrote: >> >> >>>> Basically, I have designed a moving average filter with co-efficient - >>> 0.2 >>>> 0.2 0.2 0.2 0.2 I have used two stimulus' currently to do a sanity check >>>> if the implementation is working. >>>> >>>> >>> you said it correctly, you want to verify implementation rather than >>> concept. >>> I wouldn't worry about impulse response, nonlinearity, frequency >>> response etc. that is all to do with verification of concept and is >>> waste of time at implementation. All you need some random data as input >>> and a simple fir mathematical model that is proven (Matlab) and check >>> output of your design Vs model output. >> >> To that it's probably a good idea to add an input stimulus purposely >> designed to cause overflow (if the filter is designed to allow it) to >> make sure that it is handled correctly. >>
...
> For example, a string of input samples at max value can help reveal > overflow issues, likewise a string of input samples at min value. > For filters with coefficients with differing signs, a string of > max-valued input samples with signs arranged to yield the largest > possible output can also be revealing.
i.e. x[n] = sgn{ h[n0-n] } for 0 < n <= n0 and n0 >= L, the length of the FIR. to me, that (assuming that max |x[n]| = 1) would decidedly be the acid test for detecting overflow. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."