3. Binary-Coded-Decimal (BCD)
⢠Conversions between decimal and binary can become long and complicated for
large numbers.
⢠For example, convert 87410 to binary. The answer is 11011010102, but it takes quite
a lot of time and effort to make this conversion. We call this straight binary coding.
3
4. Binary-Coded-Decimal (BCD)
⢠The Binary-Coded-Decimal (BCD) code makes conversion much easier.
Each decimal digit, 0 through 9, is represented with a 4-Bit BCD code as
shown below. The BCD code 1010, 1011, 1100, 1101, 1110 and 1111 are not
used.
4
5. ⢠Conversion between BCD and decimal is accomplished by replacing a 4-bit
BCD for each decimal digit. For example, 87410 = 1000 0111 0100BCD.
⢠BCD is not another number system like binary, octal, decimal and
hexadecimal. It is in fact the decimal system with each digit encoded in its
binary equivalent. A BCD code is not the same as a straight binary number.
For example, the BCD code requires 12 bits, while the straight binary
number requires only 10 bits to represent 87310.
Decimal ď¨ BCD Conversion
5
6. ⢠A BCD code is converted into a decimal number by taking groups of 4 bits,
starting from LSB, and replacing them with a BCD code. For example, 1
1001 0111 1000 BCD = 197810
BCD ď¨ Decimal Conversion
6
7. 7
8421 BCD Code (Natural BCD Code)
ď˝ Each decimal digit, 0 through 9, is coded by 4-bit binary number
ď˝ 8, 4, 2 and 1 weights are attached to each bit
ď˝ BCD code is weighted code
ď˝ 1010, 1011, 1100, 1101, 1110 and 1111 are illegal codes
ď˝ Less efficient than pure binary
ď˝ Arithmetic operations are more complex than in pure binary
ď˝ Example
1 4
0100
0001
Decimal
BCD
Binary 1110
9. 9
BCD Addition
ď˝ Example - 1
0 0 1 0
0 0 0 1
0 0 1 1
+
0 1 0 1
0 0 1 1
1 0 0 0
2 5
1 3
+
3 8
No carry, no illegal code. So, this is
the correct sum.
1
1
1
Rule: If there is an illegal code or carry is generated as a result of
addition, then add 0110 (6) to particular that 4 bits of result.
11. 11
BCD Subtraction
ď˝ Example - 1
0 0 1 1
0 0 0 1
0 0 1 0
-
1 0 0 0
0 1 0 1
0 0 1 1
3 8
1 5
-
2 3
No borrow. So, this is the correct
difference.
Rule: If one 4-bit group needs to take borrow from neighbor, then
subtract 0110 from the group which is receiving borrow.
14. The Gray Code
⢠The Gray code is un-weighted and is not an arithmetic code; that is,
there are no specific weights assigned to the bit positions.
⢠The important feature of the Gray code is that it exhibits only a single
bit change from one code word to the next in sequence
⢠This property is important in many applications, such as shaft position
encoders, where error susceptibility increases with the number of bit
changes between adjacent numbers in a sequence.
14
15. Table below is a listing of the 4-bit Gray code
for decimal numbers 0 through 15.
15
16. The Gray Code
⢠Notice the single-bit change between successive Gray code words.
⢠For instance, in going from decimal 3 to decimal 4, the Gray code
changes from 0010 to 0110, while the binary code changes from 0011
to 0100, a change of three bits. The only bit change in the Gray code is
in the third bit from the right: the other bits remain the same.
16
17. Binary-to-Gray Code Conversion
The following rules explain how to convert from a binary number to a
Gray code word:
⢠1) The most significant bit (left-most) in the Gray code is the same as
the corresponding MSB in the binary number.
⢠2) Going from left to right, add each adjacent pair of binary code bits
to get the next Gray code bit. Discard carries.
17
19. Gray-to-Binary Code Conversion
To convert from Gray code to binary, use a similar method; however,
there are some differences. The following rules apply:
⢠1) The most significant bit (left-most) in the binary code is the same as
the corresponding bit in the Gray code.
⢠2) Add each binary code bit generated to the Gray code bit in the next
adjacent position. Discard carries.
19
23. ASCII
⢠ASCII is the abbreviation for American Standard Code for Information
Interchange.
⢠Pronounced âaskee,â ASCII is a universally accepted alphanumeric
code used in most computers and other electronic equipment.
⢠Most computer keyboards are standardized with the ASCII. When you
enter a letter, a number, or control command, the corresponding ASCII
code goes into the computer
⢠ASCII has 128 characters and symbols represented by a 7-bit binary
code. Actually, ASCII can be considered an 8-bit code with the MSB
always 0.
23
24. ⢠The first thirty-two ASCII characters are nongraphic commands that
are never printed or displayed and are used only for control purposes.
Examples of the control characters are ânull,â âline feed,â âstart of
text,â and âescape.â
⢠The other characters are graphic symbols that can be printed or
displayed and include the letters of the alphabet (lowercase and
uppercase), the ten decimal digits, punctuation signs, and other
commonly used symbols.
24
28. Error Detecting Codes
⢠When data is transmitted from one point to another, like in wireless
transmission, or it is just stored, like in hard disks and memories, there
are chances that data may get corrupted. To detect these data errors,
we use special codes, which are error detection codes
⢠Error detection is the process of detecting the errors that are present in
the data transmitted from transmitter to receiver . We use some
redundancy codes to detect these errors, by adding to the data while it
is transmitted from source (transmitter). These codes are called âError
detecting codesâ.
28
30. Parity Checking
⢠Parity bit means nothing but an additional bit added to the data at the
transmitter before transmitting the data.
⢠Before adding the parity bit, number of 1âs or zeros is calculated in the
data.
⢠Based on this calculation of data an extra bit is added to the actual
information / data.
⢠The addition of parity bit to the data will result in the change of data
string size.
30
31. ⢠This means if we have an 8 bit data, then after adding a parity bit to
the data binary string it will become a 9 bit binary data string.
⢠Parity check is also called as âVertical Redundancy Check (VRC)â.
⢠There is two types of parity bits in error detection, they are
a) Even parity
b) Odd parity
31
32. ⢠A parity bit is attached to a group of bits to make the total number of
1s in a group always even or always odd.
⢠An even parity bit makes the total number of 1s even, and an odd
parity bit makes the total odd.
32
34. Limitations of Parity Error Detection
⢠It detects any odd number of errors. However, it cannot detect an even
number of error because such error will destroy the parity of the
transmitted group of bits.
⢠Other is that it cannot identify the location of erroneous bit. Thus, it
cannot correct the error.
34
36. Error Correcting Codes
⢠The codes which are used for both error detecting and error correction
are called as âError Correction Codesâ. The error correction
techniques are of two types. They are,
a) Single bit error correction
b) Burst error correction
⢠The process or method of correcting single bit errors is called âsingle
bit error correctionâ. The method of detecting and correcting burst
errors in the data sequence is called âBurst error correctionâ.
36
37. Hamming code
⢠Hamming code or Hamming Distance Code is the best error correcting
code we use in most of the communication network and digital
systems.
37
38. Hamming code
⢠This error detecting and correcting code technique is developed by
R.W.Hamming .
⢠This code not only identifies the error bit, in the whole data sequence
and it also corrects it.
⢠This code uses a number of parity bits located at certain positions in
the codeword.
⢠The number of parity bits depends upon the number of information
bits.
⢠These parity bits are placed at bit positions 2^n (n = 0, 1, 2, 3) within
the original data bits
38