main content

iir halfband stages in multistage filter design -凯发k8网页登录

this example discusses iir halfband stages in multistage decimators and interpolators.

introduction

rate conversion filters can be implemented efficiently using multistage decimators and interpolators, which are cascades of lowpass filters and downsampling or upsampling blocks. you can use and to obtain such efficient multistage designs. these designs use fir lowpass filters by default (usually a kaiser window or an equiripple design). however, one can replace the fir lowpass filters with iir equivalents, as long as these iir equivalents impart the same filter specifications as the fir stages. similar to the fir multirate filters, iir decimators and interpolators can be implemented efficiently using polyphase structures. iir polyphase filters present several interesting advantages over fir designs. these filters require a very small number of multipliers to implement, thus incur a smaller computational cost. they also have better gain response. the drawbacks presented by iir designs are their nonlinear phase, and potential challenges if implemented in fixed-point, due to instability, sensitivity to quantization, and limit cycles problems. however, in some cases, those drawbacks of iir designs can be addressed.

this example focuses on halfband stages of decimators, but this methodology can be generalized to higher rates, as well for interpolators.

cost efficiency case study

the computational cost of convolution filters is mostly affected by the number of multiplications needed on an average per input sample (mpis). in this example, we measure mpis count as the computational cost of a filter. as a case study, analyze several fir and iir designs for the filter specifications below.

fs  = 9.6e3;   % sampling frequency: 9.6 khz
tw  = 120;     % transition width
ast = 80;      % minimum stopband attenuation: 80 db
m   = 8;       % decimation factor

multistage halfband standard fir design

you can obtain an efficient multistage fir decimator design using designmultistagedecimator. in this example, designing a decimator of rate m=8 using designmultistagedecimator results in a cascade of three fir halfband decimators.

multistagefirdecim = designmultistagedecimator(m,fs,tw,ast)
multistagefirdecim = 
  dsp.filtercascade with properties:
         stage1: [1x1 dsp.firdecimator]
         stage2: [1x1 dsp.firdecimator]
         stage3: [1x1 dsp.firdecimator]
    clonestages: false

this default design achieves a computational cost of 12.875 mpis on average. use the function to determine the numerical cost of the designed filter cascade system object™.

cost(multistagefirdecim)
ans = struct with fields:
                  numcoefficients: 69
                        numstates: 126
    multiplicationsperinputsample: 12.8750
          additionsperinputsample: 12

halfband iir conversion

given the cascade multistagefirdecim, replace every halfband decimator stage with an equivalent iir design. the function redesignhalfbandstages(origdesign, designmethod) shipped with this demo replaces every halfband stage of the cascade origdesign with a system object design using the method specified in designmethod. the design method can be either "elliptic" or "quasi-linear phase".

first, use an elliptic design, which is the iir equivalent of an optimal fir equiripple filter. elliptic designs produce the most efficient iir halfband designs.

multistageiirdecim = redesignhalfbandstages(multistagefirdecim, "elliptic");
cost(multistageiirdecim)
ans = struct with fields:
                  numcoefficients: 11
                        numstates: 17
    multiplicationsperinputsample: 2.5000
          additionsperinputsample: 5

this method achieves computational cost of only 2.5 mpis on average - more than 5x cheaper than the fir design.

magnitude response comparison

overlay the magnitude responses of the fir and iir multirate multistage filters. the two filters look very similar and both meet the specifications.

fvfig = fvtool(multistagefirdecim,multistageiirdecim);
legend(fvfig,'multirate/multistage fir polyphase', 'multirate/multistage iir polyphase')

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 2 objects of type line. these objects represent multirate/multistage fir polyphase, multirate/multistage iir polyphase.

close inspection actually shows the passband ripples of the iir filter to be far superior to that of the fir filter. so computational cost savings don't come at the price of a degraded magnitude response.

zoom(fvfig,[0 0.325 -0.0016 0.0016])

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 2 objects of type line. these objects represent multirate/multistage fir polyphase, multirate/multistage iir polyphase.

quasi-linear phase halfband iir designs

the drawback of iir designs is their nonlinear phase, which may cause distortion. this can be largely mitigated by compensating for the nonlinear phase. it is possible to achieve almost linear phase response using specialized iir design algorithms. the design method "quasi-linear phase" of the dsp.iirhalfbanddecimator achieves an almost linear phase response on the pass band of the filter.

in this method, the iir halfband filter is implemented in a way that includes a pure delay connected in parallel with an allpass filter. this constraint on the implementation helps provide the quasi linear phase response (almost flat group delay). this implementation comes at the expense of a slight increase in the computational cost compared to the elliptic designs.

iirlinearphasefilt = redesignhalfbandstages(multistagefirdecim, "quasi-linear phase");
cost(iirlinearphasefilt)
ans = struct with fields:
                  numcoefficients: 25
                        numstates: 55
    multiplicationsperinputsample: 4.3750
          additionsperinputsample: 8.7500

although not as efficient as the elliptic case, the design is far more efficient than using fir halfband filters.

group delay comparison

overlaying the group delay of the three designs, and focusing on the passband of the filters (the area of interest), we can verify that the latter iir design achieves a nearly flat group delay in that area. in contrast, the elliptic filter, while more efficient (and with a lower group delay overall), has a clearly nonlinear phase response.

fvfig = fvtool(multistagefirdecim, multistageiirdecim, iirlinearphasefilt, analysis='grpdelay');
zoom(fvfig, [0 0.6 0 225]);
legend(fvfig, 'linear-phase fir', 'nonlinear phase elliptic iir', 'quasi-linear phase iir')

figure figure 2: group delay contains an axes object. the axes object with title group delay, xlabel frequency (khz), ylabel group delay (in samples) contains 3 objects of type line. these objects represent linear-phase fir, nonlinear phase elliptic iir, quasi-linear phase iir.

summary

one can choose either fir or iir for multirate designs, depending on the problem specification and requirements. each approach has its own benefits and drawbacks.

  • iir filters have traditionally been considered numerically efficient to meet a given set of specifications, much more than their fir counterparts. they also offer better magnitude response. on the downside, they present a nonlinear phase (which results in a distortion), and could be numerically sensitive.

  • in contrast, fir filters can provide a linear-phase response along with robust numerical behabior (especially in fixed point implementations). however, they are more computationally costly, and suffer from inferior magnitude response compared to iir filters.

utilizing special structures (such as polyphase techniques) can bridge the gaps between the two approaches. polyphase fir filters are more computationally efficient than single-phase. similarly, polyphase iir filters enjoy most of the advantages that fir filters have (numerical stability and near flat group delay) while remaining computationally cheap.

网站地图