Lecture04-Introduction To Logic
Lecture04-Introduction To Logic
1
Overview
• This Lecture
– Introduction to Digital Logic
• Gates
• Boolean algebra
– Combinatorial Logic
– Source: Chapter 11 (10th edition)
• Next Lecture
– Sequential Logic
2
Basic Logic Gates
• Basic logic Gates
3
NOT Gate (or Inverter)
A Q
0 1
Q=Ā
1 0
4
How Many Functions
• How many functions are there of 1 binary input with 1
binary output?
A Q A Q A Q A Q
0 0 0 0 0 1 0 1
1 0 1 1 1 0 1 1
5
AND Gate
A B Q
0 0 0 Q=A·B
0 1 0 Can be extended:
Q=A·B·C
1 0 0
·...
1 1 1
6
NAND (AND then NOT)
A B Q
0 0 1
0 1 1
1 0 1 Q =𝐀·𝐁
1 1 0
(a) Circuit symbol (b) Truth Table (c) Boolean expression
7
OR
A B Q
0 0 0
Q=A+B
0 1 1 Can be extended
Q=A+B+
1 0 1 C+...
1 1 1
8
NOR (or then not)
A B Q
0 0 1
0 1 0 Q=𝐀+𝐁
1 0 0
1 1 0
(a) Circuit symbol (b) Truth Table (c) Boolean expression
9
EOR / XOR Gate (exclusive or)
A B Q
0 0 0
0 1 1
1 1 0
(b) Truth Table
(c) Boolean expression
10
Introduction to Combinatorial Logic
• Combinatorial logic circuit - one whose outputs are
dependent only on the inputs
• Assume the outputs respond immediately
• In real circuits, propagation delays must be considered
– Hence the clock-cycle on your PC
11
Defining a Combinatorial Circuit
• Truth table
– For each of the 2n possible combinations of input signals, the
binary value of each of the m outputs is listed
• Boolean equations
– Each output signal is expressed as a Boolean function of its input
signals
12
1-Bit Half Adder A 1-bit
Sum
S
half adder
B Carry
C
A B CS
0 0 00
S=A•B+A•B
0 1 01 = A xor B
1 0 01 C=A•B
= A and B
1 1 10
(a) Truth Table (b) Circuit symbol (c) Boolean expression
13
Full Adder
Inputs Outputs
A B Cin Cout S
000 0 0
100 0 1
010 0 1
110 1 0
001 0 1
101 1 0
011 1 0 (b) Circuit symbol
111 1 1
(a) Truth Table 14
Ripple Carry Adder
15
Boolean Algebra
• Boolean Constants
• These are ‘0’ (false) and ‘1’ (true)
• Boolean Variables
• Variables that only take the values ‘0’ or ‘1’
• Boolean Functions
• Each of the logic functions (such as AND, OR and NOT are
represented by symbols as described previously)
• Boolean Theorems
• As set of identities and laws as will be shown next
Boolean Algebra laws
Identity Proposition
A+0=A
A+1=1
Operator Precedence
A•1=A
- (NOT) 1
A•0=0
• (AND) 2
Inverse Proposition
+ (OR) 3
A + Ā= 1 A • Ā= 0
Commutative Proposition
A•B=B•A A+B=B+A
Distributive Proposition
A • (B + C) = (A • B) + (A • C) A + (B • C) = (A + B) • (A + C)
17
Boolean Algebra (cont)
(AB)’ = A’ + B’
Same expression to
(A + B)’ = A’ * B’
19
Proof by Truth Table
20
De Morgan
• Equations of 1-bit half adder requires 2 AND gates, 1 OR
gate, and 2 NOT gates
21
NAND Logic
• NOT
• AND
• OR
23
NAND Logic
• NAND
• NOR
• XOR
24
Example: 3-Bit Parity Generator
A
Parity
Generator P
B
25
Example (cont): 3-Bit Parity
Generator
• Boolean Equation A B C P
0 0 0 0 1
– In ‘sum of products form’
1 0 0 1 0
• In which rows does p=1
2 0 1 0 0
• What are the inputs on those rows
3 0 1 1 1
4 1 0 0 0
5 1 0 1 1
6 1 1 0 1
7 1 1 1 0
26
Example (cont): 3-Bit Parity
Generator
27
7-Segment Decimal Decoder
Example
28
C
Transistor B
29
NAND Gate
• For Q to be Low (binary 0)
– A and B must be closed
• Otherwise Q
– If A is open
+5V
A
• +5V flows to Q
– If A is closed but B is open
• +5V flows to Q
– If A and B are closed B
• “short circuit Q”
30
Electronic Switch
• How about a switch that we can
– turn on and off with a control C
line (C)
•Output (Q) = Input (A) iff C = 1
A Switch Q
C
• This is the same as an AND gate
A Q
31
Flip-flops
• Consider the following circuit:
34
Demultiplexer
• The demultiplexer works in reverse
– One of the outputs (Y0-Y3) is selected (sel1-sel2) for input
• Imagine INPUT is 1-bit value and sel selects where to
store the value
35
Multiplexing
• Imagine using 1 wire to carry 5 conversations
36
Summary
• You computer consist of different logic gates:
- Not
- AND
- NAND
- OR
- NOR
- XOR