<<

BINARYBINARY –SUBTRACTORADDER–

TheThe mostmost basicbasic arithmeticarithmetic operationoperation isis thethe additionaddition ofof twotwo binarybinary digits.digits.

ThisThis simplesimple additionaddition consistsconsists ofof fourfour possiblepossible elementaryelementary operations:operations: 00 ++ 00 == 0,0, 00 ++ 11 == 1,1, 11 ++ 00 == 1,1, andand 11 ++ 11 == 10.10.

TheThe firstfirst threethree operationsoperations produceproduce aa sumsum ofof oneone digit,digit, butbut whenwhen bothboth augendaugend andand addendaddend bitsbits areare equalequal toto 1,1, thethe binarybinary sumsum consistsconsists ofof twotwo digits.digits.

TheThe higherhigher significantsignificant bitbit ofof thisthis resultresult isis calledcalled aa .carry.

CS1026 1 CS1026 2 TheThe two'stwo's complementcomplement ofof anan N-bitN-bit numbernumber isis defineddefined asas thethe resultresult ofof subtractingsubtracting thethe numbernumber fromfrom 2^N2^N

SoSo two'stwo's complementcomplement ofof 33 isis 1616 -- 33 == 1313

SoSo 55 ++ -3-3 (( 55 ++ 1616 –– 3)3) ModMod 1616 (5(5 -3)-3) ModMod 1616 22

CS1026 3 TheThe two'stwo's complementcomplement ofof anan N-bitN-bit numbernumber isis defineddefined asas thethe complementcomplement withwith respectrespect toto 2^N,2^N, inin otherother wordswords thethe resultresult ofof subtractingsubtracting thethe numbernumber fromfrom 2^N.2^N.

ThisThis isis alsoalso equivalentequivalent toto takingtaking thethe ones'ones' complementcomplement andand thenthen addingadding one,one, sincesince thethe sumsum ofof aa numbernumber andand itsits ones'ones' complementcomplement isis allall 11 bits.bits.

CS1026 4 BINARYBINARY ADDER–SUBTRACTORADDER–SUBTRACTOR

CS1026 5 Augend.Augend. TheThe firstfirst ofof severalseveral addends,addends, oror "the"the oneone toto whichwhich thethe othersothers areare added,"added," isis sometimessometimes calledcalled thethe augendaugend

WhenWhen thethe augendaugend andand addendaddend numbersnumbers containcontain moremore significantsignificant digits,digits, thethe carrycarry obtainedobtained fromfrom thethe additionaddition ofof twotwo bitsbits isis addedadded toto thethe nextnext higherhigher orderorder pairpair ofof significantsignificant bits.bits.

AA combinationalcombinational circuitcircuit thatthat performsperforms thethe additionaddition ofof twotwo bitsbits isis calledcalled aa halfhalf adder.adder.

OneOne thatthat performsperforms thethe additionaddition ofof threethree bitsbits (two(two significantsignificant bitsbits andand aa previousprevious carry)carry) isis aa fullfull adder.adder. TheThe namesnames ofof thethe circuitscircuits stemstem fromfrom thethe factfact thatthat twotwo halfhalf addersadders cancan bebe employedemployed toto implementimplement aa fullfull adderadder

CS1026 6 CS1026 7 ImplementationImplementation ofof halfhalf adderadder

CS1026 8 FullFull AdderAdder

CS1026 9 FullFull AdderAdder

CS1026 10 ImplementationImplementation ofof fullfull adderadder inin sum-of-productssum-of-products formform

CS1026 11 ImplementationImplementation ofof fullfull adderadder withwith twotwo halfhalf addersadders andand anan OROR gategate

CS1026 12 AdditionAddition ofof n-bitn-bit numbersnumbers requiresrequires aa chainchain ofof nn fullfull addersadders oror aa chainchain ofof one-halfone-half adderadder andand nn -- 11 fullfull adders.adders.

InIn thethe formerformer case,case, thethe inputinput carrycarry toto thethe leastleast significantsignificant positionposition isis fixedfixed atat 0.0.

InterconnectionInterconnection ofof fourfour full-adderfull-adder (FA)(FA) circuitscircuits toto provideprovide aa four-bitfour-bit binarybinary rippleripple carrycarry adder.adder.

CS1026 13 CS1026 14 TheThe augendaugend bitsbits ofof AA andand thethe addendaddend bitsbits ofof BB areare designateddesignated byby subscriptsubscript numbersnumbers fromfrom rightright toto left,left, withwith subscriptsubscript 00 denotingdenoting thethe leastleast significantsignificant bit.bit.

TheThe carriescarries areare connectedconnected inin aa chainchain throughthrough thethe fullfull adders.adders. TheThe inputinput carrycarry toto thethe adderadder isis C0,C0, andand itit ripplesripples throughthrough thethe fullfull addersadders toto thethe outputoutput carrycarry C4.C4.

