Chapter 7
description
Transcript of Chapter 7
![Page 1: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/1.jpg)
Chapter 7
Arithmetic Operations and Circuits
1
![Page 2: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/2.jpg)
7-1 Binary Arithmetic
• Addition– When the sum exceeds 1, carry a 1 over to the
next-more-significant column.– 0 + 0 = 0 carry 0– 0 + 1 = 1 carry 0– 1 + 0 = 1 carry 0– 1 + 1 = 0 carry 1
5
![Page 3: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/3.jpg)
Binary Arithmetic• Addition
– General form A0 + B0 = 0 + Cout
• Summation symbol ()• Carry-out (Cout)
6
![Page 4: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/4.jpg)
Binary Arithmetic– Carry-out is added to the next-more-significant
column as a carry-in.
7
![Page 5: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/5.jpg)
Binary Arithmetic
• Subtraction– 0 0 = 0 borrow 0– 0 1 = 1 borrow 1– 1 0 = 1 borrow 0– 1 1 = 0 borrow 0
• General form A0 B0 = R0 + Bout
– Remainder is R0
– Borrow is Bout
8
![Page 6: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/6.jpg)
9
![Page 7: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/7.jpg)
Binary Arithmetic
• Subtraction– When A0 borrows from its left, A0 increases by
210.
10
![Page 8: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/8.jpg)
Binary Arithmetic
• Multiplication– Multiply the 20 bit of the multiplier times the
multiplicand.– Multiply the 21 bit of the multiplier times the
multiplicand. Shift the result one position to the left.
– Repeat step 2 for the 22 bit of the multiplier, and for all remaining bits.
– Take the sum of the partial products to get the final product.
11
![Page 9: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/9.jpg)
Binary Arithmetic• Multiplication
– Very similar to multiplying decimal numbers.
12
![Page 10: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/10.jpg)
Binary Arithmetic• Division
–The same as decimal division. –This process is illustrated in
Example 7-4.
13
![Page 11: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/11.jpg)
14
Example 7-4
![Page 12: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/12.jpg)
14
Example 7-4 (Continued)
![Page 13: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/13.jpg)
7-2 Two’s-Complement Representation• Both positive and negative numbers can be
represented• Binary subtraction is simplified• Groups of eight• Most significant bit (MSB) signifies positive or
negative
15
![Page 14: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/14.jpg)
Two’s-Complement Representation
• Sign bit– 0 for positive– 1 for negative
• Range of positive numbers (8-bit)– 0000 0000 to 0111 1111 (0 to 127)– Maximum positive number: 2N-1-1
• Range of negative numbers (8-bit)– 1111 1111 to 1000 0000 (-1 to -128)– Minimum negative number: -2N-1
16
![Page 15: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/15.jpg)
Decimal-to-Two’s-Complement Conversion
• If a number is positive, – the two’s complement number is the true binary
equivalent of the decimal number.• If a number is negative:
– Complement each bit (one’s complement)– Add 1 to the one’s complement
• The sign bit will always end up a 1.
18
![Page 16: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/16.jpg)
Two’s-Complement Representation
18
![Page 17: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/17.jpg)
Two’s-Complement-to-Decimal Conversion
• If the number is positive (sign bit = 0), convert directly
• If the number is negative:– Complement the entire two’s-complement
number– Add 1– Do the regular b-to-d conversion to get the
decimal numeric value– Result will be a negative number
19
![Page 18: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/18.jpg)
Discussion Point
• Convert the following numbers to two’s-complement form:3510
-3510
• Convert the following two’s-complement number to decimal:1101 1101
20
![Page 19: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/19.jpg)
7-3 Two’s-Complement Arithmetic
• Addition– Regular binary addition
• Subtraction– Convert number to be subtracted to a negative
two’s-complement number– Regular binary addition– Carry out of the MSB is ignored
21
![Page 20: Chapter 7](https://reader035.fdocuments.in/reader035/viewer/2022062812/5681634e550346895dd3ecb8/html5/thumbnails/20.jpg)
Discussion Point
• Add the following numbers using two’s complement arithmetic:
19 + 2718 – 721 – 1359 – 96
22