Hod - Ic@gitjaipur - Com 21619102020091514pm
Hod - Ic@gitjaipur - Com 21619102020091514pm
YEAR/SEMESTER: II/III
Recommended books:
T1 :- Modern Digital Electronics 4th Edition, R.P Jain: Tata Mcgraw-Hill
T2 :- Digital Design [5th Edition] (M. Morris Mano and Michael Ciletti), Pearson
T3 :- Digital Electronics, A.Anand , Pearson
FACULTY NAME:SUJEET KUMAR GUPTA
GLOBAL INSTITUTE OF TECHNOLOGY JAIPUR DIGITAL ELECTRONICS CSE/III SEM
UNIT 1
BLOWN UP OF UNIT 1
NUMBER SYSTEMS
AND CODES
Objectives :
Outcomes
At the end of this chapter, students should be able to:-
– Differentiate between decimal, binary, octal, hexadecimal and BCD.
– Convert number between bases.
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary 2 0, 1
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
•Note that the first remainder becomes the most significant bit (MSB). The last
remainder becomes the least significant bit (LSB).
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary to Hexadecimal conversion
FACULTY NAME:SUJEET
KUMAR GUPTA
GLOBAL INSTITUTE OF TECHNOLOGY JAIPUR DIGITAL ELECTRONICS CSE/III SEM
FACULTY NAME:SUJEET
KUMAR GUPTA
GLOBAL INSTITUTE OF TECHNOLOGY JAIPUR DIGITAL ELECTRONICS CSE/III SEM
Hexadecimal Number
• The hexadecimal number uses base 16. It uses the digits 0 through 9 plus
the letters A, B, C, D, E and F.
• The letter A stands for decimal 10, B for 11, C for 12, D for 13, E for 14 and
F for 15.
Hexadecimal Number
• In binary number system there are only 2 digits 0 and 1, and any number can be
represented by these two digits. The arithmetic of binary numbers means the
operation of addition, subtraction, multiplication and division. Binary arithmetic
operation starts from the least significant bit i.e. from the right most side. We will
discuss the different operations one by one in the following.
• Binary Addition
• Binary Subtraction
• Binary Multiplication
• Binary Division
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary Addition
• There are four steps in binary addition, they are written below
• 0+0=0
• 0+1=1
• 1+0=1
• 1 + 1 = 0 (carry 1 to the next significant bit)
• An example will help us to understand the addition process. Let us take two binary
numbers 10001001 and 10010101
• The above example of binary arithmetic clearly explains the binary addition
operation, the carried 1 is shown on the upper side of the operands.
FACULTY NAME:SUJEET
KUMAR GUPTA
Complements
• Complements are used in the digital computers in order to simplify the subtraction
operation and for the logical manipulations. For each radix-r system (radix r
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary system complements
• As the binary system has base r = 2. So the two types of complements for the binary
system are 2's complement and 1's complement.
• 1's complement
• The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's.
This is called as taking complement or 1's complement. Example of 1's
Complement is as follows.
FACULTY NAME:SUJEET
KUMAR GUPTA
Cont…
• 2's complement
• The 2's complement of binary number is obtained by adding 1 to the Least
Significant Bit (LSB) of 1's complement of the number.
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary Subtraction
• Here are too four simple steps to keep in memory
• 0–0=0
• 0 – 1 = 1, borrow 1 from the next more significant bit
• 1–0=1
• 1–1=0
• Evaluate:
• After dropping the carry over we get the result of subtraction to be 100000.
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary Multiplication
• Binary multiplication may sound like it would be more difficult than binary
addition or subtraction – but is actually a simple process. Here are the four steps to
be followed, using the same binary numbers 10001001 and 10010101:
• 0×0=0
• 1×0=0
• 0×1=0
• 1×1=1 (there is no carry or borrow for this)
• The arithmetic of multiplying binary numbers is shown below:
FACULTY NAME:SUJEET
KUMAR GUPTA
Binary Division
FACULTY NAME:SUJEET
KUMAR GUPTA
Different Types of Binary Codes
• Table of Contents
• Introduction
• Commonly used Binary Codes
• Weighted Binary Systems
– Binary Weights
– 8421 Code or BCD Code
– 2421 Code
– 5211 Code
– Reflective Code
– Sequential Codes
• Non-Weighted Codes
– Excess-3 Code
• Excess -3 Code Examples
– Gray Code
FACULTY NAME:SUJEET
KUMAR GUPTA
Commonly used Binary Codes
• Other than the 8421 code or BCD code, 2421 code, 5211 code, reflective code,
sequential code, non-weighted code, excess-3 code and Grey code are some of
the codes which are popularized.
• Commonly used Binary Codes
• Before going into the details of individual binary codes, let us quickly take a
look at some of the commonly used Binary Codes. The following is the list:
• 8421 Codes
• 2421 Codes
• 5211 Codes
• Excess-3 Codes
• Gray Codes
• In the above list, the first three i.e. 8421, 2421 and 5211 are Weighted codes
while the other two are non-weighted binary codes.
FACULTY NAME:SUJEET
KUMAR GUPTA
Weighted Binary Systems
FACULTY NAME:SUJEET
KUMAR GUPTA
8421 Code or BCD Code
FACULTY NAME:SUJEET
KUMAR GUPTA
Cont….
DECIMAL NUMBER BINARY NUMBER 4 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 FACULTY
1001 NAME:SUJEET 1001
KUMAR GUPTA
2421 Code
• This code also a 4 bit application code where the binary weights carry 2, 4, 2, 1
from left to right.
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
FACULTY NAME:SUJEET
KUMAR GUPTA
5211 Code
• This code is also a 4 bit application code where the binary weights carry 5, 4, 2, 1
from left to right.
0 0 0000
1 1 0001
2 10 0011
3 11 0101
4 100 0111
5 101 1000
6 110 1010
7 111 1100
FACULTY NAME:SUJEET
KUMAR GUPTA
8 1000 1110
Reflective Code
• 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.Excess-3 is also reflective code. 8421 code is not a
reflective code.
FACULTY NAME:SUJEET
KUMAR GUPTA
Cont…
DECIMAL NUMBER DECIMAL NUMBER 2421 CODE 5211 CODE
0 0 0000 0000
1 1 0001 0001
2 10 0010 0011
3 11 0011 0101
FACULTY NAME:SUJEET
8 1000 KUMAR GUPTA 1110 1110
Sequential Codes
• Sequential codes are the codes in which 2 subsequent numbers in binary
representation differ by only one digit. The 8421 and Excess-3 codes are examples
of sequential codes. 2421 and 5211 codes do not come under sequential codes.
DECIMAL NUMBER BINARY NUMBER 8421 CODE EXCESS-3
0 0 0000 0011
1 1 0001 0100
2 10 0010 0101
3 11 0011 0110
• Some of the codes will not follow the weights of the sequence binary numbers these
are called as non-weighted codes. ASCII code and Grey code are some of the
examples where they are coded for some special purpose applications and they do
not follow the weighted binary number calculations.
FACULTY NAME:SUJEET
KUMAR GUPTA
Excess-3 Code
• As mentioned above, some of the codes will not follow the binary weights, Excess-
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. It is the
reflective code.
FACULTY NAME:SUJEET
KUMAR GUPTA
Excess -3 Code Examples
• 1) Find the excess-3 code of (237.75)10
• 2) Find the decimal number of excess-3 number 110010100011.01110101.
• Sol:
• 1) The excess-3 code for (237)10 is obtained by adding 3 to all the digits
individually, that is 2, 3 an
• d 7 will become 5, 6 and 10 respectively. These 5, 6 and 10 decimals have to be
converted into binary form and the result is 010101101010.
• The excess-3 code for (.75)10 is obtained by replacing 7 and 5 with 10 and 8
respectively by adding 3 to each digit. That is, the excess-3 code for (.75) ₁₀
is.10101000.
• Combining the results of the integral and fractional parts, the excess-3 code
for (237.75)₁₀ is 010101101010.10101000.
FACULTY NAME:SUJEET
KUMAR GUPTA
Gray Code
• The gray code is the code where one bit will be differed to the preceding number.
For example, decimal numbers 13 and 14 are represented by gray code numbers
1011 and 1001, these numbers differ only in single position that is the second
position from the right. In the same way first position on the left changes for 7 and
8 which are 0100 and 1100 and this is also called Unit-distance code. The gray code
has very special place in digital electronics.
FACULTY NAME:SUJEET
KUMAR GUPTA
Cont..
DECIMAL NUMBER BINARY CODE GRAY CODE
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
FACULTY NAME:SUJEET
8 1000
KUMAR GUPTA 1100
What is Error?
• Error is a condition when the output information does not match with the input
information. During transmission, digital signals suffer from noise that can
introduce errors in the binary bits travelling from one system to other. That means a
0 bit may change to 1 or a 1 bit may change to 0.
FACULTY NAME:SUJEET
KUMAR GUPTA
Error-Detecting codes &Error-Correcting codes
• Error-Detecting codes
• Whenever a message is transmitted, it may get scrambled by noise or data may get
corrupted. To avoid this, we use error-detecting codes which are additional data
added to a given digital message to help us detect if an error occurred during
transmission of the message. A simple example of error-detecting code is parity
check.
• Error-Correcting codes
• Along with error-detecting code, we can also pass some data to figure out the
original message from the corrupt message that we received. This type of code is
called an error-correcting code. Error-correcting codes also deploy the same
strategy as error-detecting codes but additionally, such codes also detect the exact
location of the corrupt bit.
• In error-correcting codes, parity check has a simple way to detect errors along with
a sophisticated mechanism to determine the corrupt bit location. Once the corrupt
bit is located, its value is reverted (from 0 to 1 or 1 to 0) to get the original message.
FACULTY NAME:SUJEET
KUMAR GUPTA
How to Detect and Correct Errors?
• To detect and correct the errors, additional bits are added to the data bits at the time
of transmission.
• The additional bits are called parity bits. They allow detection or correction of the
errors.
• The data bits along with the parity bits form a code word.
FACULTY NAME:SUJEET
KUMAR GUPTA
Parity Checking of Error Detection
• It is the simplest technique for detecting and correcting errors. The MSB of an 8-
bits word is used as the parity bit and the remaining 7 bits are used as data or
message bits. The parity of 8-bits transmitted word can be either even parity or odd
parity.
• Even parity -- Even parity means the number of 1's in the given word including the
parity bit should be even (2,4,6,....).
• Odd parity -- Odd parity means the number of 1's in the given word including the
parity bit should be odd (1,3,5,....).
FACULTY NAME:SUJEET
KUMAR GUPTA
Cont..
• Use of Parity Bit
• The parity bit can be set to 0 and 1 depending on the type of the parity required.
• For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is even. Shown in fig. (a).
• For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word
is odd. Shown in fig. (b).
FACULTY NAME:SUJEET
KUMAR GUPTA
How Does Error Detection Take Place?
• Parity checking at the receiver can detect the presence of an error if the parity of the
receiver signal is different from the expected parity. That means, if it is known that
the parity of the transmitted signal is always going to be "even" and if the received
signal has an odd parity, then the receiver can conclude that the received signal is
not correct. If an error is detected, then the receiver will ignore the received byte
and request for retransmission of the same byte to the transmitter.
FACULTY NAME:SUJEET
KUMAR GUPTA
GLOBAL INSTITUTE OF TECHNOLOGY JAIPUR DIGITAL ELECTRONICS CSE/III SEM
Exercises
Exercises
3. Convert hexadecimal ABF216 to
a. decimal
b. binary
c. octal
d. BCD
Exercises
a) 11101.112 to decimal.
b) FED.4716 to octal.
c) 01101001BCD to binary.
d) 7548 to BCD.
e) 152.2510 to hexadecimal.