TheThe SS outputsoutputs generategenerate thethe requiredrequired sumsum bits.bits. AnAn n-bitn-bit adderadder requiresrequires nn fullfull adders,adders, withwith eacheach outputoutput carrycarry connectedconnected toto thethe inputinput carrycarry ofof thethe nextnext higherhigher orderorder fullfull adder.adder.

CS1026 15 CarryCarry PropagationPropagation

TheThe additionaddition ofof twotwo binarybinary numbersnumbers inin parallelparallel impliesimplies thatthat allall thethe bitsbits ofof thethe augendaugend andand addendaddend areare availableavailable forfor computationcomputation atat thethe samesame time.time.

AsAs inin anyany combinationalcombinational circuit,circuit, thethe signalsignal mustmust propagatepropagate throughthrough thethe gatesgates beforebefore thethe correctcorrect outputoutput sumsum isis availableavailable inin thethe outputoutput terminals.terminals.

TheThe totaltotal propagationpropagation timetime isis equalequal toto thethe propagationpropagation delaydelay ofof aa typicaltypical gate,gate, timestimes thethe numbernumber ofof gategate levelslevels inin thethe circuit.circuit.

TheThe longestlongest propagationpropagation delaydelay timetime inin anan adderadder isis thethe timetime itit takestakes thethe carrycarry toto propagatepropagate throughthrough thethe fullfull adders.adders.

CS1026 16 InverterInverter DelayDelay

CS1026 17 FullFull adderadder withwith PP andand GG shownshown

The signals at Pi and Gi settle to their steady-state values after they propagate through their respective gates. These two signals are common to all half adders and depend on only the input augend and addend bits. The signal from the input carry Ci to the output carry Ci + 1 propagates through an AND gate and an OR gate, which constitute two gate levels. If there are four full adders in the adder, the output carry C4 would have 2 * 4 = 8 gate levels from C0 to C4. For an n-bit adder, there are 2n gate levels for the carry to propagate from input to output.

CS1026 18 GiGi isis calledcalled aa carrycarry generate,generate, andand itit producesproduces aa carrycarry ofof 11 whenwhen bothboth AiAi andand BiBi areare 1,1, regardlessregardless ofof thethe inputinput carrycarry Ci.Ci.

PiPi isis calledcalled aa carrycarry propagate,propagate, becausebecause itit determinesdetermines whetherwhether aa carrycarry intointo stagestage ii willwill propagatepropagate intointo stagestage ii ++ 11 i.e.,i.e., whetherwhether anan assertionassertion ofof CiCi willwill propagatepropagate toto anan assertionassertion ofof CiCi ++ 11

CS1026 19 CarryCarry lookaheadlookahead logiclogic

CS1026 20 SinceSince thethe BooleanBoolean functionfunction forfor eacheach outputoutput carrycarry isis expressedexpressed inin sum-of-productssum-of-products form,form, eacheach functionfunction cancan bebe implementedimplemented withwith oneone levellevel ofof ANDAND gatesgates followedfollowed byby anan OROR gate.gate.

TheThe threethree BooleanBoolean functionsfunctions forfor C1,C1, C2,C2, andand C3C3 areare implementedimplemented inin thethe carrycarry lookaheadlookahead generator.generator.

NoteNote thatthat thisthis circuitcircuit cancan addadd inin lessless timetime becausebecause C3C3 doesdoes notnot havehave toto waitwait forfor C2C2 andand C1C1 toto propagate;propagate; inin fact,fact, C3C3 isis propagatedpropagated atat thethe samesame timetime asas C1C1 andand C2.C2. ThisThis gaingain inin speedspeed ofof operationoperation isis achievedachieved atat thethe expenseexpense ofof additionaladditional complexitycomplexity (hardware).(hardware).

CS1026 21 LogicLogic diagramdiagram ofof carrycarry lookaheadlookahead generatorgenerator

CS1026 22 Four-bitFour-bit adderadder withwith carrycarry lookaheadlookahead

CS1026 23 7428374283 4-bit4-bit binarybinary FullFull AdderAdder ConnectionConnection DiagramDiagram

CS1026 24 7428374283 4-bit4-bit binarybinary FullFull AdderAdder LogicLogic DiagramDiagram

CS1026 25 BinaryBinary SubtractorSubtractor

RememberRemember thatthat thethe subtractionsubtraction AA -- BB cancan bebe donedone byby takingtaking thethe 2’s2’s complementcomplement ofof BB andand addingadding itit toto A.A.

TheThe 2’s2’s complementcomplement cancan bebe obtainedobtained byby takingtaking thethe 1’s1’s complementcomplement andand addingadding 11 toto thethe leastleast significantsignificant pairpair ofof bits.bits.

TheThe 1’s1’s complementcomplement cancan bebe implementedimplemented withwith inverters,inverters, andand aa 11 cancan bebe addedadded toto thethe sumsum throughthrough thethe inputinput carry.carry.

CS1026 26 Four-bitFour-bit adder–subtractoradder–subtractor (with(with overflowoverflow detection)detection)

