浮点运算单元公开课一等奖省优质课大赛获奖课件_第1页
浮点运算单元公开课一等奖省优质课大赛获奖课件_第2页
浮点运算单元公开课一等奖省优质课大赛获奖课件_第3页
浮点运算单元公开课一等奖省优质课大赛获奖课件_第4页
浮点运算单元公开课一等奖省优质课大赛获奖课件_第5页
已阅读5页,还剩42页未读 继续免费阅读

下载本文档

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

文档简介

浮点运算单元浮点运算Floating-PointNumbersIEEE754Floating-PointStandardFloating-PointAdditionandSubtractionFloating-PointMultiplication浮点数在计算机内格式浮点数:X=MS

ESEm-1...E2E1

M-1M-2...M-n

符号位

阶码位

尾数数码位

总位数短浮点数:

1

8

23

32长浮点数:

1

11

52

64

暂时浮点数:1

15

64

80IEEE标准:阶码用移码,基为2;尾数用原码X=MX*2EX浮点数阶码位数决定数表示范围,

尾数位数决定数有效精度。浮点数在计算机内格式浮点数:X=M

EE...EE

MM...M

ssm-110-1-2-nIEEE标准:尾数用原码X=MX

*2EX浮点数是数学中实数子集合,由一个纯小数乘上一个指数值来组成。在计算机内,其纯小数部分被称为浮点数尾数,对非0值浮点数,要求尾数绝对值必须>=1/2,称满足这种表示要求浮点数为规格化表示;把不满足这一表示要求尾数,变成满足这一要求尾数操作过程,叫作浮点数规格化处理,经过尾数移位和修改阶码实现。浮点数在计算机内格式浮点数:X=M

EE...EE

MM...M

ssm-110-1-2-nIEEE标准:尾数用原码X=MX*2EX按国际电子电气工程师协会要求标准,浮点数尾数要用原码表示,即符号位Ms:0表示正,1表示负,且非0值尾数数值最高位M-1必为1,才能满足浮点数规格化表示要求;既然非0值浮点数尾数数值最高位必定为1,则在保留浮点数到内存前,经过尾数右移,强行把该位去掉,用一样多尾数位就能多存一位二进制数,有利于提升数据表示精度,称这种处理方案使用了隐藏位技术。当然,在取回这么浮点数到运算器执行运算时,必须先恢复该隐藏位。FloatingPoint浮点数在计算机内格式X=Ms

EsEm-1...E1E0

M-1M-2...M-n

IEEE标准:阶码用移码,基为2X=MX*2EX按国际电子电气工程师协会要求国际通用标准,浮点数阶码用整数给出,而且要用移码表示,用作为以2为底指数幂。既然该指数底一定为2,能够无须在浮点数格式中明确表示出来,只需给出阶码幂值即可。

移码表示只用于表示整数,只用在浮点数阶码部分,其定义类似于整数补码定义,差异在符号位。

移码符号位是0表示负,1表示正,与补码符号位恰好相反,移码是指机器数在数轴上有个移位关系;

移码数值位则与补码数值位完全相同。浮点数格式:关于移码知识浮点数:X=M

EE...EE

MM...M

ssm-110-1-2-nX=MX*2EX移码表示整数,用在浮点数阶码部分。一位符号位和n位数值位组成移码,其定义为;[E]移=2n+E-2n<=E<2n表示范围:00000000111111110负数正数机器数[X]补=X0X<2n

2n+1+X-2nX0浮点数格式:关于移码知识一位符号位和n位数值位组成移码,其定义为;[E]移=2n+E-2n<=E<2n表示范围:00000000~11111111

负数

