Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
The first successful system of electrical communication was
the telegraph, which was invented by Samuel F.B. Morse in
the year 1832. The telegraph operators used a code of clicks
to send the messages. If the key pressed for a short time it is
the Morse code called ‘dot’ and if the key pressed for a long-
time it is ‘Dash’. A sample Morse code is shown below:
Introduction
In weighted codes, each digit is assigned a specific weight according
to its position. For example, in 8421BCD code, 1001 the weights of 1, 0,
0, 1 (from left to right) are 8, 4, 2 and 1 respectively.
Suppose W1' W
2' W
3and W
4are the weights of binary digits and X
l' X
2,
X3
and X4
are the corresponding digit values then decimal digit. N =
W1
Xl+ W
2X
2+ W
3X
3+ W
4X
4is represented by binary sequence
X4
X3
X2
X4.
Weighted codes
The codes 8421BCD, 2421BCD, 5211BCD are all weighted codes
The non-weighted codes are not positionally weighted. In other words,
each digit position within the number is not assigned a fixed value ( or
weight ).
Non-weighted codes:
Excess-3 and gray code are non-weighted codes.
A code is reflective when the code is self complementing. In
other words, when the code for 9 is the complement the code
for 0, 8 for 1, 7 for 2, 6 for 3 and 5 for 4.
Reflective codes:
2421BCD, 5421BCD and Excess-3 code are reflective codes.
In sequential codes, each succeeding 'code is one binary
number greater than its preceding code. This property helps
in manipulation of data.
Sequential codes:
8421 BCD and Excess-3 are sequential codes
Codes used to represent numbers, alphabetic characters,
symbols and various instructions necessary for conveying
intelligible information.
Alphanumeric codes:
ASCII, EBCDIC, UNICODE are the most-commonly used alphanumeric
codes.
ASCII--------- American Standard Code for Information Interchange
EBCDIC ------ Extended Binary Coded Decimal Interchange Code
Codes which allow error defection and correction are called
error detecting and' correcting codes.
Error defecting and correcting codes:
Hamming code is the mostly commonly used error detecting
and correcting code
Whenever any binary number appears, its decimal equivalent can be
found easily as follows.
When there is 1 in a digit position, weight of that position should be
added.
When there is 0 in a digit position, weight of that position should be
disregarded.
Binary Weights
For example binary number 1101 has a decimal equivalent of 8 + 4 + 0 + 1 =
13.
The decimal numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 can be expressed in
Binary numbers as shown below. All these binary numbers again
expressed in the last column by expanding into 4 bits. As per the
weighted binary digits, the 4 Bit binary numbers can be expressed
according to their place value from left to right as 8421 (2³ 2² 2¹ 2⁰ =
8421).
8421 Code or BCD Code
DECIMAL NUMBER BINARY NUMBER4 BIT
EXPRESSION(8421)
0 0 0000
1 1 0001
2 10 0010
3 11 0011
4 100 0100
5 101 0101
6 110 0110
7 111 0111
8 1000 1000
9 1001 1001
DECIMAL NUMBER BINARY NUMBER 2421 CODE
0 0 0000
1 1 0001
2 10 0010
3 11 0011
4 100 0100
5 101 1011
6 110 1100
7 111 1101
8 1000 1110
9 1001 1111
This code also a 4 bit application code where the binary weights carry 2, 4, 2, 1 from
left to right.
2421 Code
DECIMAL NUMBER BINARY NUMBER 5211 CODE
0 0 0000
1 1 0001
2 10 0011
3 11 0101
4 100 0111
5 101 1000
6 110 1010
7 111 1100
8 1000 1110
9 1001 1111
This code is also a 4 bit application code where the binary weights
carry 5, 4, 2, 1 from left to right.
It can be observed that in the 2421 and 5211 codes,
the code for decimal 9 is the complement of the code for decimal 0,
the code for decimal 8 is the complement of the code for decimal 1,
the code for decimal 7 is the complement of the code for decimal 2,
the code for decimal 6 is the complement of the code for decimal 3,
the code for decimal 5 is the complement of the code for decimal 4,
these codes are called as reflexive codes.
Reflective Code
DECIMAL
NUMBER
DECIMAL
NUMBER2421 CODE 5211 CODE
0 0 0000 0000
1 1 0001 0001
2 10 0010 0011
3 11 0011 0101
4 100 0100 0111
5 101 1011 1000
6 110 1100 1010
7 111 1101 1100
8 1000 1110 1110
9 1001 1111 1111
In sequential codes, each succeeding 'code is one binary
number greater than its preceding code. This property helps
in manipulation of data
Sequential codes:
DECIMAL
NUMBERBINARY NUMBER 8421 CODE EXCESS-3
0 0 0000 0011
1 1 0001 0100
2 10 0010 0101
3 11 0011 0110
4 100 100 0111
5 101 0101 1000
6 110 0110 1001
7 111 0111 1010
8 1000 1000 1011
9 1001 1001 1100
Some of the codes will not follow the weights of the sequence binary
numbers these are called as non-weighted codes. ASCII code ,Grey
code and XS-3 are some of the examples where they are coded for
some special purpose applications and they do not follow the weighted
binary number calculations.
Non-Weighted Codes
Some of the codes will not follow the binary weights, Excee-3 code is
an example of it and it is an important 4 bit code. The excess – 3 code
of a decimal number is achieved by adding the number 3 to the 8421
code.
Excess-3 Code
Some of the codes will not follow the weights of the sequence binary
numbers these are called as non-weighted codes. ASCII code ,Grey
code and XS-3 are some of the examples where they are coded for
some special purpose applications and they do not follow the weighted
binary number calculations.
Non-Weighted Codes
Some of the codes will not follow the binary weights, Excee-3 code is
an example of it and it is an important 4 bit code. The excess – 3 code
of a decimal number is achieved by adding the number 3 to the 8421
code.
Excess-3 Code
Decimal BCD + 0011 Excee-3
Decimal Digit BCD Code Excess-3 Code
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
These are following advantages of Excess-3 codes,
These are unweighted binary decimal codes.
These are self-complementary codes.
The codes 0000 and 1111 are not used for any digit which is an
advantage for memory organization as these codes can cause fault in
transmission line.
It has no limitation, and it considerably simplifies arithmetic
operations.
It is particularly significant for arithmetic operations as it overcomes
shortcoming encountered while using 8421 BCD code to add two
decimal digits whose sum exceeds 9.
Advantages of Excess-3 Codes:
The gray code is the code where one bit will be differed to the
preceding number.
Gray code is not weighted that means it does not depends on positional
value of digit.
This cyclic variable code that means every transition from one value to
the next value involves only one bit change.
Gray Code
Gray codes are used in rotary and optical encoders, Karnaugh maps,
and error detection..
Conversion of Binary to Gray Code:
The hamming distance of two neighbours Gray codes is always 1 and
also first Gray code and last Gray code also has Hamming distance is
always 1, so it is also called Cyclic codes.
Using Karnaugh (K) - map:
Decimal Binary Gray Code
0 000 000
1 001 001
2 010 011
3 011 010
4 100 110
5 101 111
6 110 101
7 111 100
These are following steps for n-bit binary numbers:
The most significant bit (MSB) of the Gray code is always equal to the
MSB of the given Binary code.
Other bits of the output Gray code can be obtained by XORing binary
code bit at the index and previous index.
Using Exclusive-Or (⊕) operation:
Error Detection & Correction Codes- Hamming Code
We know that the bits 0 and 1 corresponding to two different range of
analog voltages. So, during transmission of binary data from one
system to the other, the noise may also be added. Due to this, there
may be errors in the received data at other system i.e. a bit 0 may
change to 1 or a bit 1 may change to 0
We can get back the original data first by detecting whether any
error(s) present and then correcting those errors. For this purpose, we
can use the following codes.
Error detection codes
Error correction codes
This method are used to detect the error(s) present in the received
data (bit stream). These codes contain some bit(s), which are included
(appended) to the original bit stream.
Error detection codes
Example − Parity code, Hamming code.
This method are used to correct the error(s) present in the received
data (bit stream) so that, we will get the original data.
Error correction codes −
Example − Hamming code
Parity Code
It is easy to include (append) one parity bit either to the left of MSB or
to the right of LSB of original bit stream. There are two types of parity
codes, namely even parity code and odd parity code based on the type
of parity being chosen.
The value of even parity bit should be zero, if even number of ones
present in the binary code. Otherwise, it should be one. So that, even
number of ones present in even parity code. Even parity code
contains the data bits and even parity bit.
Even Parity Code
Binary Code Even Parity bit Even Parity Code
000 0 0000
001 1 0011
010 1 0101
011 0 0110
100 1 1001
101 0 1010
110 0 1100
111 1 1111
The value of odd parity bit should be zero, if odd number of ones
present in the binary code. Otherwise, it should be one. So that, odd
number of ones present in odd parity code. Odd parity code contains
the data bits and odd parity bit.
Odd Parity Code
Binary Code Odd Parity bit Odd Parity Code
000 1 0001
001 0 0010
010 0 0100
011 1 0111
100 0 1000
101 1 1011
110 1 1101
111 0 1110
Hamming Code
Hamming code is useful for both detection and correction of error
present in the received data. This code uses multiple parity bits and we
have to place these parity bits in the positions of powers of 2.
The minimum value of 'k' for which the following relation is correct
(valid) is nothing but the required number of parity bits.
2k ≥ n+k+1
Where,
‘n’ is the number of bits in the binary code (information)
‘k’ is the number of parity bits
Laws of Boolean Algebra
Idempotent Law
A * A = A
A + A = A
Associative Law
(A * B) * C = A * (B * C)
(A + B) + C = A + (B + C)
Commutative Law
A * B = B * A
A + B = B + A
Distributive Law
A * (B + C) = A * B + A * C
A + (B * C) = (A + B) * (A + C)
Identity Law
A * 0 = 0 A * 1 = A
A + 1 = 1 A + 0 = A
Complement Law
A * ~A = 0
A + ~A = 1
Involution Law
~(~A) = A
In boolean algebra, the OR operation is performed by which
properties?
a) Associative properties
b) Commutative properties
c) Distributive properties
d) All of the Mentioned
The expression for Absorption law is given by _________
a) A + AB = A
b) A + AB = B
c) AB + AA’ = A
d) A + B = B + A
DeMorgan’s theorem states that _________
a) (AB)’ = A’ + B’
b) (A + B)’ = A’ * B
c) A’ + B’ = A’B’
d) (AB)’ = A’ + B
Complement of the expression A’B + CD’ is _________
a) (A’ + B)(C’ + D)
b) (A + B’)(C’ + D)
c) (A’ + B)(C’ + D)
d) (A + B’)(C + D’)
The boolean function A + BC is a reduced form of ____________
a) AB + BC
b) (A + B)(A + C)
c) A’B + AB’C
d) (A + C)B
The idempotence law of Boolean algebra says that
a) x + y = 1
b) x + x = x
c) x + xy = x
d) x(x+y) = x
A universal logic gate is one which can be used to generate
any logic function. Which of the following is a universal logic
gate?
a) OR
b) AND
c) XOR
d) NAND
Which of following are known as universal gates?
a) NAND & NOR
b) AND & OR
c) XOR & OR
d) EX-NOR & XOR
A single transistor can be used to build which of the
following digital logic gates?
a) AND gates
b) OR gates
c) NOT gates
d) NAND gates
Which input values will cause an AND logic gate to produce a
HIGH output?
a) At least one input is HIGH
b) At least one input is LOW
c) All inputs are HIGH
d) All inputs are LOW
Exclusive-OR (XOR) logic gates can be constructed from
what other logic gates?
a) OR gates only
b) AND gates and NOT gates
c) AND gates, OR gates, and NOT gates
d) OR gates and NOT gates
The basic logic gate whose output is the complement of the
input is the ___________
a) OR gate
b) AND gate
c) INVERTER gate
d) XOR gate
If we use an AND gate to inhibit a signal from passing one of
the inputs must be ___________
a) LOW
b) HIGH
c) Inverted
d) Floating