Beruflich Dokumente
Kultur Dokumente
They are: i) Numeric codes ii) Alphanumeric codes Numeric codes may be divided in to four classes. Thay are 1. Weighted codes 2. Self-complementing codes 3. Cyclic, reflected codes 4. Error detecting and correcting codes.
1) Weighted Codes In weighted codes, the decimal value of a code is the algebraic sum of the weights of those columns in which a 1 appears. Examples of weighted codes are the 8421 code (BCD), 8421 code and 2421 code.
2421 Code
This is a weighted code, its weights are 2, 4, 2 and 1. A decimal number is represented in 4-bit form and the total four bits weight is 2 + 4 + 2 + 1 = 9. Hence the 2421 code represents the decimal numbers from 0 to 9. Decimal 0 1 2 3 4 5 6 8421 0000 0001 0010 0011 0100 0101 0110 2421 0000 0001 0010 0011 0100 1011 1100
7 8 9
Self-complementing Codes
y
A self complementing code is one thats 9's complement in decimal is the 1's complement in binary.
o
y y
and . Note: if a weighted code is self-complementing, the total weight must be 9. In thes respect, BCD code is not self complementing. XS3 code is another example of a self-complementing code.
CODE FOR DIGIT 4 2 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 1 1 CODE FOR COMPLEMENT 4 2 1 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 DIGIT COMPLEMENT 9-D 9 8 7 6 5 4 3 2 1 0
DIGIT D 0 1 2 3 4 5 6 7 8 9
2 0 0 0 0 0 0 1 1 1 1
1 0 1 0 1 0 1 0 1 0 1
2 1 1 1 1 1 1 0 0 0 0
1 1 0 1 0 1 0 1 0 1 0
Excess-3 Code
Excess-3 is a non weighted code used to express decimal numbers. The code derives its name from the fact that each binary code is the corresponding 8421 code plus 0011(3).
2 3 4 5 6 7 8 9
Gray code (Unit Distance code or Reflective code) There are applications in which it is desirable to represent numerical as well as other information with a code that changes in only one bit position from one code word to the next adjacent word. This class of code is called a unit distance code (UDC). These are sometimes also called as cyclic, reflective or gray code. These codes finds great applications in Boolean function minimization using Karnaugh map.
Binary to gray conversion: Starting from right to left 1. If it is MSB then place it as it is
2. Otherwise, Add the bit to the previous bit and place the sum in GRAY, ignoring any carry 3. Repeat step 2 till end Eg. Convert 1011 to gray
Gray to Binary conversion: Starting from right to left 1. If it is MSB then place it as it is 2. Otherwise, Add the bit to the previous than corresponding bit of GRAY code and place the sum in GRAY, ignoring any carry 3. Repeat step 2 till end Eg. Convert 1110 to gray