Sie sind auf Seite 1von 4

DIGITAL CODES There are two types of digital code.

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.

8421 Code/BCD Code


The BCD (Binary Coded Decimal) is a straight assignment of the binary equivalent. It is possible to assign weights to the binary bits according to their positions. The weights in the BCD code are 8,4,2,1. Example: The bit assignment 1001, can be seen by its weights to represent the decimal 9 because: 1x8+0x4+0x2+1x1 = 9

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

0111 1000 1001

1101 1110 1111

Self-complementing Codes
y

A self complementing code is one thats 9's complement in decimal is the 1's complement in binary.
o

Ex: The 9's complement of 7 is 2 in decimal. In 2421 code,

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).

Example: 1000 of 8421 = 1011 in Excess-3


DECIMAL DIGIT D 0 1 EXCESS - 3 CODE 0011 0100

2 3 4 5 6 7 8 9

0101 0110 0111 1000 1001 1010 1011 1100

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.

gray codes of decimal values.

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

Das könnte Ihnen auch gefallen