close

Вход

Забыли?

вход по аккаунту

?

Practical FIR Filter Design in MATLAB

код для вставкиСкачать
Ricardo A. Losada
PracticalFIRFilterDesigninMATLAB
R
Revision1.1
RicardoA.LosadaTheMathWorks,Inc.3AppleHillDr.Natick,MA01760,USA
January12,2004Abstract
Thistutorialwhite-paperillustratespracticalaspectsofFIR
filterdesignandfixed-pointimplementationalongwiththe
algorithmsavailableintheFilterDesignToolboxandtheSignalProcessingToolboxforthispurpose.
Theemphasisismostlyonlowpassfilters,butmanyofthe
resultsapplytootherfiltertypesaswell.
Thetutorialfocusesonpracticalaspectsoffilterdesign
andimplementation,andontheadvantagesanddisadvan-
tagesofthedifferentdesignalgorithms.Thetheorybehind
thedesignalgorithmsisavoidedexceptwhenneededtomo-
tivatethem.
Contents
1Ideallowpassfilter22FIRlowpassfilters22.1FIRfilterdesignspecifications......23OptimalFIRdesignswithfixedtransition
widthandfilterorder33.1Linear-phasedesigns...........43.1.1Equiripplefilters.........43.1.2Least-squaresfilters.......43.2Nonlinear-phasedesigns.........53.2.1Minimum-phasedesigns.....53.2.2Moregeneralnonlinear-phasede-
signs...............63.2.3Awordonpracticalimplementation74Optimalequirippledesignswithfixedtransi-
tionwidthandpeakpassband/stopbandripple74.1Minimum-phasedesignswithfixedtran-
sitionwidthandpeakpassband/stopband
ripple...................85Optimalequirippledesignswithfixedpeakrip-
pleandfilterorder85.1Minimum-phasedesignswithfixedpeak
rippleandfilterorder...........96Otherequirippledesigns96.1Constrained-bandequirippledesigns...96.2Slopedequiripplefilters..........107Advanceddesignalgorithms-interpolatedFIR
filters107.1FurtherIFIRoptimizations........127.2MultirateimplementationofIFIRdesign.138Interpolationfilterdesign138.1Idealband-limitedinterpolationinthe
frequencydomain.............148.2Idealband-limitedinterpolationinthe
timedomain................158.3DesignofFIRinterpolationfilters....168.3.1NyquistFIRfilters........178.3.2Halfbandfilters..........178.3.3OtherNyquistfilters.......179Designofperfect-reconstructiontwo-channel
FIRfilterbanks181
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage210ImplementinganFIRfilterusingfixed-point
arithmetic2010.1Somenotation...............2110.2Quantizingthecoefficients........2110.3Fixed-pointfiltering............2210.3.1Usinganaccumulatorwithex-
tendedprecision.........2511Adesignexample2611.1Usingthe4016forGSM.........2711.1.1DesigningtheCFIRfilter.....2711.1.2DesigningthePFIRfilter.....28ARevisionhistory311Ideallowpassfilter
Theideallowpassfilterisonethatallowsthroughallfre-
quencycomponentsofasignalbelowadesignatedcutoff
frequency
c
,andrejectsallfrequencycomponentsofa
signalabove
c
.
Itsfrequencyresponsesatisfies
H
LP
(e
j
) =
1,0≤≤
c
0,
c
<≤
(1)
Theimpulseresponseoftheideallowpassfilter(1)can
easilybefoundtobe[1]
h
LP
[n] =
sin(
c
n)n
,−<n<.(2)
2FIRlowpassfilters
Becausetheimpulseresponserequiredtoimplementthe
ideallowpassfilterisinfinitelylong,itisimpossibleto
designanidealFIRlowpassfilter.
Finitelengthapproximationstotheidealimpulsere-
sponseleadtothepresenceofripplesinboththepassband
(<
c
)andthestopband(>
c
)ofthefilter,aswell
astoanonzerotransitionwidthbetweenthepassbandand
stopbandofthefilter(seeFigure1).Figure1:Illustrationofthetypicaldeviationsfromtheideal
lowpassfilterwhenapproximatingwithanFIRfilter,
c
=0.4.2.1FIRfilterdesignspecifications
Boththepassband/stopbandripplesandthetransition
widthareundesirablebutunavoidabledeviationsfromthe
responseofanideallowpassfilterwhenapproximating
withafiniteimpulseresponse.PracticalFIRdesignstyp-
icallyconsistoffiltersthatmeetcertaindesignspecifi-
cations,i.e.,thathaveatransitionwidthandmaximum
passband/stopbandripplesthatdonotexceedallowable
values.
Inaddition,onemustselectthefilterorder,orequiva-
lently,thelengthofthetruncatedimpulseresponse.
AusefulmetaphorforthedesignspecificationsinFIR
designistothinkofeachspecificationasoneoftheangles
inatriangleasinFigure2.
Themetaphorisusedtounderstandthedegreesof
freedomavailablewhendesignatingdesignspecifications.
Becausethesumoftheanglesisfixed,onecanatmost
selectthevaluesoftwoofthespecifications.Thethird
specificationwillbedeterminedbythedesignalgorithm
utilized.Moreover,aswiththeanglesinatriangle,ifwe
makeoneofthespecificationslarger/smaller,itwillim-
pactoneorbothoftheotherspecifications.
Asanexample,considerthedesignofanFIRfilterthat
meetsthefollowingspecifications:SpecificationsSet1
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage3Figure2:FIRdesignspecificationsrepresentedasatriangle.1.Cutofffrequency:0.4rad/sample2.Transitionwidth:0.06rad/sample3.Maximumpassband/stopbandripple:0.05
Thefiltercaneasilybedesignedwiththetruncated-and-
windowedimpulseresponsealgorithmimplementedin
fir1 (orusingfdatool)ifweuseaKaiserwindow.
Thezero-phaseresponseofthefilterisshowninFigure3.Notethatsincewehavefixedtheallowabletransition
widthandpeakripples,theorderisdeterminedforus.
Closeexaminationatthepassband-edgefrequency,
p
= 0.371andatthestopband-edgefrequency
s
=
0.43showsthatthepeakpassband/stopbandripplesare
indeedwithintheallowablespecifications.Usuallythe
specificationsareexceededbecausetheorderisrounded
tothenextintegergreaterthantheactualvaluerequired.1
Thepassband-edgefrequencyistheboundarybetweenthepassband
andthetransitionband.IfthetransitionwidthisTW,thepassband-
edgefrequency
p
isgivenintermsofthecutofffrequency
c
by
p
=
c−TW/2Similarly,thestopband-edgefrequencyisgivenby
s
=
c+TW/2.Figure3:Kaiserwindowdesignmeetingpredescribedspecifi-
cations.3OptimalFIRdesignswithfixed
transitionwidthandfilterorder
Whilethetruncated-and-windowedimpulseresponsede-
signalgorithmisverysimpleandreliable,itisnotop-
timalinanysense.Thedesignsitproducesaregener-
allyinferiortothoseproducedbyalgorithmsthatemploy
someoptimizationcriteriainthatitwillhavegreateror-
der,greatertransitionwidthorgreaterpassband/stopband
ripples.Anyoftheseistypicallyundesirableinpractice,
thereforemoresophisticatedalgorithmscomeinhandy.
Optimaldesignsarecomputedbyminimizingsome
measureofthedeviationbetweenthefiltertobedesigned
andtheidealfilter.ThemostcommonoptimalFIRdesign
algorithmsarebasedonfixingthetransitionwidthandthe
orderofthefilter.Thedeviationfromtheidealresponse
ismeasuredonlybythepassband/stopbandripples.This
deviationorerrorcanbeexpressedmathematicallyas[2]
E() =H
a
() −H
LP
(e
j
),∈
whereH
a
() isthezero-phaseresponseofthedesigned
filterand=[0,
p
] ∪[
s
,].Itisstillnecessarytode-
fineameasuretodetermine“thesize”ofE() -thequan-
titywewanttominimizeasaresultoftheoptimization.
ThemostoftenusedmeasuresaretheL
-norm(E()
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage4-minimaxdesigns)andtheL
2
-norm(E()
2
-least-
squaresdesigns).
Inordertoallowfordifferentpeakripplesinthepass-
bandandstopband,aweightingfunction,W() isusually
introduced,
E
W
() =W()[H
a
() −H
LP
(e
j
)],∈
3.1Linear-phasedesigns
Afilterwithlinear-phaseresponseisdesirableinmany
applications,notablyimageprocessinganddatatransmis-
sion.OneofthedesirablecharacteristicsofFIRfiltersis
thattheycanbedesignedveryeasilytohavelinearphase.
Itiswellknown[3]thatlinear-phaseFIRfilterswillhave
impulseresponsesthatareeithersymmetricorantisym-
metric.Forthesetypesoffilters,thezero-phaseresponse
canbedeterminedanalytically[3],andthefilterdesign
problembecomesawellbehavedmathematicalapprox-
imationproblem[4]:Determinethebestapproximation
toagivenfunction-theideallowpassfilter’sfrequency
response-bymeansofapolynomial-theFIRfilter-of
givenorder-thefilterorder-.By“best”itismeanttheone
whichminimizesthedifferencebetweenthem-E
W
() -
accordingtoagivenmeasure.
Theremez functionimplementsanalgorithmdevel-
opedin[5]thatcomputesasolutiontothedesignproblem
forlinear-phaseFIRfiltersintheL
-normcase.Thede-
signproblemisessentiallytofindafilterthatminimizes
themaximumerrorbetweentheidealandactualfilters.
Thistypeofdesignleadstoso-calledequiripplefilters,
i.e.filtersinwhichthepeakdeviationsfromtheidealre-
sponseareallequal.
Thefirls functionimplementsanalgorithmtocom-
putesolutionforlinear-phaseFIRfiltersintheL
2
-norm
case.Thedesignproblemistofindafilterthatminimizes
theenergyoftheerrorbetweenidealandactualfilters.
3.1.1Equiripplefilters
Linear-phaseequiripplefiltersaredesirablebecausethey
havethesmallestmaximumdeviationfromtheidealfil-
terwhencomparedtoallotherlinear-phaseFIRfiltersof
thesameorder.Equiripplefiltersareideallysuitedforap-
plicationsinwhichaspecifictolerancemustbemet.For
example,ifitisnecessarytodesignafilterwithagivenFigure4:PassbandrippleforofboththeKaiser-window-
designedFIRfilterandtheremez-designedFIRfilter.minimumstopbandattenuationoragivenmaximumpass-
bandripple.
ForexampletheKaiser-windowdesignofSection2.1wasof42ndorder.Withthissameorder,anequiripple
filter(withfixedtransitionwidth)canbedesignedthatis
superiortotheKaiser-windowdesign:br = remez(42,[0 0.37 0.43 1],[1 1 0 0]);
Figure4showsthesuperpositionofthepassbandde-
tailsforthefiltersdesignedwiththeKaiserwindowand
withtheremez function.Clearlythemaximumdeviation
issmallerfortheremez design.Infact,sincethefilteris
designedtominimizethemaximumripple(minimaxde-
sign),weareguaranteedthatnootherlinear-phaseFIR
filterof42ndorderwillhaveasmallerpeakrippleforthe
sametransitionwidth.
3.1.2Least-squaresfilters
Equirippledesignsmaynotbedesirableifwewantto
minimizetheenergyoftheerror(betweenidealandac-
tualfilter)inthepassband/stopband.Consequently,ifwe
wanttoreducetheenergyofasignalasmuchaspossi-
bleinacertainfrequencyband,least-squaresdesignsare
preferable.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage5Figure5:ComparisonofanoptimalequirippleFIRdesignand
anoptimalleast-squaresFIRdesign.Theequiripplefilterhasa
smallerpeakerror,butlargeroverallerror.Forexample,forthesametransitionwidthandfilter
orderastheequiripplefilterdesignedinSection3.1.1,a
least-squaresFIRdesigncanbecomputedfrombls = firls(42,[0 0.37 0.43 1],[1 1 0 0]);
Thestopbandenergyforthiscaseisgivenby
E
sb
=
12
0.43
|H
a
(e
j
)|
2
d
whereH
a
(e
j
) isthefrequencyresponseofthefilter.
Inthiscase,thestopbandenergyfortheequiripplefilter
isapproximately1.7608e-004whilethestopbandenergy
fortheleast-squaresfilteris3.3106e-005.(Asareference,
thestopbandenergyfortheKaiser-windowdesignforthis
orderandtransitionwidthis6.1646e-005).
Sowhiletheequirippledesignhaslesspeakerror,it
hasmore“total”error,measuredintermsofitsenergy.
Thestopbanddetailsforbothequirippledesignandthe
least-squaresdesignisshowninFigure5.
3.2Nonlinear-phasedesigns
OneoftheadvantagesofFIRfilters,whencomparedto
IIRfilters,istheabilitytoattainexactlinearphaseinaFigure6:Depictionofthesolutionspaceforlinear-phaseand
nonlinear-phaseFIRfiltersforagivensetofspecifications.Re-
gionArepresentsthesetofalllinear-phaseFIRfiltersthatmeet
thespecifications.RegionBrepresentsthesetofalllinearand
nonlinear-phaseFIRfiltersthatmeetthespecifications.straightforwardmanner.Aswehavealreadymentioned,
thelinear-phasecharacteristicimpliesasymmetryoran-
tisymmetrypropertyforthefiltercoefficients.Neverthe-
less,thissymmetryofthecoefficientsconstraintsthepos-
sibledesignsthatareattainable.Thisshouldbeobvious
sinceforafilterwithN+1coefficients,onlyN/2+1
ofthesecoefficientsarefreelyassignable(assumingNis
even).TheremainingN/2coefficientsareimmediately
determinedbythelinear-phaseconstraint.
Onecanthinkofthisasreducingthesearchspaceforan
optimalsolution.TheideaisdepictedinFigure6[7].Re-
gionAinthegraphrepresentsthesetofalllinear-phase
FIRfiltersthatmeetagivensetofspecifications.This
setcontainsboththeoptimalequirippleandtheoptimal
least-squaresfilterswehavementionedsofar.RegionB
representsthesetofallFIRfiltersthatmeetasetofspec-
ifications,regardlessoftheirphasecharacteristic.Clearly
RegionBcontainsRegionA.
3.2.1Minimum-phasedesigns
Ifoneisabletorelaxthelinear-phaseconstraint(i.e.ifthe
applicationathanddoesnotrequirealinear-phasecharac-
teristic),itispossibletodesignminimum-phaseequirip-
plefiltersthataresuperiortooptimalequiripplelinear-
phasedesignsbasedonatechniquedescribedin[8].
Forexample,thefollowingminimum-phasedesignhas
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage6bothsmallerpeakpassbandrippleandsmallerpeakstop-
bandripplethanthelinear-phaseequirippledesignofSec-
tion3.1.1:bm = gremez(42,[0 0.37 0.43 1],...
[1 1 0 0],[1 10],’minphase’);
Itisimportanttonotethatthisisnotatotallyun-
constraineddesign.Theminimum-phaserequirementre-
strictstheresultingfiltertohaveallitszerosonorinside
theunitcircle.23.2.2Moregeneralnonlinear-phasedesigns
Wehavejuststatedthatminimum-phasedesignsarenot
completelyunconstrainedduetotherequirementonthe
lociofthezeros.Ageneralnonlinear-phasedesignalgo-
rithmisprovidedinthefirlpnorm function.
Considerthefollowingspecifications:SpecificationsSet21.Cutofffrequency:0.375rad/sample2.Transitionwidth:0.15rad/sample3.Maximumpassbandripple:0.0084.Maximumstopbandripple:0.0009
A30thorderFIRequiripplefilter(withnonlinearphase)
canbedesignedtomeetthatsetofspecswithfirlpnorm,blp = firlpnorm(30,[0.3.45 1],[0.3...
.45 1],[1 1 0 0],[1 1 10 10]);
Thiscontrastswitha37thorderfilterifwerequirelin-
earphase.Bycomparison,aminimum-phaseequiripple
filterdesignedusinggremez asdescribedabovealsore-
quiresa30thorderfiltertomeetthespecificationswhich
isquiteremarkableconsideringtheminimum-phasecon-
straint.
Thefactthattwodifferentnonlinear-phasefiltersofthe
sameordermeetthesamespecificationsillustratesthedif-
ficultyassociatedwithnonlinear-phasedesignsingeneral.
Thereisnolongerauniqueoptimalsolutiontoagiven
designproblem.Figure7showsthevirtuallyidentical
magnituderesponses.Incontrast,Figure8showsthere-
markablydifferentimpulseresponses.Figure7:Magnituderesponsesofaminimum-phaseequiripple
30thorderfilterandageneralnonlinear-phaseequiripplefilter
ofthesameorder.Bothfiltersaredesignedtomeetthesame
specs.Figure8:Impulseresponsecomparisonforanequiripple
minimum-phasefilterandanonlinear-phaseequiripplefilter
withvirtuallythesamemagnituderesponse.2
Givenanylinear-phaseFIRfilterwithnonnegativezero-phasechar-
acteristic,itispossibletoextracttheminimum-phasespectralfactorus-
ingthefirminphasefunction.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage7Figure9:Stopbanddetailsofanonlinear-phaseleast-squaresfil-
terandalinear-phaseleast-squaresfilterofthesameorder.The
nonlinear-phasefilterprovidesasmallertransitionwidthanda
largerstopbandattenuation.firlpnorm alsoprovidestheabilitytoselectadifferent
normfortheoptimization.Whilethedefaultoptimization
isfortheL
norm,anynormbetween(andincluding)L
2
andL
ispossible.
Bytheargumentsgivenabove,itispossibletoattain
asuperiordesignusingfirlpnorm insteadoffirls for
thesamefilterorder,providedlinearphaseisnotare-
quirement.Forexample,b = firlpnorm(40,[0.4.45 1],[0.4.45 1],...
[1 1 0 0],[1 1 10 10],[2 2]);
b2 = firls(40,[0.4.45 1],[1 1 0 0],[1 20]);
yieldsasmallertransitionwidthandalargerstopband
attenuationforthenonlinear-phasecase(withapproxi-
matelythesamepeakpassbandripple).Thestopbandde-
tailsareshowninFigure9.
BecauseitispossibletochoosetheL
p
normwith
whichtooptimize,firlpnorm isveryflexibleandallows
forthedesignertoreachacompromisebetweenequirip-
pleandleast-squaresdesigns.ThisisillustratedinFigure10.Figure10:OptimalL
p
normdesignsfordifferentvaluesofp.
Allfiltershavethesameorderandtransitionwidth.3.2.3Awordonpracticalimplementation
Becauseofthesymmetryinthecoefficients,somepracti-
calimplementationswillallowforalinear-phaseresponse
usingroughlyhalfthenumberofmultipliers.Thisispar-
ticularlytruewithFPGAsandspecializedhardware.The
endresultisthatitmayverywellbepossibletostickto
alinear-phasedesignandachieveamoreefficientimple-
mentationthancomparablenonlinear-phasedesigns.
4Optimalequirippledesignswith
fixedtransitionwidthandpeak
passband/stopbandripple
Wehaveseenthattheoptimalequirippledesignsout-
performKaiser-windowdesignsforthesameorderand
transitionwidth.Thedifferencesareevenmoredramatic
whenthepassbandrippleandstopbandripplespecifica-
tionsaredifferent.Thereasonisthatthetruncated-and-
windowedimpulseresponsemethodsalwaysgivearesult
withapproximatelythesamepassbandandstopbandpeak
ripple.Therefore,alwaysthemorestringentpeakrip-
pleconstraintissatisfied,resultinginexceeding(possibly
significantly)allotherrippleconstraintsattheexpenseof
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage8Figure11:PassbandrippledetailsforboththeKaiser-window-
designedFIRfilterandtheremez-designedFIRfilter.The
Kaiser-windowdesignover-satisfiestherequirementattheex-
penseofincreasenumberoftaps.unnecessarilylargefilterorder.
Toillustratethis,weturntoadifferentequiripplede-
signinwhichboththepeakripplesandthetransition
widtharefixed.ReferringbacktothetriangleinFigure2,thismeanstheresultingfilterorderwillcomefromthe
designalgorithm.
ConsideronceagaintheSpecificationsSet2.The
gremez functioncanbeusedtodesignthisfilterb = gremez(’minorder’,[0.3.45 1],...
[1 1 0 0],[.008.0009]);
resultinginafilterof37thorder(38taps).Bycompari-
son,aKaiser-windowdesignrequiresa50thorderfilter
(51taps)tomeetthesamespecifications.Thepassband
detailscanbeseeninFigure11.Itisevidentthatthe
Kaiser-windowdesignover-satisfiestherequirementssig-
nificantly.
4.1Minimum-phasedesignswithfixed
transitionwidthandpeakpass-
band/stopbandripple
Thesameproceduretodesignminimum-phasefilterswith
fixedfilterorderandfixedtransitionwidthcanbeusedtodesignminimum-phasefilterswithfixedtransitionwidth
andpeakpassband/stopbandripple.Inthiscase,rather
thanobtainingsmallerripples,thebenefitismeetingthe
sametransitionwidthandpeakpassband/stopbandripples
withareducedfilterorder.
Asanexample,considerthefollowingspecifications
set:SpecificationsSet31.Cutofffrequency:0.13rad/sample2.Transitionwidth:0.02rad/sample3.Maximumpassbandripple:0.014.Maximumstopbandripple:0.001
Theminimumorderneededtomeetsuchspecifications
withalinear-phaseFIRfilteris262.Thisfiltermustbe
theresultofanoptimalequirippledesign.Ifwerelaxthe
linear-phaseconstrainthowever,thegremez functioncan
designaminimum-phaseFIRfilterthatmeetsthespecifi-
cationssetwith216thorder:bgm = gremez(’minorder’,[0.12.14 1],...
[1 1 0 0],[0.01 0.001],’minphase’);
5Optimalequirippledesignswith
fixedpeakrippleandfilterorder
Sofarwehaveillustratedequirippledesignswithfixed
transitionwidthandfixedorderanddesignswithfixed
transitionwidthandfixedpeakripplevalues.TheFilter
DesignToolboxalsoprovidesalgorithmsfordesignswith
fixedpeakripplevaluesandfixedfilterorder[6].This
givesmaximumflexibilityinutilizingthedegreesoffree-
domavailabletodesignanFIRfilter.
Wehaveseenthat,whencomparedtoKaiser-window
designs,fixingthetransitionwidthandfilterorderresults
inanoptimalequirippledesignwithsmallerpeakripple
values,whilefixingthetransitionwidthandpeakripple
valuesresultsinafilterwithlessnumberoftaps.Nat-
urally,fixingthefilterorderandthepeakripplevalues
shouldresultinasmallertransitionwidth.
Toverifythis,weusethefirceqrip function,
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage9Figure12:ComparisonofaKaiser-window-designedFIRfil-
terandanoptimalequirippleFIRfilterofthesameorderand
peakripplevalues.Theequirippledesignresultsinareduced
transition-width.bc = firceqrip(50,0.375,[0.008 0.0009]);
ThecomparisonofthisnewdesignwiththeKaiser-
windowdesignisshowninFigure12.Thetransition
widthhasbeenreducedfrom0.15toapproximately
0.11.
5.1Minimum-phasedesignswithfixed
peakrippleandfilterorder
Onceagain,iflinear-phaseisnotarequirement,a
minimum-phasefiltercanbedesignedthatisasuperior
insomesensetoacomparablelinear-phasefilter.In
thiscase,forthesamefilterorderandpeakripplevalue,
aminimum-phasedesignresultsinasmallertransition
widththanalinear-phasedesign.
Forexample,comparedtothe50thorderlinear-phase
designbc,thefollowingdesignhasanoticeablysmaller
transitionwidth:bcm=firceqrip(50,0.375,[0.008 0.0009],’min’);6Otherequirippledesigns
Forspecificdesignproblems,furtherequirippledesign
optionsareavailableintheFilterDesignToolbox.No-
tably,theconstrained-banddesign-whereonecanfix
thefilterorderalongwiththepeakrippleandthebeggin-
ing/endofagivenband(passbandorstopband)-andthe
slopedstopbanddesign,wherethestopbandisnolonger
equiripple,butratherhasapredeterminedslope.
6.1Constrained-bandequirippledesigns
Sometimeswhendesigninglowpassfiltersfordecimation
itisnecessarytoguaranteethatthestopbandofthefil-
terbeginsataspecificfrequencyvalueandthatthefilter
provideagivenminimumstopbandattenuation.
Ifthefilterorderisfixed-forinstancewhenusingspe-
cializedhardware-therearetwoalternativesavailablein
theFilterDesignToolboxforoptimalequirippledesigns.
Oneposibilityistofixthetransitionwidth,theotheristo
fixthepassbandripple.
Forexample,thedesignSpecificationsSet2callfor
astopbandthatextendsfrom0.45toandprovidea
minimumstopbandattenuationofapproximately60dB.
Forillustrationpurposes,supposethefilterorderavailable
is40(41taps).Thefirceqrip functioncandesignthis
filterifwealsofixthepassbandrippleto0.008.Theresult
willbeafilterwiththesmallestpossibletransitionwidth
foranylinear-phaseFIRfilterofthatorderthatmeetsthe
givenspecifications.bc = firceqrip(40,0.45,[0.008 0.0009],...
’stopedge’);
Ifincontrastwewanttofixthetransitionwidth,wecan
usethegremez function.Theresultinthiscasewillbe
afilterwiththesmallestpossiblepassbandrippleforany
linear-phaseFIRfilterofthatorderthatmeetsthegiven
specifications.bg = gremez(40,[0.3.45 1],[1 1 0 0],...
[1 0.0009],{’w’,’c’});
ThepassbanddetailsofthetwofiltersareshowninFig-
ure13.NotethatbothfiltersmeettheSpecificationsSet2becausetheorderused(40)islargerthantheminimum
orderrequired(37)byanequiripplelinear-phasefilterto
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage10Figure13:ComparisonoftwooptimalequirippleFIRfiltersof
40thorder.Bothfiltershavethesamestopband-edgefrequency
andminimumstopbandattenuation.Oneisoptimizedtomini-
mizethetransitionwidthwhiletheotherisoptimizedtomini-
mizethepassbandripple.meetsuchspecifications.Thefiltersdifferinhowthey
“use”theextranumberoftapstobetterapproximatethe
ideallowpassfilter.
6.2Slopedequiripplefilters
Analternativetousingleast-squaresdesignsistodesign
optimalequiripplefiltersbutallowingforaslopeinthe
stopbandofthefilter.Thishastheadvantage(overleast-
squaresdesigns)thatthepassbandcanremainequiripple,
thusminimizingtheinputsignalfluctuationsinthatre-
gion.
Whileonecanachieveslopedstopbandsusingthe
remez orgremez methodsbyutilizingtheweights,
firceqrip providesthebestcontrolandeasiestwayto
dothis(attheexpenseofnothavingfullcontroloverthe
transitionwidth).Usingfirceqrip onecanspecifythe
desiredslope(indBperfrequencyunit)forthestopband.
Forexample,thefollowingdesign,bf = firceqrip(42,0.4346,[0.035],[0.03],...
’slope’,40,’stopedge’);Figure14:PassbanddetailsofaslopedoptimalequirippleFIR
designandanoptimalleast-squaresFIRdesign.Theequiripple
filterhasasmallerpeakerrororsmallertransitionwidthdepend-
ingontheinterpretation.resultsinastopbandenergyofapproximately3.9771e-
005,notmuchlargerthattheleast-squaresdesignofSec-
tion3.1.2,whilehavingasmallertransitionwidth(orpeak
passbandripple-dependingontheinterpretation).The
passbanddetailsofboththeleast-squaresdesignandthe
slopedequirippledesignareshowninFigure14(indB).
ThestopbanddetailsareshowninFigure15(alsoindB).
7Advanceddesignalgorithms-in-
terpolatedFIRfilters
ForanygivenFIRdesignalgorithm,ifthepeakripple
specificationsremainthesame,thefilterorderrequiredto
meetagivenspecificationssetisinverselyproportionalto
thetransitionwidthallowed.
Whenthetransitionwidthissmall,suchasintheSpeci-
ficationsSet3,thefilterorderrequiredmaybequitelarge.
ThisisoneoftheprimarydisadvantagesofFIRfilters.
Wehavealreadyseenthatrelaxingthelinear-phasere-
quirementresultsinasignificantsavingsinthenumberof
filtercoefficients.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage11Figure15:StopbanddetailsofaslopedoptimalequirippleFIR
designandanoptimalleast-squaresFIRdesign.Theoverall
erroroftheequiripplefilterapproachesthatoftheleast-squares
design.Theso-calledinterpolatedFIR(IFIR)approach
[9],[10],[11]yieldslinear-phaseFIRfiltersthatcanmeet
thegivenspecificationswithareducednumberofmulti-
pliers.
Theideaisrathersimple.Sincethelengthofthefilter
growsasthetransitionwidthshrinks,wedon’tdesigna
filterforagiven(small)transitionwidth.Rather,wede-
signafilterforamultipleLofthetransitionwidth.This
filterwillhaveasignificantlysmallerlengththanadi-
rectdesignfortheoriginal(small)transitionwidth.Then,
weupsampletheimpulseresponsebyafactorequaltothe
multipleofthetransitionwidth,L.Upsamplingwillcause
thedesignedfiltertocompress,meetingtheoriginalspec-
ificationswithoutintroducingextramultipliers(itonlyin-
troduceszeros,resultinginalargerdelay).Thepriceto
payistheappearanceofspectralreplicasofthedesired
filterresponsewithintheNyquistinterval.Thesereplicas
mustberemovedbyasecondfilter(calledinthiscon-
texttheinterpolationfilterorimagesuppressorfilter)that
iscascadedwiththeoriginaltoobtainthedesiredoverall
response.Althoughthisextrafilterintroducesadditional
multipliers,itispossibleinmanycasestostillhaveover-
allcomputationalsavingsrelativetoconventionaldesigns.
TheimplementationisshowninFigure16.Figure16:TheIFIRimplementation.Anupsampledfilteriscas-
cadedwithanimagesuppressorfiltertoattainanoveralldesign
withareducedcomputationalcost.Figure17:IllustrationoftheIFIRdesignparadigm.Twofilters
areusedtoattainstringenttransitionwidthspecificationswith
reducedtotalmultipliercountwhencomparedtoasinglefilter
design.TheideaisdepictedbyexampleinFigure17forthe
caseofanupsamplingfactorof3.The“relaxed”design
isapproximatelyofonethirdthelengthofthedesiredde-
sign,ifthelatterweretobedesigneddirectly.Theupsam-
pleddesignhasthesametransitionwidthasthedesired
design.Allthatisleftistoremovethespectralreplica
introducedbyupsampling.Thisisthejoboftheimage
suppressorfilter.
Asanexampleofthecomputationalcostsavings,con-
sideronceagainthedesignSpecificationsSet3.Thenum-
berofmultipliersrequiredforasinglelinear-phasedesign
was263.AnIFIRdesigncanattainthesamespecswith
127multiplierswhenusinganupsamplingfactorof6:[bup,bimg]=ifir(6,’low’,[.12.14],[.01.001]);
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage12Figure18:Magnituderesponseoftheupsampledfilterandthe
imagesuppressorfilterinanIFIRdesign.Figure19:OverallmagnituderesponseofanIFIRdesignand
aconventionalequirippledesign.TheIFIRimplementationre-
quires127multipliersvs.263fortheconventionalimplementa-
tion.Theresponseoftheupsampledfilterandtheimagesup-
pressorfilterisshowninFigure18.Theoverallresponse,
comparedtoasinglelinear-phaseequirippledesignis
showninFigure19.Figure20:PassbanddetailsofanIFIRdesignrevealingarather
chaoticbehavioroftheripple.7.1FurtherIFIRoptimizations
AdrawbackintheIFIRdesignisthatthepassbandripples
ofthetwofiltersarecombinedinadisorderlyfashion.In
theworstcasescenario,theycanaddup,requiringthe
designtoensurethatthesumofthetwopeakpassband
ripplesdoesnotexceedtheoriginalsetofspecifications.
Closeinspectionofthepassbandoftheoveralldesignin
thepreviousexample,showninFigure20,revealsarather
chaoticbehavior(butcertainlywithinspec.)oftheripple.
Furtheroptimizeddesigns,[2],[12],attainamuch
cleanerpassbandbehaviorbyjointlyoptimizingthede-
signofthetwofilterstoworkbettertogether.Thisresults
inafilterthatcanmeetthespecificationssetwithaneven
furtherreductioninthenumberofmultipliers.Thesav-
ingsareespeciallysignificantfortheimagesuppressor
filter,whichisgreatlysimplifiedbythisjointoptimiza-
tion.
Utilizingthisjointoptimization,theSpecificationsSet3canbemetwithonly74multipliers,onceagainforan
upsamplingfactorof6.Thefiltercanbedesignedusing
the’adv’ flagintheifir function.
Themannerinwhichthetwofiltersworktogetheris
bestdescribedbylookingattheirmagnituderesponses,
showninFigure21.Bypre-compensatingforasevere
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage13Figure21:Magnituderesponseoftheupsampledfilterandthe
imagesuppressorfilterinanoptimizedIFIRdesign.Thetwo
filtersarejointlyoptimizedinthedesigntoachieveaspecifica-
tionssetwithareducednumberofmultipliers.“droop”intheimagesuppressorfilter,aflatpassbandcan
beachievedwithdramaticsavingsinthenumberofmul-
tipliersrequiredfortheimagesuppressorfilter.Outof
the74multipliersrequired,29arefortheimagesuppres-
sorfilterand45fortheupsampledfilter.Bycontrast,in
thepreviousIFIRdesign,78ofthe127multiplierscorre-
spondtotheimagesuppressorfilter,while49correspond
totheupsampledfilter.
Thepassbanddetailsoftheoveralldesignshowanice
equiripplebehavior,hintingatamuchbetteroptimized
design.ThepassbanddetailsareshowninFigure22.
7.2MultirateimplementationofIFIRde-
sign
WhendesigninganIFIRfilter,theupsamplingfactorL
usedmustbesuchthatthe(normalized)stopband-edge
frequency
s
satisfiesL
s
< .Thisimpliesthatthe
bandwidthoftheoutputsignalwouldbereducedbyafac-
torofL.
Itisconvenientfromacomputationalcostperspective
toreducethesamplingfrequencyofthefilteredsignal,
sinceatthatpointtheNyquistcriterionisbeingunneces-
sarilyoversatisfied.SubsequentprocessingofthefilteredFigure22:PassbanddetailsofanoptimizedIFIRdesign.The
optimizeddesignexhibitsniceequiripplebehavior.Figure23:CascadinganIFIRimplementationwithadownsam-
pler.signalwithoutreducingitssamplingratewouldincurin
unnecessary(andexpensive)redundantprocessingofin-
formation.
Theideaistodownsamplethefilteredsignalbyafac-
torofLtomatchthereductioninbandwidthduetofilter-
ing.IfwedenotebyI(z) theimagesuppressorfilterand
byU(z
L
) theupsampledfilter,wewouldhaveacascade
ofthesetwofiltersandadownsamplerasshowninFig-
ure23.UsingtheNobleidentities,wecan“commute”
thedownsamplerandU(z
L
) toobtaintheimplementa-
tionshowninFigure24.ThecombinationofI(z) and
thedownsamplerformadecimatorwhichcanbeimple-
mentedefficientlyinpolyphaseform.
8Interpolationfilterdesign
Inthecontextofmultiratesignalprocessing,interpolation
usuallyreferstoband-limitedinterpolation.Band-limited
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage14Figure24:Interchangeofthedownsamplerandtheupsampled
filterusingtheNobleidentities.interpolationisbasedonthenotionofanunderlyingband-
limitedcontinuous-timesignalthatisbeingsampled.
Idealband-limitedinterpolationwilltakeadigital
(sampled)signalandproducedaninterpolatedsignalthat
willbeidenticaltothesignalthatwouldbeobtained
bysamplingtheunderlyingcontinuous-timesignalata
higherrate.
Idealband-limitedinterpolationcanbeaccomplished
bymeansofupsamplingandusinganideallowpassfilter.
Especiallyinterestingisatime-domaininterpretationof
theidealinterpolator,whichleadsnaturallytopolyphase
implementations.
8.1Idealband-limitedinterpolationinthe
frequencydomain
Aswehavealreadymentioned,thekeyconceptof
bandlimited-interpolationisthatasignaltobeinterpo-
latedisasampledversionofaband-limitedcontinuous
timesignal.
Denotethecontinuous-timesignalbyx
c
(t) andsuppose
itsspectrumiszeroforall| f| > f
max
.Itsfrequencyspec-
trumX(2jf) isshowninFigure25.
Ifthesignalissampledatf
s
= 2f
max
,weobtainthe
signal
x
T
[n] ={x
c
(nT)},T=
1f
s
.
Itsspectrum,X
T
(e
2jf/f
s
) isshowninFigure26.
Nowsupposethecontinuous-timesignalwassampled
ataratef
s
= Lf
s
= 2Lf
max
.Thesampledsignalatthe
higherrate,
x
T
[m] ={x
c
(mT
)},T
=
1f
s
=
TL
,
wherem=Ln+k,k=0,...,L−1,willhaveaspectrum
X
T
(e
2jf/f
s
) asshowninFigure27forthecaseL=2.Figure25:Spectrumofband-limitedcontinuous-timesignal.Figure26:Spectrumofsampledsignalwithf
s
=2f
max
.Thejoboftheidealinterpolationfiltershouldnowbe
clearfromthefrequencydomainstandpoint.Takethe
discrete-timesignalwithspectrumX
T
(e
2jf/f
s
) anddig-
itallyproducethediscrete-timesignalX
T
(e
2jf/f
s
) that
wouldhavebeenobtainedfromsamplingtheoriginal
continuous-timesignalatratef
s
=Lf
s
.
Theresponseoftheidealinterpolationfilterisshown
inFigure28.Clearlyitisalowpassfilterwithperiodicity
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage15Figure27:Spectrumofsampledsignalwithf
s
=4f
max
.f
s
,i.e.itmustbeoperatingatthehighsamplingrate.For
thisreason,itisnecessarytoupsampletheinputsignal3byinsertinganappropriateamountofzerosbetweensam-
plesinordertofeedtheinterpolationfilterasignalatthe
correctrate.
Moreprecisely,theresponseoftheidealfilter
H
D
(e
2jf/f
s
) forthegeneralcaseofinterpolationbyafac-
torofLisgivenby
H
D
(e
2jf/f
s
) =
L,| f| ≤
f
s2
0,
f
s2
<| f| ≤
f
s2
(3)
Theimpulseresponseoftheidealinterpolationfilter
canbefoundfromtheinverseDTFT[1],
h
D
[m] =
Lf
s
sin(f
s
T
m)T
m
(4)
Ifweusethefactthatf
s
=1/T
andT
=
1Lf
s
wehave
h
D
[m] =
sin(m/L) m/L
,−<m<(5)
Asexpectedforanideallowpassfilter,ittakesaninfi-
niteimpulseresponsetorealizeit.Furtherinsightforthe
idealinterpolationfilterwillbegiveninSection8.2where
weanalyzethingsinthetime-domain.3
Althoughthisisnotnecessaryinpracticewhereefficientalgorithms
areused.Figure28:Idealinterpolationfilteroverlaidwithspectrumof
sampledsignalwithf
s
=2f
max
.8.2Idealband-limitedinterpolationinthe
timedomain
Onceagain,thekeyideaofidealband-limitedinterpola-
tionistodigitallyproduceasignalthatwouldbeexactly
thesameasasignalwehadobtainedbysamplingaband-
limitedcontinuoustimesignalatthehighersamplingrate.
ThesituationinthetimedomainisdepictedinFigure29.
AssumingtheNyquistsamplingcriterionhasbeensat-
isfied,i.e.thecontinuous-timesignalisband-limitedand
hasbeensampledataratef
s
=
1T
≥ 2f
max
,noinforma-
tionhasbeenlostfromthecontinuous-timesignalx
c
(t).
Thereforeitshouldbepossibletosomehowrecreateany
instantaneousvaluex
c
(t
0
) ofthecontinuous-timesignal
fromthesampledsignalx
T
[n].
LookingatFigure29,wecanseethatthejobofthe
5-foldinterpolatoristotakeeveryinputsamplex
T
[n]
andproduce5outputsamples{x
T
[m]},m=5n+k,k=
0,...,4asfollows(notethatT=0.5andT
=T/5=0.1):•x
T
[5n] =x
T
[n]•x
T
[5n+1] =x
T
[n+
15
]•x
T
[5n+2] =x
T
[n+
25
]
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage16Figure29:Illustrationofidealband-limitedinterpolationinthe
timedomain.•x
T
[5n+3] =x
T
[n+
35
]•x
T
[5n+4] =x
T
[n+
45
]
Ingeneral,theidealinterpolatorconsistsofabankof
Lfilterswhichwillfractionallyadvancetheinputsignal
byafactork/L,k=0,...,L−1.Theoutputsofthefilters
aretheninterleaved(i.e.onlyonefilterneedstooperate
perhighrateoutputsample)toproducetheinterpolated
signal.
TheLfiltersthatcomprisethefilterbankarethefrac-
tionaladvancefiltersH
k
(z),
H
k
(z) =z
k/L
,k=0,...,L−1.
Evaluatingontheunitcircle,wehave
H
k
(e
j
) =e
jk/L
,k=0,...,L−1
sothateachfilterH
k
(e
j
) isallpass,i.e.|H
k
(e
j
)| = 1
andhaslinearphase,arg{H
k
(e
j
)} =k/L.
Hereinliestheimpossibilityofdesigningthesefilters.
WecannotdesignthemasFIRfiltersbecausenoFIRfil-
tercanbeallpass(exceptforapuredelay).Wecannot
designthemasIIRfilters,becausenostableIIRfiltercan
havelinearphase.However,itisclearhowwewantto
approximatetheidealinterpolationfilterbank.FIRapproximationscanproducetheexactlinearphase,
whileapproximatinganallpassresponseasbestpossible.
Ontheotherhand,IIRapproximationswillbeexactlyall-
pass,whiletryingtoproducetherequiredphase.
Itisinsightfultorealizethatthefilterscomprisingthe
filterbankarethepolyphasecomponentsoftheidealin-
terpolationfilterderivedin(5)!Thusthisviewoftheideal
interpolatorhastheefficientpolyphasestructure“built-
in”.
Indeed,theimpulseresponseofeachfractionaladvance
filterinthefilterbankisgivenbytheinverseDTFT,
h
k
[n] =
12
−
e
jk/L
e
jn
d
=
sin
Ln+kL
Ln+kL
whichcorrespondstotheLdecimatedsequencesofthe
idealimpulseresponsebyagainwritinguniquelym=
Ln+k,k=0,...,L−1in(5).
8.3DesignofFIRinterpolationfilters
Whileinterpolationfiltersaresimplylowpassfiltersthat
canbedesignedwiththevarioustechniquesoutlinedpre-
viously,thepolyphasefiltersthatcomposetheidealinter-
polationfiltergivesomeinsightonthingstobelooking
forwhendesigninginterpolationfilters.
ConsideraninterpolationbyafactorofL.TheidealL
polyphasefilterswillhaveagroup-delaygivenby
−
kL
,k=0,...,L−1
Forsimplicity,consideranFIRapproximationtothe
idealinterpolationfilterwheretheorderisoftheform
N= 2LM.Theneachpolyphasefilterwillhaveorder
N/L=2M.
Notethattheidealinterpolationfilterisinfinitelynon-
causal.Afterfinitelengthtruncation,itispossibleto
maketheapproximationcausalbydelayingbyhalfthe
filterorder,N/2.However,becausewewillimplement
inefficientpolyphaseform,wecanmakeeachpolyphase
componentcausalbydelayingitbyMsamples.
Thedelaywillmeantheintroductionofaphasecom-
ponentintheresponseofeachpolyphasecomponent.
Sothatinsteadofapproximatingtheidealfractionalad-
vancee
jk/L
thepolyphasecomponentswillapproximate
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage17e
j(k/L−M)
.Thegroup-delaywillconsequentlybeofthe
form
−
d()d
=−
d(k/L−M)d
=M−k/L.
AproblemthatarisesisthateventhoughtheFIRap-
proximationtotheidealinterpolationfilterissymmetric
andthushaslinearphase,thepolyphasecomponentsare
notnecessarilysymmetricandthuswillnotnecessarily
haveexactlinearphase.However,foreachnonsymmet-
ricpolyphasefilter,thereisamirrorimagepolyphasefil-
terwhichwillhavetheexactsamemagnituderesponse
withamirrorimagegroup-delaythatwillcompensateany
phasedistortion.
8.3.1NyquistFIRfilters
Whenweanalyzedthebehavioroftheidealinterpolation
filterinthetime-domain,wesawthatforeveryinputsam-
ple,Lsamplesareproducedincludingonethatisexactly
thesameastheinputsample.Thisexactcopyis“pro-
duced”bythepolyphasefilterthathasallpassmagnitude
andzerophase(i.e.thecasek=0).Inpractice,thisisthe
onlypolyphasefilterthatcanbedesignedexactly,albeit
withagroup-delayofMratherthanzero.
Roughlyspeaking,aNyquistfilterisoneforwhich
oneofitspolyphasecomponentsisapuredelayandthus
leavestheinputsignalunchanged(exceptforapossible
delay).Whendesigninganinterpolationfilter,itisdesir-
ableforittobeaNyquistfiltersincethiswillensurethat
evenanonidealfilterwillallowtheinputsamplestopass
throughunchanged.Itcanalsobecomputationallyadvan-
tageoussinceoneofthepolyphasesubfilterswillhaveno
multipliers.
8.3.2Halfbandfilters
NyquistfiltersarealsocalledLth-bandfiltersbecausethe
passbandoftheirmagnituderesponseoccupiesroughly
1/LoftheNyquistinterval.Inthespecialcaseofanin-
terpolationbyafactorof2,thefiltersareknownashalf-
bandfilters.Halfbandfiltersarecommonlyusedwhen
interpolating(ordecimating)byafactorof2.
Thecutofffrequencyforahalfbandfilterisalways
0.5.Moreover,thepassbandandstopbandripplesare
identical,limitingthedegreesoffreedominthedesign.Thefunctionfirhalfband designsFIRhalfbandfilters.
Thespecificationssetstillfollowsthetrianglemetaphor
showninFigure2,takingintoaccountthelimitationsjust
described.
Thefollowingthreefunctioncallsdesignthreeequirip-
plelinear-phasehalfbandfiltersusingadifferentpairof
specificationsineachcasefromthethreeavailable-order
(N),transition-width(TW),andpeakpassband/stopband
ripple(R)-:b1=firhalfband(102,.47);% N and TW
b2=firhalfband(102,.01,’dev’);% N and R
b3=firhalfband(’minorder’,.47,.01);% TW and R
Toanalyzehowthedesigncomparestotheidealinter-
polationfilter,wecancreateanFIRinterpolatorobject
andlookatitspolyphasesubfilters,forexampleifweuse
thethirdfilter,b3,h = mfilt.firinterp(2,2*b3);
polyphase(h)
Themagnitudeandgroup-delayresponsesforthe
polyphasecomponentsofthisfilterareshowninFigures30and31.NotethatM=N/2Lis16.5inthiscase,sothat
thegroup-delaysareexactlyM−k/L,k=0,1.Theonly
deviationfromanidealfilter(ignoringanoveralldelayof
Msamples)comesfromthefactthatoneofthepolyphase
subfiltersisnotperfectlyallpass.
8.3.3OtherNyquistfilters
Nyquistfiltersarecharacterizedinthetime-domainby
theirimpulseresponsebeingexactlyequaltozeroevery
Lsamples(excepttheexactmiddlesampleoftheimpulse
response).Thisispreciselywhywegetapolyphasesub-
filterthatisaperfectallpassdelayandallowsthesamples
tobeinterpolatedtopassthroughthefilterunchanged.
Designingafilterthatisbothalowpassandsimultane-
ouslysatisfiesthejustmentionedtime-domaincharacter-
isticisnotatrivialtaskexceptforthecaseofwindow-
baseddesigns,[13],[14].
Nevertheless,theadvantageofconventionaloptimal
equirippledesignsoveraNyquistwindow-baseddesignis
notasclearinthiscaseasitiswithanyconventionallow-
passfilter.Weillustratebyexample:consideraKaiser
windowNyquistfilterdesignwithastopbandattenuation
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage18Figure30:Magnituderesponseforpolyphasesubfiltersofa
halfbandFIRfilter.Ideally,bothsubfilterswouldbeperfectly
allpass.Figure31:Group-delayresponseforpolyphasesubfiltersofa
halfbandFIRfilter.Ifthe16.5samplesdelay-introducedfor
causalityreasons-isignored,thegroup-delaybehavesexactly
astheidealinterpolationfilter,withanoffsetof1/Lbetween
thegroup-delayofeachsubfilter(L=2inthisexample).of40dB.Nyquistfiltersareoftendesignedintermsof
theirroll-offfactor,,duetotheirapplicationsincom-munications.4Theroll-offfactorisrelatedtotransition-
widthsimplybyTW= /L.Inthisexample,= 0.1
andL=4thusthetransition-widthis0.025.b1 = firnyquist(’minorder’,4,.1,.01);% L=4
Theresultingfilterisof90thorder.Ifwedesignan
equiripplefilterofthesameorderandsameattenuation,
weobtainafilterwithasmallertransitionwidth,butthat
doesnotsatisfythetime-domainrequirement.b2 = firceqrip(90,.25,[.01.01]);
Themagnituderesponsesofthepolyphasesubfiltersfor
theNyquistwindow-baseddesignareshowninFigure32.
Forcomparison,themagnituderesponsesfortheoptimal
equirippledesignareshowninFigure33.Notethebet-
terapproximationtoallpassfiltersintheNyquistdesign
comparedtotheequirippledesign(albeitforaslightly
smallerinterval-thisisthetradeoff).
Similarly,ifwecomparethegroup-delayresponseof
thepolyphasesubfilters,theNyquistdesignonceagain
betterapproximatestheidealconstantgroup-delayas
comparedtotheequirippledesign.Thegroup-delayre-
sponsesforthepolyphasesubfiltersoftheNyquistdesign
areshowninFigure34.Thegroup-delayresponsesforthe
polyphasesubfiltersoftheequirippledesignareshownin
Figure35.
9Designofperfect-reconstruction
two-channelFIRfilterbanks
Atwo-channelfilterbankisshowninFigure36.Filters
H
0
(z) andH
1
(z) arecalledtheanalysisfilterswhileG
0
(z)
andG
1
(z) arethesynthesisfilters.
Thefilterbankiscalledperfectreconstructionifthe
end-to-endsystemactsasadelay,i.e.iftheoutputsignal
issimplyadelayed(andpossiblyscaled)versionofthe
input.4
Thewell-knownraised-cosinefilterisaspecialcaseofaNyquist
filter.Infact,thesamereasonthatraised-cosinefiltersarecommon,i.e.
toachievezerointersymbol-interferencewithanonidealfilter,iswhy
theyareabletointerpolatewithoutaffectingtheinputsamples-namely
thefactthattheimpulseresponsebecomeszeroexactlyattherighttime.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage19Figure32:Magnituderesponseforpolyphasesubfiltersofa
NyquistFIRfilterdesignedwiththewindowmethod.The
polyphasesubfiltersbetterapproximateallpassfiltersthana
comparableequirippledesignforthebulkofthefrequencyband.Figure33:Magnituderesponseforpolyphasesubfiltersofaop-
timalequiripplelowpassFIRfilter.Noneofthesubfiltersbe-
havesasaperfectallpass,anindicationthatthisisnotaNyquist
filter.Itiswell-known,[10],[15],[16],thatperfectrecon-Figure34:Group-delayresponseforpolyphasesubfiltersofa
NyquistFIRfilteroforder90andL=4.Figure35:Group-delayresponseforpolyphasesubfiltersofa
conventionalequiripplelowpassdesignthatcouldbeusedfor
interpolationwithL=4.structioncanbeachievedif
12
G
0
(z)H
0
(−z) +
12
G
1
(z)H
1
(−z) =0
and
12
G
0
(z)H
0
(z) +
12
G
1
(z)H
1
(z) =z
−k
.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage20Figure36:Two-channelsubbandcodingfilterbank.StartingwithaprototypelowpassfilterH(z) ofoddor-
derN,thefollowingselectionforthefiltersresultsinper-
fectreconstructionusingsolelyFIRfilters[15],
H
0
(z) =H(z) H
1
(z) =z
−N
H
0
(−z
−1
)
G
0
(z) =2z
−N
H
0
(z
−1
) G
1
(z) =2z
−N
H
1
(z
−1
)
Thistypeofperfectreconstructionfilterbankiscalledan
orthogonalfilterbankorapower-symmetricfilterbank
[15].
Thefunctionfirpr2chfb designsequirippleFIRfil-
tersH
0
(z),H
1
(z),G
0
(z),G
1
(z) suchthatthefilterbankis
anorthogonalperfectreconstructionfilterbank.Thepa-
rameterstospecifyaresimplythefilterorderNandthe
passband-edgefrequency
p
.Aprototypelowpassfilter
isdesignedfromwhichthefourrequiredfiltersareob-
tained.Forexample,[h0,h1,g0,g1] = firpr2chfb(99,.45);
Alternatively,thepeakstopbandripplecanbespeci-
fied.Asusual,wecanobtainminimum-orderdesignsby
specifyingboththepassband-edgefrequencyandthepeak
stopbandripple.Inallcases,thedesignspecificationsap-
plytotheprototypefilterH(z),[h0,h1,g0,g1]=firpr2chfb(99,1e-3,’dev’);
[h0,h1,g0,g1]=firpr2chfb(’minorder’,.45,1e-3);
Thepower-symmetrictermisusedbecauseforthese
designs,thefollowingholds:
|H
0
(e
j
)|
2
+|H
1
(e
j
)|
2
=1,∀.
Wecanlookatthemagnitude-squaredresponsesof
H
0
(z),H
1
(z) usingfvtool.Themagnitude-squaredre-
sponsesareshowninFigure37forN=19and
p
=.45.Figure37:Magnitude-squaredresponsesoftheanalysisfilters
inanFIRperfectreconstructionfilterbank.Thetwofiltersare
power-complementary.Noticehowwhereonefilter’sripplerisestheotherfilter’s
rippledeclinestoadduptoone.
Increasingthefilterorder(andpossiblythepassband-
edgefrequency)improvesthelowpass/highpasssepara-
tionprovidedbytheanalysisfiltersbutdoesn’thavean
effectontheperfectreconstructioncharacteristicofthe
overallsystem.
10ImplementinganFIRfilterusing
fixed-pointarithmetic
Severalfactorshavetobetakenintoaccountwhenimple-
mentinganFIRfilterusingfixed-pointarithmetic.For
onething,thecoefficientshavetobequantizedfrom
double-precisionfloatingpointinwhichtheyaredesigned
intofixed-pointrepresentationwithusuallyasmaller
numberofbits.Wemustmakesurewemakethemost
ofthelimitednumberofbitswehave.Furthermore,per-
formingthearithmeticinfixed-pointwillintroducefur-
therquantizationerrorswhenactuallyfilteringwiththe
quantizedcoefficients.Onceagain,wemustmakesure
weminimizethesequantizationerrorsasmuchasthe
hardwareathandallowsus.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage2110.1Somenotation
Firstwewillliketointroducethenotationusedinthe
FilterDesignToolboxtorepresentfixed-pointnumbers.
Consideraregisterusedtostoreafixed-pointnumber,
b
0
b
1
b
2
...
b
B−1
B−bits
TheregisterhasBbits(ithasawordlengthofB),thevalue
ofthekthbitisgivenbyb
k
whichcanobviouslybeonly
0or1.Atwo’scomplementfixed-pointnumberstoredin
sucharegisterhasavaluegivenby
value=−b
0
2
B−L−1
+
B−1
k=1
b
k
2
B−L−k−1
(6)
whereLisapositiveornegativeintegertobedescribed
now.
From(6),wecanseethatthevalueofafixed-point
numberisdeterminedbyassigningweightsoftheform
2
−m
toeachbit.Theleftmostbit,b
0
hasthelargest
weight,2
B−L−1
,thisbitiscalledthemost-significantbit
(MSB).Therightmostbit,b
B−1
,hasthesmallestweight,
2
−L
,whichiswhyitiscalledtheleast-significantbit
(LSB).
Giventhebitvalues,b
k
,thepair{B,L} completely
characterizesafixed-pointnumber,i.e.sufficesindeter-
miningthevaluethatthebitsrepresent.Wecallsucha
pairtheformatofagivenquantity,andstoreitinatwo-
elementvector,[B,L].
10.2Quantizingthecoefficients
Considerthefollowingfilterb=gremez(’minorder’,[0.11.14 1],...
[1 1 0 0],[.01.0001]);
Thefilterhasanattenuationof80dBandaitslargest
coefficientis0.1206.
Thefirstthingtodoischeckifthereareenoughbits
availabletorepresentthecoefficientsandprovidethere-
quireddynamicrange.Agoodruleofthumb[17]isto
assume5dB/bitforthedynamicrange5.Inthisexample5
Notethattheusual6db/bitruledoesn’tapplybecausequantization
errorforthefiltercoefficientstendstobecorrelated,especiallyatthe
extremesoftheimpulseresponse.Figure38:Magnituderesponseofthefilterquantizedwith
[16,15]format.weneedatleast16bitsinordertoprovidethe80dBof
attenuation.
Itisnotsufficienttosimplysaywearegoingtouse
16bits.Forexample,thefollowingcodecreatesafixed-
pointFIRfilterusing16bitstorepresentthecoefficients
infractionalformat:Hq=qfilt(’fir’,{b},...
’CoefficientFormat’,[16,15]);
Themagnituderesponseofthequantizedfilterisshown
inFigure38.Forcomparisonpurposes,thenonquantized
magnituderesponseisalsoshown.Notethatthestopband
attenuationforthequantizedresponseissignificantlyless
than80dBatvariousfrequencybands.Theproblemis
thepoorutilizationoftheavailablerangeforthe[16,15]
formatasshowninFigure39.
Tomakethemostofthe16bits,therearetwoequiva-
lentapproacheswecantake.Ifwewanttouse[16,15]
format,wecanscalethecoefficientsbymultiplyingthem
byafactorof8tomakethelargestcoefficientsascloseto
1aspossiblewithoutoverflowing.
Alternatively,wecanuse[16,18] formatsothatthe
quantizationrangebecomes[0.125,0.125).Themagni-
tuderesponseusingthisformatisshowninFigure40.
Theimprovementoverthefirstcaseisevident.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage22Figure39:Impulseresponseoffiltertobequantizedshownrel-
ativetotheavailablerangeforthecoefficientformatselected.Figure40:Magnituderesponseofthefilterquantizedwith
[16,18]format.Notethatwhetherwescalethecoefficientsanduse
[16,15] orwedon’tscaleandweuse[16,18],theac-
tualstoredvalue(thebinarybits)ofeachcoefficientis
thesame.However,intheformercase,thefilternowhas
againof18dBduetothemultiplicationbyeight.But
thiscanbecompensatedattheend,bymovingthebinaryFigure41:Magnituderesponsesforvariousquantizationsofa
filterwith80dBstopbandattenuation.point3bitstotheleft,withoutchangingthebits.
Toemphasizethepointregardingtheneedtouseboth
therightnumberofbitsandusethemwisely,wepresent
themagnituderesponseoffourdifferentquantizationsof
thesamefilter.Inallcases,theformathasbeenselectedto
covertherange[0.125,0.125).Theresponsesareshown
inFigure41.Noticethatifyouhavefewerthan16bits
available,youmightaswellredesignthefilter,sinceyou
havemanymoremultipliersthanyoucanuse6.Onthe
otherhand,increasingtheprecisionto24bitsprovides
onlymodestimprovementsinthiscase.
10.3Fixed-pointfiltering
Quantizingthecoefficientscorrectlyisnottheonlything
weneedtoworryaboutwhenimplementinganFIRfilter
withfixed-pointarithmetic.Supposewewanttoimple-
mentthisfilterusingtheDirect-formstructure.Thestruc-
tureisshownasareferenceinFigure42for5coefficients.
Fortheexampleathand,wehave16bitcoefficients,and
supposeweneedtofilter16-bitdatathatiswellscaledin6
Ifthespecificationischangedfrom80dBto60dB,178multipliers
arerequiredasopposedto220.Ifitisreducedto40dB,134multipliers
arerequired.Ofcourseitisnotagiventhattheapplicationcanallow
thischangeinspecifications.Thepointishavinglessthan16bitsmakes
itunfeasibletoattain80dB.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage23Figure42:Direct-formimplementationofanFIRfilterwith5
coefficients.the[−1,1) range.Wecangeneraterandomdatawiththat
characteristicasfollows7:q=quantizer([16,15],’RoundMode’,’round’);
xq=randquant(q,1000,1);
Wewilluse[16,18] formatforthecoefficientsforillus-
trationpurposes.Sincetheinputisalreadyquantized,we
don’tneedaninputquantizeroramultiplicandquantizer,Hq=qfilt(’fir’,{b},...
’CoefficientFormat’,[16,18]);
set(Hq,’InputFormat’,’none’)
set(Hq,’MultiplicandFormat’,’none’);
Forreference,theotherparametersaresetbydefaultas
follows:OutputFormat = [16 15]
ProductFormat = [32 30]
SumFormat = [32 30]7
Inordertoreproducetheresults,onecanresettheseedof
therandomnumbergeneratorpriortogeneratingtherandomvector:
rand(’seed’,0);however,wewilltemporarilysetthemto’none’ tohave
areferencetocompareto:set(Hq,’OutputFormat’,’none’);
set(Hq,’ProductFormat’,’none’);
set(Hq,’SumFormat’,’none’);
yi=filter(Hq,xq);
Thequantityyi representsthe“ideal”output.Thisisthe
bestoutputwecanhopetocompute.Asidefromusing
the16-bitquantizedcoefficients,allcomputationsareper-
formedwithdouble-precisionarithmetic.Havingyi pro-
videsanicereferencesignaltocompareto.
Nowwesettheparametersbacktotheirdefaultval-
ues,excepttheproductformatisnotaccurateforthis
case.Themultiplicationofa[16,18] coefficientswith
a[16,15] inputsampleresultsina[32,33] product.On
aDSPprocessor,wehavetwo16-bitregistersbeingmul-
tipliedandtheresultstoredina32-bitproductregister.
ThecorrectsettingfortheProductFormat is[32,33]:set(Hq,’OutputFormat’,quantizer([16,15]));
set(Hq,’ProductFormat’,quantizer([32,33]));
set(Hq,’SumFormat’,quantizer([32,30]));
yq=filter(Hq,xq);
Anextremelyusefultooltomonitorwhathashappened
isqreport(Hq),MaxMinNOvNUnNOpsCoefficient0.12-0.02600220Input0.999-0.999001e3Output0.474-0.536021e3Multiplicand0.999-0.9990022e3Prod0.12-0.120022e3Sum0.527-0.5370022e3whichinthiscasereportsthatnooverflowshaveoccurred.
Tomeasurehowgoodtheoutputis,wecomputetheen-
ergyoftheerrorandthemaximumerror,norm(yi-yq,2)
ans =
0.00054794884123692
norm(yi-yq,inf)
ans =
3.05137364193797e-005
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage24Figure43:Modelshowingthequantizationnoisebyreducing
thenumberofbitsfromtheadderstotheoutput.LookingatFigure42,onecanseethereisclearlya
sourceoferrorwhenmovingthedatafromthesetof
adders(whatwouldbetheaccumulatorinaDSPproces-
sor)totheoutput.Indeed,thewordlengthisbeingre-
ducedfrom32to16bits.Amodelofwhatishappening
isshowninFigure43.
Thetheoreticalpowerspectrumofthequantization
noiseattheoutputofthefiltercorrespondingtothemodel
inFigure43isgivenby
S
y
() =|H
n
(e
j
)|
2
2
x
whereH
n
(e
j
) isthetransferfunctionfromthenoise-
sourcetotheoutput-inthiscasesimplyone-,and
2
x
is
thepowerspectrumofthenoisesource-inthiscaseitis
constantandequaltothevarianceofthenoise8
2
x
=
2
2(1−b)12
wherebisthenumberofbits.Sointhiscase,thetheoret-
icalpowerspectrumisconstantandfor16bitsitis,
S
y
() =10log
10
2
2(−15) 12
=−101.100811159671dB8
Strictlyspeaking,thisformulaisapproximatebecausethesignalat
theaccumulatordoesnotcovertheentirerange[−1,1) andbecausewe
arenotquantizingananalogsignal,ratherwearereducingthenumber
ofbitsinanalreadyquantizedsignal.Figure44:Theoreticalandestimatedpowerspectrumofthe
quantizationnoise.Anestimateofthenoisepowerspectrumcanbecomputed
withthenlm function,[H,w,Pnn]=nlm(Hq,512,100);
AplotofPnn (indB)comparedtothetheoreticalpower
spectrumisshowninFigure44.
IfthequantizationnoiseshowninFigure43istheonly
noiseinthesystem,weshouldbeabletogetanoutput
thatexactlymatchesyi bysettingtheoutputformatto
bethesameasthesumformat(onecanthinkofitasthe
abilityto“lookinsidetheaccumulator”),set(Hq,’OutputFormat’,quantizer([32,30]));
yq=filter(Hq,xq);
norm(yi-yq,2)
ans =
2.02838467848398e-006
norm(yi-yq,inf)
ans =
7.98609107732773e-008
Whiletheerrorhasclearlybeenreduced,thereisstill
someleft,indicatingsomeroundoffstillpresentinthe
system.Thisisconfirmedbylookingatthepowerspec-
trumforthenoiseusingnlm.Theplotofthepowerspec-
trumisshowninFigure45.Thenoiseisobviouslyless
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage25Figure45:Noisepowerspectrumwhenmakingtheoutputfor-
matequaltothesumformat.thanbefore(about-168dB),whichisconsistentwiththe
smallererrorswecomputed.Tofindthesourceofthe
erroritissimplyamatteroflookingatthediscrepancy
betweentheproductformatandthesumformat.
Thesumformatissetto[32,30] sothatthethreeleast
significantbitsfromtheproductregisterarebasicallybe-
inglost.Wemaybetemptedtomakethesumformatthe
sameastheproductformat,butoverflowsoccurleftand
right,set(Hq,’SumFormat’,quantizer([32,33]));
yq=filter(Hq,xq);
Warning:1944 overflows in QFILT/FILTER.
Theproblemisthatforadditions,ingeneralkbitsarenot
enoughtoalwaysstoretheresultofaddingtwoquantities
withkbitseach.Overflowmightoccur,andwhenadding
somanynumbers(220inthisexample)chancesarevery
highthatitwilloccur.Soitispreferabletolivewithsome
roundofferror,ratherthantooverflow(thetwo-normof
theerrorisawhooping2.09011261755715,whilethein-
finitynormis0.285711827455089).
Wecanfollowatrial-and-errorprocedurereducingthe
sumformatto[32,32],[32,31],etc.untilnoover-
flowoccurs.However,abetterwayistogobacktothe
[32 30] setting,filter,andlookatthereportgivenbyFigure46:Noisepowerspectrumwhensettingboththesum
formatandtheoutputformatto[32,31].qreport.Forthisexample,qreport showsthatthemax-
imumandminimumsumvaluesare0.527and-0.5357
respectively.Therefore,aformatof[32,31] willbethe
optimalsettingtominimizequantizationnoisewhilenot
overflowing.set(Hq,’SumFormat’,quantizer([32,31]));
set(Hq,’OutputFormat’,quantizer([32,31]));
yq=filter(Hq,xq);
norm(yi-yq,2)
ans =
7.53800283935414e-007
norm(yi-yq,inf)
ans =
2.93366611003876e-008
Onceagain,thebetterresultsareconfirmedbynlm which
nowshowsapowerspectrumforthenoiseof-174dB.
ThepowerspectrumplotisshowninFigure46.
10.3.1Usinganaccumulatorwithextendedprecision
Theresultsobtainedpreviouslyarethebestwewere
abletoobtainwitha32-bitaccumulatorsuchasthat
availableinsomeearlyDSPprocessors.ModernDSP
processorsprovideanaccumulatorwithextendedpreci-
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage26sion,so-calledguardbits,typically40bitswhenthedata
wordlengthis16bits.
Ifsuchanaccumulatorisavailable,wecangetbetter
resultsonceagainifweusetheextrabitswisely.For
instance,thefollowingsettingforthesumformatwillnot
do,set(Hq,’SumFormat’,quantizer([40,31]));
set(Hq,’OutputFormat’,quantizer([40,31]));
becausenooverflowoccurredwiththe[32,31] setting
anyway.Sothrowingextrabitsdoesnogood(theerrors
areexactlythesameasforthe[32,31} case).However,
ifwesettheLSBweightingthesameasfortheproduct
format,namely,ifweusethefollowingsetting,set(Hq,’SumFormat’,quantizer([40,33]));
set(Hq,’OutputFormat’,quantizer([40,33]));
theerrorsbetween“ideal”andactualbecomeexactly
zero.Ofcourse,inthisexampleitwasnotnecessaryto
haveafull40-bitaccumulatortoachieveanoutputex-
actlyequaltowhatwehavecalledideal.Onceagain,
fromthereportgeneratedwithqreport itwasevident
thatasettingof[34,33] forbothsumandoutputwould
havedone.
InanactualDSPprocessortheoutputisnotofthesame
widthastheaccumulator,sorealisticallyweneedtoset
theoutputformatbacktoeither16bitsor32bitsinthis
example.Assumingwehave32bitsfortheoutput,we
canonceagaindeterminethebestpossibleoutputsetting
byusingqreport.Inthiscase,[32,31] isthebestset-
tingbecausetheminimumvaluereportedattheoutputis
-0.5357.Thetwo-normandinfinity-normoftheerrorsarenorm(yi-yq,2)
ans =
6.82098421980174e-009
norm(yi-yq,inf)
ans =
3.49245965480804e-010
whichcomparefavorablywith7.53800283935414e-007
and2.93366611003876e-008respectively(whichwere
thebestwecoulddofora32-bitoutputwitha32-bitac-
cumulator).Figure47:BlockdiagramofthedecimationpartoftheDDC.11Adesignexample
Inthissectionwepresentanexampleofdesigningtwo
FIRfiltersforuseonadigitaldown-converter(DDC)to
beusedtodownconvertaGSMsignal.Thehardwareto
workwithisaGraychip4016multi-standardquadDDC
chip[18].
Roughlyspeaking,adigitaldown-converterhastwo
mainparts.Thefirstsection,whichconsistsofa
numerically-controlledoscillator(NCO)andamixeris
usedto“bring”anIFsignaldowntobaseband.Thesec-
ondsectionisa(multistage)decimatorusedtoisolatethe
desiredsignal.
Inthisdesignexampleweconcentrateonthesecond
part,i.e.,weassumethesignalhasbeenmovedtobase-
bandinasatisfactorymanner.
Fordecimationpurposes,the4016providesforamulti-
stageapproachconsistingof3FIRfilters.Ofthethreefil-
ters,oneisacascadedintegrator-comb(CIC)5-stagedec-
imatorandtwoareprogrammabledecimate-by-twoFIR
filters.
Themultistagedecimatorblockdiagramisshownin
Figure47.The5-stageCICfiltertakesthehigh-ratein-
putsignalanddecimatesitbyaprogrammablefactor.
TheCICfilterisfollowedbya21-tapcompensationFIR
(CFIR)filterthatequalizesthe“droop”duetotheCICfil-
terandprovidesfurtherlowpassfilteringanddecimation
by2.TheCFIRisfollowedbya63-tapprogrammable
FIR(PFIR)filterthatisusedforafinaldecimate-by-2.
Onethingtonoteisthatinamultistagedecimatorone
wouldalwaysputthesimplestfilterfirst(thatis,work-
ingatthehighestrate),andwouldprogressivelyincrease
thecomplexityofthefiltersinsubsequentstages.This
isexactlywhathappenshere,theCICfilterisattractive
athighratesbecauseitprovidesmultiplierlessoperation.
Thefilterprovides(coarse)lowpassfilteringusingadders
anddelays.Thefilterisnotwithoutitsdrawbacksthough,
itsmagnituderesponseisveryfarfromidealandexhibits
a“droop”inthepassbandwhichprogressivelyattenuates
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage27signals.TheCFIRfilterisalsorelativelysimple,having
only21taps.Itsprimarymissionistocompensateforthe
droopfromtheCICfilter.ThePFIRfilteristhemostcom-
plexofthethree,requiring63multiplicationspersample,
whichiswhyitoperatesatthelowestrate.
Itisworthpointingoutthatthisisagoodexampleof
designsthatrequireafixedfilterorder.Also,boththe
CFIRandPFIRarelinear-phasefiltersbyconstruction,
thedesignercanspecifyonlyhalfofitsmultipliers.Lin-
earphaseisusuallyadesirablecharacteristicindatatrans-
mission.Theavailablewordlengthforthecoefficientsof
boththeCFIRandPFIRfiltersis16bits.
11.1Usingthe4016forGSM
The4016isprogrammablesothatitcanbeusedwithmul-
tiplestandards.Tothisextent,thedecimationfactorof
theCICfiltercanbeselectedaswellasthecoefficients
forboththeCFIRandthePFIRfilters.
FortheparticularcaseofGSM,wehavethefollowing
requirements[18]•Inputsamplerate:69.333248MHz•CICdecimationfactor:64•CFIRinputsamplerate:1.083332MHz•PFIRinputsamplerate:541.666kHz•PFIRoutputsamplerate:270.833kHz•Passbandwidth:80kKz•Passbandripple:lessthan0.1dBpeaktopeak
TheCICfilterhas5stagesandadecimationfactorof
64.Toviewthemagnituderesponseofthisfilter,wecan
simplycreateaCICdecimationobjectandusefvtool,Hcic=mfilt.cicdecim(64,1,5);
fvtool(Hcic)
ThemagnituderesponseisshowninFigure48.Thefilter
exhibitsa|sin(x)/x|
5
shape.ItalsohasalargeDCgain
(morethan180dB),thathastobecompensatedfor.To
compensateforthislargegain,the4016providesapower-
of-twoscalingpriortodataenteringthefilter,inorderto
avoidoverflows.Figure48:Magnituderesponseof5-stageCICdecimator.11.1.1DesigningtheCFIRfilter
Sincetheoverallpassbandthatisdesiredis80kHz,itis
worthwhiletolookattheCICresponseinthisbandtoget
anideaofwhattheCFIRfiltermustcompensatefor.The
passbanddetailsoftheCICfilterareshowninFigure49.
Thefiltershowsadroopwithanattenuationofabout0.4
dBat80kHz.Thisisfarmorethantheallowablepeakto
peakripple.
Wewanttodesignanoptimalequiripplefiltertomake
themostofthe21tapsavailable.Sinceonly11coeffi-
cientsareactuallyfreelyspecifiable,weareconstrained
toalinear-phasedesign.
Wechoosetousethefirceqrip functionforthefol-
lowingimportantreasons:•Itallowsforcompensationofresponsesoftheform
|
sin(x)x
|
N
.•Thefilterorderisspecifiable.•Itallowsforaslopeinthestopband,whichwewill
usetoattenuatespectralreplicasofthePFIRfilter
thatfollows.•Wecanconstrainthepeakpassbandandstopband
ripples.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage28Figure49:Passbanddetailsofscaled5-stageCICdecimator.•Insteadofthecutofffrequency,wecanspecifythe
passband-edgefrequency.Inthisparticularcase,
sincethepassbandistheinterval[0,80kHz],wewant
tocompensatefortheCICdroopinthepassband
only.
Thefilterorderisdeterminedforusbythehardware.
Forthepassband-edgefrequency,weselect80kHz,since
thisthefinalpassbandofinterest.Wechooseaverysmall
passbandripple,0.01dB,inorderfortheoverallripple
tobewaywithinspec,keepinginmindthereisstillthe
PFIRfiltertofollowwhichwilladditsownpassbandrip-
ple.Thestopbandattenuationisselectedas40dBwitha
60dBslopetoprovideadequateattenuationofthePFIR
spectralreplicas.Becausethisisa5-stageCIC,thedroop
isoftheform|
sin(x)x
|
5
,soweselect5asthesincpower
tocompensatefor.Finally,thesincfrequencyfactoris
chosenas0.5.N = 20;% Filter order
Npow = 5;% Sinc power
w = 0.5;% Sinc frequency factor
Apass = 5.7565e-004;% 0.01 dB
Astop = 0.01;% 40 dB
Aslope = 60;% 60 dB slope
Fpass = 80/541.666;% Passband-edge
cfir = firceqrip(N,Fpass,[Apass,Astop],...Figure50:MagnituderesponseofCFIRfilter.’passedge’,’slope’,...
Aslope,’invsinc’,[w,Npow]);
Hcfir = mfilt.firdecim(2,cfir);
ThemagnituderesponseoftheCFIRfilterisshownin
Figure50quantizedto16bits.Withoutzoomingin,itis
hardtoseethepassbandinverse-sincresponse.Wecan
seehowever,asexpected,thelargetransitionwidthalong
withtheslopedstopband.Sincethelargestcoefficientof
theCFIRfilteris0.37,weusea[16,16] formattomake
themostofthe16bitsavailable.
TogetanideaofthecombinedfilterCIC*CFIR,we
overlaythemagnituderesponseofeachofthesefilters,
alongwiththecombinedmagnituderesponseofthetwo.
ThisisshowninFigure51.Wecanseethespectralrepli-
casoftheCFIRfiltercenteredaroundthefrequencyitis
operatingat,1.083332MHz.Itishardtoseethesinc-
compensationinthisplot.Forthiswezoominfurther.
Thezoomed-inplotisshowninFigure52.Theplotcov-
ersapproximatelytheband[0,120kHz].Itisevidentfrom
theplotthatthecombinedresponseisvirtuallyflatinthe
passband(upto80kHz).
11.1.2DesigningthePFIRfilter
AnoverlayoftheGSMspectralmaskrequirements[18]
withthecombinedresponseoftheCICfilterandtheCFIR
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage29Figure51:MagnituderesponseofCICfilterandCFIRfilter
overlayed,alongwiththecombinedresponseofthetwo.Figure52:PassbanddetailsforthemagnituderesponseofCIC
filterandCFIRfilteroverlayed,alongwiththecombinedre-
sponseofthetwo.filterisshowninFigure53.Itisevidentfromtheplot
thatthecombinationofthesetwofiltersisnotsufficientto
meettheGSMrequirementsforeitheradjacentbandre-
jectionorblockerrequirements.Thecombinedfilterstill
hasatransitionbandthatistoolarge,duetothelargeFigure53:MagnituderesponseofcombinedCICandCFIRfil-
tersoverlaidwiththeGSMspectralmaskrequirements.Clearly
thecombinationofthesetwofiltersdoesnotmeettheGSMre-
quirements.transitionbandfromtheCFIRfilter.
ThePFIRfilterisintendedtobeusedtodotheextra
workrequiredtomeettheGSMspecifications.Itisa
linear-phaseFIRfilterconsistingof63taps.Thedesign
getsalittletrickythough.Weknowthatthepassband-
edgeis80kHz,andthefirstadjacentbandisat100kHz.
Ifwedesignasimplelowpassfilterwithremez orgremez
asfollows:N = 62;
Fs=541666;
F=[0 80e3 100e3 541666/2]/(Fs/2);
A = [1 1 0 0];
W = [1 1];
pfir= gremez(N,F,A,W);
Hpfir = mfilt.firdecim(2,pfir);
Thepassbandripplerequirementisnotquitemet.Wecan
altertheweightstogetbetterpassbandripple,butwemust
becarefulnottoviolatetheadjacentbandspecifications.
AsettingofW = [10,1];woulddothetrick,butwith
significantlylessadjacentbandattenuation.Acompro-
misecanbeachievedbysettingupthedesignasalow-
passwithtwoseparatestopbandregions,eachonewitha
differentweighttobeusedintheoptimization:
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage30Figure54:MagnituderesponseofPFIRfilter.N = 62;
Fs=541666;
F=[0 80e3 100e3 122e3 132e3 541666/2]/(Fs/2);
A = [1 1 0 0 0 0];
W = [10 1 10];
pfir= gremez(N,F,A,W);
Hpfir = mfilt.firdecim(2,pfir);
ThequantizedPFIRfilterisshowninFigure54.The
maximumcoefficientis0.3378soonceagainweusethe
[16,16] format.Thereference(nonquantized)filteris
alsoshown,butitispracticallyindistinguishablefromthe
quantizedresponse.Thedifferentattenuationinthetwo
stopbandsduetothedifferentweightingisevident.The
passbandrippleiskeptsmallinordertonotexceedthe
allowedpeaktopeakripple.
Aplotshowingthemagnituderesponsesofallthreefil-
ters,CIC,CFIR,andPFIR,isshowninFigure55.Notice
thattheslopedstopbandoftheCFIRfilterprovidesmax-
imumattenuationwhenthespectralreplicasofthePFIR
filteroccur.
Theoverallresponseofthecombination
CIC*CFIR*PFIRisshowninFigure56.TheGSM
spectralmaskrequirementsarenoweasilymetasis
clearlyshowninthefigure.Thepassbanddetailsare
showninFigure57.Therequirementthatthepeakto
peakripplebelessthan0.1dBiseasilymet.ClearlyFigure55:MagnituderesponseofCIC,CFIR,andPFIRfilters.Figure56:CombinedresponseofCIC,CFIR,andPFIRfilters,
alongwithGSMspectralmaskrequirement.thedesigncouldbefurthertunedtoprovideasmaller
transitionwidthattheexpenseoflargerpeaktopeak
passbandrippleand/orlesseradjacentbandrejection.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage31Figure57:Passbanddetailsofcombinedmagnituderesponseof
theCIC,CFIR,andPFIRfilters.ARevisionhistory
Revision1.1-Correctedsectionondesignofperfect-
reconstructiontwo-channelfilterbanks.
Revision1.0-Initialrelease.
References[1]S.J.Orfanidis,IntroductiontoSignalProcessing,
PrenticeHall,UpperSaddleRiver,1996.[2]T.Saramaki.“Finiteimpulseresponsefilterdesign,”
Chapter4inHandbookforDigitalSignalProcess-
ing,S.K.MitraandJ.F.Kaisereds.JohnWileyand
Sons,NewYork,1993.[3]L.R.RabinerandB.Gold,TheoryandApplication
ofDigitalSignalProcessing,PrenticeHall,Engle-
woodCliffs,1975.[4]E.W.Cheney,IntroductiontoApproximationThe-
ory,AmericanMathematicalSociety,RhodeIsland,
1998.[5]J.H.McClellan,T.W.Parks,andL.R.Rabiner,“A
computerprogramfordesigningoptimumFIRlin-earphasedigitalfilters,”IEEETrans.AudioElec-
troacoust.AU-21,506-526,1973.[6]I.W.SelesnickandC.S.Burrus,“Exchangeal-
gorithmsthatcomplementtheParks-McClellanal-
gorithmforlinear-phaseFIRfilterdesign,”IEEE
Trans.onCircuitsandSystemsII,44(2):137-142,
February1997.[7]SuggestedbyR.A.Vargas,inprivatecommunica-
tion,2001.[8]O.Hermann,andH.W.Sch
¨
ussler,“Designofnon-
recursivedigitalfilterswithminimumphase,”Elec-
tron.Lett.6,pp.329-330,1970.[9]Y.Neuvo,C.-Y.Dong,andS.K.Mitra,“Interpo-
latedfiniteimpulseresponsefilters,”IEEETrans.on
Acoust.SpeechandSignalProc.,vol.ASSP-32,pp.
563-570,June1984.[10]P.P.Vaidyanathan,MultirateSystemsandFilter
Banks,PrenticeHallSignalProc.Series,Englewood
Cliffs,1993.[11]R.Lyons,“InterpolatednarrowbandlowpassFIRfil-
ters,”IEEESignalProc.Mag.,pp.50-57,January,
2003.[12]T.Saramaki,Y.Neuvo,andS.K.Mitra,“Design
ofcomputationallyefficientinterpolatedFIRfilters,”
IEEETrans.onCircuitsandSystems,vol.35,N0.
1,pp.70-88,January1988.[13]T.Saramaki,“AclassofFIRNyquist(Nth-band)
filterswithzerointersymbolinterference,”IEEE
Trans.CircuitsSyst.CAS-34,pp.1182-1190,1987.[14]P.P.VaidyanathanandT.Q.Nguyen,“Eigenfilters:
anewapproachtoleastsquaresFIRfilterdesignand
applicationsincludingNyquistfilters,”IEEETrans.
CircuitsSyst.CAS-34,pp.11-23,1987.[15]S.K.Mitra,DigitalSignalProcessing.AComputer-
BasedApproach,2ndEd.,McGraw-Hill,NewYork,
2001.[16]N.J.Fliege,MultirateDigitalSignalProcessing,
JohnWiley&SonsLtd.Chichester,1994.
PracticalFIRFilterDesigninMATLAB
RicardoA.LosadaPage32[17]f.harris,“MultirateSignalProcessinginTransmit-
ter&ReceiverDesigns,”UCLAExtensioncourse,
November,2000.[18]Graychip,Inc.,“GC4016MULTI-STANDARD
QUADDDCCHIPDATASHEET,”Revision1.0,
August27,2001.
Автор
dima202
dima202579   документов Отправить письмо
Документ
Категория
Наука
Просмотров
137
Размер файла
1 101 Кб
Теги
matlab
1/--страниц
Пожаловаться на содержимое документа