COMPUTER ARITHMETIC Algorithms and Hardware Designs SECOND EDITION Behrooz Parhami DepartmentofElectricalandComputerEngineering UniversityofCalifornia,SantaBarbara NEWYORK OXFORD OXFORDUNIVERSITYPRESS 2010 OxfordUniversityPress,Inc.,publishesworksthatfurtherOxfordUniversitiy’s objectiveofexcellenceinresearch,scholarship,andeducation. Oxford NewYork Auckland CapeTown DaresSalaam HongKong Karachi KualaLumpur Madrid Melbourne MexicoCity Nairobi NewDelhi Shanghai Taipei Toronto withofficesin Argentina Austria Brazil Chile CzechRepublic France Greece Guatemala Hungary Italy Japan Poland Portugal Singapore SouthKorea Switzerland Thailand Turkey Ukraine Vietnam Copyright©2010byOxfordUniversityPress,Inc. PublishedbyOxfordUniversityPress,Inc. 198MadisonAvenue,NewYork,NewYork10016 http://www.oup.com OxfordisaregisteredtrademarkofOxfordUniversityPress Allrightsreserved.Nopartofthispublicationmaybereproduced, storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans, electronic,mechanical,photocopying,recording,orotherwise, withoutthepriorpermissionofOxfordUniversityPress. LibraryofCongressCataloging-in-PublicationData Parhami,Behrooz. Computerarithmetic/BehroozParhami.–2nded. p.cm. ISBN978-0-19-532848-6 1.Computerarithmetic.2.Computeralgorithms.I.Title. QA76.9.C62P372009 005.1—dc22 2009034155 Printingnumber:9 8 7 6 5 4 3 2 1 PrintedintheUnitedStatesofAmerica onacid-freepaper Tothememoryofmyfather, SalemParhami(1922–1992), andtoallothersonwhomIcancount foraddedinspiration, multipliedjoy, anddividedanguish. PREFACE to the first edition THECONTEXTOFCOMPUTERARITHMETIC Advancesincomputerarchitectureoverthepasttwodecadeshaveallowedtheper- formanceofdigitalcomputerhardwaretocontinueitsexponentialgrowth,despite increasingtechnologicaldifficultyinspeedimprovementatthecircuitlevel.Thisphe- nomenal rate of growth, which is expected to continue in the near future, would not have been possible without theoretical insights, experimental research, and tool- buildingeffortsthathavehelpedtransformcomputerarchitecturefromanartintoone of the most quantitative branches of computer science and engineering. Better under- standing of the various forms of concurrency and the development of a reasonably efficientanduser-friendlyprogrammingmodelhavebeenkeyenablersofthissuccess story. The downside of exponentially rising processor performance is an unprecedented increaseinhardwareandsoftwarecomplexity.Thetrendtowardgreatercomplexityis notonlyatoddswithtestabilityandcertifiabilitybutalsohampersadaptability,perfor- mancetuning,andevaluationofthevarioustrade-offs,allofwhichcontributetosoaring developmentcosts.Akeychallengefacingcurrentandfuturecomputerdesignersisto reversethistrendbyremovinglayerafterlayerofcomplexity,optinginsteadforclean, robust,andeasilycertifiabledesigns,whilecontinuingtotrytodevisenovelmethodsfor gainingperformanceandease-of-usebenefitsfromsimplercircuitsthatcanbereadily adaptedtoapplicationrequirements. Inthecomputerdesigners’questforuser-friendliness,compactness,simplicity,high performance, lowcost, andlowpower, computerarithmeticplaysakeyrole. Itisone ofoldestsubfieldsofcomputerarchitecture.Thebulkofhardwareinearlydigitalcom- putersresidedinaccumulatorandotherarithmetic/logiccircuits.Thus,first-generation computer designers were motivated to simplify and share hardware to the extent pos- sible and to carry out detailed cost–performance analyses before proposing a design. Manyoftheingeniousdesignmethodsthatweusetodayhavetheirrootsinthebulky, power-hungrymachinesof30–50yearsago. In fact computer arithmetic has been so successful that it has, at times, become transparent.Arithmeticcircuitsarenolongerdominantintermsofcomplexity;registers, memory and memory management, instruction issue logic, and pipeline control have xix xx Preface become the dominant consumers of chip area in today’s processors. Correctness and highperformanceofarithmeticcircuitsareroutinelyexpected,andepisodessuchasthe IntelPentiumdivisionbugofthemid1990sareindeedrare. Theprecedingcontextischangingforseveralreasons.First,atveryhighclockrates, theinterfacesbetweenarithmeticcircuitsandtherestoftheprocessorbecomecritical. Arithmeticunitscannolongerbedesignedandverifiedinisolation.Rather,anintegrated designoptimizationisrequired,whichmakesthedevelopmentevenmorecomplexand costly.Second,optimizingarithmeticcircuitstomeetdesigngoalsbytakingadvantageof thestrengthsofnewtechnologies,andmakingthemtoleranttotheweaknesses,requires a reexamination of existing design paradigms. Finally, incorporation of higher-level arithmetic primitives into hardware makes the design, optimization, and verification effortshighlycomplexandinterrelated. Thisiswhycomputerarithmeticisaliveandwelltoday.Designersandresearchers inthisareaproducenovelstructureswithamazingregularity. Carry-lookaheadadders compriseacaseinpoint.Weusedtothink,inthenotsodistantpast,thatweknewall therewastoknowaboutcarry-lookaheadfastadders.Yet,newdesigns,improvements, andoptimizationsarestillappearing.TheIEEE754standardfloating-pointformathas removed many of the concerns with compatibility and error control in floating-point computations, thus resulting in new designs and products with mass-market appeal. Giventhearithmetic-intensivenatureofmanynovelapplicationareas(suchasencryp- tion, error checking, and multimedia), computer arithmetic will continue to thrive for yearstocome. THEGOALSANDSTRUCTUREOFTHISBOOK Thefieldofcomputerarithmetichasmaturedtothepointthatadozenorsotextsand referencebookshavebeenpublished. Someofthesebooksthatcovercomputerarith- metic in general (as opposed to special aspects or advanced/unconventional methods) arelistedattheendofthepreface.Eachofthesebookshasitsuniquestrengthsandhas contributedtotheformationandfruitionofthefield.Thecurrenttext,ComputerArith- metic: Algorithms and Hardware Designs, is an outgrowth of lecture notes the author developedandrefinedovermanyyears.Herearethemostimportantfeaturesofthistext incomparisontothelistedbooks: Divisionofmaterialintolecture-sizechapters.Inmyapproachtoteaching,alecture isamoreorlessself-containedmodulewithlinkstopastlecturesandpointerstowhat will transpire in future. Each lecture must have a theme or title and must proceed frommotivation,todetails,toconclusion.Indesigningthetext,Istrivedtodivide thematerialintochapters, eachofwhichissuitableforonelecture(1–2hours).A shortlecturecancoverthefirstfewsubsections,whilealongerlecturecandealwith variations,peripheralideas,ormoreadvancedmaterialneartheendofthechapter. Tomakethestructurehierarchical,asopposedtoflatorlinear,lecturesaregrouped intosevenparts,eachcomposedoffourlecturesandcoveringoneaspectofthefield (Fig.P.1). Preface xxi Emphasisonboththeunderlyingtheoryandactualhardwaredesigns.Theabilityto copewithcomplexityrequiresbothadeepknowledgeofthetheoreticalunderpin- nings of computer arithmetic and examples of designs that help us understand the theory.Suchdesignsalsoprovidebuildingblocksforsynthesisaswellasreference pointsforcost-performancecomparisons.Thisviewpointisreflectedin,forexample, thedetailedcoverageofredundantnumberrepresentationsandassociatedarithmetic algorithms(Chapter3)thatlaterleadtoabetterunderstandingofvariousmultiplier designsandon-linearithmetic.AnotherexamplecanbefoundinChapter22,where coordinate rotation digital computer, or CORDIC, algorithms are introduced from themoreintuitivegeometricviewpoint. Linkingcomputerarithmetictoothersubfieldsofcomputing. Computerarithmetic isnourishedby,andinturnnourishes,othersubfieldsofcomputerarchitectureand technology.Examplesofsuchlinksabound.Thedesignofcarry-lookaheadadders became much more systematic once it was realized that the carry computation is a special case of parallel prefix computation that had been extensively studied by researchersinparallelcomputing.Arithmeticforandbyneuralnetworksisanarea thatisstillbeingexplored.Theresiduenumbersystemhasprovidedaninvaluable toolforresearchersinterestedincomplexitytheoryandthelimitsoffastarithmetic, aswellastothedesignersoffault-tolerantdigitalsystems. Widecoverageofimportanttopics.Thetextcoversvirtuallyallimportantalgorith- micandhardwaredesigntopicsincomputerarithmetic, thusprovidingabalanced and complete view of the field. Coverage of unconventional number representa- tionmethods(Chapters3and4),arithmeticbytablelookup(Chapter24),whichis becomingincreasinglyimportant,multiplicationanddivisionbyconstants(Chapters 9and13), errorsandcertifiablearithmetic(Chapters19and20), andthetopicsin PartVII(Chapters25–28)donotallappearinothertextbooks. Unifiedandconsistentnotationandterminologythroughoutthetext.Everyeffortis madetouseconsistentnotationandterminologythroughoutthetext.Forexample,r alwaysstandsforthenumberrepresentationradixandsfortheremainderindivision orsquare-rooting.Whileotherauthorshavedonethisinthebasicpartsoftheirtexts, manytendtocovermoreadvancedresearchtopicsbysimplyborrowingthenotation and terminology from the reference source. Such an approach has the advantage ofmakingthetransitionbetweenreadingthetextandtheoriginalreferencesource easier, but it is utterly confusing to the majority of the students, who rely on the textanddonotconsulttheoriginalreferencesexcept, perhaps, towritearesearch paper. SUMMARYOFTOPICS The seven parts of this book, each composed of four chapters, were written with the followinggoals. Part I sets the stage, gives a taste of what is to come, and provides a detailed per- spectiveonthevariouswaysofrepresentingfixed-pointnumbers.Includedaredetailed discussionsofsignednumbers,redundantrepresentations,andresiduenumbersystems. xxii Preface PartIIcoversadditionandsubtraction,whichformthemostbasicarithmeticbuilding blocksandareoftenusedinimplementingotherarithmeticoperations.Includedinthe discussions are addition of a constant (counting), various methods for designing fast adders,andmultioperandaddition. Part III deals exclusively with multiplication, beginning with the basic shift/add algorithmsandmovingontohigh-radix,tree,array,bit-serial,modular,andavarietyof othermultipliers.Thespecialcaseofsquaringisalsodiscussed. PartIVcoversdivisionalgorithmsandtheirhardwareimplementations, beginning withthebasicshift/subtractalgorithmsandmovingontohigh-radix,prescaled,modular, array,andconvergencedividers. PartVdealswithrealnumberarithmetic,includingvariousmethodsforrepresenting real numbers, floating-point arithmetic, errors in representation and computation, and methodsforhigh-precisionandcertifiablearithmetic. Part VI covers function evaluation, beginning with the important special case of square-rooting and moving on to coordinate rotation digital computer, or CORDIC, algorithms,followedbygeneralconvergenceandapproximationmethods,includingthe useoflookuptables. PartVII deals with broad design and implementation topics, including pipelining, low-powerarithmetic, andfaulttolerance. Thispartconcludesbyprovidinghistorical perspectiveandexamplesofarithmeticunitsinrealcomputers. POINTERSONHOWTOUSETHEBOOK Forclassroomuse,thetopicsineachchapterofthistextcanbecoveredinalecturelasting 1–2hours.Inhisownteaching,theauthorhasusedthechaptersprimarilyfor1.5-hour lectures, twice a week, in a 10-week quarter, omitting or combining some chapters to fitthematerialinto18–20lectures.Butthemodularstructureofthetextlendsitselfto otherlectureformats,self-study,orreviewofthefieldbypractitioners.Inthelattertwo cases,readerscanvieweachchapterasastudyunit(foroneweek,say)ratherthanasa lecture.Ideally,alltopicsineachchaptershouldbecoveredbeforethereadermovesto thenextchapter.However,iffewerlecturehoursareavailable,someofthesubsections locatedattheendofchapterscanbeomittedorintroducedonlyintermsofmotivations andkeyresults. Problemsofvaryingcomplexities,fromstraightforwardnumericalexamplesorexer- cisestomoredemandingstudiesorminiprojects, aresuppliedforeachchapter.These problems form an integral part of the book: they were not added as afterthoughts to make the book more attractive for use as a text.Atotal of 464 problems are included (15–18 per chapter). Assuming that two lectures are given per week, either weekly or biweekly homework can be assigned, with each assignment having the specific coverage of the respective half-part (two chapters) or full-part (four chapters) as its “title.” Aninstructor’ssolutionsmanualisavailable.Theauthor’sdetailedsyllabusforthe courseECE252BatUCSBisavailableat: http://www.ece.ucsb.edu/∼parhami/ece_252b.htm. Preface xxiii A simulator for numerical experimentation with various arithmetic algorithms is availableat: http://www.ecs.umass.edu/ece/koren/arith/simulator/ courtesyofProfessorIsraelKoren. Referencestoclassicalpapersincomputerarithmetic,keydesignideas,andimpor- tant state-of-the-art research contributions are listed at the end of each chapter. These referencesprovidegoodstartingpointsforin-depthstudiesorfortermpapersorprojects. Alargenumberofclassicalpapersandimportantcontributionsincomputerarithmetic havebeenreprintedintwovolumes[Swar90]. Newideasinthefieldofcomputerarithmeticappearinpaperspresentedatbiannual conferences,knownasARITH-n,heldinodd-numberedyears[Arit].Otherconferences of interest includeAsilomar Conference on Signals, Systems, and Computers [Asil], InternationalConferenceonCircuitsandSystems[ICCS],MidwestSymposiumonCir- cuitsandSystems[MSCS],andInternationalConferenceonComputerDesign[ICCD]. RelevantjournalsincludeIEEETransactionsonComputers[TrCo],particularlyitsspe- cialissuesoncomputerarithmetic,IEEETransactionsonCircuitsandSystems[TrCS], Computers & Mathematics with Applications [CoMa], IET Circuits, Devices & Sys- tems[CDS],IETComputers&DigitalTechniques[CDT],IEEETransactionsonVLSI Systems[TrVL],andJournalofVLSISignalProcessing[JVSP]. ACKNOWLEDGMENTS Computer Arithmetic: Algorithms and Hardware Designs is an outgrowth of lecture notestheauthorusedforthegraduatecourse“ECE252B:ComputerArithmetic”atthe University of California, Santa Barbara, and, in rudimentary forms, at several other institutionspriorto1988.Thetexthasbenefitedgreatlyfromkeenobservations,curios- ity, and encouragement of my many students in these courses.Asincere thanks to all ofthem! REFERENCESANDFURTHERREADINGS Note:Referencesappearinupdated2nd-editionform,inordertoavoidtheneedforaseparatelist forthelatter. [Arit] InternationalSymposiumonComputerArithmetic,sponsoredbytheIEEEComputer Society.Thisseriesbeganwithaone-dayworkshopin1969andwassubsequently heldin1972,1975,1978,andinodd-numberedyearssince1981.The19th symposiumintheseries,ARITH-19,washeldJune8–10,2009,inPortland,Oregon. [Asil] AsilomarConferenceonSignalsSystems,andComputers,sponsoredannuallyby IEEEandheldontheAsilomarConferenceGroundsinPacificGrove,California, eachfall.The43rdconferenceinthisserieswasheldonNovember1–4,2009. [Cava84] Cavanagh,J.J.F.,DigitalComputerArithmetic:DesignandImplementation, McGraw-Hill,1984. [CDS] IETCircuits,Devices&Systems,journalpublishedbytheInstitutionofEngineering andTechnology,UnitedKingdom. xxiv Preface [CDT] IETComputers&DigitalTechniques,journalpublishedbytheInstitutionof EngineeringandTechnology,UnitedKingdom. [CoMa] Computers&MathematicswithApplications,journalpublishedbyPergamonPress. [Desc06] Deschamps,J.-P.,G.J.A.Bioul,andG.D.Sutter,SynthesisofArithmeticCircuits: FPGA,ASICandEmbeddedSystems,Wiley-Interscience,2006. [Erce04] Ercegovac,M.D.,andT.Lang,DigitalArithmetic,MorganKaufmann,2004. [Flor63] Flores,I.,TheLogicofComputerArithmetic,Prentice-Hall,1963. [Gosl80] Gosling,J.B.,DesignofArithmeticUnitsforDigitalComputers,Macmillan,1980. [Hwan79] Hwang,K.,ComputerArithmetic:Principles,Architecture,andDesign,Wiley, 1979. [ICCD] InternationalConferenceonComputerDesign,sponsoredannuallybytheIEEE ComputerSociety.ICCD-2009washeldonOctober4–7,inLakeTahoe,California. [ICCS] InternationalConferenceonCircuitsandSystems,sponsoredannuallybytheIEEE CircuitsandSystemsSociety.ThelatestinthisserieswasheldonMay24–27,2009, inTaipei,Taiwan. [JVSP] J.VLSISignalProcessing,publishedbyKluwerAcademicPublishers. [Knut97] Knuth,D.E.,TheArtofComputerProgramming,Vol.2:SeminumericalAlgorithms, 3rded.,Addison-Wesley,1997.(Thewidelyusedsecondedition,publishedin1981, iscitedinPartsVandVI.) [Kore02] Koren,I.,ComputerArithmeticAlgorithms,2nded.,A.K.Peters,2002. [Kuli81] Kulisch,U.W.,andW.L.Miranker,ComputerArithmeticinTheoryandPractice, AcademicPress,1981. [Lu04] Lu,M.,ArithmeticandLogicinComputerSystems,Wiley,2004. [MSCS] MidwestSymposiumonCircuitsandSystems,sponsoredannuallybytheIEEE CircuitsandSystemsSociety. [Omon94] Omondi,A.R.,ComputerArithmeticSystems:Algorithms,Architectureand Implementations,Prentice-Hall,1994. [Rich55] Richards,R.K.,ArithmeticOperationsinDigitalComputers,VanNostrand,1955. [Scot85] Scott,N.R.,ComputerNumberSystemsandArithmetic,Prentice-Hall,1985. [Stei71] Stein,M.L.,andW.D.Munro,IntroductiontoMachineArithmetic, Addison-Wesley,1971. [Stin04] Stine,J.E.,DigitalComputerArithmeticDatapathDesignUsingVerilogHDL, Kluwer,2004. [Swar90] Swartzlander,E.E.,Jr.,ComputerArithmetic,Vols.IandII,IEEEComputerSociety Press,1990. [TrCo] IEEETrans.Computers,journalpublishedbytheIEEEComputerSociety. Occasionallyentirespecialissuesorsectionsaredevotedtocomputerarithmetic (e.g.,Vol.19,No.8,August1970;Vol.22,No.6,June1973;Vol.26,No.7,July 1977;Vol.32,No.4,April1983;Vol.39,No.8,August1990;Vol.41,No.8,August 1992;Vol.43,No.8,August1994;Vol.47,No.7,July1998;Vol.49,No.7,July 2000;Vol.54,No.3,March2005;Vol.58,No.2,February2009). [TrCS] IEEETrans.CircuitsandSystems,PartsI&II,journalspublishedbyIEEE.Thetwo partshavebeendistinguisheddifferentlyovertheyears.Currently,PartIpublishes “regularpapers,”whilePartIIisdevotedto“expressbriefs.” Preface xxv [TrVL] IEEETrans.VeryLargeScaleIntegration(VLSI)Systems,journalpublishedjointly bytheIEEECircuitsandSystemsSociety,ComputerSociety,andSolid-State CircuitsCouncil. [Wase82] Waser,S.,andM.J.Flynn,IntroductiontoArithmeticforDigitalSystemsDesigners, Holt,Rinehart,&Winston,1982. [Wino80] Winograd,S.,ArithmeticComplexityofComputations,SIAM,1980.
Description: