From: Pete Fraser on
"Steve Pope" <spope33(a)speedymail.org> wrote in message
news:i3nu2p$u18$1(a)blue.rahul.net...
> Pete Fraser <pfraser(a)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


From: Steve Pope on
Pete Fraser <pfraser(a)covad.net> wrote:

>"Steve Pope" <spope33(a)speedymail.org> wrote in message

>> Pete Fraser <pfraser(a)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
From: Pete Fraser on
"Steve Pope" <spope33(a)speedymail.org> wrote in message
news:i3p8af$btu$1(a)blue.rahul.net...
> Pete Fraser <pfraser(a)covad.net> wrote:

>>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?

Yes.

> Do you have the option of quantizing just the coefficients, and
> not the data path? That is the first step.

Unfortunately not.

>>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.

I've got many filters to design (on this project).
Also, I think Matlab will be a good tool for future projects.
In the past almost all my projects were video.
Recently I've been doing audio and data acquisition, hence the
interest in IIR.

> 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.

The Matlab sales guy said that I could do a phone conference with
a Matlab support guy if I needed talked through something.
Maybe I'll take him up on that.

Pete


From: Steve Pope on
Pete Fraser <pfraser(a)covad.net> wrote:

>"Steve Pope" <spope33(a)speedymail.org> wrote in message

>> Pete Fraser <pfraser(a)covad.net> wrote:

>>>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?

>Yes.

>> Do you have the option of quantizing just the coefficients, and
>> not the data path? That is the first step.

>Unfortunately not.

For the tool to be useful, it must let you conduct experiments
in the right order. It sounds like it does not allow this,
or at least you haven't figured out how to coerce it into doing so.

It does not take too long to write, in MATLAB or C or C++, functions
to quantize double precision floating point values into
IEEE 1666 fixed-point values in one or two of the most useful
modes ("saturating, rounding" mode being the single most useful
for your purposes; it is often reasaonable to do an entire design
in just this mode). Or you can dig around online for such code.

There is only an issue if your fixed-point words exceed 52 bits
wide in which case they cannot be directly stored in a double.

>The Matlab sales guy said that I could do a phone conference with
>a Matlab support guy if I needed talked through something.
>Maybe I'll take him up on that.

That's a good plan. If you go through that excercise, and it
still is not doing what you want, that's a bad sign for the tool.

Steve
From: robert bristow-johnson on
On Aug 7, 9:26 pm, "Pete Fraser" <pfra...(a)covad.net> wrote:
> I'm new to Matlab, and to IIR design, so
> sorry in advance if these questions are dumb.
>

there are no dumb questions, just dumb cliches.

> 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?

dunno. i haven't used either.

> 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.

okay, right here is a little problem. if you have double-wide (32
bit) words for the product of 16x16 multiplication, and if you can add
those numbers full precision until you're done and then quantize to 16
bit, then you should not use DF2. you should use DF1 instead. your
6th-order filter will have 8 states instead of 6 (big deeeel) but
you'll do much better in terms of signal quantization error and
saturation error, particularly if the filter is resonant (which each
section of the Butterworth is).

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

sure, why not? as far as the signal is concerned, it's just a scaling
factor. and the same for the feedforward coefficients {b0, b1, b2}.
but, for the feedback coefs {a1, a2}, their scale matters. although |
a2| is less than 1 (for a stable filter), |a1| can be nearly as big as
2.

> 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?

it might not be a step response that causes the worst overflow. a
resonant filter can have much greater gain (as the resonant frequency)
than even 5 extra guard bits will accommodate. but it's not likely.

> 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 output spectrum.
> The response in the stop-band is a combination of the actual
> frequency response, and the stop-band noise caused by
> pass-band components being quantized. Is that right?

dunno, i'd just be guessing.

r b-j