Chapter I Digital Systems
Chapter I Digital Systems
1-1Digital Systems
Digital systems are used in: Communication Business transaction Traffic Control Medical treatment Internet
The signals in digital systems use just two discrete values: a binary digit. Binary digit called a bit, has two values: 0 or 1. Example: The decimal digits a through 9 are represented in digital system with a code of four bits (e.g. is represented by 0111, 8 is represented by 1000, 9 is represented by 1001).
1x23 + 1x22 + 0x21 + 1x20 + 1x2-1 + 1x2-2 = 8 + 4 + 0 + 1 +0,5 + 0.25 = 13.75 In general, a number expressed in a base r system has coefficients multiplied by powers of r. an.rn + an-1.rn-1 ++ a2.r2 + a1.r1 + a0 + a-1.r-1 + a-2.r-2 +..+ a-m.r-m The coefficient aj coefficient rang in value from 0 to r-1. To distinguish between numbers of different bases, the coefficients are enclosed in parentheses and write a subscript equal to the based used (except sometimes for decimal number). Hexadecimal number system (Base 16): It uses 16 digits : (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). The letter A, B, C, D, E, and F are used for the digits 10,11, 12, 13, 14, and 15 respectively. Example: (124)16 = 1x162 + 2x161 + 4x160 = 256 + 32 + 4 = 292 (B32A)16 = 11x163 + 3x162 + 2x161 + 10x160 = 45056 + 768 + 32 + 10 = 45866
Example3: Convert decimal 153 to octal. Dividing by 8 153 19 2 0 1 3 2 result reading (153)10 = (231)8
The conversion of a decimal to a binary is accomplished by a method similar to that used for integers. However, multiplication is used instead of division, and integers instead of remainders are accumulated. Example4: Convert (0.6875)10 to binary, Integer 0.6875x2 0.375x2 0. 75x2 0.5x2 = = = = 1 0 1 1 + + + + fraction 0.375 0.75 0.5 0 coefficient a-1 = 1 a-2 = 0 a -3 = 1 a-4 = 1
Decimal Binary Octal Hexadecimal 0 0000 0 0 1 0001 1 1 2 0010 2 2 3 0011 3 3 4 0100 4 4 5 0101 5 5 6 0110 6 6 7 0111 7 7 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F Table1: Numbers with different bases Example1: Convert binary 1111100110011 to octal and to hexadecimal. Binary to octal: Starting from the left and partitioning the binary number into groups of three digits each, then assign the corresponding octal digit to each group. ( 001 111 100 110 011)2 = (17463)8 Binary to Hexadecimal: Conversion from binary to Hexadecimal is similar, except thr binary number is divided into groups of four digits. (0001 1111 0011 0011)2 = (1F33)16 Example2: Convert the following numbers. (110111001.110111)2 = ( ? )8 (110111001.110111)2 = ( ? )16 Solution: (110 111 001 . 110 111)2 = (671.67)8 (0001 1011 1001 . 0011 0111)2 = (1B9.37)16
1-5 Complements
Complements are used in digital computers to simplify the subtraction operation and for logical manipulation. Each base-r-system has two types of complements: The radix complement: r's Complement. The diminished complement: (r-1)'s complement.
For base 2, the two types are: 2's Complement and 1's Complement. For base 10, the two types are: 10's Complement and 9's Complement. - Diminished radix Complement Given a number N in base r having n digits, the (r-1)'s Complement of N is defined as (rn-1) N. - For decimal numbers, r =10 and r-1 = 9, so, the 9's Complement of N is (10n-1) N Example: Find the 9's Complement of 64785. The number 64785 has 5 digits (n = 5), the 9's Complement is : (105-1) 64785 = 99999 64785 = 35214 - For binary numbers, r =2 and r-1 = 1, so, the 1's Complement of N is (2n-1) N. Important: 2n is represented by a binary number that consists of a 1 followed by n 0's. e.g. : 25 = (100000) 2 ; 24 = (10000) 2. 2n-1 is binary number represented by n 1's. e.g. : 25-1 = (11111)2 ; 24 = (1111) 2. Example: Find the 1's Complement of 10011000 Solution:
N=8 so, the 1's Complement of 10011000 is: (28-1) - (10011000) = (11111111) (10011000) = 01100111 The 1's Complement can be obtained more easily by changing 1's to 0's and 0's to 1's as follow: The 1's Complement of 10011110 is 01100001 The 1's Complement of 111100 is 000011 - Radix Complement: The r's Complement of an n digits number N in base r is defined as rn N for N 0 and as 0 for N = 0. Comparing with (r-1)'s Complement, we can write: r's Complement = (r-1)'s Complement + 1. Thus the 2's Complement of binary is obtained by adding 1 to the 1's Complement value. Example: The 2's Complement of binary 101100 is :
010011 + 1 010100
1's Complement
The 2's Complement can be obtained by leaving all least significant 0's and the first 1 unchanged and replacing 1's with 0's and 0's with 1's in all other significant digits.
Example:
000110 1 00
Two least significant 0: unchanged First 1 unchanged
The subtraction of two n digits unsigned numbers M-N in base r can be done as follow. 123Add the minuend M to the r's Complement of the subtrahend N. If M > N, the Sum will produce an end carry rn, which can be discarded, what If M < N, the sum does not produce an end carry and is equal to rn (M N) M + (rn N) = M N + rn is left is the result M N. which is the r's Complement of (M N). To obtain the r's complement of the sum and place a negative sign in front.
Example: Given the two binary numbers X = 1010100 and Y = 1000011, perform the substraction: abX-Y Y X by using 2's Complement Solution:
aX = 1010100 2' s Complement of Y = L + 0111101 Sum = 10010001 Discard end carry 2 7 = 10000000 AnswerX Y = 0010001 b-
There is no end carry. Therefore, the answer is: Y X = - (2's Complement of 1101111) = - 0010001 a-
Substraction of unsigned numbers can also be done by means of the 1's X Y = 1010100 1000011 = = = = = 1010100 + 0111100 10010000 1 + 0010001
Complement:
There is no carry. Therefore, the answer is: Y X = - (1's Complement of 1101110) = -0010001