Presentation is loading. Please wait.

Presentation is loading. Please wait.

Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7×10 3 +3×10 2 +9×10 1 +7×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10.

Similar presentations


Presentation on theme: "Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7×10 3 +3×10 2 +9×10 1 +7×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10."— Presentation transcript:

1 Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7×10 3 +3×10 2 +9×10 1 +7×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10 3 +a 2 ×10 2 +a 1 ×10 1 +a 0 ×10 0 +a -1 x10 -1 +a -2 ×10 -2 a i : coefficient 10 : base or radix a 4 : most significant bit ( msb ) a -2 : least significant bit ( lsb )

2 Yuh-Jzer JoungDigital Systems2 In general, number N in a base-r system is represented as N = (a n a n-1......a 1 a 0. a -1 a -2......a -m ) which has the value N = (a n.r n + a n-1.r n-1 +......+a 1.r +a 0 +a -1.r -1 + a -2 r -2 +......+a -m.r -m ) In binary system ﹐ r = 2 ﹐ a i  {0, 1}. In octal system ﹐ r = 8 ﹐ a i  {0,1,…,7}. In decimal system ﹐ r = 10 ﹐ a i  {0,1,…,9}. In hexadecimal system ﹐ r = 16 ﹐ a i  {0,1,…9,A,B,C,D,E,F}.

3 Yuh-Jzer JoungDigital Systems3 Conversion between different Bases Base-r to base-10 conversion ﹕ Straightforward ﹗ Base-r to base-s conversion ﹕ By repeated division for integers and repeated multiplication for fractions. Ex1. Convert (153.513) 10 to octal number. Integer ﹕ 153 (153) 10 = (231) 8 19 1 2 3 0 2

4 Yuh-Jzer JoungDigital Systems4 fractional: 0.513×8 = 4.104 0.104×8 = 0.832 0.832×8 = 6.656 (0.513) 10 = (0.4065…) 8 0.656×8 = 5.248 (153.513) 10 = (231.4065…) 8 Ex2. Convert (12A) 16 to octal. 1. Convert (12A) 16 to (298) 10 2. Convert (298) 16 to octal as in Ex1.

5 Yuh-Jzer JoungDigital Systems5 Conversions between binary ﹐ octal ﹐ and hexadecimal can be done in a simpler way. Ex1. Convert (10111010011) 2 to octal and hexadecimal. 10 111 010 011 (2723) 8 2 7 2 3 101 1101 0011 (5D3) 16 5 D 3 Ex2. Convert (12A7F) 16 to binary and octal. 1 2 A 7 F 0001 0010 1010 0111 1111 binary 00 010 010 101 001 111 111 0 2 2 5 1 7 7 octal

6 Yuh-Jzer JoungDigital Systems6 Complement ﹕ for simplifying subtraction. Two types of complements for each base-r system ﹕ (r-1)’s complement r’s complement The (r-1)’s complement of an n-digital number N ﹕ ( r n  1)  N Ex. In decimal system ﹐ the 9’s complement of 546700 is (10 6  1)  546700 = 999999  546700 = 453299 The 9’s complement of 012398 is 999999  012398 = 987601 The 1’s complement of 01011000 is (2 8  1)  01011000 = 11111111  01011000 = 10100111 The 1’s complement of 0101101 is 1010010.

7 Yuh-Jzer JoungDigital Systems7 The r’s complement of an n-digital number N ﹕ r n  N N ≠0 0 N = 0 Ex. The 10’s complement of 012398 is 987602. The 10’s complement of 2467000 is 7533000. The 2’s complement of 1101100 is 0010100. The 2’s complement of 0110111 is 1001001. Comments ﹕ 1.To compute the complement of a number having radix point, first ﹐ remove the radix point ﹐ compute the complement of the new number ﹐ and restore the radix point. Ex. The 1’s complement of 01101.101 is 10010.010 The 2’s complement of 01101.101 is 10010.011

8 Yuh-Jzer JoungDigital Systems8 2.The complement of the complement of N is N. (r  1)’s complement of (2 n  1)  N = (2 n  1)  ((2 n  1)  N) = N Signed Binary Numbers Addition ﹕ 91001 + 13 + 1101 22 10110 Subtraction ﹕ 91001  13  1101  4 ?

9 Yuh-Jzer JoungDigital Systems9 How do we represent signed numbers in digital systems? representation of +9 with 8 bits: 00001001 representation of  9: signed magnitude: 10001001 signed -1’s-complement: 11110110 signed -2’s-complement: 11110111 Numbers that can be represented in n bits: signed magnitude: (  2 n  1 +1) ~ (2 n  1  1) signed-1’s-complement: (  2 n  1 +1) ~ (2 n  1  1) signed-2’s-complement: (  2 n  1 ) ~ (2 n  1  1)

