0% found this document useful (0 votes)
12 views31 pages

Unit - I (Part A)

The document discusses number systems including binary, decimal, and hexadecimal. It covers converting between number systems, binary arithmetic operations, binary codes like binary coded decimal and gray code, and error detection methods like parity bits and Hamming codes.

Uploaded by

MASTER PIECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views31 pages

Unit - I (Part A)

The document discusses number systems including binary, decimal, and hexadecimal. It covers converting between number systems, binary arithmetic operations, binary codes like binary coded decimal and gray code, and error detection methods like parity bits and Hamming codes.

Uploaded by

MASTER PIECE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Unit – I (Part A)

Number Systems, Codes &


Mathematical Operations
Course: Digital Electronics (EC 2011)
Instructor:
Dr. Sunil Kumar Mishra
Assistant Professor
School of Electronics Engineering, KIIT Bhubaneswar
Review of Decimal Numbers
• The decimal number
system has ten digits
(Symbols): 0, 1, 2, 3, 4,
5, 6, 7, 8, 9.
• It has a base of 10.
• The position of each
digit in a decimal
number indicates the
magnitude of the
quantity represented
and can be assigned a
weight.
14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 2
Example : 1

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 3


Binary Number Systems:

• Binary-to-Decimal
Conversion: Add the
weights of all 1's in a binary
number to get the decimal
value.
• Example 2: Convert the
binary whole number
1101101 to decimal.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 4


Example 2:

Additional Problems:
1. What is the largest decimal number that can be represented in binary with eight bits?
2. Determine the weight of the 1 in the binary number 10000.
3. Convert the binary number 10111101.011 to decimal.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 5


Decimal-to-Binary Conversion:

Sum of weight method: To get the binary number for a given decimal number, find
the binary weights that add up to the decimal number.
Example 3:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 6


Decimal-to-Binary Conversion:
Successive Division-by-2 Method:
• To get the binary number for a given
decimal number, divide the decimal
number by 2 until the quotient is 0.
• Remainders form the binary number.
Example 4: Convert the following decimal
numbers to binary: 12

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 7


Decimal to Binary for Fractional Numbers:

by Successive Multiplication Method:

Convert following Decimal Numbers into Binary equivalent

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 8


Binary Arithmetic:
• Binary Addition:

Reference Examples:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 9


• Binary Subtraction:
Reference Examples:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 10


• Binary Multiplication:
Reference Examples:

• Binary division:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 11


Complements:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 12


Binary Coded Decimal (BCD)
• In BCD, 4 bits represent each decimal digit.
• The 8421 code is a type of BCD (binary coded decimal) code. Binary coded decimal
means that each decimal digit, 0 through 9, is represented by a binary code of four bits.
The designation 8421 indicates the binary weights of the four bits (𝟐𝟑 , 𝟐𝟐 , 𝟐𝟏 , 𝟐𝟎 ).
• The six code combinations that are not used—1010, 1011, 1100, 1101, 1110, and 1111—
are invalid in the 8421 BCD code.
• To express any decimal number in BCD, simply replace each decimal digit with the
appropriate 4-bit code.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 13


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 14
BCD Addition/Subtraction:
• Step 1: Add/subtract the two BCD numbers, using the rules for binary
addition/subtraction.
• Step 2: If a 4-bit sum/difference is equal to or less than 9, it is a valid
BCD number.
• Step 3: If a 4-bit sum/difference is greater than 9, or if a carry/borrow
out of the 4-bit group is generated, it is an invalid result. Therefore,
add/subtract 6 (0110) to/from the 4-bit sum/difference in order to
skip the six invalid states and return the code to 8421 BCD.
• Step 4: If a carry/borrow results when 6 is added/subtract, simply
add/subtract the carry/borrow to/from the next 4-bit group.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 15


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 16
14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 17
Perform the BCD subtraction of (532-285)10.

0101 0011 0010 ➔ 532


- 0010 1000 0101 ➔ 285
0010 1010 1101
- 0110 0110 subtract 0110 from invalid codes
0010 0100 0111 ➔ 247

532 10 − 285 10 = 247 10

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 18


Types of BCD Codes

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 19


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 20
The Gray Code:
• The Gray code is unweighted 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.
• The single bit change characteristic of the Gray code minimizes the chance
for error.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 21


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 22
It is to note here that “+”
indicates XOR operation, or
add operation without any
carry generation. “+” does
not indicate OR operation.

i.e. 1 + 1 = 0 (Addition
without carry).

In other words truth tables


for XOR operation is same
as that of addition
operation without any
carry generation.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 23


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 24
Parity Method for Error Detection :
• Many systems use a parity bit as a means for bit error detection.
• Any group of bits contain either an even or an odd number of 1s.
• 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.
• A given system operates with even or odd parity, but not both.
• For instance, if a system operates with even parity, a check is made on each
group of bits received to make sure the total number of 1s in that group is
even.
• If there is an odd number of 1s, an error has occurred.
14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 25
The total code transmitted, including
the even parity bit, is

Now let’s assume that an error occurs in the


third bit from the left (the 1 becomes a 0).

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 26


14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 27


Error-Correcting Codes:Hamming Codes
• The key to error correction is to detect and locate the error.
• Once location of the bit with error is identified, complementing that bit rectify (correct) the
message.
• Hamming code is well known as an error correcting code, which is widely employed in
information transmission.
• In this each group of binary information (of 𝑚 bits), k number of parity bits (𝑝1 , 𝑝2 , 𝑝3 , … , 𝑝𝑘 ) are
inserted at (2𝑘−1 )𝑡ℎ positions from left, so that, to make a total 𝑚 + 𝑘 -bit code.
• Parity checks are performed for 𝑘-times and an error word is formed for locating the error bits.
• The 𝑘-bit error word is generated by placing a “0” or a “1” at (2𝑘−1 )𝑡ℎ positions depending upon if
check for parity involving the parity bit 𝑝𝑘 is satisfied or not.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 28


7-bit Hamming Code:
• Three parity bits located at positions 20 , 21 & 22 from left are included
to a 4-bit message code word to make a total of 7-bits (Hamming
Code).
𝑃1 𝑃2 𝐷3 𝑃4 𝐷5 𝐷6 𝐷7
here P’s are parity bits and D’s are data bits.
set 𝑝1 as 0 or 1 so that, bit positions at 1,3,5 & 7 provides even parity.
set 𝑝2 as 0 or 1 so that, bit positions at 2,3,6 & 7 provides even parity.
set 𝑝3 as 0 or 1 so that, bit positions at 4,5,6 & 7 provides even parity.

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 29


7-bit Hamming codes for decimal numbers in
BCD and Excess-3 form:

14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 30


Que: If a 7-bit even parity hamming code through a noisy channel is
transmitted through a noisy channel, which is received as “1110110”.
Decode the correct 4-bit data.

Sol.: The received hamming code is given as,

1 1 1 0 1 1 0

𝐶1 = 𝑃1 (1,3,5,7) ➔ 1110 ➔ odd ➔ 1


𝐶2 = 𝑃2 (2,3,6,7) ➔ 1110 ➔ odd ➔ 1
𝐶3 = 𝑃3 (4,5,6,7) ➔ 0110 ➔ even ➔ 0
𝐶3 𝐶2 𝐶1 == 011 == 3rd position from left there is an error. Hence 𝐷3 need to be
complemented for correction.
Corrected Hamming code (sent from transmitter) is as, 1100110
Hence, 4-bit original data: 0110
14-09-2022 Dr. Sunil Kumar Mishra, KIIT Bhubaneswar 31

You might also like