Mansoor Bashir presented on code converters and parity checkers. Code converters change coded information from one system to another, such as converting decimal to binary. Parity checkers add an extra parity bit to detect errors by making the total number of 1s either even or odd. Even parity generators add a 0 bit to make the total number of 1s even, while odd parity generators add a 1 to make the total odd. Parity checkers use logic gates to check if the received bits have the correct parity or indicate an error.
4. Code Converters:
Code is a symbolic representation of discrete information.
A converter that changes coded information to a different
code system is called code converter.
Numbers are usually coded in one form or another so as to
represent or use it as required. For instance, a number ‘nine’
is coded in decimal using symbol (9)d. Same is coded in
natural-binary as (1001)b.
While digital computers all deal with binary numbers, there
are situations where in natural-binary representation of
numbers in in-convenient or in-efficient and some other
(binary) code must be used to process the numbers.
5. Code converters are also used to enhance data portability and tractability.
Portability means the information can be transported from location to location, such
as from your house to your friend’s house.
Tractability means the information can be easily managed, stored, used, etc.
For instance, if you have a comprehensive encyclopedia in paper book form at
home, and I have the same comprehensive encyclopedia in electronic book form on
a thumb drive; not only can I carry mine in my pocket whereas you cannot even lift
yours off the table, I can also do a word search more quickly than you can. Hence,
my encyclopedia is more tractable than yours.
6. Let’s discuss the conversion of various codes from
one form to other.
Gray code to binary conversion
Binary to gray code conversion
DECIMAL TO BCD CODE CONVERTER
BCD TO EXCESS-3 CODE CONVERTER
7. Binary To Gray Code conversion:
Binary to gray code conversion is a very simple process. There are several
steps to do this types of conversions. Steps given below elaborate on the idea
on this type of conversion.
(1) The M.S.B. of the gray code will be exactly equal to the first bit of the
given binary number.
(2) Now the second bit of the code will be exclusive-or of the first and second
bit of the given binary number, i.e if both the bits are same the result will be 0
and if they are different the result will be 1.
(3)The third bit of gray code will be equal to the exclusive-or of the second
and third bit of the given binary number. Thus the Binary to gray code
conversion goes on. One example given below can make your idea clear on
this type of conversion.
8. Explanation:
Thus the equivalent gray code is 01101. Now
concentrate on the example where the M.S.B. of
the binary is 0 so for it will be 0 for the most
significant gray bit. Next, the XOR of the first
and the second bit is done. The bits are different
so the resultant gray bit will be 1. Again move to
the next step, XOR of second and third bit is
again 1 as they are different. Next, XOR of third
and fourth bit is 0 as both the bits are same.
Lastly the XOR of fourth and fifth bit is 1 as they
are different. That is how the result of binary to
gray code conversion of 01001 is done whose
equivalent gray code is 01101.
9. Gray code to binary conversion :
Gray code to binary conversion is again very simple and easy process. Following
steps can make your idea clear on this type of conversions.
(1) The M.S.B of the binary number will be equal to the M.S.B of the given gray
code.
(2) Now if the second gray bit is 0 the second binary bit will be same as the
previous or the first bit. If the gray bit is 1 the second binary bit will alter. If it
was 1 it will be 0 and if it was 0 it will be 1.
(3) This step is continued for all the bits to do Gray code to binary conversion.
One example given below will make your idea clear.
10. Explanation:
The M.S.B of the binary will be 0 as the M.S.B of gray is 0.
Now move to the next gray bit. As it is 1 the previous binary bit will alter
i.e. it will be 1, thus the second binary bit will be 1. Next look at the third
bit of the gray code. It is again 1 thus the previous bit i.e. the second binary
bit will again alter and the third bit of the binary number will be 0. Now, 4th
bit of the given gray is 0 so the previous binary bit will be unchanged, i.e.
4th binary bit will be 0. Now again the 5th grey bit is 1 thus the previous
binary bit will alter, it will be 1 from 0. Therefore the equivalent Binary
number in case of gray code to binary conversion will be (01001)
11. DECIMAL TO BCD CODE CONVERTER
BCD TO EXCESS-3 CODE CONVERTER
12. DECIMAL TO BCD CODE CONVERTER Decimal
Numerals
Binary
Numerals
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
The BCD Code
Binary Coded Decimal (BCD)
code is used to represent decimal
digits in binary. BCD
code is a 4-bit binary code the
first 10 combinations represent
the decimal digits 0 to 9.
13. DECIMAL TO BCD CODE CONVERTER
The remaining six 4 bit
(Figure 1)combinations 1010, 1011, 1100,
1101, 1110 and 1111 are considered to be
invalid and do not exist.
14. Binary Numerals Excess-3
0000 0011
0001 0100
0010 0101
0011 0110
0100 0111
0101 1000
0110 1001
0111 1010
1000 1011
1001 1100
The Excess-3 BCD system is
formed by adding 0011 (3) to each
BCD value as in Table . For
example, the decimal number 7,
which is coded as 0111 in BCD, is
coded as 0111+0011=1010 in
Excess-3 BCD.
BCD TO EXCESS-3 CODE
CONVERTER
BCD Excess-3
15. In the Excess-3 BCD system, all
pair of numbers that add up to 9
add up to 1111:
0 + 9 = 0011 + 1100 = 1111
1 + 8 = 0100 + 1011 = 1111
2 + 7 = 0101 + 1010 = 1111
BCD TO EXCESS-3 CODE CONVERTER
16.
17. Bit values may change from 1 to 0 or 0 to 1
due to noise.
An extra bit called parity bit is send with
message to make the total number of 1’s
either odd or even.
Application:
Error detection and correction.
18. Even & Odd Parity
Even Parity:
In even parity bit scheme, the parity bit is ‘0’ if there
are even number of 1s in the data stream and the parity bit
is ‘1’ if there are odd number of 1s in the data stream.
Odd Parity:
In odd parity bit scheme, the parity bit is ‘1’ if there
are even number of 1s in the data stream and the
parity bit is ‘0’ if there are odd number of 1s in the
data stream
19. 01001001 0 1
Message Odd Parity Even Parity
01010101 0 1
Message Even Parity Odd Parity
21. Even Parity Generator
Let us assume that a 3-bit message is to
be transmitted with an even parity bit.
Let the three inputs A, B and C are
applied to the circuits and output bit is
the parity bit P. The total number of 1s
must be even, to generate the even
parity bit P.
The figure below shows the truth table
of even parity generator in which 1 is
placed as parity bit in order to make all
1s as even when the number of 1s in
the truth table is odd.
22. The above expression can be
implemented by using two Ex-OR
gates. The logic diagram of even
parity generator with two Ex – OR
gates is shown below. The three bit
message along with the parity
generated by this circuit which is
transmitted to the receiving end
where parity checker circuit checks
whether any error is present or not.
To generate the even parity bit for a
4-bit data, three Ex-OR gates are
required to add the 4-bits and their
sum will be the parity bit.
23. Odd Parity Generator
Let us consider that the 3-bit data is
to be transmitted with an odd parity
bit. The three inputs are A, B and C
and P is the output parity bit. The
total number of bits must be odd in
order to generate the odd parity bit.
In the given truth table below, 1 is
placed in the parity bit in order to
make the total number of bits odd
when the total number of 1s in the
truth table is even.
24. The above Boolean expression can be
implemented by using one Ex-OR gate
and one Ex-NOR gate in order to
design a 3-bit odd parity generator.
The logic circuit of this generator is
shown in below figure , in which . two
inputs are applied at one Ex-OR gate,
and this Ex-OR output and third input
is applied to the Ex-NOR gate , to
produce the odd parity bit. It is also
possible to design this circuit by using
two Ex-OR gates and one NOT gate.
26. Even Parity Checker
Consider that three input message along
with even parity bit is generated at the
transmitting end. These 4 bits are applied
as input to the parity checker circuit which
checks the possibility of error on the data.
Since the data is transmitted with even
parity, four bits received at circuit must
have an even number of 1s.
If any error occurs, the received message
consists of odd number of 1s.
27. The above logic expression for
the even parity checker can
be implemented by using
three Ex-OR gates as shown in
figure. If the received
message consists of five bits,
then one more Ex-OR gate is
required for the even parity
checking.
28. Odd Parity Checker
Consider that a three bit message along
with odd parity bit is transmitted at the
transmitting end. Odd parity checker
circuit receives these 4 bits and checks
whether any error are present in the
data.
If the total number of 1s in the data is
odd, then it indicates no error, whereas if
the total number of 1s is even then it
indicates the error since the data is
transmitted with odd parity at
transmitting end.
29. The expression for the odd
parity checker can be designed
by using three Ex-NOR gates as
shown below.