Title: DIGITAL CODES
1DIGITAL CODES PARITY
2Binary Codes
A binary code is a group of n bits that assume up
to 2n distinct combinations of 1s and 0s with
each combination representing one element of the
set that is being coded.
3Codes and Parity
- Concept of a code, weighted and non-weighted
codes, examples of 8421, BCD, excess-3 and Gray
code - Alphanumeric codes ASCII and EBCDIC
- Concept of parity, single and double parity and
error detection
4Binary Digital Codes
- Gray Code Gray Code
- BCD 2421 BCD 2421 code
- BCD XS 3 BCD Excess 3 code
- BCD 8421 BCD 8421 code
- EBCDIC Extended BCD Interchange Code
5BCD Binary Coded Decimal
- BCD is a convention for mapping binary numbers to
decimal numbers. - When the decimal numbers are represented in BCD,
each decimal digit is represented by the
equivalent BCD code. - Example BCD Representation of Decimal 6349
6 3 4 9 0110 0011 0100 1001
6BCD Binary Coded Decimal
Decimal BCD Number Number 0 0000
1 0001 2 0010 3 0011
4 0100 5 0101 6 0110
7 0111 8 1000 9 1001
7BCD Binary Coded Decimal
Decimal BCD Number Number 10 0001
0000 121 0001 0010 0001 234 0010 0011
0100 1003 0001 0000 0000 0011
8EXCESS 3 CODE
- The excess-3 code is obtained by adding 3 (0011)
to the corresponding BCD equivalent binary
number. - Excess-3 have a self-complementing property
9EXCESS 3 CODE
Decimal BCD Excess-3 Number Number
Number 0 0000 0011 1
0001 0100 2 0010 0101 3
0011 0110 4 0100 0111 5
0101 1000 6 0110 1001 7
0111 1010 8 1000 1011 9
1001 1100
10BCD-to-Excess-3 Table
11BCD 2421 CODE
- 2421 and excess-3 have a self-complementing
property - 9s complement is obtained by 1s to 0s and 0s
to 1s. - Useful property when doing arithmetic operations
with signed complement representation. - 2421 is a weighted code
- Decimal equivalent if obtained by multiplying
bits by the weights - Ex 1101 gt 2 x 1 4 x 1 2 x 0 1 x 1 7
12ASCII
- ASCII (American Standard for Information
Interchange) - Uses 7 bits to code 128 characters upper and
lowercase letters, decimal digits, and special
characters, e.g.
13ASCII
Number ASCII Letter ASCII
0 0110000 1 0110001 2 0110010 3 0110011 4 0110100
5 0110101 6 0110110 7 0110111 8 0111000 9 0111001
A 1000001 B 1000010 C 1000011 D 1000100 E 1000101
F 1000110 G 1000111 H 1001000 I 1001001
14ASCII
Letter ASCII Letter ASCII
J 1001010 K 1001011 L 1001100 M 1001101 N 1001110
O 1001111 P 1010000 Q 1010001 R 1010010
S 1010011 T 1010100 U 1010101 V 1010110 W 1010111
X 1011000 Y 1011001 Z 1011010
15ASCII TABLE
16ASCII TABLE
17EBCDIC ALPHANUMERIC CODE
18GRAY CODE
- Unweighted and is not an arithmetic code
- Only one bit changes from one code to the next in
the sequence - Gray code can be any amounts of bits.
- The gray code originated when digital logic
circuits were built from vacuum tubes and
electromechanical relays - Counters generated tremendous power demands and
noise spikes when many bits changed at once - Using gray code counters, any increment or
decrement changed only one bit
19GRAY CODE
20VARIOUS DECIMAL CODES
21PARITY
- Parity bit used for bit error detection
- Even parity total number of 1s even
- Odd parity total number of 1s odd
- Example (even parity)
- Code transmitted 00101
- ?1s total even parity bit 0
- Code received 00001
- ?1s total odd parity bit 0 ? error
22PARITY
23Try this. Fill in the appropriate parity bit.
PARITY
24End of Digital Codes Parity