Codes When numbers alphabets or words are represented
Codes: When numbers, alphabets or words are represented by a Specific group of symbols, We can say they are Encoded. The group of symbols used to encode them are called Codes.
Binary Codes: The digital data is represented, stored and transmitted as a group of binary digits(bits). The group of bits also known as binary codes.
Classification of Binary codes:
BCD code The most commonly used BCD code is 8 -4 -2 -1. Each digit of the decimal number is represented by group of four bits.
Disadvantage of BCD code: BCD code having less efficiency than pure binary number system. Advantage of BCD code: The conversion from BCD to decimal is very easy than compared to other code conversions to decimal.
BCD addition: The are 3 cases present in the addition of BCD codes. Case: 1 Sum equals “ 9” or less with carry ” 0”. Case: 2 Sum greater than “ 9” with carry “ 0”. Case: 3 Sum equals “ 9” or less with carry ” 1”.
Procedure for BCD addition: ØAdd two BCD numbers using ordinary binary addition. ØIf four bit sum is equal to or less than “ 9”. No correction is needed. The sum is in proper BCD form. ØIf four-bit sum is greater than “ 9” or if a carry is generated from the four bit sum, the sum is invalid. ØTo correct the invalid sum, add 6(0110) to the four bit sum. If a carry results from this addition, add it to the next higher order BCD digit.
BCD Subtraction using 9’s complement ØFind the 9’s complement of the –ve number. ØAdd two numbers using BCD addition. ØIf carry is not generated the result is –ve and find the 9’ complement of the results, otherwise result is +ve and add carry to the results.
BCD Subtraction using 10’s complement ØFind the 10’s complement of the –ve number. ØAdd two numbers using BCD addition. ØIf carry is not generated the result is –ve and find the 10’ complement of the results, otherwise result is +ve and ignore the carry.
Reflective property of 2 -4 -2 -1 code. ØReflective property or self complementing property of 2 -42 -1 is code for 9 is complement of code 0, code for 8 is complement of code 1 and so on.
Decimal no 0 complement relation 2421 0000 1111 decimal no 9 1 0001 1110 8 2 0010 1101 7 3 0011 1100 6 4 0100 1011 5
Other weighted codes. Dec 3321 4221 5211 5311 5421 6311 742’ 1’ 0 0000 0000 1 0001 0001 0111 2 0010 0011 0010 0110 3 0011 0101 0100 0011 0101
Excess-3 code. The Excess-3 code can be derived from the natural BCD code by adding 3(0011) to each coded number.
Decimal Excess-3 code 0 0000+0011 3 1 0001+0011 0100 4 2 0010+0011 0101 5 3 0011+0011 0110 6 4 0100+0011 0111 7 5 0101+0011 1000 8 6 0110+0011 1001 9 7 0111+0011 1010 10 8 1000+0011 11 9 1001+0011 1100 12
Advantage of Excess-3 code. In Excess-3 code we get 9’s complement of a number by just complementing each bit. So Excess-3 code is called Self-complementing code or reflective code.
Excess-3 Addition ØAdd two Excess-3 numbers using binary addition. ØIf carry=1 add 3(0011) to the sum of two digits. ØIf carry=0 Subtract 3(0011) from the sum.
Excess-3 Subtraction or Ex-3 Subtraction using 9’s complement ØComplement the subtracted no. ØAdd complemented subtracted no to main no. ØIf carry=1 Result is +ve. Add 3(0011) and end around carry. ØIf carry= 0 Result is –ve subtract 3(0011).
Gray code: ØGray code is a non-weighted code and it is a special case of “Unit distance code”. ØIn unit-distance code bit patterns for two consecutive numbers differ is only one bit position. ØThese codes are also called “cyclic codes. And the gray code is also called as reflected code.
Gray code: 0 1. . . 1 0 00 01. . . 11 10 00 01 11 10. . . 10 11 01 00 001 010. . . 110 111 100 001 010 111 100. . . 100 101 110 011 000 0000 ---0 0001 ---1 0011 ---2 0010 ---3 0110 ---4 0111 ---5 0101 ---6 0100 ---7. . . 1100 ---8 1101 ---9 1111 ---10 1110 ---11 1010 ---12 1011 ---13 1001 ---14 1000 ---15
Binary to Gray code conversion: ØThe MSB of the gray code is the same as the MSB of the binary code. So write down as it is ØTo obtain the next gray digit , Perform an Exclusive. OR(Ex-OR) operation b/w previous and current binary bit. Write down result. ØRepeat Step-2 until all binary bits have been Exclusive. ORed with their previous bits.
Exclusive-OR operation: A B A Ex-OR B 0 0 1 1 1 0
Gray to Binary code conversion: ØThe MSB of the binary number is the same as the MSB of the gray code. So write down as it is ØTo obtain the next binary digit , Perform an Exclusive -OR(Ex-OR) operation b/w the bit just written down and the next gray code bit. Write down result. ØRepeat Step-2 until all gray code bits have been Exclusive. ORed with binary bits.
Alpha numeric code: ØOne standard alphanumeric code called the ASCII(American Standard Code for Information Interchange. ) ØIt is a 7 bit code. It represents 2 power 7=128 Symbols.
ASCII values for A to Z A-65 B-66 C-67 D-68 E-69 F-70 G-71 H-72 I-73 J-74 K-75 L-76 M-77 N-78 O-79 P-80 Q-81 R-82 S-83 T-84 U-85 V-86 W-87 X-88 Y-89 Z-90
ASCII values for a to z a-97 b-98 c-99 d-100 e-101 f-102 g-103 h-104 i-105 j-106 k-107 l-108 m-109 n-110 o-111 p-112 q-113 r-114 s-115 t-116 u-117 v-118 w-119 x-120 y-121 z-122
ASCII values for 0 to 9 0 1 2 3 4 5 6 7 8 9 - 48 49 50 51 52 53 54 55 56 57
Note: ASCII values for A to Z are 65 to 90 ASCII values for a to z are 97 to 122 ASCII values for 0 to 9 are 48 to 57
Parity bit: ØA parity bit is used for the purpose of detecting Error during the transmission of binary information. ØA parity bit is an extra bit included with a binary message to make no. of 1’s either odd or even number. ØThe circuit that generates the parity bit in the transmitter is called a parity generator. And the circuit that checks the parity in the receiver is called a parity checker.
Hamming Code ØHamming code is error detecting and correcting code. ØIn Hamming code for parity bit is used for error detecting.
3 (a) Given 8 bit data word 01011011 generate the 12 bit composite word for hamming code that corrects and detects single errors
- Slides: 33