CODES - PowerPoint PPT Presentation

Sophia
codes n.
Skip this Video
Loading SlideShow in 5 Seconds..
CODES PowerPoint Presentation
play fullscreen
1 / 29
Download Presentation
CODES
782 Views
Download Presentation

CODES

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CODES ICS 30/CS 30

  2. BINARY CODES • Electronic digital systems use signals that have two distinct values and circuit elements that have two stable states. • A binary number of n digits, for example, may be represented by n binary circuit elements, each having an output signal equivalent to a 0 or a 1. • Any discrete element of info. Distinct among a group of quantities can be represented by a binary code. • Ex. Red is one distinct color of the spectrum. XUCC

  3. BINARY CODES • A bit, by defn., is a binary digit. • Binary codes for decimal digits require a minimum of four bits. • Numerous different codes can be obtained by arranging four or more bits in ten distinct possible combinations. XUCC

  4. Decimal digit (BCD) 8421 Excess-3 84-2-1 2421 (Biquinary) 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 Binary Codes for the decimal digits XUCC

  5. BINARY CODES • It is possible to assign weights to the binary bits according to their positions. • BCD code, 84-2-1, 2421, 5043210 • Weighted codes • Numbers are represented in digital computers either in binary or in decimal through a binary code. XUCC

  6. BINARY CODES • The input decimal numbers are stored internally in the computer by means of a decimal code. • Each decimal digit requires at least four binary storage elements. The decimal numbers are converted to binary when arithmetic operations are done internally w/ numbers represented in binary. • It is also possible to perform arithmetic operations directly in decimal w/ all numbers left in a coded form throughout. XUCC

  7. BINARY CODES • Example: (395)10 when converted to binary, is equal to 110001011 and consists of nine binary digits. • The same number, when represented internally in the BCD code, occupies four bits for each decimal digit, for a total of 12 bits: 001110010101. • The first 4 bits represent a 3, the next 4 a 9, and the last 4 a 5. XUCC

  8. BINARY CODES • It is very important to understand the difference between conversion of a decimal number to binary and the binary coding of a decimal number. • In each case the final result is a series of bits. • The bits obtained from conversion are binary digits. • The bits obtained from coding are combinations of 1’s and 0’s arranged according to the rules of the code used. XUCC

  9. BINARY CODES • The BCD code, for example, has been chosen to be both a code and a direct binary conversion, as long as the decimal numbers are integers from 0 to 9. • For numbers greater than 9, the conversion and the coding are completely different. • Example: The binary conversion of decimal 13 is 1101; the coding of decimal 13 with BCD is 00010011. XUCC

  10. BINARY CODES • BCD code is the most natural to use and is indeed the one most commonly encountered • Excess-3, 2421, and the 84-2-1 are self complementary codes, that is, the 9’s complement of the decimal number is easily obtained by changing 1’s to 0’s and 0’s to 1’s. • Example: (395)10 is represented in the 2421 code by 001111111011. Its 9’s complement 604 is represented by 110000000100, which is easily obtained from the replacement of 1’s by 0’s and 0’s by 1’s. XUCC

  11. BINARY CODES • The biquinary code is an example of a seven-bit code w/ error-detection properties. • Each decimal digit consists of five 0’s and two 1’s placed in the corresponding weighted columns. • The error-detection property of this code may be understood if one realizes that digital systems represent binary 1 by one distinct signal and binary 0 by a second distinct signal. • During transmission of signals from one location to another, an error may occur. XUCC

  12. BINARY CODES • One or more bits may change value. • A circuit in the receiving side can detect the presence of more (or less) than two 1’s and, if the received combination of bits does not agree with the allowable combination, an error is detected. XUCC

  13. BINARY CODES • Error-Detection Codes • Binary information, be it pulse-modulated signals or digital computer input or output, may be transmitted through some form of communication medium such as wires or radio waves. • Any external noise introduced into a physical communication medium changes bit values from 0 to 1 or vice versa. • An error-detection code can be used to detect errors during transmission. • The detected error cannot be corrected, but its presence is indicated. XUCC

  14. BINARY CODES • A parity bit is an extra bit included w/ a message to make the total number of 1’s either odd or even. • During transfer of info. from one location to another, the parity bit is handled as follows: In the sending end, the message is applied to a “parity-generation” network where the required P bit is generated. • The message, including the parity bit, is transferred to its destination. XUCC

  15. (a) Message P (odd) (b) Message P (even) 0000 1 0000 0 0001 0 0001 1 0010 0 0010 1 0011 1 0011 0 0100 0 0100 1 0101 1 0101 0 0110 1 0110 0 0111 0 0111 1 1000 0 1000 1 BINARY CODES PARITY-BIT GENERATION XUCC

  16. 1001 1 1001 0 1010 1 1010 0 1011 0 1011 1 1100 1 1100 0 1101 0 1101 1 1110 0 1110 1 1111 1 1111 0 BINARY CODES PARITY-BIT GENERATION XUCC

  17. BINARY CODES • In the receiving end, all incoming bits are applied to a “parity-check” network to check the proper parity adopted. • An error is detected if the checked parity does not correspond to the adopted one. • The parity method detects the presence of one, three, or any odd combination of errors. • An even combination is undetectable. XUCC

  18. BINARY CODES • Reflected Code(also known as the Gray code) Digital systems can be designed to process data in discrete form only. Many physical systems supply continuous output data. These data must be converted into digital or discrete form before they are applied to a digital system. Advantage: A number in the reflected code changes by only one bit as it proceeds from one number to the next. XUCC

  19. Reflected Code Decimal Equivalent 0000 0 0001 1 0011 2 0010 3 0110 4 0111 5 0101 6 0100 7 1100 8 BINARY CODES XUCC

  20. 1101 9 1111 10 1110 11 1010 12 1011 13 1001 14 1000 15 BINARY CODES XUCC

  21. BINARY CODES • Alphanumeric Codes Many applications of digital computers require the handling of data that consist not only of numbers, but also of letters. An alphanumeric code is a binary code of a group of elements consisting of the 10 decimal digits, the 26 letters of the alphabet, and a certain number of special symbols such as $. XUCC

  22. BINARY CODES • The total number of elements in an alphanumeric group is greater than 36. Therefore, it must be coded with a minimum of 6 bits (26 = 64, but 25 = 32 is insufficient). • One possible arrangement of a 6-bit alphanumeric code is shown in the table under the name “internal code.” The need to represent more than 64 characters gave rise to 7- and 8- bit alphanumeric codes. One such code is known as ASCII. Another is known as EBCDIC. XUCC

  23. Character 6-Bit internal code 7-Bit ASCII code 8-Bit EBCDIC code 12-Bit card code A 010 001 100 0001 1100 0001 12,1 B 010 010 100 0010 1100 0010 12,2 C 010 011 100 0011 1100 0011 12,3 D 010 100 100 0100 1100 0100 12,4 E 010 101 100 0101 1100 0101 12,5 F 010 110 100 0110 1100 0110 12,6 G 010 111 100 0111 1100 0111 12,7 ALPHANUMERIC CHARACTER CODES XUCC

  24. H 011 000 100 1000 1100 1000 12,8 I 011 001 100 1001 1100 1001 12,9 J 100 001 100 1010 1101 0001 11,1 K 100 010 100 1011 1101 0010 11,2 L 100 011 100 1100 1101 0011 11,3 M 100 100 100 1101 1101 0100 11,4 N 100 101 100 1110 1101 0101 11,5 O 100 110 100 1111 1101 0110 11,6 P 100 111 101 0000 1101 0111 11,7 ALPHANUMERIC CHARACTER CODES XUCC

  25. Q 101 000 101 0001 1101 1000 11,8 R 101 001 101 0010 1101 1001 11,9 S 110 010 101 0011 1110 0010 0,2 T 110 011 101 0100 1110 0011 0,3 U 110 100 101 0101 1110 0100 0,4 V 110 101 101 0110 1110 0101 0,5 W 110 110 101 0111 1110 0110 0,6 X 110 111 101 1000 1110 0111 0,7 Y 111 000 101 1001 1110 1000 0,8 Z 111 001 101 1010 1110 1001 0,9 ALPHANUMERIC CHARACTER CODES XUCC

  26. 0 000 000 011 0000 1111 0000 0 1 000 001 011 0001 1111 0001 1 2 000 010 011 0010 1111 0010 2 3 000 011 011 0011 1111 0011 3 4 000 100 011 0100 1111 0100 4 5 000 101 011 0101 1111 0101 5 6 000 110 011 0110 1111 0110 6 7 000 111 011 0111 1111 0111 7 8 001 000 011 1000 1111 1000 8 9 001 001 011 1001 1111 1001 9 ALPHANUMERIC CHARACTER CODES XUCC

  27. Blank 110 000 010 0000 0100 0000 No punch . 011 011 010 1110 0100 1011 12,8,3 ( 111 100 010 1000 0100 1101 12,8,5 + 010 000 010 1011 0100 1110 12,8,6 $ 101 011 010 0100 0101 1011 11,8,3 * 101 100 010 1010 0101 1100 11,8,4 ) 011 100 010 1001 0101 1101 11,8,5 - 100 000 010 1101 0110 0000 11 / 110 001 010 1111 0110 0001 0,1 , 111 011 010 1100 0110 1011 0,8,3 = 001 011 011 1101 0111 1110 8,6 ALPHANUMERIC CHARACTER CODES XUCC

  28. 12-BIT CARD CODE When discrete info. is transferred through punch cards, the alphanumeric characters use a 12-bit binary code. • A punch card consists of 80 columns and 12 rows - in each column an alphanumeric character is represented by holes punched in the appropriate rows. A hole is sensed as a 1 and the absence of a hole is sensed as a 0. • The 12 rows are marked, starting from the top, as the 12, 11, 0, 1, 2,…,9 punch. The first 3 are called the zone punch and the last 9 are called the numeric punch. XUCC

  29. BINARY CODES • Most computers translate the input code into an internal 6-bit code. As an example, the internal code representation of the name “John Doe” is: 100001 100110 011000 100101 110000 J O H N blank • 010100100110 010101 D O E XUCC