正数机器数0移码只执行二数加减运算与增1、减1操作。加减运算时,符号位计算结果求反后,才是加减运算正确符号位值。注意:当用双符号位时,00代表负,01代表正,而不是11代表正8位阶码能表示-128~+127,当阶码为-128时,其补码表示为00000000,该浮点数绝对值<2-128,人们要求此浮点数值为零,若尾数不为0就清其为0,并特称此值为机器零。8位移码表示机器数为数真值在数轴上向右平移了128个位置-128+127BiasedExponentValueofexponent=val(E)=E–Bias(Biasisaconstant)8bitsforsingleprecisionEcanbeintherange0to255E=0andE=255arereservedforspecialuseE=1to254areusedfornormalizedfloatingpointnumbersBias=127(halfof254),val(E)=E–127val(E=1)=–126,val(E=127)=0,val(E=254)=127ExampleofExponentExponent(E)Adjusted

Binary(E+127)

+5

132

100001000

127

1111111-10

117

1110101+128

255

11111111-127

0

0-1

126

1111110ExampleofNormalizedMantissaBinaryValueNormalizedAsExponent1101.1011.10110130.001011.01-31.00011.00010100000111.00000117BiasedExponentExampleofFloatingPointLargestNormalizedFloatSmallestNormalizedFloatZeroInfinityNaNDenormalizednumbersZero&InfinityThevalueNaN(NotaNumber)isusedtorepresentavaluethatdoesnotrepresentarealnumber.NaNisaspecialvaluerepresentedwithmaximumEandF≠0Resultfromexceptionalsituations,suchas0/0orsqrt(negative)OperationonaNaNresultsisNaN:Op(X,NaN)=NaNQNaNdenoteindeterminateoperations,SNaNdenoteinvalidoperationsNaNSignExponent(e)Fraction(f)Value000..0000..00+0000..0000..01PositiveDenormalizedReal:0.f×2(-b+1)11..11

000..01XX..XXPositiveNormalizedReal:1.f×2(e-b)11..10

011..1100..00+Infinity011..1100..01SNaN:01..11011..1110..00QNaN:11..11SignExponent(e)Fraction(f)Value100..0000..00-0100..0000..01NegativeDenormalizedReal:-0.f×2(-b+1)11..11

100..01XX..XXNegativeNormalizedReal:-1.f×2(e-b)11..10

111..1100..00-Infinity111..1100..01SNaN:01..11111..1110..00QNaN:11.11OperationResultn÷±Infinity0±Infinity×±Infinity±Infinity±nonzero÷0±InfinityInfinity+InfinityInfinity±0÷±0NaNInfinity-InfinityNaN±Infinity÷±InfinityNaN±Infinity×0NaNFPAddFPAddFloatingPointSubtractionExampleFloatingPointSubtractionExampleExtrabitsGuardbitExtrabitRoundingModenearestInthismode,theinexactresultsareroundedtothenearerofthetwopossibleresultvalues.Iftheneitherpossibilityisnearer,thentheevenalternativeischosen.Thisformofroundingisalsocalled``roundtoeven''。“Even”whenleastsignificantbitis0Value Binary Rounded Action RoundedValue23/32 10.000112 10.002 (<1/2—down)223/16 10.001102 10.012 (>1/2—up) 21/427/8 10.111002 11.002 (1/2—up) 325/8 10.101002 10.102 (1/2—down) 21/2RoundingModeStepsinAddition/SubtractionofFloating-PointNumbersStep1:Calculatedifferencedofthetwoexponents-d=|E1-E2|Step2:Shiftsignificandofsmallernumberbyd-base

positionstotherightStep3:AddalignedsignificandsandsetexponentofresulttoexponentoflargeroperandStep4:NormalizeresultantsignificandandadjustexponentifnecessaryStep5:RoundresultantsignificandandadjustexponentifnecessaryAddition/SubtractionStructureAddition/SubtractionE1E2-

Exponentoflargernumbernotdecreased-thiswillresultinalargersignificandadderrequired.

Addition-resultantsignificandM(sumoftwoalignedsignificands)isinrange1/

M<2