CS1026 27 TheThe circuitcircuit forfor subtractingsubtracting AA -- BB consistsconsists ofof anan adderadder withwith invertersinverters placedplaced betweenbetween eacheach datadata inputinput BB andand thethe correspondingcorresponding inputinput ofof thethe fullfull adder.adder.

TheThe inputinput carrycarry C0C0 mustmust bebe equalequal toto 11 whenwhen subtractionsubtraction isis performed.performed.

TheThe operationoperation thusthus performedperformed becomesbecomes A,A, plusplus thethe 1’s1’s complementcomplement ofof B,B, plusplus 1.1.

ThisThis isis equalequal toto AA plusplus thethe 2’s2’s complementcomplement ofof B.B.

CS1026 28 ForFor unsignedunsigned numbers,numbers, thatthat givesgives AA -- BB ifif AA >=>= BB oror thethe 2’s2’s complementcomplement ofof (B(B –– A)A) ifif AA << B.B.

ForFor signedsigned numbers,numbers, thethe resultresult isis AA -- B,B, providedprovided thatthat therethere isis nono Overflow.Overflow.

BinaryBinary numbersnumbers inin thethe signed-complementsigned-complement systemsystem areare addedadded andand subtractedsubtracted byby thethe samesame basicbasic additionaddition andand subtractionsubtraction rulesrules asas areare unsignedunsigned numbers.numbers.

Therefore,Therefore, computerscomputers needneed onlyonly oneone commoncommon hardwarehardware circuitcircuit toto handlehandle bothboth typestypes ofof arithmetic.arithmetic.

CS1026 29 TheThe useruser oror programmerprogrammer mustmust interpretinterpret thethe resultsresults ofof suchsuch additionaddition oror subtractionsubtraction differently,differently, dependingdepending onon whetherwhether itit isis assumedassumed thatthat thethe numbersnumbers areare signedsigned oror unsigned.unsigned.

AnAn overflowoverflow conditioncondition cancan bebe detecteddetected byby observingobserving thethe carrycarry intointo thethe signsign bitbit positionposition andand thethe carrycarry outout ofof thethe signsign bitbit position.position.

IfIf thesethese twotwo carriescarries areare notnot equal,equal, anan overflowoverflow hashas occurredoccurred

CS1026 30 AA SimpleSimple FormulaFormula forfor OverflowOverflow

LetLet thethe carrycarry outout ofof thethe fullfull adderadder addingadding thethe leastleast significantsignificant bitbit bebe calledcalled c0.c0. Then,Then, thethe carrycarry outout ofof thethe fullfull adderadder addingadding thethe nextnext leastleast significantsignificant bitbit isis c1.c1. Thus,Thus, thethe carrycarry outout ofof thethe fullfull adderadder addingadding thethe mostmost significantsignificant bitsbits isis c(kc(k -- 1).1). ThisThis assumesassumes thatthat wewe areare addingadding twotwo kk bitbit numbers.numbers. WeWe cancan writewrite thethe formulaformula as:as:

VV == c(k-1)c(k-1) XORXOR c(k-2)c(k-2)

ThisThis isis effectivelyeffectively XORingXORing thethe carry-incarry-in andand thethe carry-outcarry-out ofof thethe leftmostleftmost fullfull adder.adder. WhyWhy doesdoes thisthis work?work? TheThe XORXOR ofof thethe carry-incarry-in andand carry-outcarry-out differdiffer ifif there'sthere's eithereither aa 11 beingbeing carriedcarried in,in, andand aa 00 beingbeing carriedcarried out,out, oror ifif there'sthere's aa 00 beingbeing carriedcarried in,in, andand aa 11 beingbeing carriedcarried out.out.

CS1026 31 WhenWhen doesdoes thatthat happen?happen? Let'sLet's looklook atat eacheach case:case:

CaseCase 1:1: 00 carriedcarried in,in, andand 11 carriedcarried outout IfIf aa 00 isis carried,carried, thenthen thethe onlyonly wayway thatthat 11 cancan bebe carriedcarried outout isis ifif x(k-1)x(k-1) == 11 andand y(k-1)y(k-1) == 1.1. ThatThat way,way, thethe sumsum isis 0,0, andand thethe carrycarry outout isis 1.1. ThisThis isis thethe casecase whenwhen youyou addadd twotwo negativenegative numbers,numbers, butbut thethe resultresult isis non-negative.non-negative.

CaseCase 1:1: 11 carriedcarried in,in, andand 00 carriedcarried outout TheThe onlyonly wayway 00 cancan bebe carriedcarried outout ifif there'sthere's aa 11 carriedcarried inin isis ifif x(k-1)x(k-1) == 00 andand y(k-1)y(k-1) == 0.0. InIn thatthat case,case, 00 isis carriedcarried out,out, andand thethe sumsum isis 1.1. ThisThis isis thethe casecase whenwhen youyou addadd twotwo non-negativenon-negative numbersnumbers andand getget aa negativenegative result.result.

(0+1=0(0+1=0 andand 0+1=10+1=1 carrycarry inin == carrycarry out)out)

CS1026 32