首页 > > > DSP入门.pdf

DSP入门.pdf

DSP入门.pdf

上传者: 寻觅虚无 2013-12-13 评分1 评论0 下载0 收藏10 阅读量221 暂无简介 简介 举报

简介:本文档为《DSP入门pdf》,可适用于硬件技术领域,主题内容包含CHAPTERSHARC,EZKIT,EZLAB,VisualDSP,EZICE,theSHARClogo,theAnalogDeviceslogo符等。

535CHAPTER29SHARC,EZ-KIT,EZ-LAB,VisualDSP,EZ-ICE,theSHARClogo,theAnalogDeviceslogo,andtheVisualDSPlogoareregisteredtrademarksofAnalogDevices,Inc.GettingStartedwithDSPsOnceyoudecidethataDigitalSignalProcessorisrightforyourapplication,youneedawaytogetstarted.Manymanufacturerswillsellyoualowcostevaluationkit,allowingyoutoexperiencetheirproductsfirst-hand.Theseareagreateducationaltool;itdoesn'tmatterifyouareanoviceorapro,theyarethebestwaytobecomefamiliarwithaparticularDSP.Forinstance,AnalogDevicesprovidestheEZ-KITLitetoteachpotentialcustomersaboutitsSHARCfamilyofDigitalSignalProcessors.Foronly$179,youreceiveallthehardwareandsoftwareyouneedtoseetheDSPinaction.Thisincludes"canned"programsprovidedwiththekit,aswellasapplicationsyoucanwriteyourselfinassemblyorC.SupposeyoubuyoneofthesekitsfromAnalogDevicesandplaywithitforafewdays.Thischapterisanoverviewofwhatyoucanexpecttofindandlearn.TheADSP-2106xfamilyInthelastchapterwelookedatthegeneraloperationoftheADSP-2106x"SHARC"familyofDigitalSignalProcessors.Table29-1showsthevariousmembersofthisfamily.Allthesedevicesusethesamearchitecture,buthavedifferentamountsofon-chipmemory,akeyfactorindecidingwhichonetouse.MemoryaccessisacommonbottleneckinDSPsystems.TheSHARCDSPsaddressthisbyprovidinganamplesupplyofon-chipdual-portedSRAM.However,thelastthingyouwanttodoispayformorememorythanyouneed.DSPsoftengointocostsensitiveproducts,suchascellulartelephonesandCDplayers.Inotherwords,theorganizationofthisfamilyisdeterminedbymarketingaswellastechnology.TheoldestmemberofthisfamilyistheADSP-21020.Thischipcontainsthecorearchitecture,butdoesnotincludeon-chipmemoryorI/Ohandling.Thismeansitcannotfunctionasastand-alonecomputer;itrequiresexternalcomponentstobeafunctionalsystem.TheotherdevicesarecompleteTheScientistandEngineer'sGuidetoDigitalSignalProcessing536PRODUCTMemoryNotesAD14604Mbit4Quad-SHARC,FourADSP-21060'sinthesamemodule;providesanincredible480MFLOPSinonly2.05"2.05"0.16".ADSP-21160M4MbitNew!FeaturesSingleInstructionMultipleData(SIMD)corearchitecture;optimizedformultiprocessingwithlinkports,64bitexternalbus,and14channelsofDMAADSP-210604MbitPowerhouseofthefamily;mostmemory;linkportsforhighspeeddatatransferandmulti-processingADSP-210622MbitSamefeaturesastheADSP-21060,butwithlessinternalmemory(SRAM),forlowercostADSP-210611MbitLowcostversionusedintheEZ-KITLite;lessmemory&nolinkports;additionalfeaturesinDMAfortheserialportADSP-21065L544kbitArecentadditiontothefamily;fastandverylowcost($10).WillattractmanyfixedpointapplicationstotheSHARCfamilyADSP-21020-0-Oldestmemberofthefamily.Containsthecoreprocessor,butnoon-chipmemoryorI/Ointerface.NotquiteaSHARCDSP.TABLE29-1MembersoftheSHARCfamily.computerswithinasinglechip.Alltheyrequiretooperateisasourceofpower,andsomewaytoloadaprogramintomemory,suchasanexternalPROMordatalink.NoticeinTable29-1thateventhelow-endproductshaveaverysignificantamountofmemory.Forinstance,theADSP-21065Lhas544kbitsofinternalSRAM.Thisisenoughtohold6-8secondsofdigitizedspeech(8ksamplespersecond,8bitspersample).Onthehigh-endofthefamily,theADSP-21060hasa4Mbitmemory.Thisismorethanenoughtostoreanentiredigitizedimage(512512pixels,8bitsperpixel).Ifyourequireevenmorememory,youeasilyaddexternalSRAM(orslowermemory)toanyofthesedevices.Inadditiontomemory,therearealsodifferencesbetweenthesefamilymembersintheirI/Osections.TheADSP-21060andADSP-21062(thehigh-end)eachhavesixlinkports.Theseare4bitwideparallelconnectionsforcombiningDSPsinmultiprocessingsystems,andotherapplicationsthatrequireflexiblehigh-speedI/O.TheADSP-21061andADSP-21065L(thelow-end)donothavelinkports,butfeaturemoreDMAchannelstoassistintheirserialportoperation.Youwillalsoseethesepartnumberswithan"L"or"M"afterthem,suchas"ADSP-21060L."Thisindicatesthatthedeviceoperatesfromavoltagelowerthanthetraditional5.0volts.ForChapter29-GettingStartedwithDSPs537SHARCUART/RS-232DriverPROMCODECemulatorconnectorprocessorbusserialportportslinkADSP-21061flagLEDsflagIRQresetPOWER9-12vdc,1ampaudioinaudioout(toPC)ExpansionserialcableserialJTAGportFIGURE29-1BlockdiagramoftheEZ-KITLiteboard.Onlyfourexternalconnectionsareneeded:audioin,audioout,aserial(RS-232)cabletoyourpersonalcomputer,andpower.TheserialcableandpowersupplyareprovidedwiththeEZ-KITLite.instance,theADSP-21060Loperatesfrom3.3volts,whiletheADSP-21160Musesonly2.5volts.InJune1998,AnalogDevicesunveiledthesecondgenerationofitsSHARCarchitecture,withtheannouncementoftheADSP-21160.ThisfeaturesaSingleInstructionMultipleData(SIMD,or"sim-dee")corearchitectureoperatingat100MHz,anacceleratedmemorybusbandwidthof1600megabytespersecond,two64bitdatabusses,andfour80-bitaccumulatorsforfixedpointcalculations.Alltotaled,thenewADSP-21160Mexecutesa1024pointFFTinonly46microseconds.TheSIMDDSPcontainsasecondsetofcomputationalunits(arithmeticandlogicunit,barrelshifter,dataregisterfile,andmultiplier),allowingADItomaintainbackwardcodecompatibilitywiththeADSP-2106xfamily,whileprovidingaroad-maptouptotentimeshigherperformance.TheSHARCEZ-KITLiteTheEZ-kitLitegivesyoueverythingyouneedtolearnabouttheSHARCDSP,including:hardware,software,andreferencemanuals.Figure29-1showsablockdiagramofthehardwareprovidedintheEZ-KITLite,basedaroundtheADSP-21061DigitalSignalProcessor.Thiscomesasa46inchprintedcircuitboard,mountedonplasticstandoffstoallowittositonTheScientistandEngineer'sGuidetoDigitalSignalProcessing538yourdesk.(ThereisalsoaversioncalledtheEZ-LAB,usingtheADSP-21062,thatplugsintoaslotinyourcomputer).Thereareonlyfourconnectionsyouneedtoworryabout:DCpower,aserialconnectiontoyourpersonalcomputer,andtheinputandoutputsignals.ADCpowersupplyandserialcableareevenprovidedinthekit.Theinputandoutputsignalsareataudiolevel,about1voltamplitude.Alternatively,ajumperontheboardallowsamicrophonetobedirectlyattachedintotheinput.Theideaistoplugamicrophoneintotheinput,andattachasetofamplifiedspeakers(suchasusedwithpersonalcomputers)totheoutput.ThisallowsyoutoheartheeffectofvariousDSPalgorithms.Analog-to-digitalanddigital-to-analogconversionisaccomplishedwithanAnalogDevicesAD1847codec(coder-decoder).Thisisa16bitsigma-deltaconverter,capableofdigitizingtwochannels(stereo)atarateofupto48ksamples/second,andsimultaneouslyoutputingtwochannelsatthesamerate.Sincetheprimaryuseofthisboardistoprocessaudiosignals,theinputsandoutputsareACcoupledwithacutoffofabout20Hz.Threepushbuttonsontheboardallowtheusertogenerateaninterrupt,resettheprocessor,andtoggleaflagbitthatcanbereadbythesystem.FourLEDsmountedontheboardcanbeturnedonandoffbytogglingbits.Ifyouareambitious,therearesectionsoftheboardthatallowyoutoaccesstheserialport,linkports(onlyontheEZ-LABwithitsADSP-21062),andprocessorbus.However,theseareunpopulated,andyouwillneedtoattachtheconnectorsandothercomponentsyourself.Here'showitworks.Whenthepowerisapplied,theprocessorbootsfromanon-boardEPROM(512kbytes),loadingaprogramthatestablishesserialcommunicationwithyourpersonalcomputer.Next,youlaunchtheEZ-LiteHostprogramonyouPC,allowingyoutodownloadprogramsanduploaddatafromtheDSP.SeveralprewrittenprogramscomewiththeEZ-KITLite;thesecanberunbysimplyclickingonicons.Forinstance,aband-passprogramallowsyoutospeakintothemicrophone,andheartheresultafterpassingthroughaband-passfilter.Theseprogramsareusefulfortworeasons:(1)theyallowyoutoquicklygetthesystemdoingsomethinginteresting,givingyouconfidencethatitdoeswork,and(2)theyprovideatemplateforcreatingprogramsofyourown.Whichbringsustoournexttopic,adesignexampleusingtheEZ-KITLite.DesignExample:AnFIRAudioFilterAfteryouexperimentwiththeprewrittenprogramsforawhile,youwillwanttomodifythemtogainexperiencewiththeprogramming.ProgramscanbewrittenineitherassemblyorC;theEZ-KITLiteprovidessoftwaretoolstosupportbothlanguages.Laterinthischapterwewilllookatadvancedmethodsofprogramming,suchassimulation,debugging,andworkinginanintegrateddevelopmentenvironment.Fornow,wewillfocusontheeasiestwaytogetaprogramtorun.Littlestepsforlittlefeet.Chapter29-GettingStartedwithDSPs539Frequency00.10.20.30.40.50123a.FrequencyresponseSamplenumber0100200300-0.50.00.51.01.5b.Impulseresponse(filterkernel)FIGURE29-2ExampleFIRfilter.In(a)thefrequencyresponseofahighlycustomfilterisshown.Thecorrespondingimpulseresponse(filterkernel)isshownin(b).ThisfilterwasdesignedinChapter17toshowthatvirtuallyanyfrequencyresponsecanbeachievedwithFIRdigitalfilters.AmplitudeAmplitudeSincethesourcecodeisinASCII,astandardtexteditorisallthatisneededtomakechangestoexistingfiles,orcreateentirelynewprograms.Table29-2showsanexampleofanFIRfilterprogramwritteninassembly.Whilethisistheonlycodeyouneedtoworryaboutfornow,keepinmindthatthereareotherfilesneededtomakethisacompleteprogram.Thisincludesan"architecturedescriptionfile"(whichdefinesthehardwareconfigurationandmemoryallocation),setupoftheinterruptvectortable,andacodecinitializationroutine.Eventuallyyouwillneedtounderstandwhatgoesoninthesesections,butfornowyousimplycopythemfromtheprewrittenprograms.AsshownatthetopofTable29-2,therearethreevariablesthatneedtobedefinedbeforejumpingintothemainsectionofcode.Thesearethenumberofpointsinthefilterkernel,NR_COEF;acircularbufferthatholdsthepastsamplesfromtheinputsignal,dline[];andacircularbufferthatholdsthefilterkernel,coef[].Wealsoneedtogivetheprogramtwootherpiecesofinformation:thesamplingrateofthecodec,andthenameofthefilecontainingthefilterkernel,sothatitcanbereadintocoef[].Allthesestepsareeasy;nothingmorethanasinglelineofcodeeach.Wedon'tshowtheminthisexamplebecausetheyarecontainedinthesectionsofcodethatweareignoringforsimplicity.Figure29-2showsthefilterkernelwewilltesttheprogramwith,thesamecustomfilterwedesignedinChapter17.Asyourecall,thisfilterwaschosentohaveaveryirregularfrequencyresponse,reinforcingthenotionthatFIRdigitalfilterscanprovidevirtuallyanyfrequencyresponseyoudesire.Figure(a)showsthefrequencyresponseofourtestfilter,while(b)showsthecorrespondingimpulseresponse(i.e.,thefilterkernel).This301pointfilterkernelisstoredinanASCIIfile,andiscombinedwiththeothersectionsofcodeduringlinkingtoformasingleexecutableprogram.TheScientistandEngineer'sGuidetoDigitalSignalProcessing540Themainsectionoftheprogramperformstwofunctions.Inlines6to13,thedata-address-generators(DAGs)areconfiguredtomanagethecircularbuffers:dline[],andcoef[].Asdescribedinthelastchapter,threeparametersareneededforeachbuffer:thestartinglocationofthebufferinmemory(b0andb8),thelengthofthebuffer(l0andl8),andthestepsizeofthedatabeingstoredinthebuffer(m0andm8).TheseparametersthatcontrolthecircularbuffersarestoredinhardwareregistersintheDAGs,allowingthemtoaccessandmanagethedataveryefficiently.Thesecondactionofthemainprogramisa"thumb-twiddling"loop,implementedinlines15to19.Thisdoesnothingbutwaitforaninterruptindicatingthataninputsamplehasbeenacquired.Alloftheprocessinginthisprogramoccursonasample-by-samplebasis.Eachtimeasampleisreadfromtheinput,asampleintheoutputsignaliscalculatedandroutedtothecodec.Mosttime-domainalgorithms,suchasFIRandIIRfilters,fallintothiscategory.Thealternativeisframe-by-frameprocessing,whichisrequiredforfrequency-domaintechniques.Intheframe-by-framemethod,agroupofsamplesisreadfromtheinput,calculationsareconducted,andagroupofsamplesiswrittentotheoutput.Thesubroutinethatservicesthesample-readyinterruptisbrokenintothreesections.Thefirstsection(lines27to33)fetchesthesamplefromthecodecasafixedpointnumber,andconvertsittofloatingpoint.InSHARCassemblylanguage,adataregisterholdingafixedpointnumberisreferredtoby"r"(suchasr0,r8,r15,etc.),andby"f"ifitisholdingafloatingpointnumber(i.e.,f0,f8,orf15.).Forinstance,inline32,thefixedpointnumberindataregister0(i.e.,r0)isconvertedintoafloatingpointnumberandoverwritesdataregister0(i.e.,f0).Thisconversionisdoneaccordingtoascalingspecifiedbythefixedpointnumberindataregister1(i.e.r1).Inthethirdsection(lines47to53),theoppositestepstakeplace;thefloatingpointnumberfortheoutputsampleisconvertedtofixedpointandsenttothecodec.TheFIRfilterthatconvertstheinputsamplesintotheoutputsamplesiscontainedinlines35to45.Allthecalculationsarecarriedoutinfloatingpoint,avoidingtheneedtoworryaboutscalingandoverflow.Asdescribedinthelastchapter,thissectionofcodeisoptimizedtotakeadvantageoftheSHARCDSP'sabilitytoexecutemultipleinstructionseachclockcycle.Afterwehavetheassemblyprogramwrittenandthefilterkerneldesigned,wearereadytocreateaprogramthatcanbeexecutedontheSHARCDSP.Thisisdonebyrunningthecompiler,theassembler,andthenthelinker;threeprogramsprovidedwiththeEZ-KITLite.ThecompilerconvertsaCprogramintotheSHARC'sassemblylanguage.Ifyoudirectlywritetheprograminassembly,suchasinthisexample,youbypassthisstep.Theassemblerandlinkerconverttheprogramandexternalfiles(suchasthearchitecturefile,codecinitializationroutines,filterkernel,etc.)intothefinalexecutablefile.Allthistakesabout30seconds,withthefinalresultbeingaSHARCprogramresidingontheharddiskofyourPC.TheEZ-KITLitehostisthenusedtoruntheprogramontheEZ-KITLite.SimplyclickChapter29-GettingStartedwithDSPs541TABLE29-2FIRfilterprograminassembly.Beforeenteringthemainprogram,thefollowingconstantandvariablesmustbedefined:NR_COEFThenumberofcoefficientsinthefilterkernel(301inthisexample)dline[NR_COEF]Acircularbufferholdingthepastinputsamples,indatamemorycoef[NR_COEF]Acircularbufferholdingthefiltercoefficients,inprogrammemory001/************************************************************************002******************MAINPROGRAM**********************003************************************************************************/004main:005006/*INITIALIZETHEDAGSTOCONTROLTHECIRCULARBUFFERS*/007008b0=dline;/*setupdline[],thebufferholdingthepastinputsamples*/009l0=@dline;010m0=1;011b8=coef;/*setupcoef[],thebufferholdingthefiltercoefficients*/012l8=@coef;013m8=1;014015/*ENTERALOOP,WAITINGFORTHESAMPLE-READYINTERRUPT*/016017wait:018idle;019jumpwait;020021022/***********************************************************************023*********SUBROUTINETOPROCESSONESAMPLE***********024***********************************************************************/025sample_ready:026027/*ACQUIRETHEINPUTSAMPLE,CONVERTTOFLOATINGPOINT*/028029r0=dm(rx_buf+1);/*movetheinputsampleintor0*/030r0=lshiftr0by16;/*shifttothehighest16bitstopreservethesign*/031r1=-31;/*setthescalingfortheconversion*/032f0=floatr0byr1;/*convertfromfixedtofloatingpoint*/033dm(i0,m0)=f0;/*storethenewsampleindline[],andzerof12*/034035/*CALCULATETHEOUTPUTSAMPLEFROMTHEFIRFILTER*/036037f12=0;/*primetheregisters*/038f2=dm(i0,m0),f4=pm(i8,m8);039f8=f2*f4,f2=dm(i0,m0),f4=pm(i8,m8);040/*efficientmainloop*/041lcntr=NR_COEF-2,do(pc,1)untillce;042f8=f2*f4,f12=f8+f12,f2=dm(i0,m0),f4=pm(i8,m8);043044f8=f2*f4,f12=f8+f12;/*completethelastloop*/045f12=f8+f12;046047/*CONVERTTHEOUTPUTSAMPLETOFIXEDPOINT&OUTPUT*/048049r1=31;/*setthescalingfortheconversion*/050r8=fixf12byr1;/*convertfromfloatingtofixedpoint*/051rti(db);/*returnfrominterrupt,butexecutenext2lines*/052r8=lshiftr8by-16;/*shifttothelowest16bits*/053dm(tx_buf+1)=r8;/*movethesampletotheoutput*/TheScientistandEngineer'sGuidetoDigitalSignalProcessing542EZ-KITSignalGeneratorOscilloscopeinputoutputFIGURE29-3TestingtheEZ-KITLite.Analogengineerstesttheperformanceofasystembyconnectingasignalgeneratortoitsinput,andanoscilloscopetoitsoutput.WhenaDSPsystem(suchastheEZ-KITLite)istestedinthisway,itappearstobeavirtuallyperfectanalogsystemonthefileyouwanttheDSPtorun,andtheEZ-KITLitehosttakescareoftherest,downloadingtheprogramandstartingitrunning.Thisbringsustotwoquestions.First,howdowetestouraudiofiltertomakesureitisoperatingaswedesignedit;andsecond,whatintheworldisacompanycalledAnalogDevicesdoingmakingDigitalSignalProcessors?AnalogmeasurementsonaDSPsystemForjustafewmoments,forgetthatyouarestudyingdigitaltechniques.Let'stakealookatthisfromthestandpointofanengineerthatspecializesinanalogelectronics.Hedoesn'tcarewhatisinsideoftheEZ-KITLite,onlythatithasananaloginputandananalogoutput.AsshowninFig.29-3,hewouldinvokethetraditionalanalogmethodofanalyzinga"blackbox,"attachasignalgeneratortotheinput,andlookattheoutputonanoscilloscope.Whatdoesouranaloggurufind?First,thesystemislinear(asleastasfarasthissimpletestcantell).Ifasinewaveisplacedintotheinput,asinewaveisobservedontheoutput.Iftheamplitudeorfrequencyoftheinputischanged,acorrespondingchangeisseenintheoutput.Whentheinputfrequencyisslowlyincreased,therecomesapointwheretheamplitudeoftheoutputsinewavedecreasesrapidlytozero.Thatoccurs

该用户的其他资料

  • 名称/格式
  • 评分
  • 下载次数
  • 资料大小
  • 上传时间

用户评论

0/200
    暂无评论
上传我的资料

相关资料

资料评价:

/ 16
所需积分:1 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!