tag 标签: floating

相关博文
  • 热度 21
    2015-10-17 20:39
    2014 次阅读|
    1 个评论
    Colin Walls recently had an article on this site about floating point math. Once it was common for embedded engineers to scoff at floats; many have told me they have no place in this space. That’s simply wrong. The very first embedded program I wrote in 1972 or so used an 8008 to control a near-infrared instrument. Even though we were limited to 4KB of EPROM (it was incredibly expensive then), all of the math had to be in floating point using a library written by one Cal Ohne. Amazingly, he crammed that into just 1KB of program memory. And that was on an 8 bitter with a ferociously-bad stack and very limited instruction set.   Today even MCUs sometimes have on-board floating point hardware. ST’s STM32F4 parts, for instance, have this feature and some are under four bucks in 1000 piece lots.   But most working in the microcontroller space don’t have hardware floating point, so have to use a software solution, which is slow and consumes a lot of memory.   We use integers because they are fast and convenient. But the dynamic range is limited and fractional arithmetic impossible. Floats give us enormous ranges but suffer from performance. An alternative, well known to DSP developers, is fixed point math.   Integers, of course, look like this (ignoring a sign bit):   Can you see the binary point? It’s not shown, but there is one all the way to the right of the 2 0 bit.   Suppose we move that binary point four bits to the left. Now, in the same 16 bit word, the format looks like this:   The number stored in this format is the 16 bit integer value times 2 -4 . So if the word looks like 11528 (decimal) it’s really 720.5, because 720.5= 11528 x 2 -4 .   Obviously, we lose some range; the biggest number expressible is smaller than devoting those 16 bits to ints. But we gain precision.   Here’s where the magic comes in: to add two fixed point numbers one just does a normal integer addition. Multiplication is little more than multiplies plus shifting. Yes, there are some special cases one must watch for, but math is very fast compared to floats. So if you need fractional values and speed, fixed point might be your new best friend. (These algorithms are well documented and not worth repeating here, but two references are Embedded Systems Building Blocks by Jean LaBrosse and Fixed Point Math in C by Joe Lemieux .   There’s no rule about where the binary point should be; you select a precision that works for your application. “Q notation” is a standardized way of talking about where the binary point is located. Qf means there are f fractional bits (e.g., Q5 means 5 bits to the right of the binary point). Qn.f tells us there are n bits to the left of the binary point and f to the right.   Integers are wonderful: they are easy to understand and very fast. Floats add huge ranges and fractional values, but may be costly in CPU cycles. Sometimes fixed point is just the ticket when one needs a compromise between the other two formats. It’s not unusual to see them used in computationally-demanding control applications, like PID loops. Add them to your tool kit!
相关资源
  • 所需E币: 1
    时间: 2023-6-25 13:26
    大小: 894.58KB
    上传者: 张红川
    TMS320C28xFloatingPointUnitandInstructionSetReferenceGuide(Rev.A).pdf
  • 所需E币: 1
    时间: 2022-7-23 18:03
    大小: 2.98KB
    上传者: Argent
    CS1-CJ1FloatingPointtoFixedPointConversionforHMI
  • 所需E币: 1
    时间: 2022-5-2 14:55
    大小: 6.36MB
    NumericalComputingwithIEEEFloatingPointArithmetic,.Michael.L..Overton,.SIAM,.2001
  • 所需E币: 5
    时间: 2019-12-25 15:02
    大小: 139.64KB
    上传者: quw431979_163.com
    DSPapplicationsareusuallyprogrammedinthesamelanguagesasotherscienceandengineeringtasks,suchas:C,BASICandassembly.ThepowerandversatilityofCmakesitthelanguageofchoiceforcomputerscientistsandotherprofessionalprogrammers.Ontheotherhand,thesimplicityofBASICmakesitidealforscientistsandengineerswhoonlyoccasionallyvisittheprogrammingworld.Regardlessofthelanguageyouuse,mostoftheimportantDSPsoftwareissuesareburiedfarbelowintherealmofwhirlingonesandzeros.Thisincludessuchtopicsas:hownumbersarerepresentedbybitpatterns,round-offerrorincomputerarithmetic,thecomputationalspeedofdifferenttypesofprocessors,etc.Thischapterisaboutthethingsyoucandoatthehighleveltoavoidbeingtrampledbythelowlevelinternalworkingsofyourcomputer.CHAPTERDSPSoftware4DSPapplicationsareusuallyprogrammedinthesamelanguagesasotherscienceandengineeringtasks,suchas:C,BASICandassembly.ThepowerandversatilityofCmakesitthelanguageofchoiceforcomputerscientistsandotherprofessionalprogrammers.Ontheotherhand,thesimplicityofBASICmakesitidealforscientistsandengineerswhoonlyoccasionallyvisittheprogrammingworld.Regardlessofthelanguageyouuse,mostoftheimportantDSPsoftwareissuesareburiedfarbelowintherealmofwhirlingonesandzeros.Thisincludessuchtopicsas:hownumbersarerepresentedbybitpatterns,round-offerrorincomputerarithmetic,thecomputationalspeedofdifferenttypesofprocessors,etc.Thischapteri……
  • 所需E币: 5
    时间: 2019-12-25 15:00
    大小: 1.09MB
    上传者: 978461154_qq
    OnceyoudecidethataDigitalSignalProcessorisrightforyourapplication,youneedawaytogetstarted.Manymanufacturerswillsellyoualowcostevaluationkit,allowingyoutoexperiencetheirproductsfirst-hand.Theseareagreateducationaltool;itdoesn'tmatterifyouareanoviceorapro,theyarethebestwaytobecomefamiliarwithaparticularDSP.Forinstance,AnalogDevicesprovidestheEZ-KIT®LitetoteachpotentialcustomersaboutitsSHARC®familyofDigitalSignalProcessors.Foronly$179,youreceiveallthehardwareandsoftwareyouneedtoseetheDSPinaction.Thisincludes"canned"programsprovidedwiththekit,aswellasapplicationsyoucanwriteyourselfinassemblyorC.SupposeyoubuyoneofthesekitsfromAnalogDevicesandplaywithitforafewdays.Thischapterisanoverviewofwhatyoucanexpecttofindandlearn.TheADSP-2106xfamilyInCHAPTERGettingStartedwithDSPs29OnceyoudecidethataDigitalSignalProcessorisrightforyourapplication,youneedawaytogetstarted.Manymanufacturerswillsellyoualowcostevaluationkit,allowingyoutoexperiencetheirproductsfirst-hand.Theseareagreateducationaltool;itdoesn'tmatterifyouareanoviceorapro,theyarethebestwaytobecomefamiliarwithaparticularDSP.Forinstance,AnalogDevicesprovidestheEZ-KITLitetoteachpotentialcustomersaboutitsSHARCfamilyofDigitalSignalProcessors.Foronly$179,youreceiveallthehardwareandsoftwareyouneedtoseetheDSPinaction.Thisincludes"canned"programsprovidedwiththekit,aswellasapplicationsyoucanwriteyourselfinassemblyorC.Suppos……
  • 所需E币: 3
    时间: 2019-12-25 15:01
    大小: 416.88KB
    上传者: 16245458_qq.com
    DigitalSignalProcessingiscarriedoutbymathematicaloperations.Incomparison,wordprocessingandsimilarprogramsmerelyrearrangestoreddata.ThismeansthatcomputersdesignedforbusinessandothergeneralapplicationsarenotoptimizedforalgorithmssuchasdigitalfilteringandFourieranalysis.DigitalSignalProcessorsaremicroprocessorsspecificallydesignedtohandleDigitalSignalProcessingtasks.Thesedeviceshaveseentremendousgrowthinthelastdecade,findinguseineverythingfromcellulartelephonestoadvancedscientificinstruments.Infact,hardwareengineersuse"DSP"tomeanDigitalSignalProcessor,justasalgorithmdevelopersuse"DSP"tomeanDigitalSignalProcessing.ThischapterlooksathowDSPsaredifferentfromothertypesofmicroprocessors,howtodecideifaDSPisrightforyourapplication,andhowtogetstartedinthisexcitingnewfield.Inthenextchapterwewilltakeamoredetailedlookatoneofthesesophisticatedproducts:theAnalogDevicesSHARC®family.CHAPTERDigitalSignalProcessors28DigitalSignalProcessingiscarriedoutbymathematicaloperations.Incomparison,wordprocessingandsimilarprogramsmerelyrearrangestoreddata.ThismeansthatcomputersdesignedforbusinessandothergeneralapplicationsarenotoptimizedforalgorithmssuchasdigitalfilteringandFourieranalysis.DigitalSignalProcessorsaremicroprocessorsspecificallydesignedtohandleDigitalSignalProcessingtasks.Thesedeviceshaveseentremendousgrowthinthelastdecade,findinguseineverythingfromcellulartelephonestoadvancedscientificinstruments.Infact,hardwareengineersuse"DSP"tomeanDigitalSignalProcessor,justasalgorithmdevelopersuse"DSP"tomeanDigitalSignalProcessing.Thischap……
  • 所需E币: 4
    时间: 2019-12-25 02:43
    大小: 157.93KB
    上传者: 2iot
    ARMVectorFloatingPointInstructionSetQuickReferenceCardVectorFloatingPointInstructionSetQuickReferenceCardKeytoTables{cond}SeeTableConditionField(onARMside).{E}E:raiseexceptiononanyNaN.WithoutE:raiseexceptiononlyonsignalingNaNs.S(singleprecision)orD(doubleprecision).{Z}Roundtowardszero.OverridesFPSCRroundingmode.Asabove,orX(unspecifiedprecision).AcommaseparatedlistofconsecutiveVFPregisters,enclosedinbraces({and}).Fd,Fn,FmSd,Sn,Sm(singleprecision),orDd,Dn,Dm(doubleprecision).……
  • 所需E币: 5
    时间: 2019-12-24 23:07
    大小: 744.37KB
    上传者: givh79_163.com
    本应用笔记介绍了如何使用LPC32x0矢量浮点协处理器(VFP)。AN10902UsingtheLPC32xxVFPRev.01―9February2010ApplicationnoteDocumentinformationInfoContentKeywordsVectorFloatingPoint(VFP)coprocessor,LPC32x0,LPC3180AbstractThisapplicationnotedescribeshowtouseLPC32x0VectorFloatingPoint(VFP)coprocessor.NXPSemiconductorsAN10902UsingtheLPC32xxVFPRevisionhistoryRevDateDescription0120100209Initialversion.Contactinformati……
  • 所需E币: 5
    时间: 2019-12-24 19:08
    大小: 110.23KB
    上传者: rdg1993
    【应用笔记】快速傅里叶变换及反变换成组浮点缩放(FFT/IFFTBlockFloatingPointScaling)Altera的FFTMegaCore功能模块内部使用成组浮点(block-floating-point,BFP)运算来执行计算。BFP结构是一个介于定点和完全浮点结构之间的一种折中方案。TheAltera®FFTMegaCore®functionusesblock-floating-point(BFP)arithmeticinternallytoperformcalculations.BFParchitectureisatrade-offbetweenfixed-pointandfullfloating-pointarchitecture.UnlikeanFFTblockthatusesfloatingpointarithmetic,ablock-floating-pointFFTblockdoesnotprovideaninputforexponents.Internally,acomplexvalueintegerpairisrepresentedwithasinglescalefactorthatistypicallysharedamongothercomplexvalueintegerpairs.AftereachstageoftheFFT,thelargestoutputvalueisdetectedandtheintermediateresultisscaledtoimprovetheprecision.Theexponentrecordsthenumberofleftorrightshiftsusedtoperformthescaling.Asaresult,theoutputmagnituderelativetotheinputlevelis:output*2-exponentForexample,ifexponent=–3,theinputsamplesareshiftedrightbythreebits,andhencethemagnitudeoftheoutputisoutput*23.FFT/IFFTBlockFloatingPointScalingOctober2005,ver.1.0ApplicationNote404IntroductionTheAlteraFFTMegaCorefunctionusesblock-floating-point(BFP)arithmeticinternallytoperformcalculations.BFParchitectureisatrade-offbetweenfixed-pointandfullfloating-pointarchitecture.UnlikeanFFTblockthatusesfloatingpointarithmetic,ablock-floating-pointFFTblockdoesnotprovideaninputforexponents.Internally,acomplexvalueintegerpairisrepresentedwitha……