教你辨别房屋出租骗子方法_第1页
教你辨别房屋出租骗子方法_第2页
教你辨别房屋出租骗子方法_第3页
教你辨别房屋出租骗子方法_第4页
教你辨别房屋出租骗子方法_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter7DigitalCameraExample1OutlineIntroductiontoasimpledigitalcameraDesigner’sperspectiveRequirementsspecificationDesignFourimplementations2PuttingitalltogetherGeneral-purposeprocessorSingle-purposeprocessorCustomStandardMemoryInterfacingKnowledgeappliedtodesigningasimpledigitalcameraGeneral-purposevs.single-purposeprocessorsPartitioningoffunctionalityamongdifferentprocessortypesIntroduction3IntroductiontoasimpledigitalcameraCapturesimagesStoresimagesindigitalformatNofilmMultipleimagesstoredincameraNumberdependsonamountofmemoryandbitsusedperimageDownloadsimagestoPCOnlyrecentlypossibleSystems-on-a-chipMultipleprocessorsandmemoriesononeICHigh-capacityflashmemoryVerysimpledescriptionusedforexampleManymorefeatureswithrealdigitalcameraVariablesizeimages,imagedeletion,digitalstretching,zoominginandout,etc.4Designer’sperspectiveTwokeytasksProcessingimagesandstoringinmemoryWhenshutterpressed:ImagecapturedConvertedtodigitalformbycharge-coupleddevice(CCD)CompressedandarchivedininternalmemoryUploadingimagestoPCDigitalcameraattachedtoPCSpecialsoftwarecommandscameratotransmitarchivedimagesserially5Charge-coupleddevice(CCD)SpecialsensorthatcapturesanimageLight-sensitivesiliconsolid-statedevicecomposedofmanycellsWhenexposedtolight,eachcellbecomeselectricallycharged.Thischargecanthenbeconvertedtoa8-bitvaluewhere0representsnoexposurewhile255representsveryintenseexposureofthatcelltolight.Someofthecolumnsarecoveredwithablackstripofpaint.Thelight-intensityofthesepixelsisusedforzero-biasadjustmentsofallthecells.Theelectromechanicalshutterisactivatedtoexposethecellstolightforabriefmoment.Theelectroniccircuitry,whencommanded,dischargesthecells,activatestheelectromechanicalshutter,andthenreadsthe8-bitchargevalueofeachcell.ThesevaluescanbeclockedoutoftheCCDbyexternallogicthroughastandardparallelbusinterface.LensareaPixelcolumnsCoveredcolumnsElectroniccircuitryElectro-mechanicalshutterPixelrows6Zero-biaserrorManufacturingerrorscausecellstomeasureslightlyaboveorbelowactuallightintensityErrortypicallysameacrosscolumns,butdifferentacrossrowsSomeofleftmostcolumnsblockedbyblackpainttodetectzero-biaserrorReadingofotherthan0inblockedcellsiszero-biaserrorEachrowiscorrectedbysubtractingtheaverageerrorfoundinblockedcellsforthatrowCoveredcellsBeforezero-biasadjustmentAfterzero-biasadjustmentZero-biasadjustment7CompressionStoremoreimagesTransmitimagetoPCinlesstimeJPEG(JointPhotographicExpertsGroup)PopularstandardformatforrepresentingdigitalimagesinacompressedformProvidesforanumberofdifferentmodesofoperationModeusedinthischapterprovideshighcompressionratiosusingDCT(discretecosinetransform)Imagedatadividedintoblocksof8x8pixels3stepsperformedoneachblockDCTQuantizationHuffmanencoding8DCTstepTransformsoriginal8x8blockintoacosine-frequencydomainUpper-leftcornervaluesrepresentmoreoftheessenceoftheimageLower-rightcornervaluesrepresentfinerdetailsCanreduceprecisionofthesevaluesandretainreasonableimagequalityFDCT(ForwardDCT)formulaC(h)=if(h==0)then1/sqrt(2)else1.0AuxiliaryfunctionusedinmainfunctionF(u,v)F(u,v)=¼xC(u)xC(v)Σx=0..7Σy=0..7Dxyxcos(π(2u+1)u/16)xcos(π(2y+1)v/16)Givesencodedpixelatrowu,columnvDxyisoriginalpixelvalueatrowx,columnyIDCT(InverseDCT)Reversesprocesstoobtainoriginalblock(notneededforthisdesign)9QuantizationstepAchievehighcompressionratiobyreducingimagequalityReducebitprecisionofencodeddataFewerbitsneededforencodingOnewayistodivideallvaluesbyafactorof2SimplerightshiftscandothisDequantizationwouldreverseprocessfordecompressionAfterbeingdecodedusingDCTAfterquantizationDivideeachcell’svalueby810Serialize8x8blockofpixelsValuesareconvertedintosinglelistusingzigzagpatternPerformHuffmanencodingMorefrequentlyoccurringpixelsassignedshortbinarycodeLongerbinarycodesleftforlessfrequentlyoccurringpixelsEachpixelinseriallistconvertedtoHuffmanencodedvaluesMuchshorterlist,thuscompressionHuffmanencodingstep