10 Yuh-Jzer JoungDigital Systems10 Addition and Subtraction on signed-magnitude numbers + 900001001 + 13 + 00001101 + 22 00010110  9 10001001 00001101 + 13 + 00001101 10001001 + 4 00000100 + 9 00001001 10001101  13 10001101 00001001  4 10000100  910001001  1310001101  2210010110 Summary: to perform arithmetic operations on signed magnitude numbers, we need to compare the signs and the magnitudes of the two numbers, and then perform either addition or subtraction.

11 Yuh-Jzer JoungDigital Systems11 Addition and subtraction on signed-2’s-complement numbers: Addition: add the corresponding digits ( including the sign digits) and ignore any carry out. + 9 00001001  9 11110111 + 13 + 00001101 + 13 + 00001101 + 22 00010110 + 4 100000100 discarded carryout

12 Yuh-Jzer JoungDigital Systems12 + 9 00001001  13 + 11110011  4 11111100 the 2’s complement of 00000100 (4)  9 11110111  13 11110011  22 111101010 the 2’s complement of 00010110 (22) Discussion: (  N) + (M)  (2 n  N) + M = 2 n  (N  M) Case N > M: there will be no carry out, and the result is the 2’s complement of (N  M) N  M: = 2 n + (M  N) there will be a carry out, and the result after discarding the carry out is (M  N)

13 Yuh-Jzer JoungDigital Systems13 overflow: + 6401000000  6411000000 + 96 + 01100000  96 +10100000 + 16010100000  160 101100000 negative! positive! using 8 bits, we can represent only -128 ~ +127! When add two n-bits (including the sign bit) numbers N and M, overflow occurs when: 1. N, M  0, N+M  2 n  1  1 2. N, M < 0, N+M   2 n  1 Note that overflow cannot occur if one of N and M is positive and the other is negative.

14 Yuh-Jzer JoungDigital Systems14 Subtraction: N  M = N+ (  M) = N + (2’s complement of M) 9 00001001 00001001  13  00001101 + 11110011  4 11111100 2’s complement of 00000100

15 Yuh-Jzer JoungDigital Systems15 Addition and Subtraction on Signed-1’s-complement numbers: Assume that M, N  0, and they have n bits (including sign) Case M + N : normal binary addition. + 9 00001001 + 13 + 00001101 + 2200010110 Case  N + M : (1’s complement of N) + M = [(2 n  1)  N] + M = (2 n  1)  (N  M) Sub-case: N  M  0: there will be no carry. Sub-case: N  M  0: (2 n  1)  (N  M) = 2 n + (M  N)  1 carry bit  0 So there will be a carry. To obtain (M  N), we discard the carry and add 1 to the result.

16 Yuh-Jzer JoungDigital Systems16 Ex.  9 11110110 + 13 + 00001101 end-around carry + 4 100000011 + 1 00000100 Case (  N) + (  M) =  (N+M) : (1’s complement of N) + (1’s complement of M) = [(2 n  1)  N] + [(2 n  1)  M] = 2 n  1 + (2 n  1)  (N+M) carry 1’s complement of (N+M) We obtain (2 n  1)  (N  M) by discarding the carry and adding 1 to the result.  911110110  13 + 11110010  22 111101000 + 1 11101001 1’s complement of 00010110 (22)

17 Yuh-Jzer JoungDigital Systems17 Overflow: Similar to the case of 2’s complement, an overflow occurs when N+M  2 n  1  1 or (  N) + (  M)   2 n  1 +1 An overflow can be detected by examining the most significant bit of the result. + 6401000000 (positive) + 96 + 01100000 (positive) 160 10100000 (negative)  6410111111 (negative)  96  10011111 (negative)  160 101011110 (positive) carry

18 Yuh-Jzer JoungDigital Systems18 Comparison of the three signed numbers systems : signed-magnitude: useful in ordinary arithmetic, awkward in computer arithmetic signed-1’s-complement: used in old computers, but is now seldom used. signed-2’s-complement: used in most computers.

19 Yuh-Jzer JoungDigital Systems19 Binary Codes Binary codes can be established for any set of discrete elements. Using n bits, we can represent at most 2 n distinct elements. So, to represent m distinct objects, we need at least  log 2 m  bits. For example, we need  log 2 10  = 4 bits to represent { 0,1,…9}. MAN(1) WOMAN (0) WHITE(00) RED(01) BLUE(10) BLACK(11)

20 Yuh-Jzer JoungDigital Systems20 Decimal BCD Excess-3 84-2-1 2421 Bi-quinary digits (8421) (5043210) 0 0000 0011 0000 0000 0100001 1 0001 0100 0111 0001 0100010 2 0010 0101 0110 0010 0100100 3 0011 0110 0101 0011 0101000 4 0100 0111 0100 0100 0110000 5 0101 1000 1011 1011 1000001 6 0110 1001 1010 1100 1000010 7 0111 1010 1001 1101 1000100 8 1000 1011 1000 1110 1001000 9 1001 1100 1111 1111 1010000 Some possible binary codes are illustrated below.

