DOC PREVIEW
UA ECE 274A - Lecture Notes

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1ECE 274 - Digital LogicLecture 12 Chapter 5.3 – 5.4 Signed Numbers Fast Adders2ECE 274 - Digital LogicRepresenting Signed Numbers Decimal Represented by “+” or “-” sign Binary Unsigned binary number All bits determine magnitude of number Signed binary number n-1 bits determine magnitude of number Sign denoted by left most bit 0 indicates positive number 1 indicates negative number523- 100 + 3bn-1b1b0magnitudeUnsigned number...bn-2bn-1b1b0Signed numbermagnitudeSign0 denotes “+”1 denotes “-”...3ECE 274 - Digital LogicSigned Number Representations2423221012120 How do we represent the magnitude? Positive Binary Numbers Represented by position numbering systems previously discussed Negative Binary Numbers Sign-and-Magnitude Representation 1’s Complement 2’s Complement1012= (1 * 22) + (0 * 21) + (1 * 20)= (1 * 4) + (0 * 2) + (1 * 1)= 5104ECE 274 - Digital LogicSign-and-Magnitude Representation of Binary Numbers Sign-and-Magnitude Representation Decimal representation Magnitude of a number is expressed the same way Symbol distinguishes positive or negative Binary can adopt same scheme n-1 bits denote magnitude Leftmost bit denotes positive (0) or negative value (1) Intuitive representation for humans Not well suited for computers+532 -532magnitude is the same (532)symbols distinguish between positive and negative value01012= 51011012= -5105ECE 274 - Digital LogicAddition of Sign-and-Magnitude Numbers Addition of sign-and-magnitude integers If signs are same Add magnitude values Copy sign If signs are different Subtract smaller magnitude from larger magnitude Copy sign of larger magnitude Circuitry required Adder Subtractor Compare +0101 (510)0010 (210)0111 (710)+1011 (-310)1011 (-310)1110 (-610)-0111 (710)1010 (210)0101 (510)6ECE 274 - Digital Logic1’s Complement Representation of Binary Numbers 1’s Complement Representation K = n-bit negative number P = corresponding positive number K = (2n-1) - PWhat we are actually doing is just complementing each of the bits (including sign bit)n = 4K= (24–1) -PConvert +5 (01012) to a negative number, using 1’s complementK = 1510-PK = 11112-PK = 11112- 01012K = 10102K= (24–1) -PConvert +3 (00112) to a negative number,using 1’s complementK = 1510-PK = 11112-PK = 11112- 00112K = 110027ECE 274 - Digital LogicAddition of 1’s Complement Numbers Addition of 1’s complement integers Consider four possible combination of signs Top two are correct Bottom two are incorrect Carry produced by sign bit If carry produced by sign bit, add it to the LSB New result correct Circuitry required Adder Detection of carry from sign bit Drawback - signed addition may require twice as long as unsigned addition+0101 (+510)0010 (+210)0111 (+710)+1010 (-510)0010 (+210)1100 (-310)+0101 (+510)1101 (-210)10010 (-1310)+1010 (-510)1101 (-210)10111 (-810)+10011 (+310)+11000 (-710)xx8ECE 274 - Digital Logic2’s Complement Representation of Binary Numbers 2’s Complement Representation K = n-bit negative number P = corresponding positive number K = 2n–P Notice value plus it’s 2’s complement result in 0 (ignoring carry)n = 4K= 24-PConvert +5 (01012) to a negative number, using 2’s complementK = 1610-PK = 100002-PK = 100002-01012K = 10112K= 24-PConvert +3 (00112) to a negative number, using 2’s complementK = 1610-PK = 100002-PK = 100002-00112K = 11012+0101 (+510)1011 (-510)1 0000+0011 (+310)1101 (-510)1 00009ECE 274 - Digital Logic2’s Complement Representation of Signed Binary Numbers -- Shortcut 2’s Complement conversion shortcut Given signed number, B = bn-1, bn-2, ..., b1, b0 Start from right to left, copy all bits that are 0 and the first bit that is 1 Complement remaining bitsConvert +6 (01102) to a negative number, using 2’s complement shortcut01100101Start from right, copy all 0’s until we hit first 1Copy first bit that is 1Complement remaining bitsResult:Convert +180 (0 1011 01002) to a negative number, using 2’s complement shortcut0 1011 0100Result:Start from right, copy all 0’s until we hit first 1Copy first bit that is 1001Complement remaining bits00101110ECE 274 - Digital Logic Comparison of Signed Number Representations Interpretation of 4-bit signed integersb3b2b1b00111011001010100001100100001000010001001101010111100110111101111Sign and Magnitude+7+6+5+4+3+2+1+0-0-1-2-3-4-5-6-71’s complement2’s complement+7+6+5+4+3+2+1+0-7-6-5-4-3-2-1-0+7+6+5+4+3+2+1+0-8-7-6-5-4-3-2-1• Multiple zero representations• Sign-and-magnitude• 1’s Complement• Single zero representation• 2’s Complement• Represent numbers from -7 to + 7• Sign-and-magnitude• 1’s Complement• Represent numbers from -8 to +7• 2’s Complement11ECE 274 - Digital LogicAddition of 2’s Complement Numbers Addition of 2’s complement integers Consider four possible combination of signs All are correct If carry produced by sign bit, ignore it Circuitry required Adder Highly suitable for implementation of addition operations+0101 (+510)0010 (+210)0111 (+710)+1011 (-510)0010 (+210)1100 (-310)+0101 (+510)1110 (-210)10011 (-310)+1011 (-510)1110 (-210)11001 (-710)ignore carry out bit12ECE 274 - Digital LogicSubtraction Using Addition What about subtraction of 2’s complement integers? We can use an adder to perform subtraction Negate subtrahend, add to the minuend A – B = A + (-B) A – (-B) = A + (+B)D = X – Y minuendsubtrahend13 Consider four possible combination of signs All are correct If carry produced by sign bit, ignore it Using 2’s complement representation of negative numbers Only 1 adder required to perform addition and subtractionECE 274 - Digital LogicSubtraction Using Addition – Does it really work? +0101 (+510)1110 (-210)10011 (+310)= 5 – 2= 5 + (-2)= 3 +1011 (-510)1110 (-210)11001 (-710)= (-5) – 2= (-5) + (-2)= -7+0101 (+510)0010 (+210)0111 (+710)= 5 – (-2)= 5 + 2= 7+1011 (-510)0010 (+210)1100 (-310)= (-5) – (-2)= (-5) + 2= - 3ignoreignore14 1’s Complement Representation K = (2n-1) – P Shortcut: obtained by complementing each bit 2’s Complement Representation K = 2n–P K = 2n–P + 1 -1 K


View Full Document

UA ECE 274A - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?