0% found this document useful (0 votes)
14 views95 pages

LSD Module 1

The document covers the fundamentals of logic design, focusing on number systems and their operations, including decimal, binary, octal, and hexadecimal systems. It explains the principles of digital logic design, switching theory, and the conversion processes between different number systems. Additionally, it provides methods for binary addition and the significance of these systems in electronic and computational hardware development.

Uploaded by

rahulroychonedan
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)
14 views95 pages

LSD Module 1

The document covers the fundamentals of logic design, focusing on number systems and their operations, including decimal, binary, octal, and hexadecimal systems. It explains the principles of digital logic design, switching theory, and the conversion processes between different number systems. Additionally, it provides methods for binary addition and the significance of these systems in electronic and computational hardware development.

Uploaded by

rahulroychonedan
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/ 95

CST 203 LOGIC SYSTEM DESIGN

MODULE 1
Number Systems Operations and Codes

Number Systems and


Codes by Azian

1
LOGIC DESIGN
• Digital logic design is basis of electronic systems, such as
computers and cell phones
• Digital Logic is rooted in binary code, a series of zeroes and ones
• Digital Logic Design is foundational to fields of electrical
engineering and computer engineering
• Digital Logic designers build complex electronic components that
use both electrical and computational characteristics
• Digital Logic Design is used to develop hardware, such as circuit
boards and microchip processors

Number Systems and


Codes by Azian

2
SWITCHING THEORY
• Switching Theory is about using switches to implement Boolean
expressions and logic gates for logic design of digital circuits

• It can be used to develop theoretical knowledge and concepts of


digital circuits when viewed as an interconnection of input
elements producing an output state

• Digital logic gates whose inputs and output can switch between
two distinct logical values of 0 and 1

Number Systems and


Codes by Azian

3
DIGITAL NUMBER SYSTEMS

Number Systems
Decimal

Binary

Octal

Hexadecimal

Number Systems and


Codes by Azian

4
DECIMAL NUMBER SYSTEMS

Number Systems and


Codes by Azian

5
• Position of each digit in a weighted number system is assigned
a weight based on base or radix of system
• Radix of decimal numbers is ten
• Ten symbols (0 through 9) are used to represent any number
• For fractional decimal numbers, column weights are negative
powers of ten that decrease from left to right:
…105 104 103 102 101 100.
• Column weights of decimal numbers are powers of ten that
increase from right to left beginning with 100 =1:
102 101 100. 10-1 10-2 10-3 10-4 … Number Systems and
Codes by Azian

6
• Decimal numbers can be expressed as sum of products of
each digit times column value for that digit
• Number 9240 can be expressed as
(9 x 103) + (2 x 102) + (4 x 101) + (0 x 100)
or
9 x 1,000 + 2 x 100 + 4 x 10 + 0 x 1

Express number 480.52 as the sum of values of each digit

480.52 = (4 x 102) + (8 x 101) + (0 x 100) + (5 x 10-1) +(2 x 10-2)

Number Systems and


Codes by Azian

7
BINARY NUMBER SYSTEMS

Number Systems and


Codes by Azian

8
• For digital systems, binary number system is used
• Binary has a radix of two and uses digits 0 and 1
• Column weights of binary numbers are powers of two that
increase from right to left beginning with 20 =1:
…25 24 23 22 21 20.
• For fractional binary numbers, column weights are negative
powers of two that decrease from left to right:
22 21 20. 2-1 2-2 2-3 2-4 …
Number Systems and
Codes by Azian

9
OCTAL NUMBER SYSTEMS
(CONT…)

Number Systems and


Codes by Azian

10
Decimal Octal Binary

• Octal is also a weighted number system 0 0 0000


