Digital Logic Design Notes
Digital Logic Design Notes
Hexadeci
Binary mal
Quick Example
2510 = 110012 = 318 = 1916
Base
Binary to Decimal
• Technique
– Multiply each bit by 2n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Octal to Decimal
• Technique
– Multiply each bit by 8n, where n is the “weight” of
the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
• Technique
– Multiply each bit by 16n, where n is the “weight”
of the bit
– The weight is the position of the bit, starting from
0 on the right
– Add the results
Example
2 31 0
15 1
2
7 1
2
2 3 1
2 1 1
0 1
12510 = 11111012
Octal to Binary
Decimal Octal
Binary Hexadecimal
Octal to Binary
• Technique
– Convert each octal digit to a 3-bit equivalent
binary representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
Hexadecimal to Binary
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary
• Technique
– Convert each hexadecimal digit to a 4-bit
equivalent binary representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Decimal to Octal
Decimal Octal
Binary Hexadecimal
Decimal to Octal
• Technique
– Divide by 8
– Keep track of the remainder
Example
123410 = ?8
8 1234
154 2
8
19 2
8
2 3
8
0 2
123410 = 23228
Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal
• Technique
– Divide by 16
– Keep track of the remainder
Example
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
Binary to Octal
Decimal Octal
Binary Hexadecimal
Binary to Octal
• Technique
– Group bits in threes, starting on right
– Convert to octal digits
Example
10110101112 = ?8
1 3 2 7
10110101112 = 13278
Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
• Technique
– Group bits in fours, starting on right
– Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
Octal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
• Technique
– Use binary as an intermediary
Example
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
• Technique
– Use binary as an intermediary
Example
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
Common Powers (1 of 2)
• Base 10 Power Preface Symbol Value
10-12 pico p .000000000001
A B A+ B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
Binary Addition (2 of 2)
• Two n-bit values
– Add individual bits
– Propagate carries
– E.g.,
1 1
10101 21
+ 11001 + 25
101110 46
Multiplication (1 of 3)
• Decimal (just for fun)
35
x 105
175
000
35
3675
pp. 39
Multiplication (3 of 3)
• Binary, two n-bit values
– As with decimal values
– E.g., 1110
x 1011
1110
1110
0000
1110
10011010
Fractions
• Decimal to decimal (just for fun)
pp. 46-
50
Fractions
• Binary to decimal
10.1011 => 1 x 2-4 = 0.0625
1 x 2-3 = 0.125
0 x 2-2 = 0.0
1 x 2-1 = 0.5
0 x 20 = 0.0
1 x 21 = 2.0
2.6875
pp. 46-
50
Fractions
.14579
• Decimal to binary x 2
3.14579 0.29158
x 2
0.58316
x 2
1.16632
x 2
0.33264
x 2
0.66528
x 2
1.33056
11.001001...
etc.
p. 50
Boolean Algebra
Introduction
• 1854: Logical algebra was published by
George Boole known today as “Boolean
Algebra”
– It’s a convenient way and systematic way of
expressing and analyzing the operation of logic
circuits.
• 1938: Claude Shannon was the first to apply
Boole’s work to the analysis and design of
logic circuits.
Boolean Operations & Expressions
• Variable – a symbol used to represent a logical
quantity.
• Complement – the inverse of a variable and is
indicated by a bar over the variable.
• Literal – a variable or the complement of a
variable.
Laws & Rules of Boolean Algebra
• The basic laws of Boolean algebra:
– The commutative laws
– The associative laws
– The distributive laws
Commutative Laws
• The commutative law of addition for two
variables is written as: A+B = B+A
A
B
A+B B
A
B+A
B A AB
B+C
C B
A
X A
X
C AC
X=A(B+C) X=AB+AC
Rules of Boolean Algebra
1. A 0 A 7. A A A
2. A 1 1 8. A A 0
3. A 0 0 9. A A
4. A 1 A 10. A AB A
5. A A A 11. A A B A B
6. A A 1 12.( A B)( A C ) A BC
DeMorgan’s Theorems
• DeMorgan’s theorems provide mathematical
verification of:
– the equivalency of the NAND and negative-OR
gates
– the equivalency of the NOR and negative-AND
gates.
DeMorgan’s Theorems
• The complement of two or NAND Negative-OR
more ANDed variables is
equivalent to the OR of the
complements of the X Y X Y
individual variables.
X Y Z
X Y Z
X Y Z
W X Y Z
DeMorgan’s Theorems (Exercises)
• Apply DeMorgan’s theorems to the expressions:
( A B C )D
ABC DEF
AB C D EF
A BC D( E F )
Boolean Analysis of Logic Circuits
• Boolean algebra provides a concise way to
express the operation of a logic circuit formed
by a combination of logic gates
– so that the output can be determined for various
combinations of input values.
Boolean Expression for a Logic Circuit
A(B+CD)
A
Constructing a Truth Table for a Logic
Circuit
• Once the Boolean expression for a given logic
circuit has been determined, a truth table that
shows the output for all possible values of the
input variables can be developed.
– Let’s take the previous circuit as the example:
A(B+CD)
– There are four variables, hence 16 (24)
combinations of values are possible.
Constructing a Truth Table for a Logic
Circuit
• Evaluating the expression
– To evaluate the expression A(B+CD), first find the
values of the variables that make the expression
equal to 1 (using the rules for Boolean add &
mult).
– In this case, the expression equals 1 only if A=1
and B+CD=1 because
A(B+CD) = 1·1 = 1
Constructing a Truth Table for a Logic
Circuit
• Evaluating the expression (cont’)
– Now, determine when B+CD term equals 1.
– The term B+CD=1 if either B=1 or CD=1 or if both
B and CD equal 1 because
B+CD = 1+0 = 1
B+CD = 0+1 = 1
B+CD = 1+1 = 1
• The term CD=1 only if C=1 and D=1
Constructing a Truth Table for a Logic
Circuit
• Evaluating the expression (cont’)
– Summary:
– A(B+CD)=1
• When A=1 and B=1 regardless of the values of C and D
• When A=1 and C=1 and D=1 regardless of the value of B
– The expression A(B+CD)=0 for all other value
combinations of the variables.
Constructing a Truth Table for a Logic
Circuit
INPUTS OUTPUT
• Putting the results in A B C D A(B+CD)
A(B+CD)
A(B+CD)=1 0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
When A=1 and 0 1 0 1 0
B=1 regardless 0 1 1 0 0
0 1 1 1 0
of the values
1 0 0 0 0
of C and D 1 0 0 1 0
When A=1 and C=1 1 0 1 0 0
and D=1 regardless of 1 0 1 1 1
1 1 0 0 1
the value of B
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1
Karnaugh Maps
• Boolean algebra helps us simplify expressions and
circuits
• Karnaugh Map: A graphical technique for simplifying
a Boolean expression into either form:
– minimal sum of products (MSP)
– minimal product of sums (MPS)
• Goal of the simplification.
– There are a minimal number of product/sum terms
– Each term has a minimal number of literals
• Circuit-wise, this leads to a minimal two-level
implementation
Re-arranging the Truth Table
• A two-variable function has four possible minterms. We can re-
arrange
these minterms into a Karnaugh map
Y
x y minterm
0 0 x’y’ 0 1
0 1 x’y 0 x’y’ x’y
X
1 0 xy’ 1 xy’ xy
1 1 xy
0 1 Y’ Y
0 x’y’ x’y X’ x’y’ x’y
X
1 xy’ xy X xy’ xy
Karnaugh Map Simplifications
• Imagine a two-variable sum of minterms:
x’y’ + x’y
• Both of these minterms appear in the top row of a Karnaugh
map, which
means that they both contain the literal x’
Y
x’y’ x’y
x’y’ + x’y = x’(y’ + y) [ Distributive ] X xy’ xy
= x’ 1 [ y + y’ = 1 ]
= x’ [x1=x]
Y Y
x’y’z’ x’y’z x’yz x’yz’ m0 m1 m3 m2
X xy’z’ xy’z xyz xyz’ X m4 m5 m7 m6
Z Z
• Another way to label the K-map (use whichever you
like):
Why the funny ordering?
• With this ordering, any group of 2, 4 or 8 adjacent squares on the map
contains common literals that can be factored out
Y x’y’z + x’yz
x’y’z’ x’y’z x’yz x’yz’ = x’z(y’ + y)
X xy’z’ xy’z xyz xyz’ = x’z 1
Z = x’z
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
Reading the MSP from the K-map
• You can find the minimal SoP expression
– Each rectangle corresponds to one product term
– The product is determined by finding the common
literals in that Y
0 1 0 0
rectangle X 0 1 1 1
Z
Y
x’y’z’ x’y’z x’yz x’yz’
X xy’z’ xy’z xyz xyz’
Z
y’z xy
F(x,y,z)= y’z + xy
71
Grouping the Minterms Together
• The most difficult step is grouping together all
the 1s in the K-map
– Make rectangles around groups of one, two, four or
eight 1s
– All of the 1s in the map should be included in at least
one rectangle
– Do not include any of the 0s
– Each group corresponds to one product term
Y
0 1 0 0
X 0 1 1 1
Z 72
For the Simplest Result
• Make as few rectangles as possible, to
minimize the number of products in the final
expression.
• Make each rectangle as large as possible, to
minimize the number of literals in each term.
• Rectangles can be overlapped, if that makes
them larger.
73
K-map Simplification of SoP Expressions
• Let’s consider simplifying f(x,y,z) = xy + y’z + xz
• Here is the truth table and sum of minterms for our example:
x y z f(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0 f(x,y,z) = x’y’z + xy’z + xyz’ + xyz
1 0 0 0
= m1 + m5 + m6 + m7
1 0 1 1
1 1 0 1
1 1 1 1
Unsimplifying Expressions
• You can also convert the expression to a sum of minterms with Boolean
algebra
– Apply the distributive law in reverse to add in missing variables.
– Very few people actually do this, but it’s occasionally useful.
Y
0 1 0 0
X 0 1 1 1
Z
X
Z
Y
m0 m1 m3 m2
X m4 m5 m7 m6
Z
77
Solutions for Practice K-map 1
• Here is the filled in K-map, with all groups shown
– The magenta and green groups overlap, which makes
each of them as
large as possible
– Minterm m6 is in a group all by its lonesome
Y
0 1 1 0
X 0 1 0 1
Z
78
K-maps can be tricky!
• There may not necessarily be a unique MSP. The K-map below yields two
valid and equivalent MSPs, because there are two possible ways to
include minterm m7
Y
0 1 0 1
X 0 1 1 1
Z
Y Y
0 1 0 1 0 1 0 1
X 0 1 1 1 X 0 1 1 1
Z Z
y’z + yz’ + xy y’z + yz’ + xz
79
Four-variable K-maps – f(W,X,Y,Z)
• We can do four-variable expressions too!
– The minterms in the third and fourth columns, and in the third and
fourth rows, are switched around.
– Again, this ensures that adjacent squares have common literals
80
Four-variable K-maps
Y
Y
m0 m1 m3 m2
w’x’y’z’ w’x’y’z w’x’yz w’x’yz’
m4 m5 m7 m6
w’xy’z’ w’xy’z w’xyz w’xyz’ X
X m12 m13 m15 m14
wxy’z’ wxy’z wxyz wxyz’ W
W m8 m9 m11 m10
wx’y’z’ wx’y’z wx’yz wx’yz’
Z
Z
81
Example: Simplify m0+m2+m5+m8+m10+m13
• The expression is already a sum of minterms, so here’s the K-
map:
Y Y
1 0 0 1 m0 m1 m3 m2
0 1 0 0 m4 m5 m7 m6
X X
0 1 0 0 m12 m13 m15 m14
W W
1 0 0 1 m8 m9 m11 m10
Z Z
Y
Y
w’x’y’z’ w’x’y’z w’x’yz w’x’yz’
1 0 0 1
w’xy’z’ w’xy’z w’xyz w’xyz’
0 1 0 0 X
X wxy’z’ wxy’z wxyz wxyz’
0 1 0 0 W
W wx’y’z’ wx’y’z wx’yz wx’yz’
1 0 0 1
Z
Z
82
Five-variable K-maps – f(V,W,X,Y,Z)
V= 0 V= 1
Y Y
m0 m1 m3 m2 m16 m17 m19 m8
m4 m5 m7 m6 m20 m21 m23 m22
X X
m12 m13 m15 m14 m28 m29 m31 m30
W W
m8 m9 m11 m10 m24 m25 m27 m26
Z Z
83
Simplify f(V,W,X,Y,Z)=Σm(0,1,4,5,6,11,12,14,16,20,22,28,30,31)
1 1 1
1 1 1 1 1
1 1 1 1 1
V= 0 V= 1
f = XZ’ Σm(4,6,12,14,20,22,28,30)
+ V’W’Y’ Σm(0,1,4,5)
+ W’Y’Z’ Σm(0,4,16,20)
+ VWXY Σm(30,31)
+ V’WX’YZ m11
84
PoS Optimization
• Maxterms are grouped to find minimal PoS
expression 00 01 yz11 10
0 x +y+z x+y+z’ x+y’+z’ x+y’+z
x
1 x’ +y+z x’+y+z’ x’+y’+z’ x’+y’+z
85
PoS Optimization
• F(W,X,Y,Z)= ∏ M(0,1,2,4,5)
yz
00 01 11 10
F(W,X,Y,Z)= Y . (X + Z)
yz
00 01 11 10
0 0 0 1 0
x
1 0 0 1 1
PoS Optimization from SoP
F(W,X,Y,Z)= Σm(0,1,2,5,8,9,10)
= ∏ M(3,4,6,7,11,12,13,14,15)
0 0 0 Or,
87
SoP Optimization from PoS
F(W,X,Y,Z)= ∏ M(0,2,3,4,5,6)
= Σm(1,7,8,9,10,11,12,13,14,15)
1 1 1 1
1 1 1 1
88
I• don’t care! n
You don’t always need all 2 input combinations in an n-variable function
– If you can guarantee that certain input combinations never occur
– If some outputs aren’t used in the rest of the circuit
• We mark don’t-care outputs in truth tables and K-maps with Xs.
x y z f(x,y,z)
0 0 0 0
0 0 1 1
0 1 0 X
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 X
1 1 1 1
• Within a K-map, each X can be considered as either 0 or 1. You should pick
the interpretation that allows for the most simplification.
89
Practice K-map
• Find a MSP for
90
Solutions for Practice K-map
• Find a MSP for: f(w,x,y,z) = m(0,2,4,5,8,14,15),
d(w,x,y,z) = m(7,10,13)
Y
1 1
1 1 x
X
x 1 1
W
1 x
Z
91
K-map Summary
• K-maps are an alternative to algebra for simplifying
expressions
– The result is a MSP/MPS, which leads to a minimal two-level circuit
– It’s easy to handle don’t-care conditions
– K-maps are really only good for manual simplification of small
expressions...
• Things to keep in mind:
– Remember the correct order of minterms/maxterms on the K-map
– When grouping, you can wrap around all sides of the K-map, and
your groups can overlap
– Make as few rectangles as possible, but make each of them as large
as possible. This leads to fewer, but simpler, product terms
– There may be more than one valid solution
92
Tabulation Method – STEP 1
1. Partition Prime Implicants (or minterms) According to Number of 1’s
Minterm Cube
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
8 1 0 0 0
3 0 0 1 1
5 0 1 0 1
10 1 0 1 0
11 1 0 1 1
13 1 1 0 1
15 1 1 1 1
STEP 1 - EXAMPLE
f on = {m0, m1, m2, m3, m5, m8, m10, m11, m13, m15} = (0, 1, 2, 3, 5, 8, 10, 11, 13, 15)
0 1 2 3 5 8 10 11 13 15
A x x x x
B x x x x
C x x x x
D x x
E x x
F x x
G x x
0 1 2 3 5 8 10 11 13 15
A x x x x
B x x x x
Essential row
C x x x x
D x x
E x x
F x x
G x x
• If Row P is equal to Row Q and Row Q does not cost more than Row P,
eliminate Row P, or if Row P is dominated by Row Q and Row Q Does
not cost more than Row P, eliminate Row P
The first level is two 2-input NAND gates using ANDInvert. The second level is one 2-
input NAND gate using Invert-OR. Using the NAND relationship, we
Logic Family Characteristics
• Complementary metal oxide semiconductor
(CMOS)
– most widely used family for large-scale devices
– combines high speed with low power consumption
– usually operates from a single supply of 5 – 15 V
– excellent noise immunity of about 30% of supply voltage
– can be connected to a large number of gates (about 50)
– many forms – some with tPD down to 1 ns
– power consumption depends on speed (perhaps 1 mW)
NAND Implementation (Cont.)
In the implementation, note that the bubbles
are on opposite ends of the same line. Thus,
they can be combined and deleted:
Fan-out >50 10 25
• A CMOS inverter
• CMOS gates
• CMOS logic levels and noise immunity
Transistor-Transistor Logic
119
Analysis procedure
To obtain the output Boolean functions from a logic diagram, proceed as follows:
1. Label all gate outputs that are a function of input variables with arbitrary
symbols. Determine the Boolean functions for each gate output.
2. Label the gates that are a function of input variables and previously labeled
gates with other arbitrary symbols. Find the Boolean functions for these
gates.
3. Repeat the process outlined in step 2 until the outputs of the circuit are
obtained.
120
Example
F2 = AB + AC + BC; T1 = A + B + C; T2 = ABC; T3 = F2’T1;
F1 = T3 + T2
F1 = T3 + T2 = F2’T1 + ABC = A’BC’ + A’B’C + AB’C’ + ABC
121
Derive truth table from logic diagram
• We can derive the truth table in Table 4-1 by using the
circuit of Fig.4-2.
122
Design procedure
1. Table4-2 is a Code-Conversion example, first, we can
list the relation of the BCD and Excess-3 codes in the
truth table.
123
Karnaugh map
2. For each symbol of the Excess-3 code, we use 1’s to
draw the map for simplifying Boolean function.
124
Circuit implementation
z = D’; y = CD + C’D’ = CD + (C + D)’
x = B’C + B’D + BC’D’ = B’(C + D) + B(C + D)’
w = A + BC + BD = A + B(C + D)
125
Binary Adder-Subtractor
• A combinational circuit that performs the addition of two bits is
called a half adder.
• The truth table for the half adder is listed below:
S: Sum
C: Carry
S = x’y + xy’
C = xy
126
Implementation of Half-Adder
127
Full-Adder
• One that performs the addition of three bits(two
significant bits and a previous carry) is a full adder.
128
Simplified Expressions
130
Another implementation
• Full-adder can also implemented with two half adders
and one OR gate (Carry Look-Ahead adder).
S = z ⊕ (x ⊕ y)
= z’(xy’ + x’y) + z(xy’ + x’y)’
= xy’z’ + x’yz’ + xyz + x’y’z
C = z(xy’ + x’y) + xy = xy’z + x’yz + xy
131
Half Subtractor
Truth table
Logic Circuit
Full Subtractor
Full Subtractor
Binary adder
• This is also called
Ripple Carry
Adder ,because of the
construction with full
adders are connected
in cascade.
135
Carry Propagation
136
Carry Propagation
• Because the propagation delay will affect the output signals on
different time, so the signals are given enough time to get the
precise and stable outputs.
• The most widely used technique employs the principle of carry
look-ahead to improve the speed of the algorithm.
137
Boolean functions
Pi = Ai ⊕ Bi steady state value
Gi = AiBi steady state value
Output sum and carry
Si = Pi ⊕ Ci
Ci+1 = Gi + PiCi
Gi : carry generate Pi : carry propagate
C0 = input carry
C1 = G0 + P0C0
C2 = G1 + P1C1 = G1 + P1G0 + P1P0C0
C3 = G2 + P2C2 = G2 + P2G1 + P2P1G0 + P2P1P0C0
139
4-bit adder with carry lookahead
• Delay time of n-bit CLAA = XOR + (AND + OR) + XOR
140
Binary subtractor
M = 1subtractor ; M = 0adder
141
4-5 Decimal adder
BCD adder can’t exceed 9 on each input digit. K is the carry.
142
Rules of BCD adder
• When the binary sum is greater than 1001, we obtain a non-valid
BCD representation.
• To distinguish them from binary 1000 and 1001, which also have a
1 in position Z8, we specify further that either Z4 or Z2 must have a
1.
C = K + Z8Z4 + Z8Z2
143
Implementation of BCD adder
• A decimal parallel
adder that adds n
decimal digits needs n
BCD adder stages.
144
4-6. Binary multiplier
• Usually there are more bits in the partial products and it is necessary to use full
adders to produce the sum of the partial products.
And
145
4-bit by 3-bit binary multiplier
• For J multiplier bits and K
multiplicand bits we need (J
X K) AND gates and (J − 1) K-
bit adders to produce a
product of J+K bits.
146
Magnitude comparator
• The equality relation of each pair
of bits can be expressed logically
with an exclusive-NOR function as:
A = A3A2A1A0 ; B = B3B2B1B0
xi=AiBi+Ai’Bi’ for i = 0, 1, 2, 3
(A = B) = x3x2x1x0
147
Magnitude comparator
• We inspect the relative magnitudes
of pairs of MSB. If equal, we
compare the next lower significant
pair of digits until a pair of unequal
digits is reached.
148
Decoders
• The decoder is called n-to-m-line decoder, where
m≤2n .
• the decoder is also used in conjunction with other
code converters such as a BCD-to-seven_segment
decoder.
• 3-to-8 line decoder: For each possible input
combination, there are seven outputs that are equal
to 0 and only one that is equal to 1.
149
Implementation and truth table
150
Decoder with enable input
• Some decoders are constructed with NAND gates, it becomes
more economical to generate the decoder minterms in their
complemented form.
• As indicated by the truth table , only one output can be equal to 0
at any given time, all other outputs are equal to 1.
151
Demultiplexer
• A decoder with an enable input is referred to as a
decoder/demultiplexer.
• The truth table of demultiplexer is the same with
decoder. A B
D0
Demultiplexer D1
E
D2
D3
152
3-to-8 decoder with enable implement the
4-to-16 decoder
153
Implementation of a Full Adder with a
Decoder
• From table 4-4, we obtain the functions for the combinational circuit in sum of
minterms:
S(x, y, z) = ∑(1, 2, 4, 7)
C(x, y, z) = ∑(3, 5, 6, 7)
154
4-9. Encoders
• An encoder is the inverse operation of a decoder.
• We can derive the Boolean functions by table 4-7
z = D 1 + D3 + D5 + D7
y = D 2 + D3 + D6 + D7
x = D 4 + D5 + D6 + D7
155
Priority encoder
• If two inputs are active simultaneously, the output produces
an undefined combination. We can establish an input priority
to ensure that only one input is encoded.
• Another ambiguity in the octal-to-binary encoder is that an
output with all 0’s is generated when all the inputs are 0; the
output is the same as when D0 is equal to 1.
• The discrepancy tables on Table 4-7 and Table 4-8 can resolve
aforesaid condition by providing one more output to indicate
that at least one input is equal to 1.
156
Priority encoder
V=0no valid inputs
V=1valid inputs
157
4-input priority encoder
0
• Implementation of 0
table 4-8 0
0
x = D 2 + D3
y = D3 + D1D’2
V = D0 + D1 + D2 + D3
158
4-10. Multiplexers
S = 0, Y = I0 Truth Table S Y Y = S’I0 + SI1
S = 1, Y = I1 0 I0
1 I1
159
4-to-1 Line Multiplexer
160
Quadruple 2-to-1 Line Multiplexer
• Multiplexer circuits can be combined with common selection inputs to provide
multiple-bit selection logic. Compare with Fig4-24.
I0 Y
I1
161
Boolean function implementation
• A more efficient method for implementing a Boolean function of
n variables with a multiplexer that has n-1 selection inputs.
F(x, y, z) = (1,2,6,7)
162
4-input function with a multiplexer
F(A, B, C, D) = (1, 3, 4, 11, 12, 13, 14, 15)
163
Three-State Gates
• A multiplexer can be constructed with three-state gates.
164
Sequential Circuits
166
The simplest sequential circuit
168
S-R (Set-Reset) Latch
XY NOR
00 1
01 0
10 0
11 0
S-R latch: similar to inverter pair, with capability to force output to 0 (reset=1) or 1
(set=1)
Q QN
R
S
169
S-R latch operation
QN =1
S 0 0=
R 0 Q 0=
QN =0
S 1 0=
R 0 Q
=1
QN =0
S 0
R 0 Q =1
=1
QN =1
S 0
1
R 170 Q =1
=0
S-R latch operation (cont’d)
(hold)
(reset)
(set)
(forbidden)
Race
R
S
Q
QN
172
R-S latch analysis
R Q(t)
Q
S(t) Q(t+)
QN R(t)
S
S(t)
S(t) R(t) Q(t) Q(t+)
0 0 0 0 0 0 X 1
hold
0 0 1 1
Q(t) 1 0 X 1
0 1 0 0 reset
0 1 1 0 R(t)
1 0 0 1 set
next state equation:
1 0 1 1
Q(t+) = S(t) + R’(t) Q(t)
1 1 0 X not allowed
1 1 1 X
Q+ = Q* = S + R’ Q
173 a.k.a. characteristic equation
S-R Latch
Q(t) X 1 1 0 Q+ = Q* = S’ + R Q
174 RN(t)
D Latch (= Transparent Latch)
175
D-Latch Timing Parameters
176
Clock signals
177
D Flip-Flop (positive edge
triggered)
Functional Table More compact
Truth Table Truth Table
D Q+
0 0
1 1
CLK
178 inputs sampled on rising edge; outputs change after rising edge
Setup and hold times for an
edge-triggered DFF
179
Minimum clock period T ?
tpINV = 2 ns
tpFF = 5 ns
tsuFF = 3 ns
T = 9 ns T = 15 ns
tpINV = 2 ns
Observation: tpFF = 5 ns
thFF doesn’t affect this calculation tsuFF = 3 ns
Tmin = 10 ns
181
D Flip-Flop (negative edge
triggered)
183
DFF with asynchronous preset
and clear (cont’d)
184
DFF with enable
0
D Q
D 1
EN
CK Q’
CLK
Reliable alternative
185
DFF with enable (cont’d)
186
JK Flip Flop (rising edge triggered)
JK Q+
00 Q Next state equation:
01 0
10 1
11 Q’
187
Summary of latches and flip flops
188
Comparison of latches and flip-
flops
D Q QFF
CLK D
positive
edge-triggered
flip-flop CLK
QFF
D Q Qlatch
G Qlatch
CLK
transparent behavior is the same unless input changes
(level-sensitive) while the clock is high
latch
189
Synchronous Sequential Circuit Analysis
190
Synchronous Sequential Circuit
• State Memory – A set of n edge-triggered flip-flops that
store the current state of the machine
– All flip-flops are triggered from the same master clock signal
– All change state together
• Combinational circuit
– Next state logic
– Output logic – Mealy and Moore
Inputs Combinational Outputs
circuit
Current Next
State State Memory State
Clock
191
Mealy Model
192
Moore Model
193
Analysis - Goals
• Characterize as Mealy or Moore machine
• Determine next state equations, i.e., find the function F
– next state = F (current state, inputs)
• Determine output equations
– Meally: outputs = F (current state, inputs), or
– Moore: outputs = F (current state)
• Express as machine behavior
– State table, or
– State diagram
• Formulate English description of machine behavior
194
An example sequential circuit
197
Next State Equations – Q(t+1)
• Find the flip-flop input equations/excitation equations
• Substitute excitation equations in the flip-flop’s characteristic equation
J1 = X’ Q0
K1 = X + Q0
J0 = X + Q1
K0 = X’
198
Next State Equations – Q(t+1)
• Excitation equations:
– J1 = X’ Q0 and K1 = X + Q0
– J0 = X + Q1 and K0 = X’
200
State1
Table & Next State Equations
• Q (t+1) = X’ (Q (t) Q (t))
0 1
201
State Table & Next State Equations
• Q1(t+1) = X’ (Q0(t) Q1(t))
• Q0(t+1) = X + Q0(t)’ Q1(t)
202
State Table & Characteristic Table
• The general JK flip-flop characteristic equation is:
Q(t+1) = K’Q(t) + JQ’(t)
• We can also determine the next state for each input/current
state combination directly from the characteristic table
J K Q(t+1) Operation
0 0 Q(t) No change
0 1 0 Reset
1 0 1 Set
1 1 Q’(t) Complement
203
State Table & Characteristic Table
• With these equations, we can make a table
showing J1, K1, J0 and K0
for the different combinations of present state
Q1Q0 and input X
J1 = X’ Q0 J0 = X + Q1
K1 = X + Q0 K0 = X’
Present State Inputs Flip-flop Inputs
Q1 Q0 X J1 K1 J0 K0
0 0 0 0 0 0 1
0 0 1 0 1 1 0
0 1 0 1 1 0 1
0 1 1 0 1 1 0
1 0 0 0 0 1 1
1 0 1 0 1 1 0
1 1 0 1 1 1 1
204
1 1 1 0 1 1 0
State Table & Characteristic Table
J K Q(t+1)
0 0 Q(t)
0 1 0
1 0 1
1 1 Q’(t)
205
State Table & Characteristic Table
J K Q(t+1)
0 0 Q(t)
0 1 0
1 0 1
1 1 Q’(t)
206
A different look
Present State Inputs Next State Outputs
Q1 Q0 X Q1 Q0 Z
0 0 0 0 0 0
0 0 1 0 1 0
0 1 0 1 0 0
0 1 1 0 1 0
1 0 0 1 1 0
1 0 1 0 1 0
1 1 0 0 0 0
1 1 1 0 1 1
Output
Next State
Z
Present State
Input Input
Q1 Q0 X= 0 X= 1
X= 0 X= 1
0 0 0 0 0 1 0 0
0 1 1 0 0 1 0 0
1 0 1 1 0 1 0 0
1 1 0 0 0 1 0 1 207
State diagrams (Mealy model)
• We can also represent the state table graphically with a state diagram
• A diagram corresponding to our example state table is shown below
input output
Present State Inputs Next State Outputs 0/0 1/0
Q1 Q0 X Q1 Q0 Z
0 0 0 0 0 0 1/0
00 01
0 0 1 0 1 0
0 1 0 1 0 0
0 1 1 0 1 0
1/1
0/0 1/0 0/0
1 0 0 1 1 0
1 0 1 0 1 0 0/0
1 1 0 0 0 0 11 10
1 1 1 0 1 1
state
208
Sizes
• Alwaysof state
check the sizediagrams
of your state diagrams
n
– If there are n flip-flops, there should be 2 nodes in the diagram
m
– If there are m inputs, then each node will have 2 outgoing arrows
• In our example,
– We have two flip-flops, and thus four states or nodes.
– There is one input, so each node has two outgoing arrows.
0/0 1/0
1/0
00 01
1/1
0/0 1/0 0/0
0/0
11 10
209
Another Mealy Circuit
210
Excitation Equations
• D0 = EN’ Q0 + EN Q0’
• D1 = EN’ Q1 + EN Q1’ Q0 + EN Q1 Q0’
211
Next State/Output Equations
Output
Next State
MAX
Present State
Input Input
Q1 Q0 X= 0 X= 1
EN= 0 EN= 1
0 0 0 0 0 1 0 0
0 1 0 1 1 0 0 0
1 0 1 0 1 1 0 0
1 1 1 1 0 0 0 1
213
Mealy State Diagram
Output
Next State
MAX
Present State
Input Input
Q1 Q0 X= 0 X= 1
EN= 0 EN= 1
0 0 0 0 0 1 0 0
0 1 0 1 1 0 0 0
1 0 1 0 1 1 0 0
1 1 1 1 0 0 0 1 214
Moore Circuit
X
Remove input
connection to
output logic =>
Moore machine
215
Next State/Output Equations
X
Next State
Output
Present State Input Input
MAX
Q1 Q0 EN= 0 EN= 1
0 0 0 0 0 1 0
0 1 0 1 1 0 0
1 0 1 0 1 1 0
1 1 1 1 0 0 1
217
Moore State Diagram
Output
Next State
MAX
Present State
Input Input
Q1 Q0 X= 0 X= 1
EN= 0 EN= 1
0 0 0 0 0 1 0 0
0 1 0 1 1 0 0 0
1 0 1 0 1 1 0 0
1 1 1 1 0 0 0 1 218
State Transitions
Basic applications
Ring counters
Johnson counters
Pseudo-random binary sequences and encryption
Ready-made shift registers are available as integrated circuits,
such as the ’165
serial D Q D Q D Q D Q
serial
input output
A B C D
clock
serial input D Q D Q D Q D Q
serial
01001110 output
A B C D
clock
input QA QB QC QD
The table shows the contents of the
0 0 0 0 0
register after successive clock transitions.
The assumption is that the register is 1 1 0 0 0
initially clear.
clock pulses
1 1 1 0 0
• The number of clock pulses needed to
fill the register is equal to the number of 1 1 1 1 0
flip-flops used to make the register. 0 0 1 1 1
• This is a 4 bit register. 0 0 0 1 1
1 1 0 0 1
0 0 1 0 0
Timing for a shift register
clock
input
QA
QB
QC
QD tpd
The pattern in successive flip-flops moves to the right with each clock
cycle to shift the pattern into and out of the register.
Timing for a shift register
clock
input
QA
QB
QC input QA QB QC QD
0 0 0 0 0
QD tpd
1 1 0 0 0
1 1 1 0 0
1 1 1 1 0
0 0 1 1 1
Applications of a basic shift register
1. Delay line — N stages delay the signal by N clock cycles
2. Multiplication and division by powers of 2, because this just requires a
shift of the binary number (like multiplication or division by 10 in decimal)
Example: decimal 3 x 4 = 12 becomes 11 x 100 = 1100 in binary The
arithmetic logic unit (ALU) of a computer processor uses a shift
register for this purpose.
Warning: the ‘sense’ of a shift — left or right — is usually based on its
effect on binary numbers written in the usual way. For example,
11 → 1100 is called a left shift. This is clearer if both numbers are
written with 8-bits as 00000011 → 00001100. Similarly, dividing by 2
such as 00010110 → 00001011 is a right shift.
This is the opposite of what we usually draw in a counter circuit, with
the least significant bit (LSB) on the left. Take care!
There is a ‘rotate’ operation where the output from the shift register is fed
back to the beginning, usually through the ‘carry bit’.
Ring counter
A shift register with its output fed back to its input forms a ring counter.
D Q D Q D Q D Q output
A B C D
clock
This can be used to generate an arbitrary binary pattern of length N, where
N is the number of stages in the ring counter. It must be preloaded with the
sequence desired, which then rotates around the counter indefinitely.
One application is to divide down the clock frequency for a slower part of a
digital system, while keeping everything synchronous. Modern computers
have several ‘buses’ running at different speeds, where a ring counter is
used to create the clocks for the various buses.
It is much harder to multiply a given frequency to obtain a higher frequency signal.
A phase locked loop (PLL) is often used.
Johnson counter
A ring counter with the complement of its output fed back is a Johnson
counter.
D Q D Q D Q D Q output
A B C D
clock
D Q D Q D Q D Q output
A B C D
clock
QA QB QC
0 0 0
1 0 0
1 1 0
1 1 1
0 1 1
0 0 1
1 0 1
0 1 0
Pseudo-random number generator
A ring counter with feedback through an exclusive-or gate makes a simple
pseudo-random number generator.
D Q D Q D Q D Q output
sender exclusive or
receiver
?
Pseudo-random binary sequences and encryption
your data (plain text) pseudo-random binary sequence
sender exclusive or
This is the basis of the method used to encrypt data sent over the internet
(https) or with a digital mobile phone.
Transmission of data — serial format
Data often has to be transmitted from one computer to another, or from a
computer to peripheral equipment (printer, modem, …). This can be done in:
• serial format, one bit at a time
• parallel format, several bits at a time (e.g. byte at a time, 8 bits)
Serial format is most commonly used because it is simpler. Only a few wires
are needed:
• traditional serial ‘COM’ ports (RS-232) need only 3 wires (transmitted
data, received data and ground — but more may be used for control)
• universal serial bus (USB, common on modern computers) uses 4
wires (two for differential data plus power and ground)
Traditional serial transmission was slow but modern systems use much
faster rates (USB version 1 up to 12 Mbits per second, FireWire 1 up to
400 Mbits per second), version 2 of both even faster.
simple serial
1 0 0 1 1 0 1 1 0 1 0 1
bit stream
Parallel data
Where higher speed is required, several bits (usually a small number of
bytes, each of 8 bits) may be moved at once. More complicated connections
are needed — more wires. Common applications include:
• inside the processor itself, e.g. our microcontroller handles bytes
• inside a computer system on the bus (e.g. PCI) and interfaces to disk
drives (e.g. e.g. SCSI or IDE)— but these are now mainly serial
Interfaces have changed to serial because it is hard to ensure that all bits on
a parallel bus arrive at the same time at the high speed of modern systems.
Parallel data
Where higher speed is required, several bits (usually a small number of
bytes, each of 8 bits) may be moved at once. More complicated connections
are needed — more wires. Common applications include:
• inside the processor itself, e.g. our microcontroller handles bytes
• inside a computer system on the bus (e.g. PCI) and interfaces to disk
drives (e.g. e.g. SCSI or IDE)— but these are now mainly serial
Interfaces have changed to serial because it is hard to ensure that all bits on
a parallel bus arrive at the same time at the high speed of modern systems.
How do we interface an external device that transmits serially with the bus of
a computer that transfers one byte (8 bits) at a time?
• Use a shift register.
In practice this would almost certainly be buried inside a larger circuit called
a UART (universal asynchronous receiver transmitter) or something similar.
Use of shift register to serialize data
parallel data in
parallel load
D Q D Q D Q D Q
serial
output
A B C D
Extra logic is added to the basic shift register so that all the flip-flops can be loaded
in parallel (simultaneously), controlled by a shift/load input.
Once the data have been loaded, the clock is enabled and the values are shifted
once per clock cycle. This causes the input data to be transferred to the output, one
bit at a time — serial output (PISO).
The opposite process is used to read in serial data, fill up the shift register, and
transfer it in parallel to a bus when the register is full (SIPO).
Shift or rotate instructions can be used for the same process inside a microcontroller
(if it doesn’t have a UART built in, which many do).
ROM
• The data stored in ROM are always there, whether the power
is on or not. A ROM can be removed from the PC, and then
replaced, and the data it contains will still be there.
237
Mask ROM
• The mask ROM is usually referred to simply as a
ROM.
• A regular ROM is constructed from hard-wired
logic, encoded in the silicon itself to perform a specific
function that cannot be changed.
• They consume very little power and reliable but cannot
reprogram or rewrite.
238
Programmable ROM (PROM)
239
Programmable ROM (PROM)
• Since all the cells have a fuse, the initial (blank) state of a
PROM chip is all 1s.
240
Programmable ROM (PROM)
241
Erasable Programmable ROM (EPROM)
242
Erasable Programmable ROM (EPROM)
243
Electrically Erasable Programmable ROM (EEPROM)
244
Electrically Erasable Programmable ROM (EEPROM)
245
Electrically Erasable Programmable ROM (EEPROM)
247
Flash Memory
• Flash memory works much faster than
traditional EEPROMs because it writes data in
chunks, usually 512 bytes in size, instead of 1
byte at a time.
248
The SRAM Memory Cell
• Circuit Schematic:
– 4 NFETs and 2 PFETs: T1 & T2 called active devices; T3
& T4 called the I/O devices; T5 & T6 sometimes called
loads.
– The cell is comprised of two cross-coupled inverters
(positive feedback).
B0 B1 – 2 vertical lines (bit lines B0 & B1) are used for sensing
Vdd state of cell and writing data in the cell
– 1 horizontal line (word line WL) is used to select a row
T5 T6 of cells for writing or reading and to prevent the
T4 unselected rows of cells from being disturbed.
T3 X0
X1 • Circuit Operation:
T1 T2 – The cell has two stable states: “0” and “1”
• “0” State = Node X0 high and Node X1 low; T2 & T5 are
ON, T1 & T6 are OFF.
• “1” State = Node X1 high and Node X0 low; T1 & T6 are
WL ON; T2 & T5 are OFF.
• No dc current flows in either state.
– Write: raise WL to Vdd; pull one bit line high & pull the
other bit line low
– Read: raise WL to Vdd; precharge bit lines to ½ Vdd
SRAM Memory Array Organization
• READ Operation:
– Word Decode circuitry selects one of
Data In n word lines and drives high to Vdd
Bit (say WL2); other word lines held at
Addr Bit Decode (Column Decode) gnd.
and Write Drivers
Word – Bit Lines all precharged to half Vdd
Addr
– Selected cell’s I/O devices turned ON
SRAM
Cell
SRAM
Cell
SRAM
Cell
and apply a V to bit line pair
11 12 13 – Sense amp triggers on bit line V and
stores read data “0” or “1”
Word
SRAM
Cell
SRAM
Cell
SRAM
Cell • WRITE Operation:
Decode 21 22 23
(Row – Selected WL is driven high to Vdd by
Decode) word decode circuitry turning ON I/O
SRAM SRAM SRAM
Cell Cell Cell devices in selected cells
31 32 33
– Selected bit column has one BL pulled
high to Vdd and the other pulled low
to gnd, thus writing the selected cell.
– Unselected bit columns merely
Sense Amplifiers perform a READ operation.
and Off-Chip Drivers/Buffers
Data Out
Combinational PLDs
• A combinational PLD is an integrated circuit with
programmable gates divided into an AND array and an OR
array to provide an AND-OR sum of product implementation.
• PROM: fixed AND array constructed as a decoder and
programmable OR array.
• PAL: programmable AND array and fixed OR array.
• PLA: both the AND and OR arrays can be programmed.
251
Combinational PLDs
252
Programmable Logic Array
• Fig.7-14, the decoder in PROM is replaced by an array of AND
gates that can be programmed to generate any product term of
the input variables.
• The product terms are then connected to OR gates to provide the
sum of products for the required Boolean functions.
• The output is inverted when the XOR input is connected to 1
(since x⊕1 = x’). The output doesn’t change and connect to 0
(since x⊕0 = x).
253
PLA
F1 = AB’+AC+A’BC’
F2 = (AC+BC)’
254
Programming Table
1. First: lists the product terms numerically
2. Second: specifies the required paths between
inputs and AND gates
3. Third: specifies the paths between the AND and OR
gates
4. For each output variable, we may have a T(ture) or
C(complement) for programming the XOR gate
255
Simplification of PLA
• Careful investigation must be undertaken in order to
reduce the number of distinct product terms, PLA
has a finite number of AND gates.
• Both the true and complement of each function
should be simplified to see which one can be
expressed with fewer product terms and which one
provides product terms that are common to other
functions.
256
Example
Implement the following two Boolean functions with a PLA:
F1(A, B, C) = ∑(0, 1, 2, 4)
F2(A, B, C) = ∑(0, 5, 6, 7)
1 elements
0 elements 257
PLA table by simplifying the function
F1 = (AB + AC + BC)’
F2 = AB + AC + A’B’C’
258
PLA implementation
AB
AC
BC
A’B’C’
259
Programmable Array Logic
• The PAL is a programmable logic device with a fixed OR array and a
programmable AND array.
260
PAL
• When designing with a PAL, the Boolean functions
must be simplified to fit into each section.
• Unlike the PLA, a product term cannot be shared
among two or more OR gates. Therefore, each
function can be simplified by itself without regard to
common product terms.
• The output terminals are sometimes driven by three-
state buffers or inverters.
261
Example
w(A, B, C, D) = ∑(2, 12, 13)
x(A, B, C, D) = ∑(7, 8, 9, 10, 11, 12, 13, 14, 15)
y(A, B, C, D) = ∑(0, 2, 3, 4, 5, 6, 7, 8, 10, 11, 15)
z(A, B, C, D) = ∑(1, 2, 8, 12, 13)
w = ABC’ + A’B’CD’
x = A + BCD
w = A’B + CD + B’D’
w = ABC’ + A’B’CD’ + AC’D’ + A’B’C’D = w + AC’D’ + A’B’C’D
262
PAL Table
• z has four product terms, and we can replace by w with two
product terms, this will reduce the number of terms for z from
four to three.
263
PAL implementation
264
Fuse map for example
265
Sequential Programmable Devices
266
Sequential Programmable Devices
1. Sequential (or simple) Programmable Logic Device (SPLD)
2. Complex Programmable Logic Device (CPLD)
3. Field Programmable Gate Array (FPGA)
267
FPLS
• The first programmable device developed to support
sequential circuit implementation is the field-programmable
logic sequencer(FPLS).
• A typical FPLS is organized around a PLA with several outputs
driving flip-flops.
• The flip-flops are flexible in that they can be programmed to
operate as either JK or D type.
• The FPLS did not succeed commercially because it has too
many programmable connections.
268
SPLD
• Each section of an SPLD is called a macrocell.
• A macrocell is a circuit that contains a sum-of-
products combinational logic function and an
optional flip-flop.
• We will assume an AND-OR sum of products but in
practice, it can be any one of the two-level
implementation presented in Sec.3-7.
269
Macrocell
• Fig.7-19 shows the logic of a basic macrocell.
• The AND-OR array is the same as in the combinational PAL shown
in Fig.7-16.
270
CPLD
• A typical SPLD has from 8 to 10 macrocells within one IC package.
All the flip-flops are connected to the common CLK input and all
three-state buffers are controlled by the EO input.
• The design of a digital system using PLD often requires the
connection of several devices to produce the complete
specification. For this type of application, it is more economical to
use a complex programmable logic device (CPLD).
• A CPLD is a collection of individual PLDs on a single integrated
circuit.
271
CPLD
• Fig.7-20 shows a general configuration of a CPLD. It consists of
multiple PLDs interconnected through a programmable switch
matrix. 8 to 16 macrocell per PLD.
272
Gate Array
• The basic component used in VLSI design is the gate
array.
• A gate array consists of a pattern of gates fabricated
in an area of silicon that is repeated thousands of
times until the entire chip is covered with the gates.
• Arrays of one thousand to hundred thousand gates
are fabricated within a single IC chip depending on
the technology used.
273
FPGA
• FPGA is a VLSI circuit that can be programmed in the user’s
location.
• A typical FPGA logic block consists of look-up tables,
multiplexers, gates, and flip-flops.
• Look-up table is a truth table stored in a SRAM and provides
the combinational circuit functions for the logic block.
274
Differential of RAM and ROM in FPGA
275
Algorithmic State
Machines
Introduction
State name T3
•Binary code of T3 – 011
•Register operation R <- 0
•START – name of
outputs signal generated
in this stage
Decision box
The state diagram can then be drawn from the state table:
MODE OF OPERATIONS
Steady-state condition: Current states and next states are the
same Difference between Y and y will cause a transition
Fundamental mode:
•No simultaneous changes of two or more variables
• The time between two input changes must be longer than the
time it takes the circuit to a stable state
•The input signals change one at a time and only when the circuit is
in a stable condition Fundamental Mode
Pulse Mode:
the inputs and outputs are represented by pulses
only one input is allowed to have pulse present at any time
Similar to synchronous sequential circuits except without a clock
signal