IfM>1-apostnormalizationstep-shiftingsignificandtotherighttoyieldM3andincreasingexponentbyone-isrequired(anexponentoverflowmayoccur)Addition/SubtractionNormalizationSubtraction-ResultantsignificandMisinrange0|M|<1-postnormalizationstep-shiftingsignificandtoleftanddecreasingexponent-isrequiredifM<1/

(anexponentunderflowmayoccur)Inextremecases,thepostnormalizationstepmayrequireashiftleftoperationoverallbitsinsignificand,yieldingazeroresult.EffectiveAddition/SubtractionDistinguishbetweeneffectiveadditionandeffectivesubtractionDependsonsignbitsofoperandsandinstructionexecutedEffectiveaddition:CalculateexponentdifferencetodeterminealignmentshiftShiftsignificandofsmalleroperand,addalignedsignificandsTheresultcanoverflowbyatmostonebitpositionLongpost-normalizationshiftnotneededSinglebitoverflowcanbedetectedand,iffound,a1-bitnormalizationisperformedusingamultiplexorEliminateIncrementinRoundingSignificandadderdesignedtoproducetwosimultaneousresults-sumandsum+1Calledcompoundadder;canbeimplementedinvariousways(e.g.,carry-look-aheadorconditionalsum)Round-to-nearest-even-useroundingbitstodeterminewhichofthetwoshouldbeselectedThesetwoaresufficientevenifasinglebitoverflowoccursIncaseofoverflow,1isaddedinRposition(insteadofLSBposition),andsinceR=1ifroundingneeded,acarrywillpropagatetoLSBtogeneratecorrectsum+1

Directedroundings-Rnotnecessarily1-sum+2maybeneededEffectiveSubtractionMassivecancellationofmostsignificantbitsmayoccur-resultinginlengthypostnormalizationHappensonlywhenexponentsofoperandsareclose(difference1)-pre-alignmentcanbeeliminatedTwoseparateprocedures-(1)exponentsareclose(difference1)-onlyapostnormalizationshiftmaybeneeded(2)exponentsarefar

(difference>1)-onlyapre-alignmentshiftmaybeneededCLOSECaseExponentdifferencepredictedbasedontwoleastsignificantbitsofoperands-allowssubtractionofsignificandstostartassoonaspossibleIf0-subtractexecutedwithnoalignmentIf1-significandofsmalleroperandisshiftedoncetotheright(usingamultiplexor)andthensubtractedfromothersignificandInparallel-trueexponentdifferencecalculatedIf>1-procedureabortedandFARprocedurefollowedIf

1-

CLOSEprocedurecontinuedInparallelwithsubtraction-numberofleadingzerospredictedtodeterminenumberofshiftpositionsinpostnormalizationCLOSECase-NormalizationandRoundingNext-normalizationofsignificandandcorrespondingexponentadjustmentLast-rounding-precomputingsum,sum+1-selectingtheonewhichisproperlyrounded-negationofresultmaybenecessaryResultofsubtractionusuallypositive-negationnotrequiredOnlywhenexponentsequal-resultofsignificandsubtractionmaybenegative(intwo'scomplement)-requiringanegationstepNegationandroundingsteps-mutuallyexclusiveFARCaseFirst-exponentdifferencecalculatedNext-significandofsmalleroperandshiftedtorightforalignmentShifted-outbitsusedtosetstickybitSmallersignificandsubtractedfromlarger-resulteithernormalized.Laststep-roundingLeadingZerosPredictionCircuitPredictpositionofleadingnon-zerobitinresultofsubtractbeforesubtractioniscompletedAllowingtoexecutepostnormalizationshiftimmediatelyfollowingsubtractionExaminebitsofoperands(ofsubtract)inaserialfashion,startingwithmostsignificantbitstodeterminepositionoffirst1Thisserialoperationcanbeacceleratedusingaparallelschemesimilartocarry-look-aheadLeadingZerosPredictionCircuitPredictpositionofleadingnon-zerobitinresultofsubtractbeforesubtractioniscompletedAllowingtoexecutepostnormalizationshifti

温馨提示

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

评论

0/150

提交评论