1 1 0001
• Column weights are powers of 8, which 2 2 0010
increase from right to left 3 3 0011
4 4 0100
5 5 0101
6 6 0110
Column weights {5128
3 82
64
81
8
80 .
1 . 7 7 0111
8 10 1000
Express 37028 in decimal. 9 11 1001
10 12 1010
Start by writing the column weights: 11 13 1011
512 64 8 1 12 14 1100
3 7 0 28 13 15 1101
3(512) + 7(64) +0(8) +2(1) = 198610 14 16Number Systems
1110and
15 17Codes by Azian
1111
11
• Octal uses eight characters the numbers 0 through 7 to represent
numbers
• There is no 8 or 9 character in octal
• Binary number can easily be converted to octal by grouping bits 3
at a time and writing equivalent octal character for each group

Express 1 001 011 000 001 1102 in octal:

Group the binary number by 3-bits starting from the right. Thus,
1130168
Number Systems and
Codes by Azian

12
HEXADECIMAL NUMBER SYSTEMS

Number Systems and


Codes by Azian

13
Decimal Hexadecimal Binary
• Hexadecimal is a weighted number 0 0 0000
system 1 1 0001
2 2 0010
• Column weights are powers of 16, which 3 3 0011
increase from right to left 4 4 0100
5 5 0101
6 6 0110
Column weights {4096
3 2 1
16 16 16 16 .
256 16 1 .
0
7 7 0111
8 8 1000
Express 1A2F16 in decimal. 9 9 1001
10 A 1010
Start by writing the column weights: 11 B 1011
4096 256 16 1 12 C 1100
1 A 2 F16 13 D 1101
1(4096) + 10(256) +2(16) +15(1) = 670310 14 E 1110
Number Systems and
15 F Codes by Azian
1111
14
• Hexadecimal uses sixteen characters to represent numbers

• Numbers 0 through 9 and alphabetic characters A through F

• Large binary number can easily be converted to hexadecimal by


grouping bits 4 at a time and writing equivalent hexadecimal
character
Express 1001 0110 0000 11102 in hexadecimal:

Group binary number by 4-bits starting from right. Thus, 960E

Number Systems and


Codes by Azian

15
CONVERSION BETWEEN NUMBER
SYSTEMS
Decimal Binary Octal Hexadecimal
Conversion Conversion Conversion Conversion

Binary Decimal
Decimal Decimal

Octal Octal

Binary Binary
Hexadecimal Hexadecimal

Number Systems and


Codes by Azian

16
DECIMAL TO BINARY

 Divide the decimal number by 2 until the quotient is 0.

LSB

50 2 0
25 2 1 MSB – Most Significant Digit
12 2 0
LSB – Least Significant Digit
6 2 0
3 2 1
1 1
MSB
=1 1 0 0 1 02
Number Systems and
Codes by Azian

17
DECIMAL TO OCTAL

 Divide the decimal number by 8 until the quotient is 0.

LSB
50 8 2
MSB – Most Significant Digit
6 6
LSB – Least Significant Digit
MSB
= 6 2 8

Number Systems and


Codes by Azian

18
DECIMAL TO HEXADECIMAL

 Divide the decimal number by 16 until the quotient is 0.

LSB

50 16 2 MSB – Most Significant Digit

3 3 LSB – Least Significant Digit

MSB

= 3 2 16

Number Systems and


Codes by Azian

19
DECIMAL (FRACTION) TO BINARY
CONVERSION
 Multiply the number by the ‘Base’(=2)
 Take the integer (either 0 or 1) as a coefficient
 Take the resultant fraction and repeat the division

Example: (0.625)10
Integer Frac tion Coefficient
0.625 * 2 = 1 . 25 a-1 = 1
0.25 * 2 = 0 . 5 a-2 = 0
0.5 *2= 1 . 0 a-3 = 1
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2

Number Systems and


MSB LSB Codes by Azian

20
Decimal (Fraction) to Binary
Conversion

Convert the decimal fraction 0.188 to binary by


repeatedly multiplying the fractional results by 2.
0.188 x 2 = 0.376 carry = 0 MSB
0.376 x 2 = 0.752 carry = 0
0.752 x 2 = 1.504 carry = 1
0.504 x 2 = 1.008 carry = 1
0.008 x 2 = 0.016 carry = 0
Answer = .00110 (for five significant digits)

Number Systems and


Codes by Azian

21
DECIMAL (FRACTION) TO OCTAL
CONVERSION

Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8

Number Systems and


Codes by Azian

22
BINARY TO DECIMAL

 Multiply each binary number by its weight and summing


products

(11101) 2
= (1x24) + (1x23) + (1x22) + (0x21 ) + (1x20)
= 16 + 8 + 4 + 1
= (29)10
Number Systems and
Codes by Azian

23
BINARY TO OCTAL

 Grouped of three bits starting at the LSB


 Then convert each group to its octal equivalent

111110102 = 011 111 010

3 7 2 = 3728

Number Systems and


Codes by Azian

24
BINARY TO OCTAL Octal Binary
0 000
1 001
2 010
Assume Zeros
Example: 3 011

( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111

Works both ways (Binary to Octal & Octal to Binary)

Number Systems and


Codes by Azian

25
BINARY TO HEXADECIMAL

 Grouped of four bits starting at the LSB


 Then convert each group to its hexadecimal equivalent
 Zeros are added to make each group complete with 4 bits

10101011112 = 0010 1010 1111

2 A F = 2AF16

Number Systems and


Codes by Azian

26
BINARY TO HEXADECIMAL
Hex Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
Assume Zeros 6 0110
Example: 7 0111
8 1000
( 1 0 1 1 0 . 0 1 )2 9 1001
A 1010
B 1011
C 1100
D 1101
(1 6 . 4 )16 E 1110
F 1111

Works both ways (Binary to Hex & Hex to Binary) Number Systems and
Codes by Azian

27
OCTAL TO DECIMAL

 Multiply each octal number by its weight and summing


products

(362) 8
= (3x82) + (6x81) + (2x80)
= 192 + 48 + 2
= (242)10
Number Systems and
Codes by Azian

28
OCTAL TO BINARY

 Convert each octal digit to its three-bit binary equivalent

= 011111010

Number Systems and


Codes by Azian

29
HEXADECIMAL TO DECIMAL

 Multiply each hexadecimal number by its weight and


summing products

(19B) 16
= (1x162) + (9x161) + (11x160)
= 256 + 144 + 11
= (411)10
Number Systems and
Codes by Azian

30
HEXADECIMAL TO BINARY

 Convert each hexadecimal digit to its four-bit binary


equivalent

2AF16 = 2 A F

0010 1010 1111


= 10101011112

Number Systems and


Codes by Azian

31
OCTAL TO HEXADECIMAL
 Convert to Binary as an intermediate step

Example:
( 2 6 . 2 )8

Assume Zeros Assume Zeros

( 0 1 0 1 1 0 . 0 1 0 )2

(1 6 . 4 )16
Number Systems and
Works both ways (Octal to Hex & Hex to Octal) Codes by Azian

32
BINARY ADDITION

The rules for binary addition are


0 + 0 = 0 Sum = 0, carry = 0
0 + 1 = 1 Sum = 1, carry = 0
1 + 0 = 1 Sum = 1, carry = 0
1 + 1 = 10 Sum = 0, carry = 1
When an input carry = 1 due to a previous result, the rules
are
1 + 0 + 0 = 01 Sum = 1, carry = 0
1 + 0 + 1 = 10 Sum = 0, carry = 1
1 + 1 + 0 = 10 Sum = 0, carry = 1
1 + 1 + 1 = 11 Sum = 1, carry = 1

Number Systems and


Codes by Azian

33
BINARY ADDITION

Add the binary numbers 00111 and 10101 and show


the equivalent decimal addition.
0111
00111 7
10101 21
11100 = 28

Number Systems and


Codes by Azian

34
BINARY ADDITION

1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23

1 0 1 0 1 0 0 = 84

Number Systems and


Codes by Azian
BINARY SUBTRACTON

The rules for binary subtraction are


0-0=0
1-1=0
1-0=1
10 - 1 = 1 with a borrow of 1
Subtract the binary number 00111 from 10101 and
show the equivalent decimal subtraction.
111
10101
/ / / 21
00111 7
01110 = 14
Number Systems and
Codes by Azian

36
BINARY SUBTRACTON

1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1 = 77
− 1 0 1 1 1 = 23

0 1 1 0 1 1 0 = 54

Number Systems and


Codes by Azian
BINARY MULTIPLICATION

 Multiplication follows the general principal of


shift and add.
 The rules include:
 0*0=0
 0*1=0
 1*0=0
 1*1=1

Number Systems and


Codes by Azian
BINARY MULTIPLICATION

1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1

1 1 1 0 0 1 1 0
Number Systems and
Codes by Azian
BINARY DIVISION

 Binary division is similar to decimal division


 It is called as the long division procedure

Number Systems and


Codes by Azian
1’S COMPLEMENT
• The 1’s complement of a binary number is just the
inverse of the digits
• To form the 1’s complement, change all 0’s to 1’s and
all 1’s to 0’s
For example, the 1’s complement of 11001010 is
00110101
In digital circuits, the 1’s complement is formed by using
inverters:
1 1 0 0 1 0 1 0

Number Systems and


0 0 1 1 0 1 0 1 Codes by Azian

41
2’S COMPLEMENT
• The 2’s complement of a binary number is found by adding
1 to the LSB of 1’s complement

Recall that the 1’s complement of 11001010 is


00110101 (1’s complement)
To form the 2’s complement, add 1: +1
1 1 0 0 1 0 1 0 00110110 (2’s complement)
1

0 0 1 1 0 1 0 1
Input bits
Carry
Adder
in (add 1)
Output bits (sum)

0 0 1 1 0 1 1 0 Number Systems and


Codes by Azian

42
SIGNED BINARY NUMBERS
• MSB in a signed number is the sign bit, that tells you if
number is positive or negative
• Computers use a modified 2’s complement for signed numbers
• Positive numbers are stored in true form (with a 0 for sign bit)
and negative numbers are stored in complement form (with a 1
for sign bit)

For example, the positive number 58 is written using 8-bits as


00111010 (true form).

Sign bit Magnitude bits


Number Systems and
Codes by Azian

43
SIGNED BINARY NUMBERS
• Negative numbers are written as the 2’s complement of
corresponding positive number
The negative number -58 is written as:
1’s complement of +58=11000101
2’s complement of +58=11000101+1= 11000110
-58 = 11000110 (complement form)
Sign bit Magnitude bits
An easy way to read a signed number that uses this notation is to
assign the sign bit a column weight of -128 (for an 8-bit number).
Then add the column weights for the 1’s.
Assuming that the sign bit = -128, show that 11000110 = -58
as a 2’s complement signed number:
Column weights: -128 64 32 16 8 4 2 1.
1 1 0 0 0 1 1 0
-128 +64 +4 +2 = -58
Number Systems and
Codes by Azian

44
ARITHMETIC OPERATIONS
WITH SIGNED NUMBERS

Rules for addition: Add the two signed numbers. Discard


any final carries. The result is in signed form.
Examples:

00011110 = +30 00001110 = +14 11111111 = -1


00001111 = +15 11101111 = -17 11111000 = -8
00101101 = +45 11111101 = -3 1 11110111 = -9
Discard carry

Number Systems and


Codes by Azian

45
ARITHMETIC OPERATIONS
WITH SIGNED NUMBERS
• Note that if the number of bits required for the answer is
exceeded, overflow will occur
• This occurs only if both numbers have the same sign. The
overflow will be indicated by an incorrect sign bit.
Two examples are:
10000001 = -127
10000001 = -127
Discard carry 100000010 = +2

Wrong! The answer is incorrect


and the sign bit has changed. Number Systems and
Codes by Azian

46
ARITHMETIC OPERATIONS
WITH SIGNED NUMBERS
• Rules for subtraction: 2’s complement subtrahend and add
numbers
• Discard any final carries, result is in signed form

Repeat the examples done previously, but subtract:


00011110 (+30) 00001110 (+14) 11111111 (-1)
- 00001111 –(+15) - 11101111 –(-17) - 11111000 –(-8)
2’s complement subtrahend and add:
00011110 = +30 00001110 = +14 11111111 = -1
11110001 = -15 00010001 = +17 00001000 = +8
1 00001111 = +15 00011111 = +31 1 00000111 = +7
Discard carry Discard carry Number Systems and
Codes by Azian

47
Hexadecimal Addition
• Start with least significant hexadecimal digits
• Let Sum= summation of two hex digits
• If sum is greater than or equal to 16, then
Sum=Sum-16 and carry 1

Number Systems and


Codes by Azian

48
Hexadecimal Subtraction
• Start with least significant hexadecimal digits
• Let Difference=subtraction of two hex digits
• If Difference is negative, then
Difference=16+Difference and borrow=-1

Number Systems and


Codes by Azian

49
Octal Addition
• Start with least significant octal digits
• Let Sum= summation of two octal digits
• If sum is greater than or equal to 8, then
Sum=Sum-8 and carry 1

Number Systems and


Codes by Azian

50
Octal Subtraction
• Start with least significant octal digits
• Let Difference=subtraction of two octal digits
• If Difference is negative, then
Difference=8+Difference and borrow=-1

Number Systems and


Codes by Azian

51
9’s Complement
• 9’s complement of a decimal number is found by subtracting
each digit in number from 9
• 9’s complement of each of decimal digits is as follows

Number Systems and


Codes by Azian

52
10’s Complement
• 10’s complement of a decimal number can be found by
adding 1 to 9’s complement of that decimal number

• 10’s complement = 9’s complement + 1

• Example: let us take a decimal number 456


9’s complement of this number will be 999-456
which will be 543
Now 10s complement will be 543+1=544

Number Systems and


Codes by Azian

53
BCD CODE
• Binary coded decimal (BCD) is a weighted code

Coding
decimal to its
binary
equivalent

BCD
CODE
Code available Four bits = one
0000 - 1001 decimal digit

Number Systems and


Codes by Azian

54
BCD code
• commonly known as a weighted 8421 Decimal Binary BCD
0 0000 0000
BCD code, with 8, 4, 2 and 1
1 0001 0001
representing weights of different bits 2 0010 0010
starting from most significant bit (MSB) 3 0011 0011
and proceeding towards least significant 4 0100 0100
bit (LSB 5 0101 0101
6 0110 0110
• It is commonly used in digital systems 7 0111 0111
when it is necessary to show decimal 8 1000 1000
9 1001 1001
numbers such as in clock displays.
10 1010 0001 0000
11 1011 0001 0001
The table illustrates the difference
12 1100 0001 0010
between straight binary and BCD. BCD 13 1101 0001 0011
represents each decimal digit with a 4- 14 1110 0001 0100
Number Systems and
bit code. Notice that the codes 1010 15 1111 0001 0101
Codes by Azian
through 1111 are not used in BCD.
55
BCD code

You can think of BCD in terms of column weights in


groups of four bits. For an 8-bit BCD number, the column
weights are: 80 40 20 10 8 4 2 1.
What are the column weights for the BCD number
1000 0011 0101 1001?

8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1


Note that you could add the column weights where there is
a 1 to obtain the decimal number. For this case:
8000 + 200 +100 + 40 + 10 + 8 +1 = 835910
Number Systems and
Codes by Azian

56
BCD Addition
• Use binary arithmetic to add BCD digit
• If binary sum is less than or equal to 1010 (9 in decimal),
corresponding BCD sum digit is correct
• If binary sum is more than 1010, must add 0110 (6 in decimal) to
corresponding BCD sum digit in order to produce correct carry
into digit to left

Number Systems and


Codes by Azian

57
BCD Addition
• Add 2905+1897 in BCD

• Final answer=4802 Number Systems and


Codes by Azian

58
BCD Subtraction Using 9’s
Complement
• BCD Subtraction using 9s Complement can be used to
perform subtraction by adding minuend to 9s Complement
of subtrahend
• In 9s Complement subtraction when 9s Complement of
smaller number is added to larger number carry is generated,
It is necessary to add this carry to result (this is called an
end-around carry)
• When larger number is subtracted from smaller one, there is
no carry, and result is in 9s Complement form and negative
Number Systems and
Codes by Azian

59
BCD Subtraction

Number Systems and


Codes by Azian

60
BCD Subtraction Using 10’s
Complement
• BCD Subtraction using 10s Complement can be used to
perform subtraction by adding minuend to 10s Complement
of subtrahend and dropping carry

Number Systems and


Codes by Azian

61
Character Coding Schemes
• In computing, a single character such as a letter, a number
or a symbol is represented by a group of bits
• Number of bits per character depends on coding scheme
used
• Most common coding schemes are:
1. Binary Coded Decimal (BCD)
2. Extended Binary Coded Decimal Interchange Code
(EBCDIC)
3. American Standard Code for Information Interchange
(ASCII)

Number Systems and


Codes by Azian

62
ASCII CODE
• ASCII (American Standard Code for Information Interchange)
is a code for alphanumeric characters and control characters
• Every time a character is typed on a keyboard a code number
is transmitted to computer
• Code numbers are stored in binary on computers as Character
Sets called ASCII
• Table below shows a version of ASCII that uses 7 bits to code
each character
• 128 different characters characters i.e. 27 can be represented
using ASCII

Number Systems and


Codes by Azian

63
ASCII CODE
• Biggest number that can be held in 7-bits is 1111111 in
binary (127 in decimal)
• More than enough to cover all of characters on a standard
English-Language keyboard
• First 32 characters are control characters
• In 1981, IBM introduced extended ASCII, which is an 8-bit
code and increased the character set to 256
• Characters from 0 to 31 are control characters, 32 to 64 special
characters, 65 to 96 uppercase letters and few symbols, 97 to
127 lowercase letters and other symbols and 128 to 255 are
other symbols
Number Systems and
Codes by Azian

64
Number Systems and
Codes by Azian

65
Number Systems and
Codes by Azian

66
EXTENDED ASCII TABLE

Number Systems and


Codes by Azian

67
EBCDIC CODE
• It is pronounced as “ebb-see-dick

• Extended Binary Coded Decimal Interchange code (EBCDIC)


is an 8-bit character-coding scheme used primarily on IBM
computers

• A total of 256 (28) characters can be coded using this scheme.


For example, symbolic representation of letter A using
Extended Binary Coded Decimal Interchange code is
110000012

Number Systems and


Codes by Azian

68
EBCDIC CODE
• In EBCDIC code eight bits for each character is divided into
two four-bit zones

• One zone indicating type of character, digit, punctuation


mark, lowercase letter, capital letter, and so on, and other zone
indicating value (that is, specific character within this type)

• Below is given some characters of EBCDIC code to get


familiar with it

Number Systems and


Codes by Azian

69
EBCDIC CODE TABLE

Number Systems and


Codes by Azian

70
BINARY CODES
• A binary code represents text, computer processor instructions,
or any other data using a two-symbol system
• Two-symbol system used is often "0" and "1" from binary
number system
• For example, a binary string of eight bits can represent any of
256 possible values and can, therefore, represent a wide variety
of different items
• Following are some binary codes
1. Decimal codes
2. Error detection codes
3. Reflected code

Number Systems and


Codes by Azian

71
ERROR DETECTION
CODES
• These are used to detect errors present in received data bitstream
• These codes contain some bits, which are appended to original
bit stream
• These codes detect error, if it is occurred during transmission of
original data bit stream
• Example − Parity code, Checksum, Cyclic Redundancy Check

Number Systems and


Codes by Azian

72
PARITY CODE
• It is easy to append one parity bit either to left of MSB or to right
of LSB of original bit stream
• There are two types of parity codes, namely even parity code and
odd parity code based on type of parity being chosen
• Parity bit helps to check if any error occurred in data during
transmission.

Number Systems and


Codes by Azian

73
EVEN PARITY CODE
• 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 data bits and even parity bit
• Following table shows even parity codes corresponding to each
3-bit binary code
• Here, even parity bit is included to right of LSB of binary code

Number Systems and


Codes by Azian

74
EVEN PARITY CODE

Number Systems and


Codes by Azian

75
ODD PARITY CODE
• Value of odd parity bit should be zero, if odd number of ones
present in binary code. Otherwise, it should be one. So that, odd
number of ones present in odd parity code
• Odd parity code contains data bits and odd parity bit
• Following table shows odd parity codes corresponding to each
3-bit binary code
• Here, odd parity bit is included to right of LSB of binary code

Number Systems and


Codes by Azian

76
ODD PARITY CODE

Number Systems and


Codes by Azian

77
PARITY CHECKING STEPS
Error detection using single parity check involves following steps

Step-01:
At sender side,
• Total number of 1’s in data unit to be transmitted is counted.
• Total number of 1’s in the data unit is made even in case of even
parity.
• Total number of 1’s in the data unit is made odd in case of odd
parity.
• This is done by adding an extra bit called as parity bit.

Number Systems and


Codes by Azian

78
PARITY CHECKING STEPS
Step-02:

• Newly formed code word (Original data + parity bit) is transmitted


to receiver

Step-03:

At receiver side,
• Receiver receives transmitted code word
• Total number of 1’s in the received code word is counted

Number Systems and


Codes by Azian

79
PARITY CHECKING STEPS
Then, following cases are possible
• If total number of 1’s is even and even parity is used, then
receiver assumes that no error occurred.
• If total number of 1’s is even and odd parity is used, then
receiver assumes that error occurred.
• If total number of 1’s is odd and odd parity is used, then receiver
assumes that no error occurred.
• If total number of 1’s is odd and even parity is used, then
receiver assumes that error occurred.

Number Systems and


Codes by Azian

80
PARITY CHECK EXAMPLE
• Consider the data unit to be transmitted is 1001001 and even
parity is used
At Sender Side-

• Total number of 1’s in the data unit is counted.


• Total number of 1’s in the data unit = 3.
• Clearly, even parity is used and total number of 1’s is odd.
• So, parity bit = 1 is added to the data unit to make total number
of 1’s even.
• Then, the code word 10010011 is transmitted to the receiver.

Number Systems and


Codes by Azian

81
PARITY CHECK EXAMPLE

Number Systems and


Codes by Azian

82
PARITY CHECK EXAMPLE
At Receiver Side-

• After receiving the code word, total number of 1’s in the code
word is counted.
• Consider receiver receives the correct code word = 10010011.
• Even parity is used and total number of 1’s is even.
• So, receiver assumes that no error occurred in the data during the
transmission.

Number Systems and


Codes by Azian

83
PARITY CHECK EXAMPLE
Advantage-

• This technique is guaranteed to detect an odd number of bit


errors (one, three, five and so on).
• If odd number of bits flip during transmission, then receiver can
detect by counting the number of 1’s.
Limitation-

• This technique can not detect an even number of bit errors (two,
four, six and so on).
• If even number of bits flip during transmission, then receiver can
not catch the error.
Number Systems and
Codes by Azian

84
PARITY CHECK EXAMPLE
• Consider data unit to be transmitted is 10010001 and even parity
is used.
• Then, code word transmitted to the receiver = 100100011
• Consider during transmission, code word modifies as 101100111.
(2 bits flip)
• On receiving the modified code word, receiver finds the number
of 1’s is even and even parity is used.
• So, receiver assumes that no error occurred in the data during
transmission though the data is corrupted.

Number Systems and


Codes by Azian

85
CHECKSUM
• It also uses same method of parity bits transmitter send data
followed by bits known as checksum bits
Algorithm:-
1. In checksum error detection scheme, data is divided into k
segments each of m bits.
2. In sender end segments are added using complement arithmetic to
get the sum, sum is complemented to get Checksum.
3. Checksum segment is sent along with data segments.
4. At receiver end, all received segments are added using 1s
complement arithmetic to get sum. Sum is complemented
5. If result is zero, received data is accepted; otherwise discarded

Number Systems and


Codes by Azian

86
CHECKSUM

Number Systems and


Codes by Azian

87
CHECKSUM EXAMPLE

Number Systems and


Codes by Azian

88
GRAY CODE/REFLECTED
CODE
• Reflected binary code or Gray code is an ordering of binary
numeral system such that two successive values differ in only one
bit (binary digit)
• Gray code is not weighted that means it does not depends on
positional value of digit
• Gray code also known as reflected binary code, because the first
(n/2) values compare with those of the last (n/2) values, but in
reverse order.

Number Systems and


Codes by Azian

89
GRAY CODE/REFLECTED
CODE

Number Systems and


Codes by Azian

90
GRAY CODE
Remove most significant bit and you
Consider gray code sequence obtain a nice reflected sequence:
x000
0000
x001
0001
x011
0011
x010
0010
x110
0110
x111
0111
x101
0101
x100 ----
0100
---mirror
1100
x100
1101
x101 same kind of reflection can
1111
x111 be found for Gray sequences
1110
x110 of any width
1010
x010
1011
x011
1001 Number Systems and
x001 Codes by Azian
1000
x000 91
GRAY CODE

Convert Binary to Gray Code


• MSB (Most Significant Bit) of the gray code will be exactly equal
to first bit of the given binary number
• Second bit of gray code will be exclusive-or (XOR) of first and
second bit of 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.
• Third bit of gray code will be equal to exclusive-or (XOR) of the
second and third bit of the given binary number
• Thus binary to gray code conversion goes on

Number Systems and


Codes by Azian

92
GRAY CODE
Gray Code to Binary Conversion
• MSB of binary number will be equal to the MSB of the given
gray code.
• Second bit of binary code will be exclusive-or (XOR) of first bit
of binary code and second bit of given gray code, i.e if both the
bits are same the result will be 0 and if they are different the
result will be 1.
• Third bit of binary code will be equal to exclusive-or (XOR) of
second bit of binary code and third bit of the given gray code
• Thus binary to gray code conversion goes on

Number Systems and


Codes by Azian

93
GRAY CODE

Binary to
Gray Code

Gray to
Binary
Code

Number Systems and


Codes by Azian

94
END……………….

Number Systems and


Codes by Azian

95

You might also like