Chapter 3
Chapter 3
Chapter 3
Digital Logic
Structures
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-2
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Switch open:
No current through circuit
Light is off
Vout is +2.9V
Switch closed:
Short circuit across switch
Current flows
Light is on
Vout is 0V
Gate = 0
Terminal #2 must be
connected to GND (0V).
3-4
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Gate = 1
Gate = 0
Terminal #1 must be
connected to +2.9V.
3-5
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Logic Gates
Use switch behavior of MOS transistors
to implement logical functions: AND, OR, NOT.
Digital symbols:
recall that we assign a range of analog voltages to each
digital (logic) symbol
CMOS Circuit
Complementary MOS
Uses both n-type and p-type MOS transistors
p-type
Attached to + voltage
Pulls output voltage UP when input is zero
n-type
Attached to GND
Pulls output voltage DOWN when input is one
For all inputs, make sure that output is either connected to GND or to +,
but not both!
3-7
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Truth table
In Out In Out
0 V 2.9 V 0 1
2.9 V 0V 1 0
3-8
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
NOR Gate
A B C
0 0 1
0 1 0
1 0 0
1 1 0
Note: Serial structure on top, parallel on bottom. 3-9
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
OR Gate
A B C
0 0 0
0 1 1
1 0 1
1 1 1
3-10
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
A B C
0 0 1
0 1 1
1 0 1
1 1 0
Note: Parallel structure on top, serial on bottom. 3-11
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
AND Gate
A B C
0 0 0
0 1 0
1 0 0
1 1 1
3-12
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-13
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
DeMorgan's Law
Converting AND to OR (with some help from NOT)
Consider the following gate:
To convert AND to OR
A B A B A B A B (or vice versa),
0 0 1 1 1 0 invert inputs and output.
0 1 1 0 0 1
1 0 0 1 0 1
1 1 0 0 0 1
Same as A+B!
3-14
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-15
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Summary
MOS transistors are used as switches to implement
logic functions.
n-type: connect to GND, turn on (with 1) to pull down to 0
p-type: connect to +2.9V, turn on (with 0) to pull up to 1
DeMorgan's Law
Convert AND to OR (and vice versa)
by inverting inputs and output
3-16
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-17
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Decoder
n inputs, 2n outputs
exactly one output is 1 for each possible input pattern
2-bit
decoder
3-18
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Multiplexer (MUX)
n-bit selector and 2n inputs, one output
output equals one of the inputs, depending on selector
4-to-1 MUX
3-19
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Full Adder
Add two bits and carry-in,
produce one-bit sum and carry-out. A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
3-20
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Four-bit Adder
3-21
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Logical Completeness
Can implement ANY truth table with AND, OR, NOT.
A B C D
0 0 0 0
0 0 1 0 1. AND combinations
that yield a "1" in the
0 1 0 1
truth table.
0 1 1 0
1 0 0 0
1 0 1 1 2. OR the results
1 1 0 0 of the AND gates.
1 1 1 0
3-22
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-23
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 0 0 1
0
1 1
1 0
0
1 Output changes to zero.
1
1 0
1
0 1
0
0
0 1
1 0
R=S=0
both outputs equal one
final state determined by electrical properties of gates
Dont do it!
3-27
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Gated D-Latch
Two inputs: D (data) and WE (write enable)
when WE = 1, latch is set to value of D
S = NOT(D), R = D
when WE = 0, latch holds previous value
S = R = 1
3-28
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Register
A register stores a multi-bit value.
We use a collection of D-latches, all controlled by a common
WE.
When WE=1, n-bit value D is written to register.
3-29
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
A = 0101001101010101
Memory
Now that we know how to store bits,
we can build a memory a logical k m array of
stored bits.
Address Space:
k = 2n
number of locations locations
(usually a power of 2)
Addressability:
number of bits per location m bits
(e.g., byte-addressable)
3-31
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
22 x 3 Memory
word select word WE input
address
bits
write
enable
address
decoder
output bits 3-32
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
State Machine
Another type of sequential circuit
Combines combinational logic with storage
Remembers state, and changes output (and state)
based on inputs and current state
State Machine
Storage
Elements
3-34
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
30
25 5
4 1 8 4 20 10
15
Combinational Sequential
Success depends only on Success depends on
the values, not the order in the sequence of values
which they are set. (e.g, R-13, L-22, R-3).
3-35
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
State
The state of a system is a snapshot of
all the relevant elements of the system
at the moment the snapshot is taken.
Examples:
The state of a basketball game can be represented by
the scoreboard.
Number of points, time remaining, possession, etc.
The state of a tic-tac-toe game can be represented by
the placement of Xs and Os on the board.
3-36
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-37
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
State Diagram
Shows states and
actions that cause a transition between states.
3-38
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
3-39
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Clock
Frequently, a clock circuit triggers transition from
one state to the next.
1
0
One time
Cycle
3-40
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
State Machine
Storage
Clock Elements
3-41
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Storage
Each master-slave flipflop stores one state bit.
Examples:
Sequential lock
Four states two bits
Basketball scoreboard
7 bits for each score, 5 bits for minutes, 6 bits for seconds,
1 bit for possession arrow, 1 bit for half,
3-43
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Complete Example
A blinking traffic sign
No lights on
1 & 2 on 3
1, 2, 3, & 4 on 4
1
1, 2, 3, 4, & 5 on 5
2
(repeat as long as switch
is turned on)
DANGER
MOVE
RIGHT
3-44
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Switch on
Switch off
State bit S1
State bit S0
Outputs
3-45
Transition on each clock cycle.
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Lights 3 and 4 In S1 S0 S1 S0
Light 5
0 X X 0 0
S1 S0 Z Y X 1 0 0 0 1
0 0 0 0 0 1 0 1 1 0
0 1 1 0 0 1 1 0 1 1
1 0 1 1 0 1 1 1 0 0
1 1 1 1 1
Whenever In=0, next state is 00.
3-46
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Master-slave
flipflop
3-47
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Combinational Logic
Decoders -- convert instructions into control signals
Multiplexers -- select inputs and outputs
ALU (Arithmetic and Logic Unit) -- operations on data
Sequential Logic
State machine -- coordinate control signals and data movement
Registers and latches -- storage elements
3-48
Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Combinational
Logic
Storage
State Machine
3-49