11HuffmanencodingexamplePixelfrequenciesonleftPixelvalue––1occurs15timesPixelvalue14occurs1timeBuildHuffmantreefrombottomupCreateoneleafnodeforeachpixelvalueandassignfrequencyasnode’svalueCreateaninternalnodebyjoininganytwonodeswhosesumisaminimalvalueThissumisinternalnodesvalueRepeatuntilcompletebinarytreeTraversetreefromroottoleaftoobtainbinarycodeforleaf’spixelvalueAppend0forlefttraversal,1forrighttraversalHuffmanencodingisreversibleNocodeisaprefixofanothercode14453210-2-1-10-5-3-4-8-96141121121224354659510511514617818152935641PixelfrequenciesHuffmantreeHuffmancodes12ArchivestepRecordstartingaddressandimagesizeCanuselinkedlistOnepossiblewaytoarchiveimagesIfmaxnumberofimagesarchivedisN:SetasidememoryforNaddressesandNimage-sizevariablesKeepacounterforlocationofnextavailableaddressInitializeaddressesandimage-sizevariablesto0SetglobalmemoryaddresstoNx4Assumingaddresses,image-sizevariablesoccupyNx4bytesFirstimagearchivedstartingataddressNx4GlobalmemoryaddressupdatedtoNx4+(compressedimagesize)MemoryrequirementbasedonN,imagesize,andaveragecompressionratio13UploadingtoPCWhenconnectedtoPCanduploadcommandreceivedReadimagesfrommemoryTransmitseriallyusingUARTWhiletransmittingResetpointers,image-sizevariablesandglobalmemorypointeraccordingly14RequirementsSpecificationSystem’srequirements–whatsystemshoulddoNonfunctionalrequirementsConstraintsondesignmetrics(e.g.,““shoulduse0.001wattorless”)FunctionalrequirementsSystem’sbehavior(e.g.,““outputXshouldbeinputYtimes2””)Initialspecificationmaybeverygeneralandcomefrommarketingdept.E.g.,shortdocumentdetailingmarketneedforalow-enddigitalcamerathat:capturesandstoresatleast50low-resimagesanduploadstoPC,costsaround$100withsinglemedium-sizeICcostinglessthat$25,haslongaspossiblebatterylife,hasexpectedsalesvolumeof200,000ifmarketentry<6months,100,000ifbetween6and12months,insignificantsalesbeyond12months15NonfunctionalrequirementsDesignmetricsofimportancebasedoninitialspecificationPerformance:timerequiredtoprocessimageSize:numberofelementarylogicgates(2-inputNANDgate)inICPower:measureofavg.electricalenergyconsumedwhileprocessingEnergy:batterylifetime(powerxtime)ConstrainedmetricsValuesmustbebelow(sometimesabove)certainthresholdOptimizationmetricsImprovedasmuchaspossibletoimproveproductMetriccanbebothconstrainedandoptimization16Nonfunctionalrequirements(cont.)PerformanceMustprocessimagefastenoughtobeuseful1secreasonableconstraintSlowerwouldbeannoyingFasternotnecessaryforlow-endofmarketTherefore,constrainedmetricSizeMustuseICthatfitsinreasonablysizedcameraConstrainedandoptimizationmetricConstraintmaybe200,000gates,butsmallerwouldbecheaperPowerMustoperatebelowcertaintemperature(coolingfannotpossible)Therefore,constrainedmetricEnergyReducingpowerortimereducesenergyOptimizedmetric:wantbatterytolastaslongaspossible17InformalfunctionalspecificationFlowchartbreaksfunctionalitydownintosimplerfunctionsEachfunction’sdetailscouldthenbedescribedinEnglishDoneearlierinchapterLowqualityimagehasresolutionof64x64Mappingfunctionstoaparticularprocessortypenotdoneatthisstageserialoutpute.g.,011010...yesnoCCDinputZero-biasadjustDCTQuantizeArchiveinmemoryMore8×8blocks?TransmitseriallyyesnoDone?18RefinedfunctionalspecificationRefineinformalspecificationintoonethatcanactuallybeexecutedCanuseC/C++codetodescribeeachfunctionCalledsystem-levelmodel,prototype,orsimplymodelAlsoisfirstimplementationCanprovideinsightintooperationsofsystemProfilingcanfindcomputationallyintensivefunctionsCanobtainsampleoutputusedtoverifycorrectnessoffinalimplementationimagefile101011010110101010010101101...CCD.CCNTRL.CUART.Coutputfile1010101010101010101010101010...CODEC.CCCDPP.CExecutablemodelofdigitalcamera19CCDmoduleSimulatesrealCCDCcdInitializeispassednameofimagefileCcdCapturereads““image””fromfileCcdPopPixeloutputspixelsoneatatimecharCcdPopPixel(void){charpixel;pixel=buffer[rowIndex][colIndex];if(++colIndex==SZ_COL){colIndex=0;if(++rowIndex==SZ_ROW){colIndex=-1;rowIndex=-1;}}returnpixel;}#include<stdio.h>#defineSZ_ROW64#defineSZ_COL(64+2)staticFILE*imageFileHandle;staticcharbuffer[SZ_ROW][SZ_COL];staticunsignedrowIndex,colIndex;voidCcdInitialize(constchar*imageFileName){imageFileHandle=fopen(imageFileName,"r");rowIndex=-1;colIndex=-1;}voidCcdCapture(void){intpixel;rewind(imageFileHandle);for(rowIndex=0;rowIndex<SZ_ROW;rowIndex++){for(colIndex=0;colIndex<SZ_COL;colIndex++){if(fscanf(imageFileHandle,"%i",&pixel)==1){buffer[rowIndex][colIndex]=(char)pixel;}}}rowIndex=0;colIndex=0;}20CCDPP(CCDPreProcessing)modulePerformszero-biasadjustmentCcdppCaptureusesCcdCaptureandCcdPopPixeltoobtainimagePerformszero-biasadjustmentaftereachrowreadin#defineSZ_ROW64#defineSZ_COL64staticcharbuffer[SZ_ROW][SZ_COL];staticunsignedrowIndex,colIndex;voidCcdppInitialize(){rowIndex=-1;colIndex=-1;}voidCcdppCapture(void){charbias;CcdCapture();for(rowIndex=0;rowIndex<SZ_ROW;rowIndex++){for(colIndex=0;colIndex<SZ_COL;colIndex++){buffer[rowIndex][colIndex]=CcdPopPixel();}bias=(CcdPopPixel()+CcdPopPixel())/2;for(colIndex=0;colIndex<SZ_COL;colIndex++){buffer[rowIndex][colIndex]-=bias;}}rowIndex=0;colIndex=0;}charCcdppPopPixel(void){charpixel;pixel=buffer[rowIndex][colIndex];if(++colIndex==SZ_COL){colIndex=0;if(++rowIndex==SZ_ROW){colIndex=-1;rowIndex=-1;}}returnpixel;}21UARTmoduleActuallyahalfUARTOnlytransmits,doesnotreceiveUartInitializeispassednameoffiletooutputtoUartSendtransmits(writestooutputfile)bytesatatime#include<stdio.h>staticFILE*outputFileHandle;voidUartInitialize(constchar*outputFileName){outputFileHandle=fopen(outputFileName,"w");}voidUartSend(chard){fprintf(outputFileHandle,"%i\n",(int)d);}22CODECmoduleModelsFDCTencodingibufferholdsoriginal8x8blockobufferholdsencoded8x8blockCodecPushPixelcalled64timestofillibufferwithoriginalblockCodecDoFdctcalledoncetotransform8x8blockExplainedinnextslideCodecPopPixelcalled64timestoretrieveencodedblockfromobufferstaticshortibuffer[8][8],obuffer[8][8],idx;voidCodecInitialize(void){idx=0;}voidCodecDoFdct(void){intx,y;for(x=0;x<8;x++){for(y=0;y<8;y++) obuffer[x][y]=FDCT(x,y,ibuffer);}idx=0;}voidCodecPushPixel(shortp){if(idx==64)idx=0;ibuffer[idx/8][idx%8]=p;idx++;}shortCodecPopPixel(void){shortp;if(idx==64)idx=0;p=obuffer[idx/8][idx%8];idx++;returnp;}23CODEC(cont.)ImplementingFDCTformulaC(h)=if(h==0)then1/sqrt(2)else1.0F(u,v)=¼¼xC(u)xC(v)ΣΣx=0..7Σy=0..7Dxyxcos(ππ(2u+1)u/16)xcos(π(2y+1)v/16)Only64possibleinputstoCOS,sotablecanbeusedtosaveperformancetimeFloating-pointvaluesmultipliedby32,678androundedtonearestinteger32,678choseninordertostoreeachvaluein2bytesofmemoryFixed-pointrepresentationexplainedmorelaterFDCTunrollsinnerloopofsummation,implementsoutersummationastwoconsecutiveforloopsstaticconstshortCOS_TABLE[8][8]={{32768,32138,30273,27245,23170,18204,12539,6392},{32768,27245,12539,-6392,-23170,-32138,-30273,-18204},{32768,18204,-12539,-32138,-23170,6392,30273,27245},{32768,6392,-30273,-18204,23170,27245,-12539,-32138},{32768,-6392,-30273,18204,23170,-27245,-12539,32138},{32768,-18204,-12539,32138,-23170,-6392,30273,-27245},{32768,-27245,12539,6392,-23170,32138,-30273,18204},{32768,-32138,30273,-27245,23170,-18204,12539,-6392}};staticintFDCT(intu,intv,shortimg[8][8]){doubles[8],r=0;intx;for(x=0;x<8;x++){s[x]=img[x][0]*COS(0,v)+img[x][1]*COS(1,v)+img[x][2]*COS(2,v)+img[x][3]*COS(3,v)+img[x][4]*COS(4,v)+img[x][5]*COS(5,v)+img[x][6]*COS(6,v)+img[x][7]*COS(7,v);}for(x=0;x<8;x++)r+=s[x]*COS(x,u);return(short)(r*.25*C(u)*C(v));}staticshortONE_OVER_SQRT_TWO=23170;staticdoubleCOS(intxy,intuv){returnCOS_TABLE[xy][uv]/32768.0;}staticdoubleC(inth){returnh?1.0:ONE_OVER_SQRT_TWO/32768.0;}24CNTRL(controller)moduleHeartofthesystemCntrlInitializeforconsistencywithothermodulesonlyCntrlCaptureImageusesCCDPPmoduletoinputimageandplaceinbufferCntrlCompressImagebreaksthe64x64bufferinto8x8blocksandperformsFDCToneachblockusingtheCODECmoduleAlsoperformsquantizationoneachblockCntrlSendImagetransmitsencodedimageseriallyusingUARTmodulevoidCntrlSendImage(void){for(i=0;i<SZ_ROW;i++)for(j=0;j<SZ_COL;j++){temp=buffer[i][j];UartSend(((char*)&temp)[0]);/*sendupperbyte*/UartSend(((char*)&temp)[1]);/*sendlowerbyte*/}}}#defineSZ_ROW64#defineSZ_COL64#defineNUM_ROW_BLOCKS(SZ_ROW/8)#defineNUM_COL_BLOCKS(SZ_COL/8)staticshortbuffer[SZ_ROW][SZ_COL],i,j,k,l,temp;voidCntrlInitialize(void){}voidCntrlCaptureImage(void){CcdppCapture();for(i=0;i<SZ_ROW;i++)for(j=0;j<SZ_COL;j++)buffer[i][j]=CcdppPopPixel();}voidCntrlCompressImage(void){for(i=0;i<NUM_ROW_BLOCKS;i++)for(j=0;j<NUM_COL_BLOCKS;j++){for(k=0;k<8;k++)for(l=0;l<8;l++)CodecPushPixel( (char)buffer[i*8+k][j*8+l]);CodecDoFdct();/*part1-FDCT*/for(k=0;k<8;k++)for(l=0;l<8;l++){buffer[i*8+k][j*8+l]=CodecPopPixel();/*part2-quantization*/ buffer[i*8+k][j*8+l]>>=6;}}}25PuttingitalltogetherMaininitializesallmodules,thenusesCNTRLmoduletocapture,compress,andtransmitoneimageThissystem-levelmodelcanbeusedforextensiveexperimentationBugsmucheasiertocorrecthereratherthaninlatermodelsintmain(intargc,char*argv[]){char*uartOutputFileName=argc>1?argv[1]:"uart_out.txt";char*imageFileName=argc>2?argv[2]:"image.txt";/*initializethemodules*/UartInitialize(uartOutputFileName);CcdInitialize(imageFileName);CcdppInitialize();CodecInitialize();CntrlInitialize();/*simulatefunctionality*/CntrlCaptureImage();CntrlCompressImage();CntrlSendImage();}26DesignDeterminesystem’’sarchitectureProcessorsAnycombinationofsingle-purpose(customorstandard)orgeneral-purposeprocessorsMemories,busesMapfunctionalitytothatarchitectureMultiplefunctionsononeprocessorOnefunctionononeormoreprocessorsImplementationAparticulararchitectureandmappingSolutionspaceissetofallimplementationsStartingpointLow-endgeneral-purposeprocessorconnectedtoflashmemoryAllfunctionalitymappedtosoftwarerunningonprocessorUsuallysatisfiespower,size,andtime-to-marketconstraintsIftimingconstraintnotsatisfiedthenlaterimplementationscould:usesingle-purposeprocessorsfortime-criticalfunctionsrewritefunctionalspecification27Implementation1:MicrocontrolleraloneLow-endprocessorcouldbeIntel8051microcontrollerTotalICcostincludingNREabout$5Wellbelow200mWpowerTime-to-marketabout3monthsHowever,oneimagepersecondnotpossible12MHz,12cyclesperinstructionExecutesonemillioninstructionspersecondCcdppCapturehasnestedloopsresultingin4096(64x64)iterations~100assemblyinstructionseachiteration409,000(4096x100)instructionsperimageHalfofbudgetforreadingimagealoneWouldbeoverbudgetafteraddingcompute-intensiveDCTandHuffmanencoding28Implementation2:

