🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Lec1 Digital Electronics - Number Systems Notes.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

© 2009 Pearson Education Number Systems, Operations, and Codes © 2009 Pearson Education,©Upper 2009 Pearson Education Floyd, Digit...

© 2009 Pearson Education Number Systems, Operations, and Codes © 2009 Pearson Education,©Upper 2009 Pearson Education Floyd, Digital Fundamentals, 10th ed Saddle River, NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal numbers is ten, because only ten symbols (0 through 9) are used to represent any number. The column weights of decimal numbers are powers of ten that increase from right to left beginning with 100 =1: …105 104 103 102 101 100. For fractional decimal numbers, the column weights are negative powers of ten that decrease from left to right: 102 101 100. 10-1 10-2 10-3 10-4 … Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Numbers Decimal numbers can be expressed as the sum of the products of each digit times the column value for that digit. Thus, the number 9240 can be expressed as (9 x 103) + (2 x 102) + (4 x 101) + (0 x 100) or 9 x 1,000 + 2 x 100 + 4 x 10 + 0 x 1 Example Express the number 480.52 as the sum of values of each digit. Solution 480.52 = (4 x 102) + (8 x 101) + (0 x 100) + (5 x 10-1) +(2 x 10-2) Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Numbers For digital systems, the binary number system is used. Binary has a radix of two and uses the digits 0 and 1 to represent quantities. The column weights of binary numbers are powers of two that increase from right to left beginning with 20 =1: …25 24 23 22 21 20. For fractional binary numbers, the column weights are negative powers of two that decrease from left to right: 22 21 20. 2-1 2-2 2-3 2-4 … Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Binary Number Number Binary Numbers 0 0000 1 0001 A binary counting sequence for numbers 2 0010 from zero to fifteen is shown. 3 0011 4 0100 Notice the pattern of zeros and ones in 5 0101 each column. 6 0110 Digital counters frequently have this 7 0111 8 1000 same pattern of digits: 9 1001 Counter 0 1 0 1 0 1 0 1 0 1 Decoder 10 1010 0 0 1 1 0 0 1 1 0 0 11 1011 12 1100 0 0 0 0 1 1 1 1 0 0 13 1101 0 0 0 0 0 0 0 0 1 1 14 1110 15 1111 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Conversions The decimal equivalent of a binary number can be determined by adding the column values of all of the bits that are 1 and discarding all of the bits that are 0. Example Convert the binary number 100101.01 to decimal. Solution Start by writing the column weights; then add the weights that correspond to each 1 in the number. 25 24 23 22 21 20. 2-1 2-2 32 16 8 4 2 1. ½ ¼ 1 0 0 1 0 1. 0 1 32 +4 +1 +¼ = 37¼ Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Conversions You can convert a decimal whole number to binary by reversing the procedure. Write the decimal weight of each column and place 1’s in the columns that sum to the decimal number. Example Convert the decimal number 49 to binary. Solution The column weights double in each position to the right. Write down column weights until the last number is larger than the one you want to convert. 26 25 24 23 22 2 1 20. 64 32 16 8 4 2 1. 0 1 1 0 0 0 1. Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Conversions You can convert a decimal fraction to binary by repeatedly multiplying the fractional results of successive multiplications by 2. The carries form the binary number. Example Convert the decimal fraction 0.188 to binary by repeatedly multiplying the fractional results by 2. Solution 0.188 x 2 = 0.376 carry = 0 MSB 0.376 x 2 = 0.752 carry = 0 0.752 x 2 = 1.504 carry = 1 0.504 x 2 = 1.008 carry = 1 0.008 x 2 = 0.016 carry = 0 Answer =.00110 (for five significant digits) Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Conversions You can convert decimal to any other base by repeatedly dividing by the base. For binary, repeatedly divide by 2: Example Convert the decimal number 49 to binary by repeatedly dividing by 2. Solution You can do this by “reverse division” and the answer will read from left to right. Put quotients to the left and remainders on top. Answer: remainder 1 1 0 0 0 1 0 1 3 6 12 24 49 2 Continue until the Decimal Quotient base last quotient is 0 number Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Addition Example Add the binary numbers 00111 and 10101 and show the equivalent decimal addition. Solution 0111 00111 7 10101 21 11100 = 28 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary Subtraction The rules for binary subtraction are 0−0=0 1−1=0 1−0=1 10 − 1 = 1 with a borrow of 1 Example Subtract the binary number 00111 from 10101 and show the equivalent decimal subtraction. Solution 111 10101 / / / 21 00111 7 01110 = 14 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Operations in Binary, Octal, and Hexadecimal Systems 2.1 Binary System Operations 2.2 Octal System Operations 2.3 Hexadecimal System Operations © 2009 Pearson Education Quantities/Counting (1 of 3) Hexa- Decimal Binary Octal decima l 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 © 2009 Pearson Education Quantities/Counting (2 of 3) Hexa- Decimal Binary Octal decima l 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 © 2009 Pearson Education Quantities/Counting (3 of 3) Hexa- Decimal Binary Octal decima l 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 20 10100 24 14 21 10101 25 15 22 10110 26 16 23 10111 27 17 © 2009 Pearson Education Conversion Among Bases The possibilities: Decimal Octal Binary Hexadecimal © 2009 Pearson Education Quick Example 2510 = 110012 = 318 = 1916 Base © 2009 Pearson Education Decimal to Decimal (just for fun) Decimal Octal Binary Hexadecimal © 2009 Pearson Education Weight 12510 => 5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base © 2009 Pearson Education Binary to Decimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Binary to Decimal Technique – Multiply each bit by 2n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results © 2009 Pearson Education Example Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310 © 2009 Pearson Education Octal to Decimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Octal to Decimal Technique – Multiply each bit by 8n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results © 2009 Pearson Education Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810 © 2009 Pearson Education Hexadecimal to Decimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Hexadecimal to Decimal Technique – Multiply each bit by 16n, where n is the “weight” of the bit – The weight is the position of the bit, starting from 0 on the right – Add the results © 2009 Pearson Education Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810 © 2009 Pearson Education Decimal to Binary Decimal Octal Binary Hexadecimal © 2009 Pearson Education Decimal to Binary Technique – Divide by two, keep track of the remainder – First remainder is bit 0 (LSB, least-significant bit) – Second remainder is bit 1 – Etc. © 2009 Pearson Education Example 12510 = ?2 2 125 2 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 0 1 12510 = 11111012 © 2009 Pearson Education Octal to Binary Decimal Octal Binary Hexadecimal © 2009 Pearson Education Octal to Binary Technique – Convert each octal digit to a 3-bit equivalent binary representation © 2009 Pearson Education Example 7058 = ?2 7 0 5 111 000 101 7058 = 1110001012 © 2009 Pearson Education Hexadecimal to Binary Decimal Octal Binary Hexadecimal © 2009 Pearson Education Hexadecimal to Binary Technique – Convert each hexadecimal digit to a 4-bit equivalent binary representation © 2009 Pearson Education Example 10AF16 = ?2 1 0 A F 0001 0000 1010 1111 10AF16 = 00010000101011112 © 2009 Pearson Education Decimal to Octal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Decimal to Octal Technique – Divide by 8 – Keep track of the remainder © 2009 Pearson Education Example 123410 = ?8 8 1234 8 154 2 8 19 2 8 2 3 0 2 123410 = 23228 © 2009 Pearson Education Decimal to Hexadecimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Decimal to Hexadecimal Technique – Divide by 16 – Keep track of the remainder © 2009 Pearson Education Example 123410 = ?16 16 1234 16 77 2 16 4 13 = D 0 4 123410 = 4D216 © 2009 Pearson Education Binary to Octal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Binary to Octal Technique – Group bits in threes, starting on right – Convert to octal digits © 2009 Pearson Education Example 10110101112 = ?8 1 011 010 111 1 3 2 7 10110101112 = 13278 © 2009 Pearson Education Binary to Hexadecimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Binary to Hexadecimal Technique – Group bits in fours, starting on right – Convert to hexadecimal digits © 2009 Pearson Education Example 10101110112 = ?16 10 1011 1011 2 B B 10101110112 = 2BB16 © 2009 Pearson Education Octal to Hexadecimal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Octal to Hexadecimal Technique – Use binary as an intermediary © 2009 Pearson Education Example 10768 = ?16 1 0 7 6 001 000 111 110 2 3 E 10768 = 23E16 © 2009 Pearson Education Hexadecimal to Octal Decimal Octal Binary Hexadecimal © 2009 Pearson Education Hexadecimal to Octal Technique – Use binary as an intermediary © 2009 Pearson Education Example 1F0C16 = ?8 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4 1F0C16 = 174148 © 2009 Pearson Education Exercise – Convert... Hexa- Decimal Binary Octal decimal 33 1110101 703 1AF Don’t use a calculator! Skip answer Answer Skip answer Answer © 2009 Pearson Education Exercise – Convert … Answer Hexa- Decimal Binary Octal decimal 33 100001 41 21 117 1110101 165 75 451 11100001 703 1C3 1 431 11010111 657 1AF 1 © 2009 Pearson Education Decimal Hexadecimal Binary Hexadecimal Numbers 0 0 0000 1 1 0001 Hexadecimal uses sixteen characters to 2 2 0010 represent numbers: the numbers 0 3 3 0011 through 9 and the alphabetic characters 4 4 0100 A through F. 5 5 0101 6 6 0110 Large binary number can easily 7 7 0111 be converted to hexadecimal by 8 8 1000 grouping bits 4 at a time and writing 9 9 1001 the equivalent hexadecimal character. 10 A 1010 11 B 1011 Example Express 1001 0110 0000 11102 in hexadecimal: 12 C 1100 13 D 1101 Solution Group the binary number by 4-bits 14 E 1110 starting from the right. Thus, 960E 15 F 1111 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Hexadecimal Binary Hexadecimal Numbers 0 0 0000 1 1 0001 Hexadecimal is a weighted number 2 2 0010 system. The column weights are 3 3 0011 powers of 16, which increase from 4 4 0100 5 5 0101 right to left. 6 6 0110 7 7 0111 Column weights {4096 3 2 16 16 16 16. 256 16 1. 1 0 8 8 1000 9 9 1001 Example Express 1A2F16 in decimal. 10 A 1010 11 B 1011 Solution 4096 256 16 1 Start by writing the column weights: 12 C 1100 13 D 1101 1 A 2 F16 14 E 1110 1(4096) + 10(256) +2(16) +15(1) = 670310 15 F 1111 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Octal Binary Octal Numbers 0 0 0000 1 1 0001 Octal uses eight characters the numbers 2 2 0010 0 through 7 to represent numbers. 3 3 0011 There is no 8 or 9 character in octal. 4 4 0100 5 5 0101 Binary number can easily be 6 6 0110 converted to octal by grouping bits 3 at 7 7 0111 a time and writing the equivalent octal 8 10 1000 character for each group. 9 11 1001 10 12 1010 Example Express 1 001 011 000 001 1102 in octal: 11 13 1011 12 14 1100 Solution Group the binary number by 3-bits 13 15 1101 starting from the right. Thus, 1130168 14 16 1110 15 17 1111 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Octal Binary Octal Numbers 0 0 0000 1 1 0001 Octal is also a weighted number 2 2 0010 system. The column weights are 3 3 0011 powers of 8, which increase from right 4 4 0100 5 5 0101 to left. 6 6 0110 7 7 0111 Column weights {5128 3 82 64 81 8 80. 1. 8 10 1000 9 11 1001 Example Express 37028 in decimal. 10 12 1010 11 13 1011 Solution 512 64 8 1 Start by writing the column weights: 12 14 1100 13 15 1101 3 7 0 28 14 16 1110 3(512) + 7(64) +0(8) +2(1) = 198610 15 17 1111 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved COMPLEMENTS OF BINARY NUMBERS The 1’s complement and the 2’s complement of a binary number are important because they permit the representation of negative numbers. The method of 2’s complement arithmetic is commonly used in computers to handle negative numbers © 2009 Pearson Education 1’s Complement The 1’s complement of a binary number is just the inverse of the digits. To form the 1’s complement, change all 0’s to 1’s and all 1’s to 0’s. For example, the 1’s complement of 11001010 is 00110101 In digital circuits, the 1’s complement is formed by using inverters: 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved 2’s Complement The 2’s complement of a binary number is found by adding 1 to the LSB of the 1’s complement. Recall that the 1’s complement of 11001010 is 00110101 (1’s complement) To form the 2’s complement, add 1: +1 1 1 0 0 1 0 1 0 00110110 (2’s complement) 1 0 0 1 1 0 1 0 1 Input bits Carry Adder in (add 1) Output bits (sum) 0 0 1 1 0 1 1 0 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved SIGNED NUMBERS Digital systems, such as the computer, must be able to handle both positive and negative numbers. A signed binary number consists of both sign and magnitude information. The sign indicates whether a number is positive or negative, and the magnitude is the value of the number. © 2009 Pearson Education Signed Binary Numbers There are several ways to represent signed binary numbers. In all cases, the MSB (left-most bit) in a signed number is the sign bit, that tells you if the number is positive or negative. A 0 sign bit indicates a positive number, and a 1 sign bit indicates a negative number. Sign-Magnitude Form When a signed binary number is represented in sign-magnitude, the left- most bit is the sign bit and the remaining bits are the magnitude bits. The magnitude bits are in true (uncomplemented) binary for both positive and negative numbers. Example, for +25: For -25: 10011001 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Signed Binary Numbers In the sign-magnitude form, a negative number has the same magnitude bits as the corresponding positive number but the sign bit is a 1 rather than a zero. © 2009 Pearson Education Signed Binary Numbers Positive numbers in 1’s complement form are represented the same way as the positive sign- magnitude numbers. Negative numbers, however, are the 1’s complements of the corresponding positive numbers. For example, using eight bits, the decimal number -25 is expressed as the 1’s complement of +25 (00011001) as 11100110. In the 1’s complement form, a negative number is the 1’s complement of the corresponding positive number. © 2009 Pearson Education Signed Binary Numbers Positive numbers in 2’s complement form are represented the same way as in the sign-magnitude and 1’s complement forms. Negative numbers are the 2’s complements of the corresponding positive numbers. Example for -25: Take the 2’s complement of +25 : 00011001 2’s complement of 25 : 11100111 In the 2’s complement form, a negative number is the 2’s complement of the corresponding positive number. © 2009 Pearson Education Example (Signed Binary Numbers) Express the decimal number -39 as an 8-bit number in the sign-magnitude, 1’s complement, and 2’s complement forms. Solution: 8-bit number of +39 : 00100111 a) Sign-magnitude form: 10100111 b) 1’s complement form: 11011000 c) 2’s complement form: © 2009 Pearson Education Decimal Values of Signed Numbers Sign-Magnitude Decimal values of positive and negative numbers in the sign-magnitude form are determined by summing the weights in all the magnitude bit positions where there are 1s and ignoring those positions where there are zeros. The sign is determined by examination of the sign bit. © 2009 Pearson Education Decimal Values of Signed Numbers Example: Determine the decimal value of this signed binary number expressed in sign-magnitude: 10010101. Solution: Taking the weight of the 7-magnitude bits: Summing the weights: 16+4+1 = 21 The sign bit is 1, therefore the decimal number is -21. © 2009 Pearson Education Decimal Values of Signed Numbers (1’s Complement) Decimal values of positive numbers in the 1’s complement form are determined by summing the weights in all bit positions where there are 1s and ignoring those positions where there are zeros. Decimal values of negative numbers are determined by assigning a negative value to the weight of the sign bit, summing all the weights where there are 1s, and adding 1 to the result. © 2009 Pearson Education Decimal Values of Signed Numbers (1’s Complement) Determine the decimal values of the signed binary numbers expressed in 1’s complement: (a) 00010111 (b) 11101000 Solution: a) © 2009 Pearson Education Decimal Values of Signed Numbers (1’s Complement) b) © 2009 Pearson Education Decimal Values of Signed Numbers (2’s Complement) Decimal values of positive and negative numbers in the 2’s complement form are determined by summing the weights in all bit positions where there are 1s and ignoring those positions where there are zeros. The weight of the sign bit in a negative number is given a negative value. © 2009 Pearson Education Decimal Values of Signed Numbers (2’s Complement) Example: Determine the decimal values of the signed binary numbers expressed in 2’s complement. (a) 01010110 (b) 10101010 Solution: a) © 2009 Pearson Education Decimal Values of Signed Numbers (2’s Complement) b) © 2009 Pearson Education Floating Point Numbers Floating point notation is capable of representing very large or small numbers by using a form of scientific notation. A 32-bit single precision number is illustrated. S E (8 bits) F (23 bits) Sign bit Biased exponent (+127) Magnitude with MSB dropped Example Express the speed of light, c, in single precision floating point notation. (c = 0.2998 x 109) Solution In binary, c = 0001 0001 1101 1110 1001 0101 1100 00002. In scientific notation, c = 1.001 1101 1110 1001 0101 1100 0000 x 228. S = 0 because the number is positive. E = 28 + 127 = 15510 = 1001 10112. F is the next 23 bits after the first 1 is dropped. In floating point notation, c = 0 10011011 001 1101 1110 1001 0101 1100 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Arithmetic Operations with Signed Numbers Using the signed number notation with negative numbers in 2’s complement form simplifies addition and subtraction of signed numbers. Rules for addition: Add the two signed numbers. Discard any final carries. The result is in signed form. Examples: 00011110 = +30 00001110 = +14 11111111 = −1 00001111 = +15 11101111 = −17 11111000 = −8 00101101 = +45 11111101 = −3 1 11110111 = −9 Discard carry Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Arithmetic Operations with Signed Numbers Note that if the number of bits required for the answer is exceeded, overflow will occur. This occurs only if both numbers have the same sign. The overflow will be indicated by an incorrect sign bit. Two examples are: 01000000 = +128 10000001 = −127 01000001 = +129 10000001 = −127 10000001 = −126 Discard carry 100000010 = +2 Wrong! The answer is incorrect and the sign bit has changed. Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Arithmetic Operations with Signed Numbers Rules for subtraction: 2’s complement the subtrahend and add the numbers. Discard any final carries. The result is in signed form. Repeat the examples done previously, but subtract: 00011110 (+30) 00001110 (+14) 11111111 (−1) − 00001111 –(+15) − 11101111 –(−17) − 11111000 –(−8) 2’s complement subtrahend and add: 00011110 = +30 00001110 = +14 11111111 = −1 11110001 = −15 00010001 = +17 00001000 = +8 1 00001111 = +15 00011111 = +31 1 00000111 = +7 Discard carry Discard carry Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Binary BCD BCD 0 0000 0000 1 0001 0001 Binary coded decimal (BCD) is a 2 0010 0010 weighted code that is commonly 3 0011 0011 used in digital systems when it is 4 0100 0100 5 0101 0101 necessary to show decimal 6 0110 0110 numbers such as in clock displays. 7 0111 0111 The table illustrates the 8 1000 1000 difference between straight binary and 9 1001 1001 BCD. BCD represents each decimal 10 1010 0001 0000 digit with a 4-bit code. Notice that the 11 1011 0001 0001 codes 1010 through 1111 are not used in 12 1100 0001 0010 BCD. 13 1101 0001 0011 14 1110 0001 0100 15 1111 0001 0101 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved BCD You can think of BCD in terms of column weights in groups of four bits. For an 8-bit BCD number, the column weights are: 80 40 20 10 8 4 2 1. Question: What are the column weights for the BCD number 1000 0011 0101 1001? Answer: 8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1 Note that you could add the column weights where there is a 1 to obtain the decimal number. For this case: 8000 + 200 +100 + 40 + 10 + 8 +1 = 835910 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Decimal Binary Gray code Gray code 0 0000 0000 1 0001 0001 Gray code is an unweighted code 2 0010 0011 that has a single bit change between 3 0011 0010 one code word and the next in a 4 0100 0110 5 0101 0111 sequence. Gray code is used to 6 0110 0101 avoid problems in systems where an 7 0111 0100 error can occur if more than one bit 8 1000 1100 changes at a time. 9 1001 1101 10 1010 1111 11 1011 1110 12 1100 1010 13 1101 1011 14 1110 1001 15 1111 1000 Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Binary to Gray Code Conversion 1. The most significant bit (left-most) in the Gray code is the same as the corresponding MSB in the binary number. 2. Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit. Discard carries. © 2009 Pearson Education Binary to Gray Code Conversion Example: Convert binary number 10110 to Gray Code. © 2009 Pearson Education Gray Code to Binary Conversion 1. The most significant bit (left-most) in the binary code is the same as the corresponding bit in the Gray code. 2. Add each binary code bit generated to the Gray code bit in the next adjacent position. Discard carries. © 2009 Pearson Education Gray Code to Binary Conversion Example: Convert the Gray code 11011 to binary. © 2009 Pearson Education Gray code A shaft encoder is a typical application. Three IR emitter/detectors are used to encode the position of the shaft. The encoder on the left uses binary and can have three bits change together, creating a potential error. The encoder on the right uses gray code and only 1-bit changes, eliminating potential errors. Binary sequence Gray code sequence Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved ASCII ASCII is a code for alphanumeric characters and control characters. In its original form, ASCII encoded 128 characters and symbols using 7-bits. The first 32 characters are control characters, that are based on obsolete teletype requirements, so these characters are generally assigned to other functions in modern usage. In 1981, IBM introduced extended ASCII, which is an 8- bit code and increased the character set to 256. Other extended sets (such as Unicode) have been introduced to handle characters in languages other than English. Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved ERROR CODES Three Methods for Adding Bits to Codes to Detect a Single-Bit Error: 1. Parity Method 2. Cyclic Redundancy Check 3. Hamming Code © 2009 Pearson Education Parity Method The parity method is a method of error detection for simple transmission errors involving one bit (or an odd number of bits). A parity bit is an “extra” bit attached to a group of bits to force the number of 1’s to be either even (even parity) or odd (odd parity). Example The ASCII character for “a” is 1100001 and for “A” is 1000001. What is the correct bit to append to make both of these have odd parity? Solution The ASCII “a” has an odd number of bits that are equal to 1; therefore the parity bit is 0. The ASCII “A” has an even number of bits that are equal to 1; therefore the parity bit is 1. Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Cyclic Redundancy Check The cyclic redundancy check (CRC) is an error detection method that can detect multiple errors in larger blocks of data. At the sending end, a checksum is appended to a block of data. At the receiving end, the check sum is generated and compared to the sent checksum. If the check sums are the same, no error is detected. Floyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved Selected Key Terms Byte A group of eight bits Floating-point A number representation based on scientific number notation in which the number consists of an exponent and a mantissa. Hexadecimal A number system with a base of 16. Octal A number system with a base of 8. BCD Binary coded decimal; a digital code in which each of the decimal digits, 0 through 9, is represented by a group of four bits. © 2009 Pearson Education Selected Key Terms Alphanumeric Consisting of numerals, letters, and other characters ASCII American Standard Code for Information Interchange; the most widely used alphanumeric code. Parity In relation to binary codes, the condition of evenness or oddness in the number of 1s in a code group. Cyclic A type of error detection code. redundancy check (CRC) © 2009 Pearson Education

Use Quizgecko on...
Browser
Browser