1 Lecture No. 3 Computer Logic Design Logic Gates
1
Lecture No. 3
Computer Logic Design
Logic Gates
2
Logic Gates• Logic Gates
– Basic building blocks of the digital circuits– Control flow of information– Represent Logical Operations (Functions)
• Fundamental Gates• AND, OR, NOT
• Characteristics• Operation of the gate (what it does)• Function/truth table• Timing diagram• Application example
3
AND Gate
• AND Gate– Standard logical symbol (ANSI/IEEE Standard 91-1984)
– Where F is the output and A,B,C……,N are the inputs of the gate
– Performs logical multiplication– The output is HIGH only when all the inputs are HIGH
NCBAF ....
BAF
4
AND Gate
• The logical operation of a gate can be expressed with a table that lists all input combinations with the corresponding outputs, known as truth table
• Truth table for a two input AND gate
Input Output
A B F
0 0 0
0 1 0
1 0 0
1 1 1
5
AND Gate• Timing Diagram - a graph that accurately displays the relationship of two or
more waveforms with respect to each other on a time basis
– Graphical representation of AND gate operation
t0 t4 t5 t6t1 t2 t3
A
B
F
6
AND Gate
• Application example of AND gate– Device (Stop-watch) enable/disable switch
– When the input B is set to HIGH (enabled), the clock signal is applied to the counter
U/D
Reset
B1
B8
Carry out
ENB
Counter
A
B
Clock Pulses
EnableDisable
7
OR Gate
• Standard logical symbol
• Performs Boolean Addition• The output is HIGH when one or more inputs are
HIGH
BAF
NCBAF ..
8
OR Gate
• Truth table for a two input OR gate
Input Output
A B F
0 0 0
0 1 1
1 0 1
1 1 1
9
OR Gate
• Timing diagram of the OR-Gate
t0 t4 t5 t6t1 t2 t3
A
B
F
10
OR Gate
• OR gate application example– Car door alarm system
– When all the doors are closed, 0000 is applied to the input of the OR gate
– When one or more doors are open, the output of OR gate is 1, which activates the alarm
Alarm
Front left door
Rear left door
Front right door
Rear right door
11
NOT Gate
• The standard logical symbol
• Performs the inversion or complementation• Changes one logic level to the opposite logic level• The bubble shows the negation
AF
12
NOT Gate
• Truth table for a NOT Gate
Input Output
A F
0 1
1 0
13
NOT Gate
• Timing diagram of NOT-Gate
t0 t4 t5 t6t1 t2 t3
A
F
14
NOT Gate
• NOT gate application example– 1’s complement
1 1 1 1
1 1 1 1
0 0
0 0
0
0 0
0
15
NAND Gate
• Contraction of NOT-AND
• Standard logic symbol
• Output is LOW only when all inputs are HIGH
• Bubble indicates ACTIVE LOW output
• Output level is opposite to that of the AND gate
BAF
NCBAF ....
BAF
NCBAF ....
E
16
NAND Gate
• The truth table for a two input NAND gate
InputMiddle Output Output
A B E F
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0
17
NAND Gate
• Timing diagram of NAND gate
t0 t4 t5 t6t1 t2 t3
A
B
F
18
NAND Gate
• NAND gate application example– Device Failure Alarm System
– When all the fans are working, the input to the NAND gate is 111 and the output is 0
– If any one of the fan stops working, the output of the NAND gate becomes 1, which activates the alarm
ALARM
19
NAND Gate as Negative-OR
• The truth table for a two input NAND gate looks awfully similar to an OR gate with the inputs inverted.
Input NAND Output
A B F
0 0 1
0 1 1
1 0 1
1 1 0
Input OR Output
A B F
1 1 1
1 0 1
0 1 1
0 0 0
20
NAND Gate as Negative-OR
Bubble signifies ACTIVE LOW INPUT
21
NAND Gate as a Universal Gate
• NAND gate can be used to perform all the fundamental gate operations (NOT, AND, OR)– Universal NAND gate
22
NAND as NOT Gate
Input Output
A B F
0 0 1
0 1 1
1 0 1
1 1 0
Join all the input pins of the NAND gate together
23
NAND as AND Gate
• Using NAND gate to perform the AND gate operation
• Remember NAND is NOT-AND. What if we inverse this one more level? NOT-(NOT-AND) = AND
• Accomplished by applying a NOT operation (implemented through NAND gate) to the output of the NAND gate
1 2
24
NAND as OR Gate
• Using NAND gate to perform the OR gate operation
– Can we form NOR gate as well?
25
NOR Gate
• Contraction of NOT-OR• The standard logic symbol
• Produces a LOW output when one or more of its input is HIGH
• Bubble indicates ACTIVE LOW output• The output logic is opposite to that of the OR gate
BAF
NCBAF ....
26
NOR Gate
• Truth table for a two input NOR gate
Input Output
A B F
0 0 1
0 1 0
1 0 0
1 1 0
27
NOR Gate
• Timing diagram of a NOR gate
t0 t4 t5 t6t1 t2 t3
28
NOR Gate
• Application as Washing Machine Controller
– If the machine lid is open or the water in the tub is below certain level or the machine is overloaded (weight of water and clothes in the tub is above certain limit), the output of corresponding sensor is set to 1, producing a 0 at the NOR gate output that switches the machine off
Switch
29
NOR Gate as Negative-AND
• The truth table for a two input NOR gate looks awfully similar to an AND gate with the inputs inverted.
Input NOR Output
A B F
0 0 1
0 1 0
1 0 0
1 1 0
Input AND Output
A B F
1 1 1
1 0 0
0 1 0
0 0 0
30
NOR Gate as Negative-AND
Bubble signifies ACTIVE LOW INPUT
31
NOR Gate as a Universal Gate
• NOR gate can be used to perform all the fundamental gate operations (NOT, AND, OR)– Universal NOR gate
32
NOR as NOT Gate
Input Output
A B F
0 0 1
0 1 0
1 0 0
1 1 0
Join all the input pins of the NOR gate together
33
NOR as OR Gate
• Using NOR gate to perform the OR gate operation• Remember NOR is NOT-OR. What if we inverse
this one more level? NOT-(NOT-OR) = OR
• Accomplished by applying a NOT operation (implemented through NOR gate) to the output of the NOR gate
34
NOR as AND Gate
• Using NOR gate to perform the AND gate operation
– Can we form NAND gate as well?
35
Review• The output of a logic gate is used to activate an
alarm whenever at least one of its inputs is LOW. Name the gate?
• Name the following gate?
• Name the following gate?
t0 t4 t5 t6t1 t2 t3
36
XOR Gate• Exclusive OR (XOR for short)
– Standard logic symbol
– This gate has only two inputs
– Logical expression
– The output is HIGH only when the two the inputs are at opposite logic level
BAF
37
XOR Gate
• The truth table for XOR Gate
Input Output
A B F
0 0 0
0 1 1
1 0 1
1 1 0
38
XOR Gate
• Timing diagram of XOR gate
t0 t4 t5 t6t1 t2 t3
39
XOR Gate
• Application example of XOR gate– Detecting odd parity
– Applying 0011 at the input A, B, C and D respectively generates 0 at the output of XOR gate 1, XOR gate 2 and XOR gate 3, indicating that number of 1s are not odd
– Applying 1011at the input generates a 1 at the output of XOR gate 3 indicating odd number of 1s
1
2
3
A
B
C
D
40
XNOR Gate
• Exclusive-NOR (XNOR for short)– Standard logic symbol
This gate has only two inputs– Logical expression
– The output is LOW only when the two inputs are at opposite logic level
BAF
41
XNOR Gate
• Truth table for XNOR gate
Input Output
A B F
0 0 1
0 1 0
1 0 0
1 1 1
42
XNOR Gate
• Timing diagram of XNOR gate
t0 t4 t5 t6t1 t2 t3
43
XNOR Gate
• Application example of XNOR gate– Detecting even parity
– Applying 1011 at the input A, B, C and D respectively generates 1 at the output of XOR gate 1, a 0 at the output of XOR gate 2 and a 0 at the output of XNOR gate 3, indicating that the number of 1s in the input sequence are not even
– Applying 0011 generates 1 at the XNOR gate output, indicating even number of 1s
1
2
3
A
B
C
D
44
Summary of logic gates• Fundamental logic gates
– AND– OR– NOT
• Universal gates– NAND– NOR
• Other gates– XOR– XNOR
• Standard logic symbol• Logical/Boolean expression• Truth table• Application example