DSPRelated.com
Forums

IIR design / FDATool?

Started by Pete Fraser August 7, 2010
I'm new to Matlab, and to IIR design, so
sorry in advance if these questions are dumb.

I've been playing with filterbuilder and FDATool
just to get familiar with the options / design flow.
There seems to be a lot of overlap.

Why would somebody want to use filterbuilder rather
the FDATool?

Say I design a 6th order, DFII Butterworth LPF,
with Fs = 48000 and Fc = 10800.

I do a fixed point quantization with the default settings.
Input word length is 16, and input fraction length 15.

I assume that means that the input is considered to run
from -1.0 to +(2^15 -1)/2^15. Is that correct?

When the "avoid overflow" box on the output is checked,
it seems to operate as a 16 bit output with a fraction length
of ten bits. Why is that? I would have assumed that, if the
input is considered to have one bit before the point, then
the output would need two bits to accommodate
overshoots in the step response. Why are six bits needed?

I'm not sure what the Magnitude Response Estimate does.
I'm guessing it shows the difference between a white
pseudo-noise input and the associated ouput spectrum.
The response in the stop-band is a combination of the actual
frequncy resposne, and the stop-band noise caused by
pass-band components being quantized. Is that right?

Thanks

Pete




Pete Fraser <pfraser@covad.net> wrote:

>I'm new to Matlab, and to IIR design, so >sorry in advance if these questions are dumb. > >I've been playing with filterbuilder and FDATool >just to get familiar with the options / design flow. >There seems to be a lot of overlap. > >Why would somebody want to use filterbuilder rather >the FDATool? > >Say I design a 6th order, DFII Butterworth LPF, >with Fs = 48000 and Fc = 10800. > >I do a fixed point quantization with the default settings. >Input word length is 16, and input fraction length 15. > >I assume that means that the input is considered to run >from -1.0 to +(2^15 -1)/2^15. Is that correct? > >When the "avoid overflow" box on the output is checked, >it seems to operate as a 16 bit output with a fraction length >of ten bits. Why is that? I would have assumed that, if the >input is considered to have one bit before the point, then >the output would need two bits to accommodate >overshoots in the step response. Why are six bits needed? > >I'm not sure what the Magnitude Response Estimate does. >I'm guessing it shows the difference between a white >pseudo-noise input and the associated ouput spectrum. >The response in the stop-band is a combination of the actual >frequncy resposne, and the stop-band noise caused by >pass-band components being quantized. Is that right?
I guess my first recommendation would be to use fdatool to generate the (full precision) filter coefficients, then do your own quantization study from scratch. This will avoid putting you in the position of having to guess what the tool is doing. Steve
On Sun, 8 Aug 2010 02:06:42 +0000 (UTC), spope33@speedymail.org (Steve
Pope) wrote:

>Pete Fraser <pfraser@covad.net> wrote: > >>I'm new to Matlab, and to IIR design, so >>sorry in advance if these questions are dumb. >>
[Snipped by Lyons]
>> >>I'm not sure what the Magnitude Response Estimate does. >>I'm guessing it shows the difference between a white >>pseudo-noise input and the associated ouput spectrum. >>The response in the stop-band is a combination of the actual >>frequncy resposne, and the stop-band noise caused by >>pass-band components being quantized. Is that right? > >I guess my first recommendation would be to use fdatool to generate >the (full precision) filter coefficients, then do your own quantization >study from scratch. This will avoid putting you in the position >of having to guess what the tool is doing. > > >Steve
Hi Steve, I agree with your advice to Pete. Although I might even go further and suggest that Pete not use the fdatool software either. I say that because some time ago I was experimenting with the fdatool software, on a company computer, and that software seemed a little "buggy" to me. (For example, I designed a high-order tapped-delay line FIR lowpass filter. Then when I tried to view its impulse response, the software gave me an error message!! This is not a good thing.) I believe the safest thing to do is write your own in-line MATLAB code, that way you know exactly what the code is doing. [-Rick-]
Rick Lyons wrote:
> [Much snipped by Owlett] > I believe the safest thing to do is write your own > in-line MATLAB code, that way you know exactly what > the code is doing. >
I would like to paraphrase, for benefit of students and other NEWBIES, as: 'the safest thing to do is write your own {insert tool of choice} code, that way you know exactly what the code is doing. You might also learn why designer made specific choices. Not to mention that you discover holes in your understanding.' By expertise I'm a newbie, by age I'm older than most of group ;)
Richard Owlett  <rowlett@pcnetinc.com> wrote:

>Rick Lyons wrote:
>> I believe the safest thing to do is write your own >> in-line MATLAB code, that way you know exactly what >> the code is doing.
>I would like to paraphrase, for benefit of students and other >NEWBIES, as: >'the safest thing to do is write your own {insert tool of choice} > code, that way you know exactly what the code is doing. You >might also learn why designer made specific choices. Not to >mention that you discover holes in your understanding.'
>By expertise I'm a newbie, by age I'm older than most of group ;)
I doubt you're a newbie in any normal sense of the term. Back to the OP's problem -- it occurs to me that if he is intending to use fdatool's design path through to HDL generation, then he is probably stuck figuring out how the tool's fixed-point modes work, thus making the advice given in this thread of limited value. (But I would still do a grounds-up quantization study independent of the tool even in this case, approaching it as I outlined in response to OP's previous question.) Steve
"Steve Pope" <spope33@speedymail.org> wrote in message 
news:i3n53q$9sq$1@blue.rahul.net...

> Back to the OP's problem -- it occurs to me that if he is intending to > use fdatool's design path through to HDL generation,
I'd be prepared to use the tool's HDL generation, but assumed that it probably wouldn't do what I needed. I have a relatively low sample rate, so I was just going to use a pool of memory and a MAC, and put all the complexity in the memory control. I can't find any way of making the Matlab HDL generator do that (nor did I really expect to).
> then he is > probably stuck figuring out how the tool's fixed-point modes work, > thus making the advice given in this thread of limited value. > > (But I would still do a grounds-up quantization study independent of > the tool even in this case, approaching it as I outlined in > response to OP's previous question.)
I think I'll have to do that. I just need to get some familiarity with Matlab first (any paper / text you could recommend on doing a grounds up quantization study on an IIR?). It seemed to me that the FDATool pretty much did what I needed, but as I began to work with it I realized some of the answers I was getting were counter-intuitive. For relatively wide LPFs, the default quantization choices seem to be reasonable. The noise analysis shows about 60 dB stop-band artifacts, but I can increase accuracy at various points in the filter, and get the performance I need. It's when I try to understand what the various controls mean that I get a bit frustrated. The documentation just expands slightly on the titles of the boxes, but doesn't really explain anything. For example, the default 6th order Butterworth LPF has an input of 16-bits with 15 fractional, and an output of 16-bits with 10 fractional. Why would I need anything more than two bits before the binary pont on the output? Clearly I don't understand what their nomenclature means, but I can't find any detailed information (I know I've repeated myself with a previous question, but I'm hoping someone on the matlab group might answer). Things get worse when I go to higher accuracy and narrower filters. If I start looking at a filter with f3db = 0.05, things get messy. The response is ugly, the stop-band artifacts are extremely high, and the tool does things I don't expect. It doesn't seem to default to higher accuracy in the data path for narrower filters, but when I change to higher accuracy the performance gets much worse. I'm not sure if the tool is broken, I'm ignorant, or a combination of the two (wierd rendering bugs in the GUI don't fill me with confidence though.). I seem to get bad results with any architecture. DF2SOS is weird, but I tried Steve's earlier suggestion of ARMA, and converted a 6th order Butterworth LPF with f3db = 0.05 to ARMA. The floating point response looks fine, but converting to fixed point with the tool's defaults gives me a Magnitude Response Estimate of about -80 dB from DC to Nyquist. Doubling the number of bits everywhere gives me an MRE of -140 dB from DC to Nyquist (note, this is Magnitude Response Estimate -- not Noise Power Spectrum). I've also got to decide whether / what I'm buying from Mathworks (the current system is a loaner). I started off liking its power, but am now thinking it's either buggy or I'm too stupid to use it. Thanks Pete
Pete Fraser <pfraser@covad.net> wrote:

