EC-214 DIGITAL LOGIC DESIGN
J.RAVINDRANADH
Sr.Associate Professor.
E-mail : [email protected]
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
Text book & Reference book
Textbook
M Morris Mano, Digital Logic and Computer Design, PHI/Pearson Education, 2003.
RP Jain, Modern Digital Electronics, 3rd Edition, TMH, 2003
Reference book
1. Zvi Kohavi, Switching and Finite Automata Theory, 2nd Edition, TMH, 1978.
2. Fundamentals of Logic Design, ch. Roth,Jr
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
SYLLABUS
Unit -I
NUMBER SYSTEMS AND CODES: Decimal, Binary, Octal,
Hexadecimal Number systems and their conversions, Arithmetic
additions, subtraction using the method of complements, Multiplication
and division. Codes: BCD, Excess 3, Gray, Alphanumeric and Error
detection codes.
BOOLEAN ALGEBRA: Boolean expressions and theorems, Logic gates,
Universal gates, Canonical and standard forms, Boolean functions,
simplification of Boolean functions using K maps (up to five variables),
Minimal functions and their properties, Tabulation method, NAND
implementations two level and Multilevel
Unit -II
COMBINATIONAL LOGIC CIRCUITS: EX-OR, EX-NOR Circuits, General
design procedure for Combinational logic circuits ,Design and
applications of Binary Adders and Subtractors, Comparators, Encoders,
Decoders, Multiplexers and Demultiplexers, Design of BCD to 7 Segment
Decoder, Parity Generator and Checker, Error Detection and Correction
using Hamming Code, BCD Adder / Subtractor, Carry look ahead adders.
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
SYLLABUS
Unit-III
Cont.,
SEQUENTIAL LOGIC CIRCUITS: Latches, Characteristic Table, Characteristic Equation,
Excitation table, State table and State diagrams for SR, JK, Master Slave JK, D and T Flip-flops,
Conversion from one type of Flip-flop to another, Shift Registers, Analysis and Synthesis of
Sequential Circuits-Sequence Generator, Sequence Detector, Parity Generator.
COUNTERS USING FLIP- FLOPS: Design of Ripple counters, Synchronous counters, Up/Down
counters using Flip-flops.
Unit-IV
IC LOGIC FAMILIES: RTL, DTL, TTL, ECL, MOS, CMOS and IIL families and their comparison.
MSI and LSI: Programmable Logic Arrays, Programmable Array Logic.
EC214 Digital Logic Design
J Ravindranadh Sr.Associ.Prof.
Number system
Decimal
Binary
Octal
Hexadecimal
Decimal System :
1. The decimal system is composed of 10 numerals . These 10 symbols are 0,
1, 2, 3, 4, 5, 6, 7, 8, 9.
2. The decimal system is called the base-10 system or Radix-10 because it has
10 digits.
3. The decimal system is clearly most familiar to us because it is a tool that you
used every day.
Example:
Ranks,
Roll Numbers etc.,
EC214
Digital Logic
Design
J Ravindranadh
Sr.Associ.Prof.
Binary System
Octal System
The binary system is simple because it consists of only two digits , i.e. 0 and 1.
The binary system is called the base-2 system or Radix-2 because it has 2 digits.
Use of binary number system in the digital systems.
The Octal system is composed of 8 numerals. These 8 symbols are 0, 1, 2, 3, 4,
5, 6, 7.
The Octal system is called the base-8 system or Radix-8 because it has 8 digits.
Octal system is used in COBOL language
Hexadecimal system
The Hexadecimal number system uses 16 symbols. These 16 symbols are
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F.
The Hexadecimal system is called the base-16 system or Radix-16 because it
has 16 symbols.
Hexadecimal system is used in Micro Processor and used in specifying web colors.
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
Conversion Possibilities
Decimal
Octal
Binary
Hexadecimal
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
Decimal to Binary
Conversion
Converting a decimal number into a binary number is by dividing the decimal
number by 2 progressively, until the quotient of zero is obtained. The binary
number is obtained by taking the remainder after each division in the reverse
order. This method is popularly known as the double-dabble method.
Example: Convert the decimal number 5310 into its binary equivalent.
2 53
2
2
02
2
2
26
--13
--6
--3
--1 --0 ---
1
1
0
1
1
LSB
(53) 10 =
( 110101) 2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
MSB
Fractional Conversion: If the number is a fraction, its binary equivalent is
obtained by multiplying the number continuously by 2, recording a carry in
the integer position each
time. The carries in the forward order give the required binary number.
Example: Convert the decimal number (0.625)10 into its binary equivalent.
Multiplication
0.625 x 2=1.25
0.25 x2 =0.5
0.5x2
=1.0
Generated Integer
1
0
1
(0.625)10 =(0.101)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
Example: Convert the decimal number (93.8125)10 into its binary equivalent.
2 93
2 46
----- 1
2 23
2 11
----- 0
----- 1
2 5
-----1
2 2
----- 1
----- 0
---- 1
Multiplication
Integer
0.8125x2 =1.625
0.625x2 = 1.25
0.25x2 = 0.5
0.5x2
=1.0
Generated
1
1
0
1
(93.8125)10 =(1011101.1101)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
10
Convert Decimal to
Binary
Convert the decimal number (72.95)10 into its binary equivalent.
(1001000.1111001)2
Multiplication
0.95x2 =1.9
0.9x2 = 1.8
0.8x2
0.6x2
0.2x2=0.4
0.4x2=0.8
0.8x2=1.6
Generated Integer
1
1
= 1.6
=1.2
0
0
1
1
1
Convert the decimal number(432.354)10 into its binary equivalent.
(110110000.010110..)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
11
Decimal to Octal
Conversion
Example: Convert the decimal number (53.625)10 into its octal
equivalent.
8 53
8 6
0
Multiplication
--- 5
0.625x8=5.000
--- 6
Generated Integer
5
(53.625)10 =(65.5)8
Convert the decimal number (375.3125)10 into its octal equivalent
(567.24)8
Convert the decimal number(444.456)10 into its octal equivalent
(674.35136 )8
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
12
Decimal to Hexadecimal
Conversion
Example: Convert the decimal number (115.5)10 into its Hexadecimal
equivalent.
16 115
16 7
---
16 0
--- 7
Multiplication
0.5x16=8.000
Generated Integer
8
(115.5)10 =(73.8)16
Convert the decimal number (757.25)10 into its hexadecimal
equivalent
(2F5.4)16
Convert the decimal number (356.89)10 into its hexadecimal
equivalent
(164.E3D7)16
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
13
Binary to Decimal
Conversion
Example: Convert the binary number (10111.1011)2 into its decimal equivalent.
(10111.1011) 2 = 1 x 20
+ 1 x 21 + 1 x 22 + 0 x 2 3 + 1 x 24 +
1 x 2-1 + 0 x 2-2 + 1 x 2-3 + 1 x 2-4
= 1 + 2 + 4 + 0 + 16 + 0.5 + 0.0 + 0.125 + 0.0625
=(23.6875)10
Convert the binary number (1001001.011)2 into its decimal
equivalent.
(73.375)10
Convert the binary number (1101101.111)2 into its decimal
equivalent
(109.875)10
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
14
Binary to Octal Conversion
The base of the octal numbers is 8 and the base for binary numbers is 2. Thus the base for octal number is the third power of the
base for binary number .i.e 2 3 =8.
Converting a binary number to an octal, starting from the least significant bit, each group of 3 bits is replaced by its decimal
equivalents.
Example: Convert the binary number (10011101111.10111)2 into its octal equivalent.
(10011101111.10111) 2 = ( 2357.56)8
Convert the binary number (1100111110011.011101001)2 into its octal
equivalent.
(14763.351)8
Convert the binary number (111101011001101.000111)2 into its octal
EC214 Digital Logic Design
equivalent.
(75315.07)8
J Ravindranadh
Sr.Associ.Prof.
15
Binary to Hexadecimal
Conversion
The base of the hexadecimal numbers is 16 and the base for binary numbers is 2. Thus the base for hexadecimal number is the fourth
power of the base for binary number .i.e 2 4 =16.
Converting a binary number to hexadecimal, starting from the least significant bit, each group of 4 bits is replaced by its Hexadecimal
equivalents.
Example: Convert the binary number 10011101111.10111)2 into its hexadecimal equivalent.
(10011101111.10111)2 = ( 4EF.B8)16
Ex: Convert the binary number(1100111110011.011101001)2 into its
hexadecimal
(19F3.748)16
equivalent.
Ex: Convert the binary number(110101011101100.00011)2 into its hexadecimal
EC214 Digital Logic Design
(6AEC.18)16
equivalent.
J Ravindranadh
Sr.Associ.Prof.
16
Octal to Decimal
Conversion
Example: Convert the octal number (475.25)8 into its decimal equivalent.
(475.25)8 = 5 x 80
+ 7 x 81 + 4 x 82 + 2 x 8-1 + 5 x 8-2
= 5 + 56 + 256 + 0.25 + 0.078125
=(317.32825)10
Convert the octal number (432.763)8 into its decimal equivalent
(282.9738)10
Convert the octal number (567.24)8 into its decimal equivalent
(375.3125)10
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
17
Octal to Binary Conversion
Obtaining the binary equivalent of an octal number, each significant digit in the given number is replaced by its 3 bit binary
equivalent.
Example: Convert the octal number (35601.124)8 into its binary equivalent.
(35601.124)8 = ( 011101110000001.0010101)2
Convert the octal number(4531.2046)8 into its binary equivalent.
(100101011001.01000010011)2
Convert the octal number (7532.124)8 into its binary equivalent
(111101011010.0010101)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
18
Octal to- Hexadecimal
Conversion
To convert an octal number to Hexadecimal the steps are as follows
Convert the given octal number to its binary equivalent.
Form groups of 4 bits, staring from the LSB.
Write the equivalent hexadecimal number for each group of 4 bits.
Example: Convert the octal number (475.25)8 into its Hexadecimal
equivalent.
(475.25)8 = (100111101.010101)2
= (13D. 54)16
Convert the octal number ( 3457.216)8 into its Hexadecimal equivalent.
( 11100101111.01000111 )2 = ( 72F. 47 )16
Convert the octal number ( 7654.321)8 into its Hexadecimal equivalent
( 111110101100.011010001 ) 2 = ( FAC.688 )16
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
19
Hexadecimal to Decimal
Conversion
Example: Convert the hexadecimal number (9B2.1A)16 into its decimal
equivalent.
(9B2.1A)16 = 2 x 160
+ 11 x 161 + 9 x 162 + 1 x 16-1 + 10 x 16-2
= 2 + 176 + 2304 + 0.0625 + 0.039
=(2482.101)10
Convert the hexadecimal number (2F5.4) 16 into its decimal equivalent.
= (757.25)10
Convert the hexadecimal number(E1.398)16 into its decimal equivalent.
= (225.225)10
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
20
Hexadecimal to Binary
Conversion
Binary equivalent of a hexadecimal number, each significant digit in the
given number is replaced by its 4 bit binary equivalent.
Example: Convert the hexadecimal number (F9E2.1A)16 into its binary
equivalent.
(F9E2.1A)16 = ( 1111100111100010.00011010)2
Convert the hexadecimal number ( 68B5.C9D)16 into its binary equivalent.
( 0110100010110101.110010011101)2
Convert the hexadecimal number ( 79DF2.A38C )16 into its binary
equivalent.
( 1111001110111110010.1010001110001100) 2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
21
Hexadecimal to octal
Conversion
To convert an Hexadecimal number to octal the steps are as follows
Convert the given hexadecimal number to its binary equivalent.
Form groups of 3 bits, staring from the LSB.
Write the equivalent octal number for each group of 3 bits.
Example: Convert the Hexadecimal number (A48.345)16 into its octal
equivalent.
(A48.345)16 = (101001001000.001101000101)2
= (5110.1505)8
Convert the Hexadecimal number ( 72F. 47 )16 into its octal equivalent.
( 3457.216)8
Convert the Hexadecimal number ( FAC.688 )16 into its octal equivalent.
( 7654.321)8
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
22
Arithmetic Operation
Binary Arithmetic
Arithmetic operation in digital systems are usually done in binary
because design of logic circuits to perform binary arithmetic is
much easier than for decimal.
Arithmetic rules for addition
0+0=0
0+1=1
1+0=1
1+1=10
Example: Add (1010)2 and (1111)2
11
1010
1111
(11001)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
23
Binary addition
Add ( 1111.01)2 and (0111.10)2
111
1111.01
0111.10
(10110.11)2
Add (1011.011)2 and (110.1)2
(10001.111)2
Add (101.11)2 (1101.01)2 and (10000.001)2
(100011.001)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
24
Binary Subtraction
Arithmetic rules for Subtraction
0-0=0
1-0=1
1-1=0
0-1=1
Note: When 1 is subtracted from 0, a 1 is borrowed from the
immediate higher significant bit.
Subtract (11001)2 (01110)2
11001
01110
(01011)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
25
Binary Subtraction
Subtract ( 1110.01)2 From (10111.10)2
10111.10
1110.01
(1001.01)2
Subtract (110.1)2 from (1011.011)2
(100.111)2
Subtract (1101.01)2 from (10000.001)2
(10.111)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
26
Binary Multiplication
Multiply 10112 by 1012
1011
x101
1011
0000
1011
110111
Multiply 100.1102 by 11.1012
Multiply 1111012 by 100012
100.110
x11.101
100110
000000
100110
100110
100110
10001.001110
100000011012
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
27
Binary Division
Divide the binary number 100100012 by 1012
101] 10010001
11101
101
1000
101
110
101
101
101
0
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
28
Binary Division
Cont.,
Divide the binary number 110111110012 by 11112
(1110111)2
Divide the binary number 10001.001102 by 11.0012
11001] 1000100110
101.10
11101 ] 10001001110
11001
[ 100110
100101
11101
101011
11001
11101
11001
11101
11001
11101
0
0
Divide the binary number (10001.001110)2 by (111.01)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
29
Octal addition
Add ( 46)8 and (26)8
Add ( 456)8 and (123)8
1
46
26
11
456
123
(74)8
(601)8
Add (13255)8 and (7031)8
(22306)8
Add (123.456)8 (4635.01)8 and (37.25)8
(5017.736)8
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
30
Octal Subtraction
Subtract ( 124)8 - (63)8
124
-63
(41)8
Subtract (34.35)8 from (56.23)8
(21.66)8
Subtract (5234.17)8 from (7102.36)8
(1646.17)8
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
31
Octal Multiplication
Multiply 128 by 178
12
x17
106
12
226
Multiply 4138 by 158
66178
Multiply 23.128 by 4.178
23.12 x 4.17
20606
2312
11450
11
121.0726
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
32
Octal Division
Divide the octal number 278 by 58
5] 27 [ 4
-24
3
Divide the octal number 66178 by 158
(413)8
Divide the octal number 2268 by 128
178
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
33
Hexadecimal addition
Add ( 76)16 and (59)16
Add ( E498)16 and (473)16
76
59
1
E498
473
(CF)16
Add (A895)16 and (7031)16
(E90B)16
(118C6)16
Add (123.456)16 (4695.01)16 and (97.25)16
(484F.6B6)16
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
34
Hexadecimal Subtraction
Subtract ( 124)16 - (65)16
124
-65
(BF)16
Subtract (34.35)16 from (B6.23)16
(81.EE)16
Subtract (5234.17)16 from (8102.36)16
(2ECE.1F)16
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
35
Hexadecimal Multiplication
Multiply (15)16 by (16)16
15
x16
7E
15
1 CE
Multiply (64)16 by (19)16
(9C4)16
64 x 19
384
64
9C4
Multiply (23.45)16 by (4.17)16
(90.3F33)16
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
36
Hexadecimal Division
Divide the hexadecimal number (1CE)16 by (15)16
15] 1CE [ 16
-15
7E
-7E
0
Divide the Hexadecimal number (9C4)16
=6416
19 ] 9C4 [ 64
-96
64
by (19)16
-64
0
Divide the hexadecimal number 26AC16 by 1216
=22616
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
37
Complements
Complements are used in digital computer for simplifying the subtraction operation and for logical manipulations
There are two types of complements for each base r- system (1) the rs complement and (2) the (r-1) complements
1s complement:
The 1s complement of a binary number can be obtained by Subtracting each bit from 1. . (OR) The 1s complement
of a binary number can be obtained by changing all 1s to 0s and all 0s to 1s
Example: Find the 1s complement of (10101110)2
01010001
Find the 1s complement of (111001.10101)2
(000110.01010)
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
38
Complement
Cont.,
2s Complement: The 2s complement of a binary number can
be obtained by adding 1 to its 1s complement.
Example: Find the 2s complement of (1100011)2
1s complement
add
2s complement
0011100
1
0011101
Find the 2s complement of (10101000)2
2s complement
(01011000)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
39
9s Complement : The 9s complement of a decimal number can be obtain
Subtracting each digit from 9.
Example: Find the 9s complement of (5412)10
(4587)
or (104 -1-5412)
EX: Find the 9s complement of (6291)10
(3708)
EX: Find the 9s complement of (374.68)10
(625.31)
EX: Find the 9s complement of (25.639)10
(74.360)
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
40
10s Complement: The 10s complement of a decimal number can be
Obtained by adding 1 to its 9s complement
Example: Find the 10s complement of (237806)10
The 9s complement
add
762193
1
762194
0r (106 -237806)
Ex: Find the 10s complement of (0.3267)10
The 9s complement
add
0.6732
1
0.6733
0r (100 - 0.3267)
Ex: Find the 10s complement of (25.639)10
The 9s complement
add
74.360
1
74.361
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
0r (102 - 25.639)
41
7s Complement : The 7's complement of an octal number is obtained by
subtracting each digit from 7.
Example: Find the 7s complement of (5412)8
(2365)
EX: Find the 7s complement of (62037)8
(15740)
EX: Find the 7s complement of (374.125)8
(403.652)
EX: Find the 7s complement of (251036.1427)8
(526741.6350)
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
42
8s Complement: The 8s complement of a octal number can be
Obtained by adding 1 to its 7s complement
Example: Find the 8s complement of (237106)8
The 7s complement
add
8s complement
540671
1
540672
Ex: Find the 7s complement of (0.3267)8
The 7s complement
add
8s complement
0.4510
1
0.4511
Ex: Find the 8s complement of (25.634)8
The 7s complement
52.143
add
EC214 Digital Logic Design
1
J Ravindranadh
8s complement
Sr.Associ.Prof.
52.144
43
15s Complement : The 15's complement of an Hexadecimal number is
obtained by subtracting each digit from 15.
Example: Find the 15s complement of (5412)16
(ABED)
EX: Find the 15s complement of (62037)16
(9DFC8)
EX: Find the 15s complement of (374.125)16
(C8B.EDA)
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
44
16s Complement: The 16s complement of a hexadecimal number can
Obtained by adding 1 to its 15s complement
Example: Find the 16s complement of (237106)16
The 15s complement
add
16s complement
DC8EF9
1
DC8EFA
Ex: Find the 15s complement of (0.3267)16
The 15s complement
add
16s complement
0.CD98
1
0.CD99
Ex: Find the 16s complement of (25.639)16
The 15 s complement DA.9C6
add
1
DA.9C7
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
45
Subtraction using 1s Complement
Subtract ( 110010)2 - (100100)2 using 1s Complement method
1
1s Complement (100100)2
1
110010
+0 1 1 0 1 1
1001101
Carry
add carry +
1
001110
Subtract ( 100001)2 - (110)2 using 1s Complement method
1s Complement (110)2
Carry
add carry
100001
+ 111001
1011010
+
1
011011
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
46
Subtraction using 1s Complement
Subtract ( 1010.10)2 - (101.01)2 using 1s Complement method
1
1s Complement (101.01)2
10101.00
+
1
101.01
Carry
add carry
1
1010.10
+1 0 1 0 . 1 0
Subtract ( 10101.10)2 - (111.11)2 using 1s Complement method
1s Complement (111.11)2
Carry
add carry
10101.10
+ 11000.00
+
101101.10
1
01101.11
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
47
Subtraction using 1s Complement
Subtract ( 1010.10)2 - (1101.11)2 using 1s Complement method
1s Complement (1101.11)2
1010.10
+0 0 1 0 . 0 0
1100.10
no carry
1s Complement (1100.11)2
-11.01
Subtract ( 10101.10)2 - (11111.11)2 using 1s Complement method
10101.10
1s Complement (11111.11)2 + 0 0 0 0 0 . 0 0
1s Complement (10101.10)2
10101.10
( - 1 0 1 0.0 1)2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
no carry
48
Subtraction using 2s Complement
Subtract ( 110010)2 - (100100)2 using 2s Complement method
1
2s Complement (100100)2
Discard Carry
110010
+0 1 1 1 0 0
1001110
Subtract ( 100001)2 - (110)2 using 2s Complement method
2s Complement (110)2
Discard Carry
100001
+ 111010
1011011
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
49
Subtraction using 2s Complement
Subtract ( 1010.10)2 - (101.01)2 using 2s Complement method
1
2s Complement (101.01)2 +
Discard Carry
1
1010.10
1010.11
10101.01
Subtract ( 10101.10)2 - (111.11)2 using 2s Complement method
2s Complement (111.11)2
Discard Carry
10101.10
11000.01
101101.11
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
50
Subtraction using 2s Complement
Subtract ( 101110.111)2 - (111011.101)2 using 2s Complement method
2s Complement (111011.101)2
101110.111
+ 000100.011
2s Complement (1 1 0 0 1 1 . 0 1 0 )2
110011.010
=-1100.110
Subtract ( 10101.101)2 - (11000.11)2 using 2s Complement method
2s Complement (11000.11)2
2s Complement (11100.111)2
10101.101
+ 00111.010
11100.111
= -1 1 . 0 0 1
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
51
Comparison between 1s and 2s
complements
The 1s complement can be easily obtained using an inverter. The
2s complement can obtained by adding 1 to its 1s complement.
The advantage in the 2s complement system is that only one
arithmetic
operation is required; the 1s complement requires two
operations.
While the 1s complement is often used in logical manipulations
for inversion operation, the 2s complement is used only for
arithmetic applications.
the range of the numbers that are represented in 1s and 2s
complemnents of a given number N is -(2 N-1-1) to +(2N-1-1) and -(2N1) to +(2 N-1-1)
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
52
Subtraction using 9s Complement
Subtract ( 83)10 - (25)10 using 9s Complement method
9s complement (25)
83
+7 4
157
Carry
add carry
Subtract ( 5250)10 - (321)10
1
58
using 9s Complement method
5250
9s complement (321)
+9 6 7 8
14928
Carry
add carry
+
1
4929
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
53
Subtraction using 9s Complement
Subtract ( 20)10 - (1000)10 using 9s Complement method
0020
9s complement(1000) +8 9 9 9
9019
no carry 9 complement (9 0 1 9)
=-0980
Subtract ( 124 )10 - (456)10 using 9s Complement method
124
9s complement (456)
543
667
9 complement of (6 6 7) = - 3 3 2
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
54
Subtraction using 10s Complement
Subtract ( 3570)10 - (2100)10 using 10s Complement method
3570
+7900
10 s Complement (2100)10
114 70
Discard Carry
Subtract ( 72532)10 - (3250)10 using 10s Complement method
72532
+96750
10 s Complement (3250)10
169282
Discard Carry
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
55
Subtraction using 10s Complement
Subtract ( 753)10 - (864)10 using 10s Complement method
10s Complement (864)2
753
+ 1 3 6
889
no carry
10s complement = - 1 1 1
Subtract ( 345)10 - (864)10 using 10s Complement method
345
10s Complement (864)
+136
481
10s Complement
= -519
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
no carry
56
CODES
Binary Coded Decimal (BCD) (or )
8421
Excess-3 Code (or )Ex-3 code
Gray Code (or) Reflected Code (or)
unit distance Code (or) cyclic code
Alphanumerical Code
Error Detection Code
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
57
Binary Coded Decimal
BCD uses the binary number system to specify the decimal numbers
0 to 9.
BCD represent each digit in 4 bit form. It is also called 8 4 2 1 code.
The weights of the first positions is 1, the second position 2, third
position is 4 and fourth position is 8 reading from left to right, hence
it is also called as weighted code.
There are six illegal combinations in BCD code they are 1010, 1011,
1100, 1101,1110 and 1111.
Example:
(31)10 = 0011 0001 BCD
= 11111
Binary
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
58
Binary Coded Decimal
The advantage of a BCD code is that it is easy for conversion BCD
to decimal and vice-versa.
The disadvantage is less efficient than the pure binary and its
requires more bits. Another disadvantage is that, arithmetic
operations are more complex than they are in pure binary.
BCD code is used in pocket calculators, electronic counters, digital
voltmeters , digital cocks etc.,
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
59
Excess-3 code
The Ex-3 code can be obtained add 3 to the each decimal digit before converting it
into equivalent binary.
Example:
(90)10
+3 +3
1100 0011 EX-3 code
The ex-3 code has six invalid states 0000, 0001, 0010, 1101, 1110, 1111
Excess-3 code is also called unweighted code.
Ex-3 code is called self complementary code . 9s complement of code word i.e 9
N equal to the 1 complement of the code word .
Example : (4)10
9s complement = 9 4 = 5 code word 5+3= 1000
code word = 4 +3 = 0111, 1 complement codeword=1000
only four positively weighted self complement codes namely (2 4 2 1) (3 3 2 1) ( 4 3
1 1) ( 5 2 1 1).there exist 13 self complementing codes with positive and negative
weight
60
Gray (or) Reflected (or) cyclic code
Binary to gray conversion :
MSB of gray code is same as MSB of the binary number
Add MSB of the binary to the next bit in binary write the sum
and ignoring the carry. Add the 2nd bit to the 3rd bit of the
binary and so on, write the successive sums.
Decimal
Binary
Gray
0111
0100
0000
1000
1100
0001
0001
1001
1101
0010
0011
10
1010
1111
0011
0010
11
1011
1110
0100
0110
12
1100
1010
0101
0111
13
1101
1011
0110
0 1 0 1 J Ravindranadh
Decima Binar
l
y
Gray
0000
EC214 Digital Logic Design
Sr.Associ.Prof.
61
Gray code
In gray code any two adjacent code groups differ only in one bit
position.
Gray code also called reflected code because the two least
significant bits for decimal 4 through 7 are the mirror images of
those for 0 through 3. Similarly the three least significant bits
from 8 to 15 are the mirror image of those for 0 through 7.
Gray codes are used in instrumentation and data acquisition
system where linear or angular displacement is measured.
They are also used in shaft encoders, I/O devices, A/D converters
and other peripheral equipment.
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
62
Gray code
Convert the following binary number into gray code
(a) 1 1 0 1 1 0 (b) 1 1 0 0 1 0 1 0 ( c ) 1 0 1 1 1 0 1 1
101101
10101111
11100110
Gray to Binary conversion
Convert ( 1 0 1 0 1 1 1 )Gray to binary
1
0
+
1
+
1
0
+
0
1
+
0
1
+
1
+
Convert the following gray number into binary code
(a)
11
01
00
11
10
0 1 (b) 11 01 10 00 11 10 ( c )1110010011011101
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
63
Alphanumeric code
The most popular modern alphanumeric codes are
(1) ASCII (2) EBCDIC code
ASCII code: American Standard Code for Information Interchange code.
This is basically a 7-bit code. The number of different bit patterns that can be
crated with 7 bit is 27 = 128.
The ASCII can be used to encode both the lowercase and uppercase characters
of the alphabet and some special symbols in addition to 10 decimal digits.
EBCDIC : Extended Binary Coded Decimal Interchange Code. This is 8 bit code
The number of different bit patterns can be crated with 8 bit is 28 = 256.
It encodes many other symbols in addition to ASCCI.
The use of Alphanumeric code for transmitting data between computers and
its I/O devices such as printers, key boards and video display terminals.
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
64
Error Detection Code
An error detection code can be used to detect errors during
transmission adding the extra bit known as the parity bit.
There are two types of parity (1) odd parity and (2) even parity
ODD PARITY: the parity bit set to 0 or 1 at the transmitter such that
the total number of 1s in the word including the parity bit is an odd
number.
EVEN PARITY: the parity bit set to 0 or 1 at the transmitter such that
the total number of 1s in the word including the parity bit is an even
Messag odd even
number.
1010
1
1111
0
1111
1
EC214 Digital Logic Design
J Ravindranadh
Sr.Associ.Prof.
65