Lecture 3
Lecture 3
(WBCS010-05)
Lecture 3: Digital Logic Structures
Reza Hassanpour
[email protected]
Topics
› Digital Logic
› Logic Gates
› Combinational Logic
• Multiplexer
• Decoder
• Adder
› Sequential Logic
• S-R Latch
• D Latch
Digital Computers
› We use the term digital computer to refer to a device
that performs a sequence of computational steps on
data items that have discrete values.
A B A AND B A B A OR B A NOT A
0 0 0 0 0 0
0 1
0 1 0 0 1 1
1 0
1 0 0 1 0 1
1 1 1 1 1 1
Digital Logic
› Is the implementation of Boolean functions with
transistors where:
• Five volts represents Boolean 1 (true)
• Zero volts represents Boolean 0 (false)
› Voltage:
• Quantifiable property of electricity in the form of the
pressure that pushes charged electrons (current) through a
conducting loop.
• Unit: volt
› Current
• Measure of electron flow along a path
• Unit: ampere (amp)
Voltage/Current Analogy
7
A Simple Switch Circuit
› A wall switch determines whether current flows through the light bulb
› If switch is closed, current flows, lamp is ON, voltage across lamp is non-zero
› If switch is open, no current flows, lamp is OFF, voltage across lamp is zero
8
Transistor = Voltage-Controlled Switch 1
1.2 V
ON
OFF
9
Transistor = Voltage-Controlled Switch 2
› Consider the circuit below. The bar at the top represents the high
voltage rail and the triangle at the bottom represents ground (0V)
10
Transistor = Voltage-Controlled Switch 3
› Example:
› When input = 0, P-type transistor
turns on and N-type transistor
turns off. Output is connected to
+1.2V, so output = 1
Input Output
0 1
1 0
13
NOR Gate
A B C
0 0 1
0 1 0
C = NOT(A OR B)
1 0 0
1 1 0
14
OR Gate
A B C D
0 0 1 0
0 1 0 1
1 0 0 1
1 1 0 1
15
NAND and AND Gates
A B D
0 0 0
0 1 0 › AND
1 0 0
1 1 1
16
Standard Symbols for Logic Gates
› Instead of drawing the circuit diagram, we can abstract
these logic gates and give each a symbol. The bubble
indicates inversion (NOT).
17
Gates with more than one input
(a) A B C OUT
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
Challenge: Draw the CMOS circuit
1 1 0 0 for a 3-input AND gate
What about 4-input NOR gate?
1 1 1 1
18
Building Logic Circuits from Gates
19
Combinational Logic Circuits
20
Decoder
2-bit decoder
21
Example: Using Decoders to Display
Numbers on a Seven-Segment Display
Decoding BCD = 3
Turn On Segment e
e should be turned on when the input is 0, 2, 6, or 8
Encoder
› An encoder performs the
opposite of a decoder.
› Only one input of its n
inputs is 1 each time.
› The output (log2n) is the
binary representation of
the input.
Multiplexer (Mux)
› A mux has 2n data inputs, n select inputs, and one output
› The select bits are used to "choose" one of the data inputs to flow
through to the output
4-to-1 mux
4 input bits,
2 select bits
26
Full Adder (1-bit binary addition)
27
N-bit Adder
› Feed Cout from one bit into Cin of the next bit...
Bin A B D Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 0
0 1 1 0 0
1 0 0 1 1
1 0 1 0 1
1 1 0 0 0
1 1 1 1 1
Full Subtractor Using an 8 by 1 Multiplexer
Bin A B D Bout
0 0 0 0 0
0 0 1 1 1
0 1 0 1 0
0 1 1 0 0
1 0 0 1 1
1 0 1 0 1
1 1 0 0 0
1 1 1 1 1
Sequential Logic Circuits
33
Storing One Bit: R-S Latch
RESET
SET
R=S=1 R S Q'
Hold current value in latch 0 0 invalid
R = 0, S = 1
Clear/reset latch (value = 0) 0 1 0
1 0 1
R = 1, S = 0
Set latch (value = 1) 1 1 Q
Q' is output. Q is previous output
What about R = 0, S = 0?
Both outputs = 1, final state determined by electrical properties of the gates.
Don't do it!!! This set of inputs is prohibited and should never occur during the
operation of the latch.
37
D-Latch: Simpler Control for One-Bit Latch
› NOTE: This uses an R-S latch. R and S will never both be zero
38
Summary
› Digital logic is the implementation of Boolean
functions with transistors.
› Combination logic is a circuit where the output
depends on the input(s) only.
• Multiplexer
• Decoder
• Full adder/subtractor
› Sequential logic is a circuit where the output depends
on the input and the current state.
› Both combinational and sequential logic circuits are
required to design a digital computer.
Questions?