>Things get worse when I go to higher accuracy and narrower filters. >If I start looking at a filter with f3db = 0.05, things get messy. The >response >is ugly, the stop-band artifacts are extremely high, and the tool does >things I don't expect. It doesn't seem to default to higher accuracy in the >data path for narrower filters, but when I change to higher accuracy the >performance gets much worse. I'm not sure if the tool is broken, I'm >ignorant, or a combination of the two (wierd rendering bugs in the GUI don't >fill me with confidence though.).
>I seem to get bad results with any architecture. DF2SOS is weird, but >I tried Steve's earlier suggestion of ARMA, and converted a 6th >order Butterworth LPF with f3db = 0.05 to ARMA. The floating >point response looks fine, but converting to fixed point with the >tool's defaults gives me a Magnitude Response Estimate of about -80 dB >from DC to Nyquist. Doubling the number of bits everywhere gives me >an MRE of -140 dB from DC to Nyquist (note, this is Magnitude >Response Estimate -- not Noise Power Spectrum).
I don't necessarily see the above as bad results, other than the non-controllability of the tool, but I do not know your dynamic range requirements. Maybe you have extreme requirements and will need to use floating point arithmetic in your implementation; that sometimes happens. The last time I had to design a comparable Butterworth filter, it required a dynamic range of about 80 dB, and I ended up with the following precisions in a lattice (ARMA) structure: 22 bit internal data, and 12 bit coefficients. This was a 4th order filter with a passband of 0.01 * Fs. The internal data values required four additional bits to the left of the binary point than did the input value. This seems (roughly) comparable to what you're trying to do. As I mentioned, I like to plot RMS error (in dBc) vs. input signal level (in dB relative to some nominal level) to visualize quantization effects. Such a plot should typically have a flat floor in the middle of the usable range (representing the limits of your coefficient quantization; this includes your stop-band artifacts); it should have a 6 dB/octave slope in the lower-signal range (resulting from the data-path quantization); and a steep saturating effect at high signal levels. If you do not obtain this sort of U-shaped or V-shaped curve, something is seriously wrong. (I do not think this is one of the plots fdatool likes to spit out on its own.) Steve
Steve Pope <spope33@speedymail.org> wrote:

>it should have a >6 dB/octave slope in the lower-signal range (resulting from the data-path >quantization);
Oops.. meant to say a slope of one (6dB per 6dB). S.
"Steve Pope" <spope33@speedymail.org> wrote in message 
news:i3nu2p$u18$1@blue.rahul.net...
> Pete Fraser <pfraser@covad.net> wrote:
>>but converting to fixed point with the >>tool's defaults gives me a Magnitude Response Estimate of about -80 dB >>from DC to Nyquist. Doubling the number of bits everywhere gives me >>an MRE of -140 dB from DC to Nyquist (note, this is Magnitude >>Response Estimate -- not Noise Power Spectrum). > > I don't necessarily see the above as bad results, other than the > non-controllability of the tool,
Perhaps we're talking at cross purposes here, or there's something I don't understand. The Magnitude response estimate is -80 dB at DC. It should be 0 dB in the passband.
> but I do not know your dynamic > range requirements. Maybe you have extreme requirements and will > need to use floating point arithmetic in your implementation; > that sometimes happens.
I don't think so. 96 dB should be fine. I've got ample FPGA, and the data rate is slow, so I can go to very high fixed-point accuracy if I need to.
> The last time I had to design a comparable Butterworth filter, it required > a dynamic range of about 80 dB, and I ended up with the following > precisions in a lattice (ARMA) structure: 22 bit internal data, and 12 > bit coefficients. This was a 4th order filter with a passband > of 0.01 * Fs. The internal data values required four additional > bits to the left of the binary point than did the input value. > This seems (roughly) comparable to what you're trying to do.
It does. I need 6th order, and 96 dB dynamic range, but I've been setting FDATool to much greater coefficient accuracies and data-path resolutions than you're suggesting. There must be some aspect of the tool I'm not understanding (or, as Rick Lyons suggested, there are problems with it).
> As I mentioned, I like to plot RMS error (in dBc) vs. input signal level > (in dB relative to some nominal level) to visualize quantization > effects. Such a plot should typically have a flat floor in the middle of > the usable range (representing the limits of your coefficient > quantization; this includes your stop-band artifacts); it should have a > 6 dB/octave slope in the lower-signal range (resulting from the data-path > quantization); and a steep saturating effect at high signal levels. If > you do not obtain this sort of U-shaped or V-shaped curve, something is > seriously wrong.
I'll give that a try. Do you use Matlab for this? If so, what toolboxes do you need? The Mathworks is going to want money from me soon, and I'll need to decide what tool boxes to buy.
> > (I do not think this is one of the plots fdatool likes to spit out on > its own.)
It's not. Thanks Pete
Pete Fraser <pfraser@covad.net> wrote:

>"Steve Pope" <spope33@speedymail.org> wrote in message
>> Pete Fraser <pfraser@covad.net> wrote:
>>>but converting to fixed point with the >>>tool's defaults gives me a Magnitude Response Estimate of about -80 dB >>>from DC to Nyquist. Doubling the number of bits everywhere gives me >>>an MRE of -140 dB from DC to Nyquist (note, this is Magnitude >>>Response Estimate -- not Noise Power Spectrum).
>> I don't necessarily see the above as bad results, other than the >> non-controllability of the tool,
>Perhaps we're talking at cross purposes here, or there's something >I don't understand. The Magnitude response estimate is -80 dB >at DC. It should be 0 dB in the passband.
Okay that's not good. But it looked okay in full floating point? Do you have the option of quantizing just the coefficients, and not the data path? That is the first step. What precision coefficients results in a 80 dB response error at DC?
>It does. I need 6th order, and 96 dB dynamic range, but I've >been setting FDATool to much greater coefficient accuracies and >data-path resolutions than you're suggesting. There must be some >aspect of the tool I'm not understanding (or, as Rick Lyons suggested, >there are problems with it).
Yes, it's not sure it is worth the time to sort this out, when you have just one filter to design. The (full-precision) coefficients themselves are probably good; and you can just go with them in a design. However it seems the tool is not helping you make other design decisions, such as DF vs. ARMA, or helping you study precisions. Steve