CE 1111
Logic Design
Course Description
This is core course of Electrical and Electronic Engineering and
Computer Engineering that presents basic tools for the design of
digital circuits.
● It serves as a building block in many disciplines that utilize data of
digital nature like digital control, data communication, digital computers
etc.
Course Description:
● History and overview, Numbers and conversions, Switching theory,
Boolean Algebra, Combinational logic circuits, Function Optimization,
Modular design of combinational circuits, Memory elements, Sequential
logic circuits, Finite State Machines (FSMs) models, state diagrams, state
tables, state reduction and state assignment .
Textbook: Digital Design, M. Morris Mano and Michael D.
Ciletti, 6th edition, 2017
Pre-requisite : None
Course Learning Outcomes:
Students will be able to
1. Convert between different number systems and perform binary addition
and subtraction using 1’s complement and 2’s complement
representations.
2. Recall the axioms and laws of Boolean algebra and apply them for logic
functions.
3. Analyse any logic circuit to obtain the logic function and truth table.
4. Use the Karnaugh map to perform an algorithmic reduction of logic
functions.
5. Design any combinational logic circuit and examine the following
combinational components: encoders/decoders, multiplexers, exclusive-
ORs, comparators.
6. Recognize the operation of latches and flip-flops and be able to analyze
and design different sequential circuits.
Class Notes and Grading
Class notes may be picked up by student
representative. Students should use these notes
as the definitive guide to what they are expected
to know for the course.
Grading
● Midterm 1: 20%
● Midterm 2: 20%
● Quizzes and Assignments : 20%
● Final Exam: 40%
Course Outlines
ChI: Digital systems, Number systems, Codes and Conversion.
ChII: Boolean algebra: axioms and theorems and functions
forms and conversion.
ChIII: Gate level minimization methods.
ChIV: Combinational logic: analysis and design.
ChV: Sequential logic: latches and flip-flops, circuit analysis
and design
ChVI: Sequential logic applications: registers and counters
ChVII: Review
Chapter 1: Digital Systems
and Binary Numbers
Analog signal
The analog signals were used in many systems to produce signals to
carry information.
These signals are continuous in both values and time. The use of
analog signals has been declined with the arrival of digital signals.
In short, to understand the analog signals – all signals that are natural
or come naturally are analog signals.
Examples: Human voice, natural sound, analog electronic devices are
few examples
Random Sine Wave Square Wave Human voice
(not digital) 7
Analog and Digital Signal
Analog system
• The physical quantities or signals may vary continuously over a
specified range.
Digital system
• The physical quantities or signals can assume only discrete values.
• Greater accuracy
X(t) X(t)
t t
Analog signal Digital signal 8
Why Digital Signal?
Analog Signals Digital Signals
Continuous Discrete
Infinite range of values Finite range of values (2)
More exact values, but Not as exact as analog,
more difficult to work with but easier to work with
Example:
A digital thermostat in a room displays a temperature of 72.
An analog thermometer measures the room temperature at
72.482. The analog value is continuous and more accurate,
but the digital value is more than adequate for the
application and significantly easier to process electronically.
9
Digital Systems and Binary Numbers
Digital age and information age
Digital computers
• General purposes
• Many scientific, industrial and commercial applications
Digital systems
• Telephone switching exchanges
• Digital camera
• Electronic calculators, PDA's
• Digital TV
Discrete information-processing systems
• Manipulate discrete elements of information
• For example, {1, 2, 3, …} and {A, B, C, …}…
10
Logic Levels
Before examining digital signals, we must define logic
levels.
A logic level is a voltage level that represents a defined
digital state.
Logic HIGH: The higher of two voltages, typically 5 volts
Logic LOW: The lower of two voltages, typically 0 volts
5.0 v
Logic Level Voltage True/False On/Off 0/1
HIGH 5 volts True On 1 Logic High
LOW 0 volts False Off 0
2.0 v
Invalid
Logic
0.8 v Level
0.0 v Logic Low 11
NUMBER SYSTEMS – Representation
i=n-1 j=-1
(Number)r =
å
i=0
Ai r + i
å
j=-m
Aj r j
(Integer Portion) + (Fraction Portion)
12
Decimal Number System
Base (also called radix) = 10
● 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Digit Position 2 1 0 -1 -2
● Integer & fraction 5 1 2 7 4
Digit Weight 100 10 1 0.1 0.01
● Weight = (Base) Position
Magnitude
500 10 2 0.7 0.04
● Sum of “Digit x Weight”
d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2
Formal Notation
(512.74)10
13
Binary Number System
Base = 2
● 2 digits { 0, 1 }, called binary digits or “bits”
Weights 4 2 1 1/2 1/4
● Weight = (Base) Position 1 0 1 0 1
2 1 0 -1 -2
Magnitude
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
● Sum of “Bit x Weight”
=(5.25)10
Formal Notation
(101.01)2
Groups of bits 4 bits = Nibble
1011
8 bits = Byte
11000101
14
Octal Number System
Base = 8
● 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights 64 8 1 1/8 1/64
● Weight = (Base) Position 5 1 2 7 4
2 1 0 -1 -2
Magnitude
5 *82+1 *81+2 *80+7 *8-1+4 *8-2
● Sum of “Digit x Weight”
=(330.9375)10
Formal Notation
(512.74)8
15
Hexadecimal Number System
Base = 16
● 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights 256 16 1 1/16 1/256
● Weight = (Base) Position 1 E 5 7 A
2 1 0 -1 -2
Magnitude
1 *162+14 *161+5 *160+7 *16-1+10 *16-2
● Sum of “Digit x Weight”
=(485.4765625)10
Formal Notation
(1E5.7A)16
16
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
6 26=64 30 230=1G Giga
7 27=128 40 240=1T Tera
17
Addition
Decimal Addition
1 1 Carry
5 5
+ 5 5
1 1 0
= Ten ≥ Base
Subtract a Base
18
Binary Addition
Column 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
≥ (2)10
20
Binary Subtraction
Borrow a “Base” when needed
1 0 0 1 1 0 1
− 1 0 1 1 1
21
Binary Subtraction
Borrow a “Base” when needed
= (10)2
0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
1 0
22
Binary Subtraction
Borrow a “Base” when needed
2 = (10)2
0 0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
1 1 0
23
Binary Subtraction
Borrow a “Base” when needed
2 = (10)2
0 0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
0 1 1 0
24
Binary Subtraction
Borrow a “Base” when needed
2 = (10)2
0 2 0 0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
0 1 1 0
25
Binary Subtraction
Borrow a “Base” when needed
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
1 0 1 1 0
26
Binary Subtraction
Borrow a “Base” when needed
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1
− 1 0 1 1 1
1 1 0 1 1 0
27
Binary Subtraction
Borrow a “Base” when needed
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
28
Binary Multiplication
Bit by bit
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
29
Number Base Conversions
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
Magnitude 30
Binary, Octal, Hex to Decimal Conversion
Magnitude
dndn-1…………d2d1d0,d-1d-2………… d-m
dn*Bn+ dn-1*Bn-1 ……+ d2*B2+d1*B1+ d0*B0+d-1*B-1+d-2*B-2 +……….+d-m*B-m
Examples:
(10010,11)2= 1*24+ 1*21+ 1*2-1+ 1*2-2 = (18, 75)10
(127,25)8= 1*82+ 2*81+ 7*80+ 2*8-1+ 5*8-2 = (87, 328125)10
31
2 1 0 -1
Decimal (Integer) to Binary Conversion
Divide the number by the ‘Base’ (=2)
Take the remainder (either 0 or 1) as a coefficient
Take the quotient and repeat the division
Example: (13)10
Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2
MSB LSB 32
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 Fraction 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
MSB LSB
33
Decimal to Octal Conversion
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
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
34
Decimal to Hexadecimal Conversion
Example: (361)10
Quotient Remainder Coefficient
361 / 16 = 22 9 a0 = 9
22 / 16 = 1 6 a1 = 6
1 / 16 = 0 1 a2 = 1
Answer: (361) 10 = (a2 a1 a0)16 = (169)16
Example: (0. 078125)10
Integer Fraction Coefficient
0. 078125 * 16 = 1 . 25 a-1 = 1
0.25 * 16 = 4 . 0 a-2 = 4
Answer: (0. 078125)10 = (0.a-1 a-2 a-3)16 = (0.14)16
35
Binary − Octal Conversion
8 = 23 Octal Binary
Each group of 3 bits represents 0 000
an octal digit 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)
36
Binary − Hexadecimal Conversion
16 = 24 Hex Binary
0 0000
1 0001
Each group of 4 bits represents 2 0010
a hexadecimal digit 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
E 1110
F 1111
Works both ways (Binary to Hex & Hex to Binary)
37
Octal − Hexadecimal Conversion
Convert to Binary as an intermediate step
Example:
( 2 6 . 2 )8
Assume Zeros
( 0 1 0 1 1 0 . 0 1 0 )2
Assume Zeros
( 1 6 . 4 )16
Works both ways (Octal to Hex & Hex to Octal)
38
Decimal, Binary, Octal and Hexadecimal
Decimal Binary Octal Hex
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
39
Complements
1’s Complement (Diminished Radix Complement)
● All ‘0’s become ‘1’s
● All ‘1’s become ‘0’s
Example (10110000)2
(01001111)2
If you add a number and its 1’s complement …
10110000
+ 01001111
11111111
40
Complements
2’s Complement (Radix Complement)
● Take 1’s complement then add 1
OR
● Toggle all bits to the left of the first ‘1’ from the right
Example:
Number: 10110000 10110000
1’s Comp.:
01001111
+ 1
01010000 01010000
41
Negative Numbers
Computers Represent Information in ‘0’s and ‘1’s
● ‘+’ and ‘−’ signs have to be represented in ‘0’s and ‘1’s
3 Systems
● Signed Magnitude
● 1’s Complement
● 2’s Complement
All three use the left-most bit to represent the sign:
♦ ‘0’ positive
♦ ‘1’ negative
42
Signed Magnitude Representation
Magnitude is magnitude, does not change with sign
S Magnitude (Binary)
(+3)10 ( 0 0 1 1 )2
(−3)10 ( 1 0 1 1 )2
Sign Magnitude
Can’t include the sign bit in ‘Addition’
0 0 1 1 (+3)10
+ 1 0 1 1 (−3)10
1 1 1 0 (−6)10
43
1’s Complement Representation
Positive numbers are represented in “Binary”
0 Magnitude (Binary)
Negative numbers are represented in “1’s Comp.”
1 Code (1’s Comp.)
(+3)10 (0 011)2
(−3)10 (1 100)2
There are 2 representations for ‘0’
(+0)10 (0 000)2
(−0)10 (1 111)2
44
1’s Complement Range
4-Bit Representation Decimal 1’s Comp.
+7 0111
4 +6 0110
2 = 16 Combinations
+5 0101
− 7 ≤ Number ≤ + 7 +4 0100
+3 0011
−23+1 ≤ Number ≤ +23 − 1 +2 0010
+1 0001
n-Bit Representation +0 0000
−0 1111
n−1 n−1 −1 1110
−2 +1 ≤ Number ≤ +2 −1 −2 1101
−3 1100
−4 1011
−5 1010
−6 1001
−7 1000
45
2’s Complement Representation
Positive numbers are represented in “Binary”
0 Magnitude (Binary)
Negative numbers are represented in “2’s Comp.”
1 Code (2’s Comp.)
(+3)10 (0 011)2
(−3)10 (1 101)2
There is 1 representation for ‘0’ 1’s Comp. 1111
(+0)10 (0 000)2 + 1
(−0)10 (0 000)2 1 0000
46
2’s Complement Range
4-Bit Representation Decimal 2’s Comp.
+7 0111
4 +6 0110
2 = 16 Combinations
+5 0101
− 8 ≤ Number ≤ + 7 +4 0100
+3 0011
−23 ≤ Number ≤ + 23 − 1 +2 0010
+1 0001
n-Bit Representation +0 0000
−1 1111
n−1 n−1 −2 1110
−2 ≤ Number ≤ + 2 −1 −3 1101
−4 1100
−5 1011
−6 1010
−7 1001
−8 1000
47
Number Representations
4-Bit Example
Unsigned Signed
1’s Comp. 2’s Comp.
Binary Magnitude
Range 0 ≤ N ≤ 15 -7 ≤ N ≤ +7 -7 ≤ N ≤ +7 -8 ≤ N ≤ +7
0 0 0
Positive
Binary Binary Binary Binary
1 1 1
Negative X
Binary 1’s Comp. 2’s Comp.
48
Binary Subtraction Using 1’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1 (5)10 – (1)10 (5)10 – (6)10
then add it to the (+5)10 + (-6)10
(+5)10 + (-1)10
LSB, and the result
is positive 0101 0101
(in Binary) + 1110 + 1001
If “Carry” = 0
1 0011 0 1110
then the result
+
is negative
(in 1’s Comp.) 0100 1110
+4 −1
49
Binary Subtraction Using 1’s Comp. Addition
Change
“Subtraction” to
“Addition”
If “Carry” = 1
then add it to the
LSB, and the result
is positive
(in Binary)
If “Carry” = 0
then the result
is negative
(in 1’s Comp.)
Binary Subtraction Using 2’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1 (5)10 – (1)10 (5)10 – (6)10
ignore it, and the (+5)10 + (-6)10
(+5)10 + (-1)10
result is positive
(in Binary) 0101 0101
If “Carry” = 0 + 1111 + 1010
then the result
1 0100 0 1111
is negative
(in 2’s Comp.) +4 −1
51
Binary Codes
Group of n bits
● Up to 2n combinations
● Each combination represents an element of information
Binary Coded Decimal (BCD) Decimal BCD
0 0000
● Each Decimal Digit is represented 1 0001
by 4 bits 2 0010
3 0011
● (0 – 9) Valid combinations 4 0100
5 0101
● (10 – 15) Invalid combinations 6 0110
7 0111
8 1000
9 1001
53
DECIMAL CODES - Binary Codes for Decimal
Digits
Note: 8,4,2,-2,1,-1 in this table is the weight associated
with each bit position.
d3 d2 d1 d0: symbol in the codes
BCD: d3 x 8 + d2 x 4 + d1 x 2 + d0 x 1
2421: d3 x 2 + d2 x 4 + d1 x 2 + d0 x 1
84-2-1: d3 x 8 + d2 x 4 + d1 x (-2) + d0 x (-1)
Excess-3: BCD + 3
54
DECIMAL CODES - Binary Codes for Decimal
Digits
55
Binary Codes
The BCD code is the 8,4,2,1 code.
8, 4, 2, and 1 are weights
Do NOT mix up conversion of a decimal number to a
binary number with coding a decimal number with a
BINARY CODE.
(13)10 = 11012 (This is conversion)
(13)10 0001|0011 (This is BCD coding)
56
BCD Addition
One decimal digit + one decimal digit
● If the result is 1 decimal digit ( ≤ 9 ), then it is a simple
binary addition
5 0101
Example:
+ 3 + 0011
8 1000
● If the result is two decimal digits ( ≥ 10 ), then binary
addition gives invalid combinations
Example:
5 0101
+ 5 + 0101
0001 0000 10 1010 57
BCD Addition
If the binary result 5 0101
is greater than 9,
+ 5 + 0101
correct the result by
adding 6 10 1010
+ 0110
0001 0000
Multiple Decimal Digits
Two Decimal Digits
351
0011 0101 0001
58
Example -BCD addition
1 2 3
599 0101 1001 1001
+ +
984 1001 1000 0100
1583 1110 10001 1101
Binary Sum 1, 2 and 3 are greater than 1010.
So, from Step 3 and 4 add ‘6’ to the sum.
Carry 1 1
Result 1110 10001 1101
+ 0110 0110 0110
1 0101 1000 0011
1 5 8 3
Exercise: add 599 + 484 using BCD addition
60
Gray Code
One bit changes from one code to
the next code Decimal Gray Binary
00 0000 0000
01 0001 0001
02 0011 0010
03 0010 0011
04 0110 0100
05 0111 0101
06 0101 0110
07 0100 0111
08 1100 1000
09 1101 1001
10 1111 1010
11 1110 1011
12 1010 1100
13 1011 1101
14 1001 1110
15 1000 1111
61
GRAY CODE – Decimal
62