Digital Circuit and Logic Design I

Digital Circuit and Logic Design I

Digital Circuit And Logic Design I Lecture 2 Outline Number System and Codes (2) 1. Codes 2. Error detecting and correcting Panupong Sornkhom, 2005/2 2 Number System and Codes (2) 1. Codes What is code Decimal number codes Gray code Character codes Code for action, condition and states Panupong Sornkhom, 2005/2 4 What is code? A digital system requires that all information be in binary form. The external world, however, uses various other symbols to represent information. A symbol is represented in a digital system by a string of bits A set of n-bit strings in which different bit strings represent different symbol is called a code. A particular pattern of string is called code word. Panupong Sornkhom, 2005/2 5 Decimal number codes Binary-Coded Decimal Excess 3 code (BCD) code Self-complementing but is Encode the digit 0 – 9 by not weighted code their 4-bit unsigned binary Excess3 = BCD + 00112 representation, other code Biquinary code word are not used Uses 7 bits per code word BCD is a weighted code, the weight are 8,4,2,1. so, The first two bits indicate sometime this code called range of number 0-4 or 5-9, 8421 code. and the last five bits indicate which of the five 2421 code numbers in the selected Weighted code with self- range is represented complementing (9’s 1-out-of-10 code complement) Using 10-bit code word. Panupong Sornkhom, 2005/2 6 Decimal codes Decimal BCD 2421 Excess-3 Biquinary 1-out-of-10 digit (8421) 0 0000 0000 0011 0100001 1000000000 1 0001 0001 0100 0100010 0100000000 2 0010 0010 0101 0100100 0010000000 3 0011 0011 0110 0101000 0001000000 4 0100 0100 0111 0110000 0000100000 5 0101 1011 1000 1000001 0000010000 6 0110 1100 1001 1000010 0000001000 7 0111 1101 1010 1000100 0000000100 8 1000 1110 1011 1001000 0000000010 9 1001 1111 1111 1010000 0000000001 Panupong Sornkhom, 2005/2 7 Gray code It is sometimes necessary for an input sensor to produce a digital value that indicates a mechanical position. The encoder has a problem when the disk is positioned at certain boundaries between the regions where more than one bit 3-bit binary code changes This problem can be solved by devising a digital code in which only one bit changes between each pair of successive code words. Such a code is called Gray code 3-bit Gray code Panupong Sornkhom, 2005/2 8 Gray code (cont.) There are two convenient ways to Decimal 1 bit 2 bits 3 bits construct n-bit Gray code The first method is based on the 0 0 00 000 fact that Gray code is a reflected code 1 1 01 001 A 1-bit Gray code has two code words, 0 and 1. 2 - 11 011 The first 2n code words of an (n+1)-bit Gray code equal the 3 - 10 010 code words of an n-bit Gray code, written in order with a 4 - - 110 leading 0 append The last 2n code words of an 5 - - 111 (n+1)-bit Gray code equal the code words of an n-bit Gray 6 - - 101 code, written in reverse order with a leading 1 append 7 - - 100 Panupong Sornkhom, 2005/2 9 Gray code (cont.) The second method allows us Decimal Binary code Gray code to derive n-bit Gray-code code number word directly from the 0 000 000 corresponding n-bit binary code word 1 001 001 The bits of an n-bit binary or 2 010 011 Gray-code code word are numbered from right to left, 3 011 010 from 0 to n-1 Bit i of a Gray-code code word 4 100 110 is 0 if bits i and i+1 of the corresponding binary code 5 101 111 word are the same, else bit i is 1. (When i+1 = n, bit n of the 6 110 101 binary code word is considered to be 0.) 7 111 100 Panupong Sornkhom, 2005/2 10 Character codes The most commonly used character code is ASCII, the American Standard Code for Information Interchange. ASCII represents each character with a 8-bit string, in fact 7 bits are sufficient for English The code contains the uppercase and lowercase alphabet, numerals, punctuation, and various nonprinting control characters. Panupong Sornkhom, 2005/2 11 Character codes (cont.) Pictures from http://www.jimprice.com/jim-asc.htm Panupong Sornkhom, 2005/2 12 Character codes (cont.) Pictures from http://www.jimprice.com/jim-asc.htm Panupong Sornkhom, 2005/2 13 Codes for Actions, Conditions, and States Characters and numbers are considered to be data but sometimes we need non-data codes to represent actions, conditions, or states. For example, consider a simple traffic-light controller. State Lights N-S Green N-S Yellow N-S E-W Green E-W Yellow E-W Code word Red Red N-S go ON OFF OFF OFF OFF ON 000 N-S wait OFF ON OFF OFF OFF ON 001 N-S delay OFF OFF ON OFF OFF ON 010 E-W go OFF OFF ON ON OFF OFF 100 E-W wait OFF OFF ON OFF ON OFF 101 E-W delay OFF OFF ON OFF OFF ON 110 Panupong Sornkhom, 2005/2 14 2. Error detecting and correcting Introduction Single error detecting Error correcting and multiple errors detecting Hamming code Panupong Sornkhom, 2005/2 15 Introduction An error in a digital system is the corruption of the data from its correct value to some other value caused by physical failure Failure can be either temporary or permanent Single error = failure affect only a single bit of data Multiple errors = two or more bits in error Error-detecting codes n A code that uses n-bit strings need not contain 2 valid code words Corrupting a code word will likely produce a bit string that is not a code word Panupong Sornkhom, 2005/2 16 Single error detecting A code detects all single errors Information Even-parity Odd-parity is the minimum distance bits code code between all possible pairs of 000 000 0 000 1 code words is 2 001 001 1 001 0 In general, we need n+1 bits to 010 010 1 010 0 construct a single-error- detecting code with 2n code 011 011 0 011 1 words. 100 100 1 100 0 The first n bits of a code word = information bits 101 101 0 101 1 The last one bit = parity bit 110 110 0 110 1 111 111 1 111 0 Panupong Sornkhom, 2005/2 17 Error-correcting and multiple-error-detecting codes Assume that failures affect at most one bit of each code word, then a noncode word with a 1-bit error will be closer to the originally code word than to any other code word. Therefore, we can correct the error by changing the noncode word to the nearest code word A code that is used to correct errors is called an error- correcting code If a code has minimum distance 2c+1, it can be used to correct errors that affect up to c bits If a code’s minimum distance is 2c+d+1, it can be used to correct errors in put to c bits and to detect errors in put to d additional bits Panupong Sornkhom, 2005/2 18 Error-correcting and multiple-error- detecting codes (cont.) For example, a code with minimum distance 4 (c=1, d=1) Single-bit errors that produce noncode words 00101010 and 11010011 can be corrected However, a error that produces 10100011 can’t be corrected but can be detected Pictures from Textbook DDPP Panupong Sornkhom, 2005/2 19 Error-correcting and multiple-error-detecting codes (cont.) A 3-bit error may be “corrected” to the wrong value. It may be acceptable if 3- bit errors are rarely to occur. However, if we concerned about 3-bit errors, we can Picture from Textbook DDPP change the decoding policy for the code by just flag all noncode words as uncorrectable errors. Panupong Sornkhom, 2005/2 20 Hamming codes In 1950, R. W. Hamming described a general method for constructing codes with a minimum distance of 3, now called Hamming codes For any value of i, his method yields a (2i – 1)-bit code (check bits = i bits and information bits = 2i –1 –i bits) The bit positions can be numbered from 1 through 2i-1. Any position whose number is power of 2 is a check bit The remaining positions are information bits Panupong Sornkhom, 2005/2 21 Hamming codes (cont.) Each check bit is grouped with a subset of the information bits, as specified by a parity-check matrix. Each check bit is grouped with the information positions whose numbers have a 1 in the same bit when expressed in binary For example, check bit 2 (010) is grouped with information bits 3 (011), 6 (110), and 7 (111) For a given combination of information-bit values, each check bit is chosen to produce even parity, so the total number of 1s in its group is even. Panupong Sornkhom, 2005/2 22 Hamming codes (cont.) Parity-check matrices for 7-bit Hamming codes: (a) With bit positions in numerical order; (b) With check bits and information bits separated Panupong Sornkhom, 2005/2 23 Hamming codes (cont.) Example Distance-3 Hamming code Information bits = 0000 Î Parity bits = 000 Information bits = 0100 Î Parity bits = 110 Information bits = 0111 Î Parity bits = 000 Information bits = 1100 Î Parity bits = 001 Information bits = 1101 Î Parity bits = 010 A distance-3 Hamming code can easily be modified to increase its minimum distance to 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    28 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us