21 Yuh-Jzer JoungDigital Systems21 Alphanumeric Codes -- ASCII (American Standard Code for Information Interchange) originally use 7 bits to code 128 characters since most digital systems handle 8-bit (byte) more efficiently, an 8 bit version ASCII has also been developed. -- EBDIC (Extended Binary-Coded Decimal Interchange Code) used in most IBM systems use 8 bits to code the same 128 character symbols as ASCII Gray Code each binary code differs from either its successor or predecessor by only one bit.

22 Yuh-Jzer JoungDigital Systems22 Decimal Gray Code 0 0000 1 0001 2 0011 3 0010 4 0110 5 0111 6 0101 7 0100 8 1100 9 1101 10 1111 11 1110 12 1010 13 1011 14 1001 15 1000 4-bit Gray Code

23 Yuh-Jzer JoungDigital Systems23 Gray Code is often used in situations where other binary code might produce erroneous or ambiguous results during transitions from one code to another. If we use BCD code to transmit 0111 (7) and then 1000 (8), then, an erroneous intermediate code 1001 may be generated if the rightmost bit takes more time to change. The Gray code eliminates this problem since only one bit changes between two consecutive numbers. A/D Converter Transmitter Receiver

24 Yuh-Jzer JoungDigital Systems24 Generation of Gray Codes: an n-bits code is generated by reflecting the (n-1)-bit code. 00000000000 1 101 0010001 1 110110011 0100100010 10 1100110 111110111 011010101 001000100 1001100 1011101 1111111 1101110 010 1010 0111011 0011001 0001000

25 Yuh-Jzer JoungDigital Systems25 Error-Detecting Code Binary code that can detect errors during data transmission. The most common ways to achieve error-detection is by means of a parity bit. A parity bit is an extra bit included in a binary code to make the total number of 1’s transmitted either odd (odd parity) or (even parity). odd parity even parity message parity bit message parity bit 0010 0 0010 1 0110 10110 0 1110 01110 1 1010 11010 0 Transmitter  source Parity generator ERROR  destination Parity detector Receiver

26 Yuh-Jzer JoungDigital Systems26 4-bits Adder FA x3x3 x1x1 y1y1 x0x0 y0y0 x2x2 y2y2 y3y3 S3S3 S0S0 S1S1 S2S2 c0c0 c4c4 c2c2 c1c1 c3c3 Full Adder xy cz S Digital Circuits

27 Yuh-Jzer JoungDigital Systems27 NameTruth TableAlgebraic Function AND F = xy OR F = x+y Inverter F = x’ Buffer F = x NAND F = (xy)’ Gate

28 Yuh-Jzer JoungDigital Systems28 NOR F = (x+y)’ Exclusive-OR (XOR) F = xy’+x’y = x  y Exclusive-NOR (equivalence) F = xy+x’y’ = x  y

29 Yuh-Jzer JoungDigital Systems29 Extension to multiple inputs xyzxyz x y z

30 Yuh-Jzer JoungDigital Systems30 In real implementation, the three-input Exclusive-OR is usually implemented by 2-input Exclusive-OR: Even a two input Exclusive-OR is usually constructed with other types of gates. x’y+y’x x  y  z x  y = x’y+xy’

31 Yuh-Jzer JoungDigital Systems31 This is how a gate adds a binary 1 and 0 in the “ones” place. If you feed a 1 and a 0 to the gate, it puts out a 1, which is the correct result of adding a binary 1 and 0. Place 1 +0 1

32 Yuh-Jzer JoungDigital Systems32 Place 2 1 1 1 + 1 1 0 Addition with a carryover is a little more difficult, for instance, adding 1 plus 1. If you feed the gate a 1 and 1, it will put a 0 in the “ones” place and put a carryover of 1 in the “twos” place. This produces the correct result for adding 1 and 1 in binary.

33 Yuh-Jzer JoungDigital Systems33 c = f(x,y,z) =  (3,5,6,7) s =  (1,2,4,7) c: s: y y z x c = xy+yz+xz s = x’y’z+x’yz’+xy’z’+xyz y z x y

34 Yuh-Jzer JoungDigital Systems34 (a) S = xy’+x’y C = xy (b) S = (x+y)(x’+y’) C = xy Various Implementations of a half-adder

35 Yuh-Jzer JoungDigital Systems35 (c) S = (C + x’y’)’ C = xy (d) S = (x+y)(x’+y’) C = xy (e) S = x  y C = xy

36 Yuh-Jzer JoungDigital Systems36 Binary Adder and Subtractor = x  y  z = xy + yz + xz 4-bit parallel adder

37 Yuh-Jzer JoungDigital Systems37 4-bit adder-subtractor


Download ppt "Yuh-Jzer JoungDigital Systems1 Number Systems decimal number : 7397=7×10 3 +3×10 2 +9×10 1 +7×10 0 a 4 a 3 a 2 a 1 a 0. a -1 a -2 = a 4 ×10 4 +a 3 ×10."

Similar presentations


Ads by Google