MicrocontrollerandCCDPPCCDPPfunctionimplementedoncustomsingle-purposeprocessorImprovesperformance––lessmicrocontrollercyclesIncreasesNREcostandtime-to-marketEasytoimplementSimpledatapathFewstatesincontrollerSimpleUARTeasytoimplementassingle-purposeprocessoralsoEEPROMforprogrammemoryandRAMfordatamemoryaddedaswell8051UARTCCDPPRAMEEPROMSOC29MicrocontrollerSynthesizableversionofIntel8051availableWritteninVHDLCapturedatregistertransferlevel(RTL)FetchesinstructionfromROMDecodesusingInstructionDecoderALUexecutesarithmeticoperationsSourceanddestinationregistersresideinRAMSpecialdatamovementinstructionsusedtoloadandstoreexternallySpecialprogramgeneratesVHDLdescriptionofROMfromoutputofCcompiler/linkerToExternalMemoryBusController4KROM128RAMInstructionDecoderALUBlockdiagramofIntel8051processorcore30UARTUARTinidlemodeuntilinvokedUARTinvokedwhen8051executesstoreinstructionwithUART’’senableregisterastargetaddressMemory-mappedcommunicationbetween8051andallsingle-purposeprocessorsLower8-bitsofmemoryaddressforRAMUpper8-bitsofmemoryaddressformemory-mappedI/OdevicesStartstatetransmits0indicatingstartofbytetransmissionthentransitionstoDatastateDatastatesends8bitsseriallythentransitionstoStopstateStopstatetransmits1indicatingtransmissiondonethentransitionsbacktoidlemodeinvokedI=8I<8Idle:I=0Start:TransmitLOWData:Transmitdata(I),thenI++Stop:TransmitHIGHFSMDdescriptionofUART31CCDPPHardwareimplementationofzero-biasoperationsInteractswithexternalCCDchipCCDchipresidesexternaltoourSOCmainlybecausecombiningCCDwithordinarylogicnotfeasibleInternalbuffer,B,memory-mappedto8051VariablesR,Carebuffer’’srow,columnindicesGetRowstatereadsinonerowfromCCDtoB66bytes:64pixels+2blacked-outpixelsComputeBiasstatecomputesbiasforthatrowandstoresinvariableBiasFixBiasstateiteratesoversamerowsubtractingBiasfromeachelementNextRowtransitionstoGetRowforrepeatofprocessonnextrowortoIdlestatewhenall64rowscompletedC=64C<64R=64C=66invokedR<64C<66Idle:R=0C=0GetRow:B[R][C]=PxlC=C+1

ComputeBias:Bias=(B[R][11]+B[R][10])/2C=0NextRow:R++C=0FixBias:B[R][C]=B[R][C]-Bias

FSMDdescriptionofCCDPP32ConnectingSOCcomponentsMemory-mappedAllsingle-purposeprocessorsandRAMareconnectedto8051’’smemorybusReadProcessorplacesaddresson16-bitaddressbusAssertsreadcontrolsignalfor1cycleReadsdatafrom8-bitdatabus1cyclelaterDevice(RAMorSPP)detectsassertedreadcontrolsignalChecksaddressPlacesandholdsrequesteddataondatabusfor1cycleWriteProcessorplacesaddressanddataonaddressanddatabusAssertswritecontrolsignalfor1clockcycleDevice(RAMorSPP)detectsassertedwritecontrolsignalChecksaddressbusReadsandstoresdatafromdatabus33SoftwareSystem-levelmodelprovidesmajorityofcodeModulehierarchy,procedurenames,andmainprogramunchangedCodeforUARTandCCDPPmodulesmustberedesignedSimplyreplacewithmemoryassignmentsxdatausedtoload/storevariablesoverexternalmemorybus_at_specifiesmemoryaddresstostorethesevariablesBytesenttoU_TX_REGbyprocessorwillinvokeUARTU_STAT_REGusedbyUARTtoindicateitsreadyfornextbyteUARTmaybemuchslowerthanprocessorSimilarmodificationforCCDPPcodeAllothermodulesuntouchedstaticunsignedcharxdataU_TX_REG_at_65535;staticunsignedcharxdataU_STAT_REG_at_65534;voidUARTInitialize(void){}voidUARTSend(unsignedchard){while(U_STAT_REG==1){/*busywait*/}U_TX_REG=d;}RewrittenUARTmodule#include<stdio.h>staticFILE*outputFileHandle;voidUartInitialize(constchar*outputFileName){outputFileHandle=fopen(outputFileName,"w");}voidUartSend(chard){fprintf(outputFileHandle,"%i\n",(int)d);}Originalcodefromsystem-levelmodel34AnalysisEntireSOCtestedonVHDLsimulatorInterpretsVHDLdescriptionsandfunctionallysimulatesexecutionofsystemRecallprogramcodetranslatedtoVHDLdescriptionofROMTestsforcorrectfunctionalityMeasuresclockcyclestoprocessoneimage(performance)Gate-leveldescriptionobtainedthroughsynthesisSynthesistoollikecompilerforSPPsSimulategate-levelmodelstoobtaindataforpoweranalysisNumberoftimesgatesswitchfrom1to0or0to1CountnumberofgatesforchipareaPowerVHDLsimulatorVHDLVHDLVHDLExecutiontimeSynthesistoolgatesgatesgatesSumgatesGatelevelsimulatorPowerequationChipareaObtainingdesignmetricsofinterest35Implementation2:

MicrocontrollerandCCDPPAnalysisofimplementation2Totalexecutiontimeforprocessingoneimage:9.1secondsPowerconsumption:0.033wattEnergyconsumption:0.30joule(9.1sx0.033watt)Totalchiparea:98,000gates36Implementation3:MicrocontrollerandCCDPP/Fixed-PointDCT9.1secondsstilldoesn’tmeetperformanceconstraintof1secondDCToperationprimecandidateforimprovementExecutionofimplementation2showsmicroprocessorspendsmostcycleshereCoulddesigncustomhardwarelikewedidforCCDPPMorecomplexsomoredesigneffortInstead,willspeedupDCTfunctionalitybymodifyingbehavior37DCTfloating-pointcostFloating-pointcostDCTuses~260floating-pointoperationsperpixeltransformation4096(64x64)pixelsperimage1millionfloating-pointoperationsperimageNofloating-pointsupportwithIntel8051CompilermustemulateGeneratesproceduresforeachfloating-pointoperationmult,addEachprocedureusestensofintegeroperationsThus,>10millionintegeroperationsperimageProceduresincreasecodesizeFixed-pointarithmeticcanimproveonthis38Fixed-pointarithmeticIntegerusedtorepresentarealnumberConstantnumberofinteger’sbitsrepresentsfractionalportionofrealnumberMorebits,moreaccuratetherepresentationRemainingbitsrepresentportionofrealnumberbeforedecimalpointTranslatingarealconstanttoafixed-pointrepresentationMultiplyrealvalueby2^(#ofbitsusedforfractionalpart)RoundtonearestintegerE.g.,represent3.14as8-bitintegerwith4bitsforfraction2^4=163.14x16=50.24≈50=0011001016(2^4)possiblevaluesforfraction,eachrepresents0.0625(1/16)Last4bits(0010)=22x0.0625=0.1253(0011)+0.125=3.125≈≈3.14(morebitsforfractionwouldincreaseaccuracy)39Fixed-pointarithmeticoperationsAdditionSimplyaddintegerrepresentationsE.g.,3.14+2.71=5.853.14→→50=001100102.71→→43=0010101150+43=93=010111015(0101)+13(1101)x0.0625=5.8125≈5.85MultiplyMultiplyintegerrepresentationsShiftresultrightby#ofbitsinfractionalpartE.g.,3.14*2.71=8.509450*43=2150=100001100110>>4=100001108(1000)+6(0110)x0.0625=8.375≈8.5094Rangeofrealvaluesusedlimitedbybitwidthsofpossibleresultingvalues40Fixed-pointimplementationofCODECCOS_TABLEgives8-bitfixed-pointrepresentationofcosinevalues6bitsusedforfractionalportionResultofmultiplicationsshiftedrightby6voidCodecDoFdct(void){unsignedshortx,y;for(x=0;x<8;x++)for(y=0;y<8;y++)outBuffer[x][y]=F(x,y,inBuffer);idx=0;}staticconstcharcodeCOS_TABLE[8][8]={{64,62,59,53,45,35,24,12},{64,53,24,-12,-45,-62,-59,-35},{64,35,-24,-62,-45,12,59,53},{64,12,-59,-35,45,53,-24,-62},{64,-12,-59,35,45,-53,-24,62},{64,-35,-24,62,-45,-12,59,-53},{64,-53,24,12,-45,62,-59,35},{64,-62,59,-53,45,-35,24,-12}};staticconstcharONE_OVER_SQRT_TWO=5;staticshortxdatainBuffer[8][8],outBuffer[8][8],idx;voidCodecInitialize(void){idx=0;}staticunsignedcharC(inth){returnh?64:ONE_OVER_SQRT_TWO;}staticintF(intu,intv,shortimg[8][8]){longs[8],r=0;unsignedcharx,j;for(x=0;x<8;x++){s[x]=0;for(j=0;j<8;j++)s[x]+=(img[x][j]*COS_TABLE[j][v])>>6;}for(x=0;x<8;x++)r+=(s[x]*COS_TABLE[x][u])>>6;return(short)((((r*(((16*C(u))>>6)*C(v))>>6))>>6)>>6);}voidCodecPushPixel(shortp){if(idx==64)idx=0;inBuffer[idx/8][idx%8]=p<<6;idx++;}41Implementation3:MicrocontrollerandCCDPP/Fixed-PointDCTAnalysisofimplementation3Usesamea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论