Professional Documents
Culture Documents
INTRODUCTION
Boolean algebra is the mathematic of digital system. This topic covers laws, rules and
theorem of Boolean algebra and their application to digital circuits. You will also learning
the Boolean operations and expressions in terms of their relationship to NOT, AND, OR,
NAND and NOR gates introduce.
Variable, complement and literal are the terms used in Boolean algebra.
► Boolean Addition
Boolean addition is equivalent to the OR operation and the basic rules are
illustrated with their relation to the OR gate as follows:
In Boolean algebra, a sum term is a sum of literals. Some examples of sum terms
are:
_ _ _ _
A + B, A + B, A + B + C and A + B + C + D.
A sum term is equal to 1 when one or more of the literals in the term are1. A sum
term is equal to 0 only if each of the literals is 0.
Example 1:
Solution;
A B C D 0 1 0 1 0 0 0 0 0
► Boolean Multiplication
Boolean Multiplication is the equivalent to the AND operation and the basic rules
are illustrated with their relation to the AND gate as follows:
Example2:
Determine the values of A, B, C and D that make the product term ABC D
equal to 1.
Solution;
1. A + B = B + A
2. AB = BA
3. A + (B + C) = (A + B) + C
4. A (BC) = (AB) C
5. A (B + C) = AB + AC
There are 12 basic rules that are useful in manipulating and simplifying
Boolean expressions.
Rule 1. A + 0 = A
Rule 2. A + 1 = 1
Rule 3. A . 0 = 0
Rule 4. A . 1 = A
Rule 5. A + A = A
Rule 6.
Rule 7. A . A = A
Rule 8. A A 0
Rule 9. A A
Rule 10. A + AB = A
A AB A1 B - factoring
A 1 - rule 2: (1 + B) = 1
A - rule4: A . 1 = A
Rule 11. A AB A B
A AB A AB AB - rule 10: A = A + AB
AA AB AB - rule 7: A = AA
AA AB A A AB - rule 8: adding AA = 0
A A A B - factoring
1 A B - rule 6: A A 1
A B A C AA AC AB BC
A AC AB BC - rule 7: AA = A
A1 C AB BC - factoring
( A 1) AB BC - rule 2: 1 + C=1
A1 B BC - factoring
A 1 BC - rule 2: 1 + B=1
A BC - rule 4: A .1 =A
DeMorgan’s theorem is important because it show us how to find the equivalent of NAND
and NOR gates.
a.
b.
Inputs Output
0 0 1 1
0 1 1 1
1 0 1 1
1 1 0 0
Inputs Output
0 0 1 1
0 1 0 0
1 0 0 0
1 1 0 0
Notice the equality of the two output columns in each truth table. This
shows that the equivalent gates perform the same logic function.
Example 1:
Solution;
XYZ X Y Z
X Y Z XY Z
Example 1:
Solution;
Assume and
… … (1)
… … (2)
Example 2:
Solution:
Assume and
Example 3:
Solution:
When two or more product terms are summed by Boolean addition, the resulting
expression is a sum-of-products (SOP). Some examples are: -
AB ABC
ABC CDE BC D
AB ABC AC
The domain of a general Boolean expression is the set of variables contained in the
expression in either complemented or un-complemented form.
For example: -
Implementation an SOP expression simply requires from the outputs of two or more
AND gates. A product term is produced by an AND operation, and the sum
(addition) of two or more product terms is produced by an OR operation.
Therefore, an SOP expression can be implemented by AND-OR logic in which the
output of a number of AND gates connect to the inputs of an OR gate. Example AB
+ BCD + AC in figure 4.1.
Example 1:
a. A B + B (CD + EF)
b. (A + B) (B + C + D)
c. A B C
Solution;
a. A B + B (CD + EF)
=
b. (A + B) (B + C + D)
=AB+AC+AD+BB+BC+BD
= AB+AC+AD+B+BC+BD
c.
A standard SOP expression is one in which all the variables in the domain appear in
each product term in the expression. For example: -
Step 2: repeat step 1 until all resulting product terms contain all variables in the
domain in either complemented or un-complemented form.
Example 1:
Solution;
ABC AB ABCD
ABCD ABC D A BCD A BC D
A BC D ABC D ABC D
Example 1:
Example 2:
Determine the binary values for the following standard SOP expression equal to
1.
The SOP expression equals 1 when any or all of the three product terms is 1
Product-of-Sums (POS).
When two or more sum terms are multiplied, the resulting expression is a
product-of-sums (POS). Some examples are: -
( A B)( A B C )
( A B C )(C D E)( B C D)
( A B)( A B C )( A C )
POS expression simply requires AND in the outputs of two or more OR gates. A
sum term is produced by an OR operation, and the product of two or more sum
terms is produced by AND operation. Therefore, a POS expression can be
implemented by logic in which the outputs of a number of OR gates connect to
the inputs of an AND gate.
A standard POS expression is one in which all the variables in the domain appear
in each sum term in the expression. For example: -
Procedure: -
3. Repeat step 1 until resulting sum terms contain all variables in the domain
in either complemented or un-complemented form.
Example 1:
Solution;
( A B C) - Missing D D
- Add D D
( A B C D)( A B C D)
( B C D) - Missing A A
- Add A A
( A B C D)( A B C D)
Example 2:
A B C D 0 1 0 1
Example 3:
Determine the binary values of the variables for which the following standard
POS expression is equal to 0.
( A B C D)( A B C D)( A B C D)
Solution;
The POS expression equals 0 when any of the three SUM terms equals 0.
The binary values of the product terms in a given standard SOP expression are
not present in the equivalent standard POS expression. Also, the binary values
that are not represented in the SOP expression are present in the equivalent
POS expression. Therefore, to convert from standard SOP to standard POS,
the following steps are taken:
Step 1: Evaluate each product term in the SOP expression. That is, determine
the binary numbers that represent the product terms.
Step 2: Determine all of the binary numbers not included in the evaluation in
step 1.
Step 3: Write the equivalent sum term for each binary number from step 2
and express in POS form.
Example 4:
Solution;
ABC ABC ABC ABC ABC = 000 + 010 + 101 + 110 + 111
Variables = 3
N=2n = 23 = 8 possible combinations
Truth table
A B C SOP/POS
0 0 0 SOP
0 0 1 POS
0 1 0 SOP
0 1 1 POS
1 0 0 POS
1 0 1 SOP
1 1 0 SOP
1 1 1 SOP
So, the POS must contain the other three, which are 001, 011 and 100.
SOP POS
Equation Equation
From Truth Table Output = 1 From Truth Table Output = 0
Where A = 1 Where A = 0
A = 0 A = 1
Sometimes a situation arises in which some input variable combinations are not allowed. For
example, recall that in the BCD code, there are six invalid combinations: 1010, 1011, 1100,
1101, 1110 and 1111, Since these un-allowed states will never occur in a application involving
BCD code, they can be treated as “don’t care” terms with respect to their effect on the
output. That is, for these “don’t care” terms either a 1 or 0 may be assigned to the output;
it really does not matter since they will never occur.
The “don’t care” terms can be used to advantage on the Karnaugh map. Figure 4.3 shows
that for each “don’t care” term, an X is placed in the cell. When grouping the 1s, the Xs
can be treated as 1s to make larger grouping or as 0s if they cannot be used to advantage.
The larger a group, the simpler the resulting term will be. The truth table in figure 4.3(a)
describes a logic function that has a 1 output only when the BCD code for 7, 8 or 9 is
present on the inputs. If “don’t cares” are used as 1s, the resulting expression for the
function is A + BCD, as indicated in part (b). If the “don’t care” are not used as 1s, the
resulting expression is:
So you can see the advantage of using “don’t care” terms to get the simplest expression.
Figure 4.3: Example of the use of “don’t care” condition to simplify an expression
SUMMARY
In this topic, we have learn about the operation of the basic logic gate like the INVERTER
or NOT, AND, OR, NAND and NOR gate. Student also should be understand about the
operation of the exclusive-OR gate and exclusive-NOR gate.
Student should be able to identify the shape of logic gate symbols according to the
ANSI/IEEE (American National Standard Institute/ International Electrical Electronic
Engineering). To understand more about digital signal input and output, student must be
construct timing diagrams that showing the proper time relationships of inputs and outputs
for the various logic gates.
They also learned how to troubleshoot the logic gates for opens and shorts by using the
oscilloscope.
EXERCISE
______________________________
2. Determine the values of A, B and C that make the sum term A B C equal to 0.
_____________________________
3. Determine the values of A, B and C that make the product term ABC equal to 1.
______________________________
6. Which of the following rules states that if one input of an AND gate is always 1, the
output is equal to the other input?
a. A + 1 = 1
b. A + A = A
c. A . A = A
d. A . 1 = A
a. (A + B + C) D
b. ABC + DEF
c. AB + CD + EF
11. Determine the binary values for the POS expression below equal to 0
( X Y Z )( X Y Z )( X Y Z )( X Y Z )( X Y Z )
REFERENCE
1. Digital System – Principle And Applications, Tocci, R.J, Prentice Hall international
► AND – OR Logic
(a) Logic diagram (ANSI standard (b) ANSI standard distinctive shape
symbol) rectangular outline symbol
The Boolean expressions for the AND gate outputs and the resulting SOP
expression for the output X are shown on the diagram.
An AND-OR circuit directly implements an SOP expression, assuming the
complements (if any) of the variables are available.
For a 4-input AND-OR logic circuit, the output X is HIGH (1) if both input A
and input B are HIGH (1) or both input C and input D are HIGH (1)
INPUT OUTPUT
A B C D AB CD X = AB + CD
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 1 0 0 0 0
0 0 1 1 0 1 1
0 1 0 0 0 0 0
0 1 0 1 0 0 0
0 1 1 0 0 0 0
0 1 1 1 0 1 1
1 0 0 0 0 0 0
1 0 0 1 0 0 0
1 0 1 0 0 0 0
1 0 1 1 0 1 1
1 1 0 0 1 1 1
1 1 0 1 1 1 1
1 1 1 0 1 1 1
1 1 1 1 1 1 1
In general, an AND-OR Invert circuit can have any number of AND gates
each with number of inputs.
► EXCLUSIVE – OR Logic
This circuit is considered a type of logic gate with its own unique symbol, it
is actually a combination of two AND gates, one OR gate and two
inverters as shown in figure 5.3(a).
Output X is HIGH when A and B are both HIGH or both LOW(same level)
The exclusive-NOR can be implemented by simply inverting the output of an
exclusive-OR as shown in figure 5.4(a) or by directly implementing the
expression AB + AB as shown in part (b).
An XNOR has only two inputs. The bubble on the output of the XNOR symbol
indicates that its output is opposite that of the XOR gate. When the two
input logic levels are opposite, the output of the exclusive-NOR gate is
LOW. The operation can be stated as follows (A and B are inputs, X is the
output).
For an exclusive-NOR gate, output X is LOW when input A is LOW and input
B is HIGH, or when A is HIGH and B is LOW; X is HIGH when A and B are
both HIGH or both LOW.
POS SOP
► Example 1:
X AB AB
INPUTS OUTPUT
A B X
0 0 0
0 1 1
1 0 1
1 1 0
Table 5.2: Truth table for an exclusive-OR
► Example 2:
Solution;
ABC 001 = 1
ABC 100 = 1
ABC 111 = 1
INPUT OUTPUT
A B C X
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
► Example 3 :
Determine the truth table for the following standard POS expression:
( A B C )( A B C )( A B C )( A B C )( A B C )
Solution;
There are 3 variables.
So, binary values = 23 = 8
( A B C) 0 0 0 = 0
( A B C) 0 1 0 = 0
( A B C) 0 1 1 = 0
( A B C) 0 1 0 = 0
( A B C) 1 1 0 = 0
INPUT OUTPUT
A B C X
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
The Karnaugh map provides a systematic method for simplifying Boolean expressions
and if properly used, will produce the simplest SOP or POS expression possible, known
as the minimum expression. The Karnaugh map, on the other hand, basically provides a
“cookbook” method for simplification.
i. Determine the binary value of each product term in the standard SOP
expression.
ii. As each product term is evaluated, place a 1 on the map in the cell having
the same value as the product term and the 0s left off the map.
Example :
Solution:
Example:
i. Determine the binary value of each sum term in the standard POS
expression.
ii. As each sum term is evaluated, place a 0 on the map in the cell having the
same value as the sum term and the 1s left off the map.
Example:
Solution:
Example:
Solution:
Figure 5.9
► Looping
C.D
A.B
00 01 11 10
00
01
Each cell is adjacent to the
11 cell at its right, left, above
and below
10
C.
A.D Each cell at the outer left
0 00 10
B
01 11 column is adjacent to the
0
corresponding cell at the
0 outer right corner
1
1
1
1 C.D
0 00 01 11 10
A.B
00
Each cell at the top row is
01 adjacent to the
corresponding cell at the
11 bottom row
10
A group can only contain either 1, 2(pairs), 4(Quads), or 8(octets) which are all
power of two.
i. Pairs
The examples of pairs looping are shown in Figure 5.11.
ii. Quads
(c) (d)
(e)
Figure 5.12 : Looping a quads of adjacent
iii Octests
o To obtain the minimal Boolean Expression, loop the largest group as possible.
o The „1‟ must be enclosed in a group (at least one) and „1‟s that already in a
group can overlap (included) in other group as long as it contains the non-
common 1‟s.
CD Overlapped cell
AB 00 01 11 10
00 0 1 1 0
Non-common cell
01 0 1 1 1
11 0 1 1 1
10 0 1 1 0
Example
Using a Karnaugh map, convert the following standard POS expression into a
minimum POS expression, a standard SOP expression, and a minimum SOP
expression:
Solution;
__________________________________________
_________________________________________________
Example 2:
Input Output
A B C D X
0 0 0 0 1
0 0 0 1 0
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 1
1 0 0 1 0
1 0 1 0 1
1 0 1 1 1
1 1 0 0 0
1 1 0 1 1
1 1 1 0 0
1 1 1 1 1
Solution:
CD
AB 00 01 11 10
00 1 0 1 1
01 0 0 0 0
11 0 1 1 0
10 1 0 1 1
Figure 5.16
X = ___________________________________
► Draw The Combinational Logic Circuit After Simplify Using Karnaugh Map
Example 1:
Using the minimum POS expression from Figure 5.12(a), draw the
combinational Circuit.
Combinational Circuit:
Example 2 :
Using the minimum SOP expression from Figure 5.15(b), draw the
combinational Circuit.
Combinational Circuit:
Example 1:
We are given Figure 5.18(a) and the truth tables in Table 5.6. The timing diagrams
are shown in Figure 5.18(b).
Troubleshooting Example 1
NOTE:
THE DIFFERENT BETWEEN SOP AND POS EXPRESSION
SOP POS
Equation Equation
SUMMARY
In this topic, students should be able to analyze basic combination of logic circuit were
discussed in topic 3.0 and 4.0 such as AND-OR, AND-OR INVERT, exclusive-OR and
exclusive-NOR. Implementation of sum-of-product (SOP) and product-of-sum(POS)
expression in AND-OR and AND-OR INVERT circuit.
Student should know how to develop truth table from the output expression. Simplify and
design combination logic by using Karnaugh map. Student also should be able to select SSI
(small scale integration) digital IC.
Beside that, student should be able to troubleshoot logic circuit by using signal tracing and
waveform analysis.
EXERCISE
2. Use AND gates, OR gates or combinations of both to implement the following logic
expressions as stated:
(c) X = A [B + C(D + E )]
3. Draw the ANSI rectangular outline symbol for exclusive -OR and
exclusive-NOR gate.
4. Create a truth table for the standard SOP expression ABC ABC .
6. Use a Karnaugh map to convert the following expression to minimum SOP and POS
form and design that logic circuit:
(W X Y Z )(W X Y Z )(W X Y Z )(W X Y Z )(W X Y Z )
REFERENCE
1. Digital System – Principle And Applications, Tocci, R.J, Prentice Hall international
STRUCTURE
2.0 Objectives
2.1 Introduction
2.2 Simplification of Boolean Expressions
2.2.1 Sum of Products
2.2.2 Product of Sums
2.2.3 Canonical SOP and POS Forms
2.2.4 Karnaugh Maps
2.2.5 Implementing Boolean Expressions Using NAND Gates
2.2.6 Implementing Boolean Expressions Using NOR Gates
Check Your Progress 1
2.3 Combinational Logic Circuits
2.3.1 Half Adder
2.3.2 Full Adder
2.3.3 Half Subtractor
2.3.4 Full Subtractor
2.3.5 Parallel Binary Adder
2.3.6 BCD Adder
2.3.7 Encoders
2.3.8 Decoders
2.3.9 Multiplexers
2.3.10 Demultiplexers
Check Your Progress 2
2.4 Summary
2.5 Glossary
2.6 References
2.7 Answers to Check Your Progress Questions
2.0 Objectives
• Algebraic Simplification.
• Karnaugh Maps.
=X+Y+Y′ as X+X′Y=X+Y
=X+1 as Y+Y′=1
=1 as X + 1=1
1. XY+X'Y+XY'
2. AB+ABC+BC'
3. A+AB'+B'C
4. ABC+A'B+AB'C+A'BC'
Sometimes a product term may consist of a single variable.
2.2.2 Products of Sums:
A product of sums expression consists of several sum terms logically multiplied.
A sum term is the logical addition of several variables. The variables may or may not be
complemented. The following are examples of product of sums expressions:
A) (A+B) (A'+B')
B) A (B'+C') (B+C)
c) (X+Y') (X+Y+Z) (Y+Z)
Sometimes a sum term may consist of a single variable.
In case of 2 variables, the maximum possible product terms are 4, for 3 variables, the
possible product terms are 8, for 4 variables 16, and for n variables, 2ⁿ.
In the above examples the expression (ii) contains 5 out of 8 possible product terms.
When the expression is in the canonical form all terms are mutually exclusive. It means
that for a given set of values of the variables, when one of the terms is equal to 1, all
others must be 0. Of course, it is possible that all terms may be 0.
The following are examples of canonical form of product of sums expressions (or
maxterm canonical form).
(i). Z = (X + Y) (X + Y′)
(ii). F = (X′ + Y + Z′) (X′ + Y + Z) (X′ + Y′ + Z′)
The following table gives the minterms and maxterms for a three variable logical function
where the number of minterms as well as maxterms is 2³ = 8. In general, for an n-variable
logical function there are 2ⁿ minterms and an equal number of maxterms.
As shown in the above table each minterm is represented by mi and each maxterm
is represented by Mi where i is the decimal number equivalent of the natural binary
number. With these shorthand notations logical functions can be represented as follows:
1. Y = A' B' C’ + A’ B’ C + A’ B C + A B C’
= m0 + m1 + m3 + m6
= ∑m( 0, 1, 3, 6 )
2. Y = ( A + B + C’ ) ( A + B’ + C’ ) ( A’ + B’ + C )
= M1 + M3 + M6
= πM( 1, 3, 6 )
Where ∑ denotes sum of product while π denotes product of sum
A K-map consists of a grid of squares, each square representing one canonical minterm
combination of the variables or their inverse. The map is arranged so that squares
representing minterms which differ by only one variable are adjacent both vertically and
horizontally. Therefore XY'Z' would be adjacent to X'Y'Z' and would also adjacent to
XY'Z and XYZ'.
Minimization Technique
o Groups which can be circled are those which have two (2 1) 1's, four (22)
1's, and eight (23) 1's.
->Note that because squares on one edge of the map are considered adjacent to those
on the opposite edge, group can be formed with these squares.
The objective is to cover all the 1's on the map in the fewest number of groups and to
create the largest groups to do this.
Once all possible groups have been formed, the corresponding terms are identified.
->A group of two 1's eliminates one variable from the original minterm.
->A group of four 1's eliminates two variables from the original minterm.
->A group of eight 1's eliminates three variables from the original minterm, and so on.
->The variables eliminated are those which are different in the original minterms of
the group.
In any K-Map, each square represents a minterm. Adjacent squares always differ by just
one literal (So that the unifying theorem may apply: X + X' = 1). For the 2-variable case
(e.g.: variables X, Y), the map can be drawn as in Figure 2.2.4 (a). Two variable map is
the one which has got only two variables as input.
K-map need not follow the ordering as shown in the Figure 2.2.4(a). What this means is
that we can change the positions of m0, m1, m2, m3 of the above figure as shown in the
Figure 2.2.4 (b) and Figure 2.2.4(c).
Position assignment is the same as the default k-map positions. This is the one which we
will be using throughout this unit.
Figure 2.2.4(c)
The K-map for a function is specified by putting a '1' in the square corresponding to a
minterm, a '0' otherwise.
Grouping/Circling K-maps
The power of K-maps is in minimizing the terms, K-maps can be minimized with the help
of grouping the terms to form single terms as shown in Figure 2.2.4 (d). When forming
groups of squares, observe/consider the following:
• Every square containing 1 must be considered at least once.
• A square containing 1 can be included in as many groups as desired
• If a square that is containing 1 which cannot be placed in a group, then leave it out
to include in final expression.
• The number of squares in a group must be equal to 2(pair), 4(quad), 8(octet).
The map is considered to be folded or spherical; therefore squares at the end of a row or
column are treated as adjacent squares.
The simplified logic expression obtained from a K-map is not always unique.
Groupings can be made in different ways as shown in Figure 2.2.4(e).
2-Variable K-Map:
Example - F= X'Y+XY
In this example we have the equation as input, and we have one output function. Draw the
k-map for function F with marking 1 for X'Y and XY positions. Now combine two 1's as
shown in Figure 2.2.4 (f) to form the single term. As you can see X and X' get canceled
and only Y remains F = Y
Figure 2.2.4 (f)
Example - X'Y+XY+XY'
In this example we have the equation as input, and we have one output function. Draw the
k-map for function F with marking 1 for X'Y, XY and XY positions. Now combine two
1's as shown in Figure 2.2.4(g) to form two single terms.
F=X+Y
Figure 2.2.4(g)
3-Variable K-Map
There are 8 minterms for 3 variables (X, Y, Z). Therefore, there are 8 cells in a 3-variable
K-map. One important thing to note is that K-maps follow the gray code sequence, not
the binary one.
Using gray code arrangement ensures that minterms of adjacent cells differ by only one
literal.
Each cell in a 3-variable K-map has 3 adjacent neighbours. In general, each cell in an n-
variable K-map has n adjacent neighbours as shown in Figure 2.2.4(h)
Figure 2.2.4(h)
There is wrap-around in the K-map
Figure 2.2.4(i)
Example
F = XYZ'+XYZ+X'YZ
F = XY + YZ
Example
F(X, Y, Z) = (1, 3, 4, 5, 6, 7)
F=X+Z
4-Variable K-Map
There are 16 cells in a 4-variable (W, X, Y, Z) K-map as shown in the Figure 2.2.4 (j).
Figure 2.2.4(j)
Figure 2.2.4(k)
Example
F (W, X, Y, Z) = (1, 5, 12, 13)
F=WXY'+W'Y'Z
Example
F (W, X, Y, Z) = (4, 5, 10, 11, 14, 15)
F = W'XY' + WY
Don’t Care:
In some digital systems, certain input conditions never occur during normal operations;
therefore the corresponding output never appears. Since the output does not appear it is
indicated by an X in the truth table.
X is called don’t care condition. So don’t cares can be treated as 0’s and 1’s which ever is
more convenient in the process of k-map simplification.
Consider the following truth table in which the output is low for all input entries from
1001 and ‘X’ from 1010 through 1111. The don’t care conditions are denoted by ’X’.
A B C D Y
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 0
1 0 0 1 1
1 0 1 0 X
1 0 1 1 X
1 1 0 0 X
1 1 0 1 X
1 1 1 0 X
1 1 1 1 X
Here three don’t cares are treated as 1’s to get a quad which eliminates two
variables. The remaining don’t cares are treated as 0’s.
1. For the given truth table, draw a K-map with 0’s, 1’s and don’t cares.
2. Encircle the actual 1’s on the K-map in the largest groups, by treating the don’t cares as
1’s.
3. After the actual 1’s have been included in groups discard the remaining don’t cares
visualizing them as 0’s.
The implementation of a Boolean function with NAND-NAND logic requires that the
function be simplified in the sum of product form. The relationship between AND-OR
logic and NAND-NAND logic is explained using the following example.
Figure 2.2.5 (b) shows the AND gates are replaced by NAND gates and the OR gate is
replaced by a bubbled OR gate. The implementation shown in Figure 2.2.5(b) is
equivalent to implementation in Figure 2.2.5 (a), because two bubbles on the same line
represent double inversion (complementation) which is equivalent to having no bubble on
the line. In case of single variable, F, the complemented variable is again complemented
by bubble to produce the normal value of F.
In Figure 2.2.5 (c), the output NAND gate is redrawn with the conventional symbol. The
NAND gate with same inputs gives complemented result; therefore F′ is replaced by
NAND gate with F input to its both inputs. Thus all the three implementations of the
Boolean function are equivalent.
From the above example we can summarize the rules for obtaining the NAND-NAND
logic diagram from a Boolean function as follows:
1. Simplify the given Boolean function and express it in sum of products
form (SOP form).
2. Draw a NAND gate for each product term of the function that has two
or more literals. The inputs to each NAND gate are the literals of the term. This
constitutes a group of first-level gates.
3. If Boolean function includes any single literal or literals draw NAND gates for
each single literal and connect corresponding literal as an input to the NAND
gate.
4. Draw a single NAND gate in the second level, with inputs coming from
outputs of first level gates.
The NOR function is a dual of the NAND function. For this reason, the implementation
procedures and rules for NOR-NOR logic are the duals of the corresponding procedures
and rules developed for NAND-NAND logic.
The implementation of a Boolean function with NOR-NOR logic requires that the
function be simplified in the product of sums form. In product of sums form, we
implement all sum terms using OR gates. This constitutes the first level. In the second
level all sum terms are logically ANDed using AND gates. The relationship between OR-
AND logic and NOR-NOR is explained using following example
In Figure 2.2.6 (b) the OR gates are replaced by NOR gates and the AND gate is replaced
by a bubbled AND gate. The implementation shown in Figure 2.2.6 (b) is equivalent to
implementation shown in Figure 2.2.6 (a) because two bubbles on the same line represent
double inversion (complementation) which is equivalent to having no bubble on the line.
In case of single variable, F, the complemented variable is again complemented by bubble
to produce the normal value of F.
Figure 2.2.6(c) NOR-NOR
In Figure 2.2.6 (c), the output NOR gate is redrawn with the conventional symbol. The
NOR gate with same inputs gives complemented result, therefore, F is replaced by NOR
gate with F input to its both inputs. Thus all the three implementations of the Boolean
function are equivalent.
From the above example, we can summarize the rules for obtaining the NOR-NOR logic
diagram from a Boolean function as follows:
Figure 2.3
In this section we shall discuss about the functions of Half Adder, Full Adder, Half
Subtractor, Full Subtractor, Parallel Binary Adder, BCD Adder, Encoders, Decoders,
Multiplexers and Demultiplexers.
2.3.1 Half Adder
Half adder is a logic circuit that finds the arithmetic sum of two binary digits at a
time. Its logic circuit is shown in Figure 2.3.1(a).
The outputs of the XOR and AND gates produces the sum and carry respectively.
A B SUM CARRY
A B
A.B
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
CARRY = A . B
The input variables of half adder are augend and addend. The output variables are sum
and carry. It is necessary to specify two output variables, because the sum of 1+1=10. Let
A & B be input variables SUM and CARRY be output variables.
The output ‘CARRY’ represents an AND function. The output SUM represents exclusive
OR function. The Boolean functions of the two outputs are
SUM =A B and
CARRY = A . B
When two binary numbers are added a carry may be generated onto the subsequent bit
positions. Hence, it is required to add three bits for the subsequent additions. A
combinational circuit that finds the arithmetic sum of three bits is called a Full adder. A
Full adder can be constructed using two half adders and an OR gate as shown in the
Figure 2.3.2(a).
Figure 2.3.2(a) Full Adder
Truth table:
A B C CARRY SUM
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Thus a full-adder is a combinational circuit that performs the arithmetic sum of three
input bits. It consists of three inputs and two outputs. Two of the input variables denoted
by A, B represents the two significant bits to be added. The third input C represents the
carry from the lower significant position. The two outputs are denoted by SUM and
CARRY. The Boolean expressions for SUM and CARRY outputs are given below.
2.3.3 Half Subtractor:
A Half subtractor is a combinational logic circuit which is used to find the difference
between two binary digits. Its logic circuit is shown in Figure 2.3.3(a).
TRUTH TABLE:
A B BORROW DIFFERENCE
0 0 0 0
0 1 1 1
1 0 0 1
1 1 0 0
Map for DIFFERENCE:
BORROW = A'B
A half subtractor consists of two input variables A and B (minuend and subtrahend) and
two output variables DIFFERENCE and BORROW. The DIFFERENCE output is
obtained by a 2-input XOR gate. The BORROW output is obtained by the expression
A'B
Hence DIFFERENCE = A B
BORROW = A'B
2.3.4 Full Subtractor:
A full subtractor (Figure 2.3.4 (a)) is a combinational circuit that performs a subtraction
between two bits taking into account that a 1 may have been borrowed by a lower
significant stage.
A B C BORROW DIFFERENCE
0 0 0 0 0
0 0 1 1 1
0 1 0 1 1
0 1 1 1 0
1 0 0 0 1
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
The Boolean functions for the two outputs of the full subtractor are derived in the K-map
as shown below.
A parallel binary adder is a digital circuit that produces the arithmetic sum of two binary
numbers in parallel. It consists of full adders connected in cascade, with the output carry
from one full adder connected to the input carry of the next full adder. Figure 2.3.5 shows
the circuit diagram of a 4-bit parallel binary adder.
Figure 2.3.5 Parallel Binary Adder
The augend bits of A and the addend bits of B are designated by subscript number from
right to left, with subscript 0 denoting the low-order bit. The carries are connected in a
chain through the full adders. The input carry to the adder is C 0 and the output carry is C4.
The S outputs generate the required sum bits. An n-bit parallel binary adder requires n full
adders.
The following example illustrates the parallel binary addition
2.3.6. BCD adder
A BCD adder is a circuit that adds two BCD digits and produces a sum digit also in BCD.
BCD numbers use 10 digits, 0 to 9 which are represented in the binary form 0000 to
1001, i.e. each BCD digit is represented as a 4-bit binary number. When we write BCD
number say 526, it can be represented as
5 2 6
The addition of two BCD numbers can be best understood by considering the two cases
that occur when two BCD digits are added.
Sum Equals 9 or less with carry 0 :
Let us consider additions of 3 and 6 in BCD.
6 0110 BCD for 6
+3 0011 BCD for 3
_____ _____
9 1001 BCD for 9
The addition is carried out as in normal binary addition and the sum is 1001,
which is BCD code for 9.
Sum greater than 9 with carry 0 :
Let us consider addition of 6 and 8 in BCD
6 0110 BCD for 6
+8 1000 BCD for 8
_____ ______
14 1110 Invalid BCD number
The sum 1110 is an invalid BCD number. This has occurred because the sum of
the two digits exceeds 9. Whenever this occurs the sum has to be corrected by the
addition of six (0110) in the invalid BCD number, as shown below
6 0110 BCD for 6
+8 1000 BCD for 8
_______ ______
14 1110 Invalid BCD number
+ 0110 add 6 for correction
_____
0001 0100 BCD for 14
2.3.7 Encoders
An encoder (Figure 2.3.7(a)) converts an active input signal into a coded output
signal. There is n input lines of which only one is active. Internal logic within the
encoder converts this active input to a coded binary output with m bits.
Figure 2.3.7(a) Encoders
The Figure 2.3.7 (b) shows a common type of encoder such as a Decimal to BCD
Encoder. The switches are push-button switches like those of a pocket calculator.
When button 3 is pressed, the C and D OR gates receive high inputs.
Therefore the output is
ABCD=0011
If button 5 is pressed, the output becomes
ABCD=0101
When switch 9 is pressed the output is
ABCD=1001
Figure 2.3.7 (b) Decimal to BCD Encoder
2.3.8 Decoders
A decoder is a combinational circuit that converts binary information from ‘n’ input lines
to a maximum of 2n unique output lines. The circuit in Figure 2.3.8(a) represents a 2-to-4
line decoder.
Figure 2.3.8 (a) 2-to-4 decoder.
The two inputs are decoded into 4 outputs each output representing one of the minterms
of the 2-input variables. The two inverters provide the complement of inputs and each of
the four AND gates generate one of the minterms.
The following is the truth table of the 2-to-4 line decoder with two inputs and 4 outputs.
A B D0 D1 D2 D3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
2.3.9 Multiplexer
A multiplexer is circuit with many inputs but only one output. By applying
control signals, we can steer any one of the inputs to the output. Figure 2.3.9 (a)
illustrates the general idea.
The circuit has n input signals, m control signals and one output signal.
Figure 2.3.9(a) Multiplexer
A B Y
0 0 D0
0 1 D1
1 0 D2
1 1 D3
Figure 2.3.9 (b) shows a 4-to-1 Multiplexer. A multiplexer is also called Data
selector because the output bit depends on the input data bit that is selected. The input
bits are labeled D0 through D4. Only one of these inputs is transmitted to the output,
depending on the control inputs AB.
For instance, when AB=00 the upper AND gate is enabled while all other AND
gates are disabled. Therefore, data bit D0 is transmitted to the output, giving
Y=D0. If D0 is low, Y is low; If D0 is high, Y is high. The point is that Y depends
only on the value of D0. If control bits are changed to AB=11, all gates are disabled
except the bottom AND gate. In this case D3 is the only bit transmitted to the output
and Y= D3. As you can see, the control bits determine which of the input data bits is
transmitted to the output.
2.3.10 Demultiplexer
A demultiplexer is a logic circuit with one input and may outputs. By applying control
signals, we can steer the input signal to one of the output lines. Figure 2.3.10(a) illustrates
the general idea. The circuit has 1 input signal, m control signals and n output signals.
Figure 2.3.10 (b) shows a 1x4 Demultiplexer. The input bit is labeled as D. This data bit
(D) is transmitted to the data bit of the output lines. This depends on the value of AB, the
control inputs. When AB=00 the upper AND gate is enabled while all other AND gates
are disabled. Therefore the data bit (D) is transmitted only to the Y0 output, giving Y0 = D.
If D is low, Y0 is low. If D is high, Y0 is high. As you can see, the value of Y0 depends on
the value of D. All other outputs are in the low state. If the control bits are changed to
AB=11 all gates are disabled except the bottom AND gate. Then D is transmitted only to
the Y3 output and Y3=D.
6. A combinational circuit which is used to send data coming from a single source to two
or more separate destinations is called as:
(a) Decoder (b) Encoder (c) Multiplexer (d) Demultiplexer
2.4 Summary
2.5 Glossary
BCD adder A logic circuit that adds two BCD digits and produces a sum digit also in
BCD.
Decoder is a combinational circuit that converts binary information from ‘n’ input lines
to a maximum of 2n unique output lines.
Demultiplexer A circuit with one input and many outputs.
Don’t care conditions An input output condition that never occurs during normal
operations. Since the condition never occurs, you can use X in the truth table.
Encoder An circuit that converts an active input signal into coded output form.
Full adder A logic circuit with three inputs and two outputs. The circuit adds three bits at
a time, giving a sum and a carry output.
Half adder A logic circuit with two inputs and two outputs. It adds two bits at a time,
producing a sum and a carry output.
Half subtractor A logic circuit that subtracts two bits and produce their difference.
Full subtractor A logic circuit that performs a subtraction between two bits, taking into
account borrowing by lower significant stage. It has three inputs and two outputs.
Karnaugh map A map that shows all the fundamental products and the corresponding
output values of a truth table.
Multiplexer A circuit with many inputs but with only one output.
Octet Eight adjacent 1s in a karnaugh map.
Overlapping groups Using the same 1 more than once when looping the 1s of a
karnaugh map.
Pair Two horizontally or vertically adjacent 1s in a Karnaugh map..
Parallel binary adder A logic circuit with number of full adders connected in cascade.
The carry output of each adder is connected to the carry input of the next higher adder.
Product of sum equation The logical product of those fundamental sums that produce
output 1s in the truth table.
Quad Four horizontal, vertical, or rectangular 1s in a Karnaugh map.
Redundant group A group of 1s in a karnaugh map that is a part of other groups.
Sum of products equation The logical sum of those fundamental products that produce
output 1s in the truth table.
Truth table A table that shows all the input-output possibilities of a logic circuit.
2.6 References
1.”Digital logic and computer design” M.Moris Mano, prentice-hall of India private
limited.
2.”Digital principles and applications” Albert Paul Malvino, Tata McGraw-Hill book
company
3.”Digital computer fundamentals” Thomous c. Bartee, Tata McGraw-Hill book
company.
4.”Computer fundamentals- architecture and organization”, B.Ram, New age
international (P) Ltd.
1 BINARY ADDERS
One of the most important tasks performed by a digital computer is the opera-
tion of adding two binary numbers.1 A useful measure of performance is speed.
Of course, speed can be improved by using gate designs that favor speed at the
1As discussed in Chapter 1, subtraction of two numbers is included in the meaning of addition, since sub-
traction is performed first by carrying out some operation on the subtrahend and then adding the result.
(What operation is first performed depends on the type of computer—either inverting the subtrahend or
taking its two’s complement, as discussed in Chapter 1.)
132
Binary Adders 133
X xi Si
S
Y yi Ci+1
Ci
(a) (b)
Figure 1 Binary addition. (a) General adder. (b) Full adder
of two 1-bit words.
Full Adder
An alternative approach for the addition of two n-bit numbers is to use a sep-
arate circuit for each corresponding pair of bits. Such a circuit would accept the
2 bits to be added, together with the carry resulting from adding the less signif-
icant bits. It would yield as outputs the 1-bit sum and the 1-bit carry out to the
more significant bit. Such a circuit is called a full adder. A schematic diagram is
shown in Figure 1b. The 2 bits to be added are xi and yi , and the carry in is Ci.
The outputs are the sum Si and the carry out Ci+1. The truth table for the full
adder and the logic maps for the two outputs are shown in Figure 2.
The minimal sum-of-products expressions for the two outputs obtained
from the maps are
Si = xi'yiCi' + xi yi'Ci' + xi'yi'Ci + xi yiCi (1a)
Ci+1 = xi yi + xiCi + yiCi
= xi yi + Ci(xi + yi) (1b)
(Make sure you verify these.) Each minterm in the map of Si constitutes a prime
implicant. Hence, a sum-of-products expression will require four 3-input AND
Short gates and a 4-input OR gate. The carry out will require three AND gates and an
Even
134 Chapter 4 Combinational Logic Design
Ci Xi Yi Si Ci + 1 x x
0 1 0 1
0 0 0 0 0
0 0 1 1 0 00 1 00
0 1 0 0 1
0 1 1 1 0 01 1 01 1
1 0 0 1 0 yz yz
1 0 1 0 1 11 1 11 1 1
1 1 0 1 1
10 1 10 1
1 1 1 0 1
(a) (b) (c)
Figure 2 Truth table and logical maps of the full adder. (a) Truth table.
(b) Si map. (c) Ci+1 map.
OR gate. If we assume that each gate has the same propagation delay tp, then a
two-level implementation will have a propagation delay of 2tp.
In the map of the carry out, minterm m7 is covered by each of the three
prime implicants. This is overkill; since m7 is covered by prime implicant xiyi,
there is no need to cover it again by using it to form prime implicants with m5
and m6. If there is some benefit to it, we might use the latter two minterms as
implicants without forming prime implicants with m7. The resulting expression
for Ci+1 becomes
Ci+1 = xi yi + Ci(xi'yi + xi yi') = xi yi + Ci(xi ⊕ yi) (2)
(Confirm this result.) We already have an expression for Si in (1a), but it is in
canonic sum-of-products form. It would be useful to seek an alternative form
for a more useful implementation.
Exercise 1 With the use of switching algebra, confirm that the expression for
the sum in (1a) can be converted to
Si = xi ⊕ yi ⊕ Ci (3) ◆
Using the expressions for Si and Ci+1 containing XORs, confirm that we can
obtain the implementation of the full adder shown in Figure 3a. Notice that the
circuit consists of two identical XOR-AND combinations and an additional OR
gate. The circuit inside each dashed box is shown in Figure 3b; it is named a half
adder. Its only inputs are the 2 bits to be added, without a carry in. The two out-
puts are (1) the sum of the 2 bits and (2) the carry out.
Assuming that an XOR gate (implemented in a two-level circuit) has a
propagation delay of 2tp, the full adder in Figure 3a has a propagation delay of
4tp, both for the sum and for the carry. (Verify these claims.)
We will observe in the following section that the overall speed in the addition of
two n-bit binary numbers depends mainly on the speed with which the carry propa-
gates from the least significant bit to the most significant bit. Hence, reducing the
delay experienced by the carry of a full adder is a significant improvement. This is an
incentive in seeking other implementations of the full adder. In some of the cases in Short
Problem 1 at the end of the chapter, additional implementations of the full adder are Even
Binary Adders 135
Ci
xi Si
yi xi ⊕yi
Ci+1
xi ⋅yi
(a)
xi
xi ⊕yi
yi xi Si
xi ⋅yi yi Ci+1
(b) (c)
Figure 3 Full adder implemented with half adders. (a) Full adder.
(b) Half adder. (c) Half adder schematic diagram.
S1 S2 S3 S4
A1
A2 A3 A4
B1 B2 B3 B4
C1 = 0 C5
C2 C3 C4 Figure 4 Four-bit ripple-carry adder.
proposed in which the propagation delay for the carry is 2t p instead of 4t p. Henceforth,
for a full adder, we will assume that the propagation delay of the carry is 2tp.
Ripple-Carry Adder
The problem of adding two multidigit binary numbers has the following form.
Two n-bit binary numbers are available, with all digits being presented in par-
allel. The addition is performed by using a full adder to add each correspond-
ing pair of digits, one from each number. The full adders are connected in
tandem so that the carry out from one stage becomes the carry into the next
stage, as illustrated for the case of four-digit numbers in Figure 4. Thus, the
carry ripples through each stage. For binary addition, the carry into the first
(least significant) stage is 0. The last carry out (the overflow carry) becomes the
most significant bit of the (n + 1)-bit sum.
Since the carry of each full adder has a propagation delay of 2tp, the total
delay in carrying out the sum of two n-bit numbers is 2ntp. Not every pair of two
n-bit numbers will experience this much delay. Take the following two numbers
as an example:
Short 101010
Even 010101
136 Chapter 4 Combinational Logic Design
Ai
Bi Ci+2
Ai+1
Bi+1
Ci+1
Ci
Si Si+1
Figure 5 Carry-lookahead circuit schematic.
Assuming that the carry into the first stage is zero, no carries are generated at
any stage in taking the sum. Hence, there will be no carry ripple, and so no
propagation delay along the carry chain.
However, to handle the general case, provision must be made for the worst
case; no new numbers should be presented for addition before the total delay
represented by the worst case. The maximum addition speed, thus, is limited by
the worst case of carry propagation delay.
Carry-Lookahead Adder
In contemplating the addition of two n-digit binary numbers, we were appalled
by the thought of a single combinational circuit with all those inputs. So we con-
sidered the repeated use of a simpler circuit, a full adder, with the least possi-
ble number of inputs. But what is gained in circuit simplicity with this approach
is lost in speed. Since the speed is limited by the delay in the carry function,
some of the lost speed might be regained if we could design a circuit—just for
the carry—with more inputs than 2 but not as many as 2n. Suppose that several
full-adder stages are treated as a unit. The inputs to the unit are the carry into
the unit as well as the input digits to all the full adders in that unit. Then per-
haps the carry out could be obtained faster than the ripple carry through the
same number of full adders.
These concepts are illustrated in Figure 5 with a unit consisting of just two
full adders and a carry-lookahead circuit. The four digits to be added, as well as
the input carry Ci, are present simultaneously. It is possible to get an expression
for the carry out, Ci+2, from the unit by using the expression for the carry of the
full adder in (2).
For reasons which will become clear shortly, let’s attach names to the two
terms in the carry expression in (2), changing the names of the variables to A
and B from x and y in accordance with Figure 5. Define the generated carry Gi
and the propagated carry Pi for the ith full adder as follows:
Gi = AiBi (4a)
Pi = Ai ⊕ Bi (4b)
Inserting these into the expression for the carry out in (2) gives
Short
Ci+1 = Ai Bi + Ci(Ai ⊕ Bi) = Gi + PiCi (5) Even
Binary Adders 137
A carry will be generated in the ith full adder (that is, Gi = 1) if Ai and Bi both
equal 1. But if only one of them is 1, a carry out will not be generated. In that
case, however, Pi will be 1. (Confirm this.) Hence, the carry out will be Ci+1 =
Ci. We say that the carry will be propagated forward.
The expression for the carry out in (5) can be updated by changing the
index i to i + 1:
The last expression can be interpreted in the following way. A carry will appear
at the output of the unit under three circumstances:
Obviously, this result can be extended through any number of stages, but the
circuit will become progressively more complicated.
Exercise 2 Extend the previous result by one more stage and write the ex-
pression for Ci +3. Then describe the ways in which this carry out can be 1.
Confirm your result using the general result given next. ◆
This expression looks complicated, but it is easy to interpret. Since the carry out
Ci+j+1 = 1 if any one of the additive terms on the right is 1, the carry out from
the unit will be 1 for several possibilities. Either it is generated in the last (jth)
stage of the unit, or it is generated in an earlier stage and is propagated through
all succeeding stages, or the carry into the unit is propagated through all the
stages to the output.
The greater the number of full-adder stages included in a unit, the greater
the improvement in speed—but also the greater the complexity of the carry-
lookahead circuit. There is an obvious trade-off between the two. Consider a
unit of four stages. This unit is to add two 4-bit words A and B. Each stage can
be considered as having a sum circuit (S) and a separate carry circuit (C). The
sum circuit of each stage has as inputs the carry from the preceding stage and
the corresponding bits of the A and B words. The inputs to the carry network of
each stage consist of all the bits of the A and B words up to that stage and the
carry—not just from the preceding stage, but from the input to the whole unit.
Thus, if the first stage is stage i, the inputs to the carry circuit of stage i + 2 are:
Ai, Ai+1, Ai+2, Bi, Bi+1, Bi+2, and Ci.
Gi+3
Pi+3
Gi+2
Pi+3
Pi+2
Gi+1
Pi+3 Ci+4
Pi+2
Pi+1
Gi
Pi+3
Pi+2
Pi+1
Pi Figure 6 Four-stage carry-lookahead
Ci circuit.
Ak
Pk = Ak⊕Bk
Bk
2The sum of the delays through (a) the carry circuit of each unit (2tp each), (b) the sum circuit of the last
unit (2tp) since it depends on having the carry from the last unit, and (c) the extra delay in getting the Short
carry from the first unit. Total delay = (k + 1 + 1)2tp = (2k + 4)tp ◆ Even
Binary Adders 139
S1
C1
A1 P1 P1
B1 C1 G1 P2 S2
C2
C2
A2 P2 P2
P3 S3
C3
G2 G2 C3
P4 S4
A3 P3 P3 C4
C4
B3 G3 G3
C5
A4 P4 P4
B4 G4 G4
CO
B3
B2
B1
S3
B0
S2
S1
A3 S0
A2
A1
A0
CI
If an adder has eight 4-bit units, the propagation delay through a carry-lookahead
adder will be 20tp.The corresponding ripple-carry adder will have a propagation delay
of 4 × 8 × 2tp = 64tp. Thus, the carry-lookahead adder will have an advantage of 320
percent in speed over the ripple-carry adder. All is not gravy, however: the speed ad-
vantage has been paid for in the cost of the added hardware.
The circuits described here are available in IC packages. A single full adder,
for example, is available as a unit. A ripple-carry adder, as illustrated in Figure
4, and a carry-lookahead adder for 4-bit words, as shown in Figure 8, are avail-
able as MSI packages.
Externally, a package consisting of a ripple-carry adder of 4-bit words
Short would look the same as a package consisting of a carry-lookahead adder of 4-
Even bit words. The block diagram in Figure 9 illustrates such a package. There are
140 Chapter 4 Combinational Logic Design
nine inputs: the carry in and four inputs per word. There are five outputs: the
carry out and the 4 bits of the sum. (The carry out becomes the most significant
bit of the sum if the circuit is used just to add 4-bit words, and not as part of an
adder of longer words.)
Binary Subtractor
In Chapter 1 two representations of signed binary numbers were studied: one’s
complement and two’s complement. Recall that when numbers are represented
in one of the complement forms, the only special treatment needed in the ad-
dition of a negative number with another positive or negative number is in the
final carry out. Thus, the adders studied in the previous section are suitable for
the addition of complement numbers if some additional circuitry is used to
process the final carry out. Also, binary subtraction can be performed using the
same adder circuits by negating the subtrahend.
3The range of binary numbers having n binary digits represented in two’s complement form is Short
–2n–1 ≤ m ≤ 2n–1 – 1. Even
Binary Adders 141
B3 B2 B1 B0
M
A3 A2 A1 A0
C4 C3 C2 C1 C0
S3 S2 S1 S0
overflow
Figure 10 Two’s complement adder/subtractor with overflow detection.
B3 B2 B1 B0
M
A3 A2 A1 A0
C4 C3 C2 C1 C0
FA FA FA FA 0
HA HA HA HA
S3 S2 S1 S0
Figure 11 One’s complement adder/subtractor.
1. Any ideas on how to do this without additional gates? (Think about it before
you continue.)
The full adder for the least significant bit has a carry input signal that can
be utilized to add the required 1. The design of our two’s complement
adder/subtractor circuit is complete; a version for adding 4-bit numbers is
shown in Figure 10. If the control signal M is 0, then the circuit performs A+B;
however, if M is 1, the circuit performs A − B.
demultiplexer
multiplexer
Figure 12 A data communication problem.
2 MULTIPLEXERS
Many tasks in communications, control, and computer systems can be per-
formed by combinational logic circuits. When a circuit has been designed to
perform some task in one application, it often finds use in a different applica-
tion as well. In this way, it acquires different names from its various uses. In this
and the following sections, we will describe a number of such circuits and their
uses. We will discuss their principles of operation, specifying their MSI or LSI
implementations.
One common task is illustrated in Figure 12. Data generated in one location
is to be used in another location; A method is needed to transmit it from one
location to another through some communications channel.
The data is available, in parallel, on many different lines but must be trans-
mitted over a single communications link. A mechanism is needed to select which
of the many data lines to activate sequentially at any one time so that the data this
line carries can be transmitted at that time. This process is called multiplexing. An
example is the multiplexing of conversations on the telephone system. A number
of telephone conversations are alternately switched onto the telephone line many
times per second. Because of the nature of the human auditory system, listeners
cannot detect that what they are hearing is chopped up and that other people’s
conversations are interspersed with their own in the transmission process.
Needed at the other end of the communications link is a device that will
undo the multiplexing: a demultiplexer. Such a device must accept the incoming
serial data and direct it in parallel to one of many output lines. The interspersed
snatches of telephone conversations, for example, must be sent to the correct
listeners.
A digital multiplexer is a circuit with 2n data input lines and one output
line. It must also have a way of determining the specific data input line to be se-
lected at any one time. This is done with n other input lines, called the select or Short
selector inputs, whose function is to select one of the 2n data inputs for connec- Even
Multiplexers 143
D0
0
D1
D2
D3
r
D4
D5
D6
D7
7
s0
s1
s2
Figure 13 Multiplexer with eight data inputs.
tion to the output. A circuit for n = 3 is shown in Figure 13. The n selector lines
have 2n = 8 combinations of values that constitute binary select numbers.
Exercise 6 Write expressions for each of the AND gate outputs in terms of the si
and Di inputs, confirming that the multiplier of Dk is the binary equivalent of k. ◆
When the selector inputs have the combination s2s1s0 = 011, for example, the
outputs of all AND gates except the one to which data line D3 is connected will be
0. All other inputs to that AND gate besides D3 will be 1. Hence, D3 appears at the
output of the circuit. In this way, the select inputs whose binary combination cor-
responds to decimal 3 have selected data input D3 for transmittal to the output.
Standard MSI packages are available as multiplexers. Figure 14a shows the
circuit for a package containing two separate multiplexers for n = 2. Practical
considerations not included in Figure 13 account for some of the features of
this circuit. The enable input E, for example, is used to control the period of
time that the multiplexer is operative. Thus, when the value of E is 1, the out-
Short put will be 0 no matter what the values of the select inputs. The circuit will be
Even operative only when the corresponding enable input is 0. (In other circuits, the
144 Chapter 4 Combinational Logic Design
E1
1D0
1D1 output 1
1D2
1D3
s1
s0
1D0
2D0 1D1
1Q
1D2
1D3
2D1 2D0
2D1
output 2 2Q
2D2
2D3 2D3
S0
2D4 S1
EN
E2
(a) (b)
Figure 14 (a) Dual four-input multiplexer with enable. (b) Dual four-input multiplexer with
single enable.
enable signal is not inverted; in such cases, the circuit is operative when E = 1,
just the opposite of the case shown in Figure 14a.)
In addition, note from the figure that both the selector signals and their
complements are inputs to AND gates. The signal inputs themselves are ob-
tained after two inversions. This is especially useful if n is large. In this way, the
circuit that produces the select inputs has as load only a single gate (the in-
verter) rather than several AND gates. In Figure 14a the select inputs are com-
mon to both multiplexers, but each has its own enable. In other designs, the
enable can also be common. A schematic diagram of a dual four-input multi-
plexer (MUX) with a single enable is shown in Figure 14b.
The preferred gate form for many IC logic packages (for example, the
74LS00 and the 74LS10) is the NAND gate. Since the multiplexer design in ei-
ther Figure 13 or 14 is a two-level AND-OR circuit, a direct replacement of all
AND and OR gates by NAND gates will maintain the logic function, as dis-
cussed in the preceding chapter. In this way, the actual implementation of the Short
multiplexer is carried out with NAND gates. Even
Multiplexers 145
EXAMPLE 1
There are five other ways that the two select inputs could have been as-
signed to two of the three switching variables. No conditions need to be satis-
fied by the choice, so it is arbitrary. However, the specific outcome obtained for
the Di inputs depends on that initial choice.
Short
Even 4For a set of m − 1 variables, there are m! ways of assigning m − 1 quantities to specific variables.
146 Chapter 4 Combinational Logic Design
s1 = w s0 = x
wx
00 01 11 10
y
00 1
f
z
01 1 O
yz
11 1 1 …………
10 1
(a) (b)
Figure 15 Multiplexer implementation of f = Σ(0, 1, 6, 7, 11).
Exercise 8 For practice, choose each of the remaining possible ways of assign-
ing select inputs to the switching variables, and then determine the required Di;
specify the external gates needed. ◆
EXAMPLE 2
Demultiplexers
Refer back to the diagram in Figure 12. The demultiplexer shown there is a
single-input, multiple-output circuit. However, in addition to the data input,
there must be other inputs to control the transmission of the data to the ap-
propriate data output line at any given time. Such a demultiplexer circuit
0 = D1 = w'x', D2 = w'x, D3 = w ⊕ x; three AND gates and one XOR gate, in addition to a four-input
Short 6D
Even MUX. ◆
148 Chapter 4 Combinational Logic Design
data input
x
0 D0
1 D1
2 D2
3 D3
4 D4
Control Data
5 D5 Inputs Outputs
C2 C1 C0 D0 D1 D2 D3 D4 D5 D6 D7
6 D6 0 0 0 x 0 0 0 0 0 0 0
C0 0 0 1 0 x 0 0 0 0 0 0
0 1 0 0 0 x 0 0 0 0 0
7 D7
0 1 1 0 0 0 x 0 0 0 0
C1 1 0 0 0 0 0 0 x 0 0 0
1 0 1 0 0 0 0 0 x 0 0
1 1 0 0 0 0 0 0 0 x 0
C2
1 1 1 0 0 0 0 0 0 0 x
(a) (b)
Figure 16 A demultiplexer circuit (a) and its truth table (b).
…
0 A0′A1′A2B0 B1B2′
D14
A0 1
decoder A
A1 2
3 × 23
3
…
A2 4 A0 A1′A2
5
6 A0 A1′A2B0B1B2′
7 D46
…
B 0 B 1 B 2′
D63
0 1 2 3 4 5 6 7
decoder B
3 × 23
B0 B1 B2
n-to-2n-Line Decoder
In the demultiplexer circuit in Figure 16, suppose the data input line is removed.
(Draw the circuit for yourself.) Each AND gate now has only n (in this case three)
inputs, and there are 2n (in this case eight) outputs. Since there isn’t a data input line
to control, what used to be control inputs no longer serve that function. Instead,
they are the data inputs to be decoded. This circuit is an example of what is called
an n-to-2n-line decoder. Each output represents a minterm. Output k is 1 whenever
the combination of the input variable values is the binary equivalent of decimal k.
Now suppose that the data input line from the demultiplexer in Figure 16 is
not removed but retained and viewed as an enable input. The decoder now op-
erates only when the enable x is 1. Viewed conversely, an n-to-2n-line decoder
with an enable input can also be used as a demultiplexer, where the enable be-
comes the serial data input and the data inputs of the decoder become the con-
trol inputs of the demultiplexer.7
Decoders of the type just described are available as integrated circuits
(MSI); n = 3 and n = 4 are quite common. There is no theoretical reason why n
can’t be increased to higher values. Since, however, there will always be practi-
cal limitations on the fan-in (the number of inputs that a physical gate can sup-
port), decoders of higher order are often designed using lower-order decoders
interconnected with a network of other gates.
An illustration is given in Figure 17 for the design of a 6-to-26-line decoder
constructed from two 3-to-23-line decoders. Each of the component decoders
7In practice, the physical implementation of the decoder with enable is carried out with NAND gates. In
that case, it is the complements of the outputs in the circuit under discussion that are obtained, and the
Short enable input is inverted before it is applied to the NAND gates. These are practical details that do not
Even change the principles described here.
150 Chapter 4 Combinational Logic Design
...
AND AND AND AND
...
B
...
gates gates gates gates
C
D
E
has eight outputs. Each of the outputs from the A decoder must be ANDed with
each of the outputs from the B decoder to yield one of the 64 outputs from the
complete decoder. Thus, in addition to the 8 three-input AND gates in each
component decoder, there are 64 two-input AND gates in the interconnection
network. Only two of these are shown explicitly in Figure 17.
Tree Decoder
When higher-order decoders are designed in a hierarchy of several stages of
lower-order ones, a practical difficulty with fan-out (number of gates driven
by one terminal) results. (By a hierarchy of stages we mean, for example, two
3 × 8 stages to form a 6 × 64 decoder, as in Figure 17; then two 6 × 64 stages to
form a 12 × 2 12 decoder; and so on.) Even in Figure 17, each gate in the com-
ponent decoders drives eight other gates. In the next level of the hierarchy,
each of the outputs from the gates in the next-to-last level will have to drive
64 other gates.
This problem is overcome, but only partially, by the decoder design illus-
trated in Figure 18, called a tree decoder. The first stage is a 2-to-4-line decoder.
A new variable is introduced in each successive stage; it or its inverse becomes
one input to each of the two-input AND gates in this stage. The second input to
each AND gate comes from the preceding stage. For example, one of the outputs
of the second stage will be AB'C. This will result in two outputs from the next
stage, AB'CD and AB'CD'. This design does avoid the fan-out problem in the
early stages but not in the later stages. Nevertheless, the problem exists only for
the variables introduced in those stages. Any remedies required will have to be
used for relatively few variables, as opposed to the large number needed by the
design of Figure 17.
Inputs: Outputs:
Excess-3 Seven-Segment
Decimal
Digit w x y z S1 S2 S3 S4 S5 S6 S7
0 0 0 1 1 1 1 1 1 1 1 0
1 0 1 0 0 0 0 0 1 1 0 0
2 0 1 0 1 1 0 1 1 0 1 1
3 0 1 1 0 0 0 1 1 1 1 1
4 0 1 1 1 0 1 0 1 1 0 1
5 1 0 0 0 0 1 1 0 1 1 1
6 1 0 0 1 1 1 0 0 1 1 1
7 1 0 1 0 0 0 1 1 1 0 0
8 1 0 1 1 1 1 1 1 1 1 1
9 1 1 0 0 0 1 1 1 1 0 1
Figure 19 Excess-3 to seven-segment code conversion.
0
w 1
x 2
3
decoder
y
4 × 10
4
z 5
6
7
8
9 3
2 4
7
1 5
6
digit appears at the input, the appropriate segments will light up, displaying
the digit.
Exercise 11 Write the minterm lists for the three segments whose minterm
lists were not given in (8). Confirm the inputs to the OR gate in Figure 20. ◆
1
x1 z1
x2 z2
x3 z3
2n × m
...
...
...
mi
xn zm
2n
n inputs m output
n × 2n 2n × m
decoder interconnection
array
Figure 21 Basic structure of a ROM.
8In certain designs, it is possible for the connections to be erasable; this will be described shortly.
9Although “memory” appears in its name, a ROM does not have memory in the usual sense. As will be
described in Chapters 5 and 6, memory is a characteristic of sequential, but not combinational, circuits.
Short 10The mask, requiring minute attention, is expensive to produce. Hence, mask-programmable ROMs are
Even used only when the cost is justified by very large production runs.
154 Chapter 4 Combinational Logic Design
x1 x2 z1 z2 z3 m0
m1
0 0 1 0 1
0 1 0 1 0 m2
1 0 1 1 1 m3
1 1 0 0 1
z1 z2 z3
(a) (b)
Figure 22 A ROM truth table and its program.
EXAMPLE 3
Figure 22a gives the truth table for the interconnection matrix of a 22 × 3 ROM. The
truth table leads to the ROM program represented by the solid dots at the inter-
sections of the input and output word lines in Figure 22b. Each input word defines
an output word, as required by the truth table. If the input word is 01 (correspond-
ing to minterm m1), for example, only output line z2 will be activated because that
is the only connection with m1 in the connection matrix. Hence, the output word will
be 010, as confirmed also from the truth table. (Confirm from the truth table that
the rest of the program is correct.) ■
11Some PROMs are fabricated so that it is possible to restore them to their blank condition after they
have been programmed for a specific application; these are erasable PROMs, or EPROMs. They have Short
some clear advantages over the nonerasable kind, but their cost is correspondingly higher. Even
Other LSI Programmable Logic Devices 155
A′C′
AB′
AC
B′C
A B C f1 f2 f3 f4
Figure 23 Structure of a PLA.
x x x x
0 1 0 1 0 1 0 1
00 1 00 00 1 00 1
01 1 01 1 1 01 1 1 01 1 1
yz yz yz yz
11 1 11 1 11 11
10 1 10 10 1 10
f1 f2 f3 f4
Inputs Outputs
Product
Term x y z f1 f2 f3 f4
1: x'z' 0 – 0 1 • 1 • f1 = x'z' + xz
2: xy' 1 0 – • • • 1 f2 = xz + y'z
3: xz 1 – 1 1 1 • • f3 = x'z' + y'z
4: y'z – 0 1 • 1 1 1 f4 = xy' + y'z
Figure 24 Programming the PLA.
links at the outputs. For the example in Figure 23, the number of links is 4(6 +
4) = 40. Only 16 of these are to be kept, meaning that, during field program-
ming, 24 links are to be blown out. Typical PLAs have many more inputs, out-
puts, and AND gates than are shown in the example in Figure 23. (IC type
82S100, for example, has n = 16, m = 8, and p = 48.)
When a set of switching functions is presented for implementation with a PLA,
a design goal would be reduction in p (the number of AND gates). The economy
achieved is not derived from a reduction in the production cost of gates. (The pro-
duction cost of an IC is practically the same for one with 40 gates as it is for one
with 50 gates.) Rather, the removal of one AND gate eliminates 2n + m links; the
main source of savings is the elimination of a substantial number of links due to the
elimination of each AND gate. On the other hand, reduction of the number of
AND gates to a minimum does not mean that each function should be minimized
or that all implicants should be prime implicants. The implicants should be chosen
so that as many as possible of them are common to many of the output functions.
and the outputs? We’re sure you answered, “programming only the inputs.” This
is a possibility, but is it worthwhile?
In the case of the ROM, there is no need to program the inputs because, for
any function of n variables, there will be the same (large) number of AND
gates. In the same way, if the number of OR gates at the output could be fixed,
then programming the outputs of the AND gates could be avoided.
In many circuits with multiple outputs, even though the outputs are func-
tions of a large number of input variables, the number of product terms in each
output is small. Hence the number of AND gates that drive each OR gate is
small. In such cases, permanently fixing the number of OR gates and leaving
only the programming of the AND gate inputs for individual design might
make economic sense. The resulting circuit is called programmed array logic
(PAL).12 The number of fusible links in a PAL is only 2np. Standard PALs for
a number of low values of p exist. For example, the PAL16L8 has a maximum
of 16 inputs and 8 outputs.
A programming table for a PAL is similar to the one for a PLA. A case with
six outputs is illustrated in Figure 25. A ROM with 12 input variables would re-
quire 212 = 4096 AND gates. However, let’s assume that for some possible cases,
the canonic sum-of-products expression can be reduced to 16 implicants, only
one of which is shown in Figure 25. The entries in the table would have the same
meanings as those for the PLA. However, for the PAL, the output columns
would be fixed by the manufacturer on the basis of the number of AND gates
already connected to each OR gate.
In the present case, two of the output OR gates are each driven by four AND
gates; the remaining four OR gates are each driven by two AND gates. For any
Short
12PAL is a registered trademark of Advanced Micro Devices. Even
Chapter Summary and Review 159
• Mask-programmable ROM
• Field-programmable ROM
• Programmable logic device (PLD)
• Programmed logic array (PLA)
• Programmed array logic (PAL)
PROBLEMS
1 a. Analyze each of the full adder circuits shown in Figure P1 and write expressions for
the output of each intermediate gate.
b. Obtain logic expressions for the sum and carry circuit outputs.
c. Verify that these expressions are equivalent to the sum and carry functions in
equations (1) in the text.
2 a. A 4-bit carry-lookahead adder is to be designed. In equation (7) in the text for the
carry function, let i = 0 and let j range from 0 to 4. Write the resulting expressions for
C1, C2, C3, and C4.
b. Construct the logic diagram for the 4-bit carry-lookahead whose schematic diagram
is given in Figure 8.
8 Realize each of the functions in Problem 7 using half of a dual 4 × 1 multiplexer and the
minimum number of external gates.
9 Repeat Problem 7 using a 3-to-23-line decoder.
10 Use a dual four-input multiplexer to implement each of the following pairs of functions
with the fewest external gates.
11 a. Show how to connect a 4-bit MSI adder to serve as a BCD-to-excess-3 code converter.
b. Repeat using a 4-to-10-line (BCD-to-decimal) decoder and four AND gates.
12 Design a BCD-to-decimal decoder using two 2-to-4-line decoders and a minimum of in- Short
terconnecting AND gates. Even
Problems 161
Ci+1
xi
yi
Ci
Si
Ci
(a)
xi
Si
xi yi
yi
Ci+1
Ci
Ci+1
Si
(b)
(c)
Ci
xi Si
yi
Ci+1
(d)
Figure P1
13 A circuit is to accept two 2-bit binary numbers x1x0 and y1y0 and emit the product as a 4-bit
binary number z3z2z1z0. (Review binary multiplication in Chapter 1 if you need to.)
a. The result is to be achieved by a (possibly) multilevel circuit with two-input gates.
Determine appropriate expressions for each output. How many levels of gates does
each output have?
b. Design a circuit using a 4-to-24-line decoder with external OR gates.
14 Examine late editions of manufacturers’ data books.
a. What is n for the largest n-to-2n-line decoders?
b. Note what the standard sizes of ROMs are.
c. What are some representative dimensions of a PLA chip?
Short d. What are some representative dimensions of a PAL?
Even e. Is there a BCD adder in a single MSI package?
162 Chapter 4 Combinational Logic Design
20 The code converter in Problem 19 is to be designed with a ROM. The closest-size ROM
available is a 25 × 8. Construct the required programming table. Specify the number of links.
21 The code converter in Problem 19 is to be implemented with a PLA. A 5 × 8 PLA with 12
AND gates is available. Draw a programming diagram for implementing the desired code
converter. Specify the number of links.
22 a. Suppose the circuit in Problem 13 is to be implemented with a 24 × 4 PROM. Show
the programming table and draw an appropriate diagram.
b. Suppose instead that the circuit is to be implemented by a 4 × 4 PLA with 10 AND
gates. Show the programming diagram (in the form of Figure 23 in the text). Compare
the number of links with those of the PROM implementation. Construct the pro-
gramming table in the form of Figure 25 in the text.
c. Now suppose that the circuit is to be implemented by a PAL. Construct the pro-
gramming table in the form of Figure 25 in the text.
23 A combinational circuit having three inputs and six outputs is to be designed. The output
word is to be the square of the input word.
Short
a. Design the circuit using a ROM that has the smallest possible dimensions. Construct
the truth table and specify the number of links. Even
Problems 163
A B C D E f1 f2 f3 f4
(a)
10
A B C D E F f1 f2 f3 f4
(b)
Figure P24
b. Design the circuit using a PLA with the fewest number of product terms. Construct
the programming diagram and specify the number of links.
24 The programming diagrams for two PLAs are shown in Figure P24.
a. Write the equations of the outputs realized by each PLA. Specify the number of links.
b. The same functions are to be implemented with a ROM. Specify the dimensions of
the ROM and the number of links. Set up its programming table.
c. The same functions are to be implemented with a PAL. Is it possible to do so? If so,
Short
set up the programming table and specify the number of links. If it is not possible, ex-
Even
plain why not.
164 Chapter 4 Combinational Logic Design
25 (Review Chapter 1 on Hamming codes if you need to.) Using an n-to-2n-line decoder (for
an appropriate n) and any additional logic:
a. Design the error-correcting logic for a single-error-correcting Hamming code assum-
ing 3 message bits in each code word. The outputs of the circuit shoud be
• E, indicating that an error has been detected
• IV, indicating that the MSG output is invalid (obviously, IV is 0 when no error, or
only a single error, has occurred)
• MSG, a 3-bit output that contains the corrected transmitted message in the cases of
zero and one error
b. Design the single-error-correcting and double-error-detecting (SEC-DED) logic for
an error-correcting Hamming code extended by the addition of a parity bit over all
(that is, message and parity) positions. Assume 3 message bits in each code word. The
output signals and their meanings are to be the same as in part a.
26 Explain in words the behavior of the diagram in Figure P26. (The open-headed arrows
represent multiple-bit inputs and outputs.)
control C
argument 2
B
sum
when: C= 0: pass A
when: C= 1: bit-by-bit argument 1
binary adder
complement
Figure P26
27 A microprocessor (µp) outputs three control signals that have the meanings given in the
following table. (No knowledge of µp is necessary to solve this problem.)
a. Design a logic circuit using a suitable multiplexer and minimal additional logic to trans-
form these three signals into the following four signals, each representing an operation:
When any of the operations is desired (not desired), the value of the corresponding
signal is to be 0 (1).
b. Design a multiplexer implementation to perform the inverse transformation.
28 The 4-bit lookahead unit shown in Figure P28a receives generate and propagate variables Short
from units 0 through 3 comprising a similar group. It also receives C, the carry input to unit Even
Problems 165
0 of the group. It computes C0, C1, and C2, which are the carry outputs from units 0, 1, and 2,
respectively. It also computes the generate and propagate variables, G and P, for the whole
group. The carry outputs are generated in parallel, not in ripple fashion.
G0 G
P0
P C
G1
P1
G2 S
C0 A
P2
G3 C1
P3 G
C2
B P
4-bit
lookahead 4-bit C4
unit adder
(a) (b)
Figure P28
a. Derive equations for all the outputs, and show the implementation.
b. Using 4-bit lookahead units of the above type and 4-bit adders of the type shown in
Figure P28b, draw the logic diagram for a 48-bit adder using a single-level lookahead.
(The open arrows represent multiple-bit inputs and outputs—in this case, 4 bits. A,
for example, stands for a vector of 4 bits: A0, A1, A2, A3.)
c. Repeat part b using two levels of lookahead, in which the G and P outputs of the
first-level lookahead units feed the Gi and Pi inputs of the second-level lookahead
units. Compare with respect to speed with the design of part b.
29 This problem concerns the design of a 4-bit lookahead subtractor (Figure P29).The 4-bit vec-
tor B (B3B2B1B0) is to be subtracted from 4-bit vector A. The borrow input C0 is 1 if and only if
the next lower unit is borrowing a 1 from this unit. The 4-bit vector D is the difference output,
and C4 is the borrow output. G and P are generate and propagate variables from the whole unit.
C0
A D
B G
C4
4-bit
lookahead
subtractor Figure P29
30 An 8-input priority encoder (Figure P30) has eight request inputs: I(7. . . 0). A logic 1 on any
of these lines denotes the presence of a request from the corresponding source for some ser-
vice. The priority varies from the highest for 7 to the lowest for 0. Output LR (Local Request)
is 1 if and only if there is at least one request among the eight I inputs. If EI (Enable Input) is
1, the encoder identifies the request having the highest priority and outputs its 3-bit address on
A(0…2). If no request is active, it outputs a zero address. If the encoder is not enabled (EI = 0),
it outputs zeros on A. EO (Enable Output) is 1 if and only if the encoder is enabled (EI = 1) and
there is no request among the eight I inputs.
EI
A(7...0)
I(7...0)
LR
EO
priority
encoder Figure P30
I3–I0
a
BI BO f b
BCD-to-seven-segment g
decoder
e c
d
a b c d e f g (b)
(a)
Short
Figure P31 Even
Problems 167
Short
Even
2 Building Blocks
2.1 Comparators
2.1.1 Equality
The XOR can be used to compare equality. It will give a 0 when the two
bits are equal and a 1 when they are unequal.
To get a HIGH for equality and a LOW for inequality an XNOR can be
used.
A0
B0
A1
B1
=
A2
B2
A3
B3
26
2.1.2 Integrated Circuit Comparators
They are designed for cascading together and contain inputs for
A = B from the preceding stage
A < B from the preceding stage
A > B from the preceding stage
A0 A0 A4 A0
A1 A1 A5 A1
A2 A2 A6 A2
A3 A3 A7 A3
B0 B0 B4 B0
B1 B1 B5 B1
B2 B2 B6 B2
B3 B3 B7 B3
A<Bi A<Bo A<Bi A<Bo A < B
A=Bi A=Bo A=Bi A=Bo A = B
A>Bi A>Bo A>Bi A>Bo A > B
LSN MSN
Stage 1 Stage 2
27
2.2 Decoders
Decoding is taking a code (binary, BCD, hex etc) and activating a single
output representing its numeric value.
2.2.2 2 to 4 decoder
1 MSB 1
2
DECODER
3
A B Z3 Z2 Z1 Z0 Expression
0 0 0 0 0 1 Z0 = /A . /B
0 1 0 0 1 0 Z1 = /A . B
1 0 0 1 0 0 Z2 = A . /B
1 1 1 0 0 0 Z3 = A . B
Boolean Expressions
Z0 = /A . /B
Z1 = /A . B
Z2 = A . /B
Z3 = A . B
28
We can then construct the circuit for each output.
A B
Z0
Z1
Z2
Z3
29
2.3 Encoders
0 D
Encoder
DECODER
1 C
2 B MSB
1
3 A LSB
0
A B C D Z1 Z0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
Boolean Expressions
Z1 = A + B
Z0 = A + C
Note:
D is not used.
30
We can then construct the circuit for each output.
A
Z1
B
Z0
C
D N/C
31
2.4 Code Convertors
Gray code is a very useful code in electronics and is used for indicating
the angular position of the shaft on a motor.
Gray code allows only one bit to change when moving from one code to
the next. You are familiar with this concept when writing the inputs for a
Karnaugh Map.
_ _ _ _
eg A B , AB , AB , AB
When the motor turns, the wheel connected to the shaft also turns.
Sensors in a fixed position above the wheel pick up the codes and use
them to state the position of the wheel and hence the shaft.
32
If a gray code was used then as the wheel changes from position 3 to
position 0, the binary read goes from 10 to 00. If the sensors were
misaligned and read on a transition from position 3 to position 0 then it
could only read 10 or 00. This eliminates the problem.
1. The Most Significant Bit (MSB) in the Gray code is the same as the
binary number.
2. Going from the MSB to LSB (left to right), add the current bit to the
next bit (right) ignoring the carry. The result of the addition is the gray
code bit.
B0
G0
B1
G1
B2
G2
B3 G3 (MSB)
33
Converting Gray Code to Binary.
1. The Most Significant Bit (MSB) in the Gray code is the same as the
binary number.
2. Going from the MSB to LSB (left to right), add the current gray code
bit to the last binary bit found ignoring the carry. The result of the
addition is the binary code bit.
G0
B0
G1
B1
G2
B2
G3 B3 (MSB)
34
2.4.2 BCD to Binary
BCD 29 is
80 40 20 10 8 4 2 1
0 0 1 0 1 0 0 1
Weight Binary
20 0001 0100 +
8 0000 1000 +
1 0000 0001 +
0010 1101 =
35
2.4.3 Binary to BCD
Example
10: 1010 + 0110 = (1) 0000 BCD: 1_0
15: 1111 + 0110 = (1) 0101 BCD: 1_5
A B C D
A1 S1 LSB
A2 S2
A3 S3
A4 S4
MSB
LO B1
B2
B3 7483A
LO B4
LO C0 C4
A0
A1
A2
A3
HI B0
LO B1 7485
9 LO B2
HI B3
LO A<Bi A<Bo
HI A=Bi A=Bo
LO A>Bi A>Bo
36
2.4.4 BCD to 7 segment
Exercise
Draw the circuits to the BCD to 7 segment converter. There should be 7
equations.
Hint: Create the truth table for each segment, minimise using
Karnuagh maps, and draw the resulting circuit.
37
2.5 Multiplexers
D0
D1
D2 Z
D3
S1 S0
The control lines S0 & S1 can have 4 binary settings. Therefore the
output (Z) can be connected to any one of the inputs (D0 to D3).
S1 S0 Z
0 0 D0
0 1 D1
1 0 D2
1 1 D3
38
2.5.1 Design of Multiplexors
Selectors ANDed
together to give 1.
4. For each input data line, AND it with its equivalent selector state.
S1 S0
D0
D1
Z
D2
D3
39
2.5.2 Using A Multiplexer for Combinational Logic
The concept is that the inputs from the truth table form the selector for the
multiplexer. Each Data line is set to the appropriate output value from the
truth table. When the selector value is set, the output is connected to the
associated Data Line. Hence the output line of the multiplexer passes the
output value from the truth table that is associated with the input values
from the truth table.
Method
1. Generate a truth table.
2. The inputs in the truth table are the selectors of the Multiplexer.
3. Each output term in the truth table corresponds to one Data Input line
of the Multiplexer.
4. Tie each Data Input Line to the corresponding output value from the
truth table.
Example
Green = BC + AC + AB
Truth Table
A B C Green MUX HI LO
0 0 0 0 D0
D0
0 0 1 0 D1 D1
Green
D2 Y
0 1 0 0 D2 D3
D4
0 1 1 1 D3 D5
D6
1 0 0 0 D4 D7
A
1 0 1 1 D5 B A
B
C
1 1 0 1 D6 C
1 1 1 1 D7
40
2.6 Demultiplexers
D0
D1
Z D2
D3
S1 S0
The control lines S0 & S1 can have 4 binary settings. Therefore the input
(Z) can be connected to any one of the outputs (D0 to D3).
S1 S0 D0 D1 D2 D3
0 0 Z 0 0 0
0 1 0 Z 0 0
1 0 0 0 Z 0
1 1 0 0 0 Z
41
2.6.1 Design of Demultiplexers
Selectors ANDed
together to give 1.
4. Each output data line will be the input data (Z) ANDed with its
equivalent selector state.
Z S1 S0
D0
D1
D2
D3
42
2.7 Parity
To use parity to detect errors we must append a parity bit to the data bits
transmitted.
The parity bit is used to set the total number of 1’s to an even number or
an odd number.
Even parity uses the parity bit to make the total number of 1’s an even
number.
Odd parity uses the parity bit to make the total number of 1’s an odd
number.
Example
Q What is value of the parity bit required to make 1011
(a) even parity
(b) odd parity
Error Detection
We must know the type of parity used for the received data.
The received data will have a parity bit. This can be checked by summing
together all the bits in the data received.
For even parity, the sum of all the bits including the parity bit will be 0.
For odd parity the sum of all the bits including the parity bit will be 1.
43
The bits can be summed using XOR circuits in the following manner:
A0
Sum
A1
Summing 2 bits.
A0
A1
Sum
A2
A3
A0
A1
A2
A3
Sum
A4
A5
A6
A7
44
Digital Electronics
Part I – Combinational and
Sequential Logic
Dr. I. J. Wassell
Introduction
Aims
• To familiarise students with
– Combinational logic circuits
– Sequential logic circuits
– How digital logic gates are built using
transistors
– Design and build of digital logic systems
Course Structure
• 11 Lectures
• Hardware Labs
– 6 Workshops
– 7 sessions, each one 3h, alternate weeks
– Thu. 10.00 or 2.00 start, beginning week 3
– In Cockroft 4 (New Museum Site)
– In groups of 2
Objectives
• At the end of the course you should
– Be able to design and construct simple
digital electronic systems
– Be able to understand and apply Boolean
logic and algebra – a core competence in
Computer Science
– Be able to understand and build state
machines
Books
• Lots of books on digital electronics, e.g.,
– D. M. Harris and S. L. Harris, ‘Digital Design
and Computer Architecture,’ Morgan Kaufmann,
2007.
– R. H. Katz, ‘Contemporary Logic Design,’
Benjamin/Cummings, 1994.
– J. P. Hayes, ‘Introduction to Digital Logic
Design,’ Addison-Wesley, 1993.
• Electronics in general (inc. digital)
– P. Horowitz and W. Hill, ‘The Art of Electronics,’
CUP, 1989.
Other Points
• This course is a prerequisite for
– ECAD (Part IB)
– VLSI Design (Part II)
• Keep up with lab work and get it ticked.
• Have a go at supervision questions plus
any others your supervisor sets.
• Remember to try questions from past
papers
Semiconductors to Computers
• Increasing levels of complexity
– Transistors built from semiconductors
– Logic gates built from transistors
– Logic functions built from gates
– Flip-flops built from logic
– Counters and sequencers from flip-flops
– Microprocessors from sequencers
– Computers from microprocessors
Semiconductors to Computers
• Increasing levels of abstraction:
– Physics
– Transistors
– Gates
– Logic
– Microprogramming (Computer Design Course)
– Assembler (Computer Design Course)
– Programming Languages (Compilers Course)
– Applications
Combinational Logic
Introduction to Logic Gates
• We will introduce Boolean algebra and
logic gates
• Logic gates are the building blocks of
digital circuits
Logic Variables
• Different names for the same thing
– Logic variables
– Binary variables
– Boolean variables
• Can only take on 2 values, e.g.,
– TRUE or False
– ON or OFF
– 1 or 0
Logic Variables
• In electronic circuits the two values can
be represented by e.g.,
– High voltage for a 1
– Low voltage for a 0
• Note that since only 2 voltage levels are
used, the circuits have greater immunity
to electrical noise
Uses of Simple Logic
• Example – Heating Boiler
– If chimney is not blocked and the house is cold
and the pilot light is lit, then open the main fuel
valve to start boiler.
b = chimney blocked
c = house is cold
p = pilot light lit
v = open fuel valve
– So in terms of a logical (Boolean) expression
v = (NOT b) AND c AND p
Logic Gates
• Basic logic circuits with one or more
inputs and one output are known as
gates
• Gates are used as the building blocks in
the design of more complex digital logic
circuits
Representing Logic Functions
• There are several ways of representing
logic functions:
– Symbols to represent the gates
– Truth tables
– Boolean algebra
• We will now describe commonly used
gates
NOT Gate
Symbol Truth-table Boolean
a y a y ya
0 1
1 0
b
c v b .c. p
p
Boolean Algebra
• In this section we will introduce the laws
of Boolean Algebra
• We will then see how it can be used to
design combinational logic circuits
• Combinational logic circuits do not have
an internal stored state, i.e., they have
no memory. Consequently the output is
solely a function of the current inputs.
• Later, we will study circuits having a
stored internal state, i.e., sequential
logic circuits.
Boolean Algebra
OR AND
a0 a a.0 0
aa a a.a a
a 1 1 a.1 a
a a 1 a.a 0
• AND takes precedence over OR, e.g.,
a.b c.d (a.b) (c.d )
Boolean Algebra
• Commutation
ab ba
a.b b.a
• Association
( a b) c a (b c)
( a.b).c a.(b.c)
• Distribution
a.(b c ) (a.b) (a.c)
a (b.c. ) (a b).(a c). NEW
• Absorption
a (a.c) a NEW
a.( a c) a NEW
Boolean Algebra - Examples
Show
a.( a b) a.b
a.( a b) a.a a.b 0 a.b a.b
Show
a (a .b) a b
a (a .b) (a a ).(a b) 1.(a b) a b
Boolean Algebra
• A useful technique is to expand each
term until it includes one instance of each
variable (or its compliment). It may be
possible to simplify the expression by
cancelling terms in this expanded form
e.g., to prove the absorption rule:
a a.b a
So is equivalent to
DeMorgan’s in Gates
• So the previous function can be built
using 3 NAND gates
a a
b b
f f
c c
d d
DeMorgan’s in Gates
• Similarly, applying ‘bubbles’ to the input
of an AND gate yields
x
f
y Which is a NOT OR
(NOR) gate
What about this gate?
DeMorgan says x . y x y
So is equivalent to
d
• See in a 4 variable map:
– 1 variable term occupies 8 cells
– 2 variable terms occupy 4 cells
– 3 variable terms occupy 2 cells, etc.
K-maps – 4 variables
• For example, plot
f b f b .d
c c
cd cd
ab 00 01 11 10 ab 00 01 11 10
00 1 1 1 1 00 1 1
01 01
b b
a 11 a 11
10 1 1 1 1 10 1 1
d d
K-maps – 4 variables
• Simplify, f a .b.d b.c.d a .b.c .d c.d
c
cd
ab 00 01 11 10
00 1
01 1 1 1 1
b
1
a 11
10 1
c.d
a.b d
d b a.d d a.c
f b a.c a.d
POS Example
• Applying DeMorgans to a
f b a.c a.d c
f
gives, a
f b.(a c ).(a d ) d
f b.(a c ).(a d ) b
a
a
c
c
f f
a
a
d
d
b
b
Expression in POS form
• Apply DeMorgans and take
complement, i.e., f is now in SOP form
• Fill in zeros in table, i.e., plot f
• Fill remaining cells with ones, i.e., plot f
• Simplify in usual way by grouping ones
to simplify f
Don’t Care Conditions
• Sometimes we do not care about the
output value of a combinational logic
circuit, i.e., if certain input combinations
can never occur, then these are known
as don’t care conditions.
• In any simplification they may be treated
as 0 or 1, depending upon which gives
the simplest result.
– For example, in a K-map they are entered
as Xs
Don’t Care Conditions - Example
• Simplify the function f a .b .d a .c.d a.c.d
With don’t care conditions, a .b .c .d , a .b .c.d , a .b.c .d
c
ab
cd
00 01 11 10 See only need to include
00 X 1 1 X Xs if they assist in making
X 1
01
b a bigger group, otherwise
1
a 11 can ignore.
10 1
c.d
a.b d
f a .b c.d or, f a .d c.d
Some Definitions
• Cover – A term is said to cover a minterm if that
minterm is part of that term
• Prime Implicant – a term that cannot be further
combined
• Essential Term – a prime implicant that covers a
minterm that no other prime implicant covers
• Covering Set – a minimum set of prime
implicants which includes all essential terms plus
any other prime implicants required to cover all
minterms
Number Representation,
Addition and Subtraction
Binary Numbers
• It is important to be able to represent
numbers in digital logic circuits
– for example, the output of a analogue to digital
converter (ADC) is an n-bit number, where n is
typically in the range from 8 to 16
• Various representations are used, e.g.,
– unsigned integers
– 2’s complement to represent negative numbers
Binary Numbers
• Binary is base 2. Each digit (known as a
bit) is either 0 or 1.
• Consider these 6-bit unsigned numbers
1 0 1 0 1 0 4210
32 16 8 4 2 1 Binary
25 24 23 22 21 20 coefficients MSB – most
MSB LSB significant bit
0 0 1 0 1 1 1110 LSB – least
32 16 8 4 2 1 Binary significant bit
25 24 23 22 21 20 coefficients
MSB LSB
Unsigned Binary Numbers
• In general, an n-bit binary number, bn 1bn 2 b1b0
has the decimal value,
n 1
bi 2i
i 0
• So we can represent positive integers from
0 to 2n 1
• In computers, binary numbers are often 8
bits long – known as a byte
• A byte can represent unsigned values from
0 to 255
Unsigned Binary Numbers
• Decimal to binary conversion. Perform
successive division by 2.
– Convert 4210 into binary
42 / 2 21 remainder 0
21 / 2 10 remainder 1
10 / 2 5 remainder 0
5 / 2 2 remainder 1
2 / 2 1 remainder 0
1 / 2 0 remainder 1
• So the answer is 1010102 (reading upwards)
Octal: Base 8
• We have seen base 2 uses 2 digits (0 & 1),
not surprisingly base 8 uses 8 digits : 0, 1,
2, 3, 4, 5, 6, 7.
0 5 2 4210
64 8 1 Octal
82 81 80 coefficients
MSB LSB
• To convert from decimal to base 8 either
use successive division, i.e.,
42 / 8 5 remainder 2
5 / 8 0 remainder 5
• So the answer is 528 (reading upwards)
Octal: Base 8
• Or alternatively, convert to binary, divide
the binary number into 3-bit groups and
work out the octal digit to represent
each group. We have shown that
4210 1010102
• So,
1 0 1 0 1 0 4210
5 28
MSB LSB
Hexadecimal: Base 16
• For base 16 we need 16 different digits.
Consequently we need new symbols for
the digits to represent 10-15
10102 1010 A16 11012 1310 D16
10112 1110 B16 11102 1410 E16
11002 1210 C16 11112 1510 F16
0 2 A16 4210
256 16 1 Hex
162 161 160 coefficients
MSB LSB
Hex: Base 16
• To convert from decimal to base 16 use
either use successive division by 16, i.e.,
42 / 16 2 remainder A
2 / 16 0 remainder 2
• So the answer is 2A8 (reading upwards)
Hex: Base 16
• Or alternatively, convert to binary, divide
the binary number into 4-bit groups and
work out the hex digit to represent each
group. We have shown that
4210 1010102
• So,
0 0 1 0 1 0 1 0 4210
2 A16
MSB LSB
Hex: Base 16
• Hex is also used as a convenient way of
representing the contents of a byte (an
8 bit number), so for example 111000102
1 1 1 0 0 0 1 0 E 216
E 216
MSB LSB
Negative numbers
• So far we have only been able to represent
positive numbers. For example, we have
seen an 8-bit byte can represent from 0 to
255, i.e., 28 = 256 different combinations of
bits in a byte
• If we want to represent negative numbers,
we have to give up some of the range of
positive numbers we had before
– A popular approach to do this is called 2’s
complement
2’s Complement
• For 8-bit numbers:
0 positive 127 128 negative 1
0H 7 FH 80H FFH
• Note all negative numbers have the
MSB set
• The rule for changing a positive 2’s
complement number into a negative 2’s
complement number (or vice versa) is:
Complement all the bits and add 1.
2’s Complement
• What happens when we do this to an 8 bit
binary number x ?
– Invert all bits: x (255 x)
– Add 1: x (256 x)
• Note: 256 (= 100H) will not fit into an 8 bit
byte. However if we ignore the ‘overflow’ bit,
then 256 x behaves just like 0 x
• That is, we can use normal binary arithmetic
to manipulate the 2’s complement of x and it
will behave just like -x
2’s Complement Addition
0 0 0 0 0 1 1 1 7
0 0 0 0 0 1 0 0 4
(0) 0 0 0 0 1 0 1 1 11
• To subtract, negate the second number, then add:
0 0 0 0 0 1 1 1 7
1 1 1 1 1 0 0 1 7
(1) 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 9
1 1 1 1 1 0 0 1 7
(1) 0 0 0 0 0 0 1 0 2
2’s Complement Addition
0 0 0 0 0 1 0 0 4
1 1 1 1 1 0 0 1 7
( 0) 1 1 1 1 1 1 0 1 3
1 1 1 1 1 0 0 1 7
1 1 1 1 1 0 0 1 7
(1) 1 1 1 1 0 0 1 0 14
2’s Complement
• Note that for an n-bit number bn 1bn 2 b1b0 ,
the decimal equivalent of a 2’s complement
number is, n2
bn 1 2n 1 i
b 2 i
i 0
• For example, 1 1 1 1 0 0 1 0
6
b7 27 bi 2i
i 0
1 27 1 26 1 25 1 24 1 21
128 64 32 16 2 14
2’s Complement Overflow
• For example, when working with 8-bit
unsigned numbers, we can use the
‘carry’ from the 8th bit (MSB) to indicate
that the number has got too big.
• With signed numbers we deliberately
ignore any carry from the MSB,
consequently we need a new rule to
detect when a result is out of range.
2’s Complement Overflow
• The rule for detecting 2’s complement
overflow is:
– The carry into the MSB does not equal the
carry out from the MSB.
• We will now give some examples.
2’s Complement Overflow
0 0 0 0 1 1 1 1 15
0 0 0 0 1 1 1 1 15
(0) 0 0 0 1 1 1 1 0 30 OK
0 1 1 1 1 1 1 1 127
0 0 0 0 0 0 0 1 1
(0) 1 0 0 0 0 0 0 0 128 overflow
2’s Complement Overflow
1 1 1 1 0 0 0 1 15
1 1 1 1 0 0 0 1 15
(1) 1 1 1 0 0 0 1 0 30 OK
1 0 0 0 0 0 0 1 127
1 1 1 1 1 1 1 0 2
(1) 0 1 1 1 1 1 1 1 127 overflow
Binary Coded Decimal (BCD)
• Each decimal digit of a number is coded
as a 4 bit binary quantity
• It is sometimes used since it is easy to
code and decode, however it is not an
efficient way to store numbers.
124810 0001 0010 0100 1000BCD
123410 0001 0010 0011 0100BCD
Alphanumeric Character Codes
• ASCII: American Standard Code for
Information Exchange:
– Standard version is a 7 bit code with the
remaining bit usually set to zero
– The first 32 are ‘control codes’ originally used
for controlling modems
– The rest are upper and lower case letters,
numbers and punctuation.
– An extended version uses all 8 bits to
provide additional graphics characters
Alphanumeric Character Codes
• EBCDIC – a legacy IBM scheme, now little
used
• Unicode – a 16 bit scheme, includes
Chinese characters etc.
Binary Adding Circuits
• We will now look at how binary addition
may be implemented using combinational
logic circuits. We will consider:
– Half adder
– Full adder
– Ripple carry adder
Half Adder
• Adds together two, single bit binary
numbers a and b (note: no carry input)
• Has the following truth table:
a b cout sum
a sum
0 0 0 0
0 1 0 1 b cout
1 0 0 1
1 1 1 0
• By inspection:
sum a .b a.b a b
cout a.b
Full Adder
• Adds together two, single bit binary
numbers a and b (note: with a carry input)
a sum
b cout
cin
• Has the following truth table:
Full Adder
cin a b cout sum
sum cin .a .b cin .a.b cin .a .b cin .a.b
0 0 0 0 0
0 0 1 0 1 sum cin .(a .b a.b ) cin .(a .b a.b)
0 1 0 0 1
0 1 1 1 0 From DeMorgan
1 0 0 0 1 a .b a.b (a b).(a b )
1 0 1 1 0
1 1 0 1 0 (a.a a.b b.a b.b )
1 1 1 1 1
(a.b b.a )
So,
sum cin .(a .b a.b ) cin .(a .b a.b )
sum cin .x cin .x cin x cin a b
Full Adder
cin a b cout sum
cout cin .a.b cin .a .b cin .a.b cin .a.b
0 0 0 0 0
0 0 1 0 1 cout a.b.(cin cin ) cin .a .b cin .a.b
0 1 0 0 1
0 1 1 1 0 cout a.b cin .a .b cin .a.b
1 0 0 0 1
1 0 1 1 0 cout a.(b cin .b ) cin .a .b
1 1 0 1 0
1 1 1 1 1 cout a.(b cin ).(b b ) cin .a .b
cout b.(a cin .a ) a.cin b.(a cin ).(a a ) a.cin
cout b.a b.cin a.cin
cout b.a cin .(b a )
Full Adder
• Alternatively,
cin a b cout sum
0 0 0 0 0 cout cin .a.b cin .a .b cin .a.b cin .a.b
0 0 1 0 1
0 1 0 0 1 cout cin .(a .b a.b ) a.b.(cin cin )
0 1 1 1 0 cout cin .(a b) a.b
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
a b a b a b a b
cin cout cin cout cin cout cin cout
sum sum sum sum
s0 s1 s2 s3 c4
Further Considerations
Multilevel Logic
• We have seen previously how we can
minimise Boolean expressions to yield
so called ‘2-level’ logic implementations,
i.e., SOP (ANDed terms ORed together)
or POS (ORed terms ANDed together)
• Note also we have also seen an
example of ‘multilevel’ logic, i.e., full
adders cascaded to form a ripple carry
adder – see we have more than 2 gates
in cascade in the carry chain
Multilevel Logic
• Why use multilevel logic?
– Commercially available logic gates usually
only available with a restricted number of
inputs, typically, 2 or 3.
– System composition from sub-systems
reduces design complexity, e.g., a ripple
adder made from full adders
– Allows Boolean optimisation across multiple
outputs, e.g., common sub-expression
elimination
Building Larger Gates
• Building a 6-input OR gate
Common Expression Elimination
• Consider the following minimised SOP
expression:
z a.d . f a.e. f b.d . f b.e. f c.d . f c.e. f g
• Requires:
• Six, 3 input AND gates, one 7-input
OR gate – total 7 gates, 2-levels
• 19 literals (the total number of times
all variables appear)
Common Expression Elimination
• We can recursively factor out common literals
z a.d . f a.e. f b.d . f b.e. f c.d . f c.e. f g
z (a.d a.e b.d b.e c.d c.e). f g
z ((a b c).d (a b c).e). f g
z (a b c).(d e). f g
• Now express z as a number of equations in 2-
level form:
x abc x d e z x. y. f g
• 4 gates, 9 literals, 3-levels
Gate Propagation Delay
• So, multilevel logic can produce reductions
in implementation complexity. What is the
downside?
• We need to remember that the logic gates
are implemented using electronic
components (essentially transistors) which
have a finite switching speed.
• Consequently, there will be a finite delay
before the output of a gate responds to a
change in its inputs – propagation delay
Gate Propagation Delay
• The cumulative delay owing to a number of
gates in cascade can increase the time
before the output of a combinational logic
circuit becomes valid
• For example, in the Ripple Carry Adder, the
sum at its output will not be valid until any
carry has ‘rippled’ through possibly every full
adder in the chain – clearly the MSB will
experience the greatest potential delay
Gate Propagation Delay
• As well as slowing down the operation of
combinational logic circuits, gate delay can
also give rise to so called ‘Hazards’ at the
output
• These Hazards manifest themselves as
unwanted brief logic level changes (or
glitches) at the output in response to
changing inputs
• We will now describe how we can address
these problems
Hazards
• Hazards are classified into two types,
namely, static and dynamic
• Static Hazard – The output undergoes a
momentary transition when it is
supposed to remain unchanged
• Dynamic Hazard – The output changes
more than once when it is supposed to
change just once
Timing Diagrams
• To visually represent Hazards we will use the
so called ‘timing diagram’
• This shows the logical value of a signal as a
function of time, for example the following
timing diagram shows a transition from 0 to 1
and then back again
Logic ‘1’
Logic ‘0’
Time
Timing Diagrams
• Note that the timing diagram makes a number
simplifying assumptions (to aid clarity)
compared with a diagram which accurately
shows the actual voltage against time
– The signal only has 2 levels. In reality the signal
may well look more ‘wobbly’ owing to electrical
noise pick-up etc.
– The transitions between logic levels takes place
instantaneously, in reality this will take a finite
time.
Static Hazard
Logic ‘1’
Static 1 hazard
Logic ‘0’
Time
Logic ‘0’
Time
Dynamic Hazard
Logic ‘1’
Dynamic hazard
Logic ‘0’
Time
Logic ‘1’
Dynamic hazard
Logic ‘0’
Time
Static 1 Hazard
x y
u
y w
t
t
v u
z v
This circuit implements,
w x. y z. y w
Consider the output when z x 1
and y changes from 1 to 0
Hazard Removal
• To remove a 1 hazard, draw the K-map
of the output concerned. Add another
term which overlaps the essential terms
• To remove a 0 hazard, draw the K-map
of the complement of the output
concerned. Add another term which
overlaps the essential terms
(representing the complement)
• To remove dynamic hazards – not
covered in this course!
Removing the static 1 hazard
w x. y z. y
z
yz x
x 00 01 11 10
0 1 y w
x 1 1 1 1
y
Extra term added to remove
hazard, consequently,
w x. y z. y x.z
z
To Speed up Ripple Carry Adder
• Abandon compositional approach to the adder
design, i.e., do not build the design up from
full-adders, but instead design the adder as a
block of 2-level combinational logic with 2n
inputs (+1 for carry in) and n outputs (+1 for
carry out).
• Features
– Low delay (2 gate delays)
– Need some gates with large numbers of inputs
(which are not available)
– Very complex to design and implement (imagine
the truth table!
To Speed up Ripple Carry Adder
• Clearly the 2-level approach is not
feasible
• One possible approach is to make use
of the full-adder blocks, but to generate
the carry signals independently, using
fast carry generation logic
• Now we do not have to wait for the carry
signals to ripple from full-adder to full-
adder before output becomes valid
Fast Carry Generation
c0 a0 b0 a1 b1 a2 b2 a3 b3
a b a b a b a b
Conventional
cin cout cin cout cin cout cin cout RCA
sum sum sum sum
s0 s1 s2 s3 c4
c0 a0 b0 a1 b1 a2 b2 a3 b3
Fast Carry
Fast Carry Generation Adder
a b a b a b a b
c0 cin cout c1 cin cout c2 cin cout c3 cin cout
sum sum sum sum
s0 s1 s2 s3 c4
Fast Carry Generation
• We will now determine the Boolean
equations required to generate the fast
carry signals
• To do this we will consider the carry out
signal, cout, generated by a full-adder
stage (say i), which conventionally gives
rise to the carry in (cin) to the next stage,
i.e., ci+1.
Fast Carry Generation
Carry out always zero.
ci a b si ci+1 ki ai .bi
Call this carry kill
0 0 0 0 0
0 0 1 1 0 Carry out same as carry in.
0 1 0 1 0 pi ai bi
Call this carry propagate
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1 Carry out generated
1 1 0 0 1
independently of carry in. gi ai .bi
1 1 1 1 1 Call this carry generate
and
ci 4 g i 3 ci 3 . pi 3
ci 4 g i 3 pi 3 .( gi 2 pi 2 .( gi 1 pi 1.g i ) pi 2 . pi 1. pi .ci )
ci 4 g i 3 pi 3 .( g i 2 pi 2 .( g i 1 pi 1.g i )) pi 3 . pi 2 . pi 1. pi .ci
Fast Carry Generation
• So for example to generate c4, i.e., i = 0,
c4 g3 p3.( g 2 p2 .( g1 p1.g 0 )) p3. p2 . p1. p0 .c0
c4 G Pc0
where,
G g3 p3.( g 2 p2 .( g1 p1.g 0 ))
P p3. p2 . p1. p0
• See it is quick to evaluate this function
Fast Carry Generation
• We could generate all the carrys within an
adder block using the previous equations
• However, in order to reduce complexity, a
suitable approach is to implement say 4-bit
adder blocks with only c4 generated using
fast generation.
– This is used as the carry-in to the next 4-bit
adder block
– Within each 4-bit adder block, conventional RCA
is used
Fast Carry Generation
c0 a0 b0 a1 b1 a2 b2 a3 b3
a b a b a b a b
c0 cin cout cin cout cin cout cin cout
sum sum sum sum
s0 s1 s2 s3 c4
Other Ways to Implement
Combinational Logic
• We have seen how combinational logic
can be implemented using logic gates,
e.g., AND, OR etc.
• However, it is also possible to generate
combinational logic functions using
memory devices, e.g., Read Only
Memories (ROMs)
ROM Overview
• A ROM is a data storage device:
– Usually written into once (either at manufacture or
using a programmer)
– Read at will
– Essentially is a look-up table, where a group of
input lines (say n) is used to specify the address
of locations holding m-bit data words
– For example, if n = 4, then the ROM has 24 = 16
possible locations. If m = 4, then each location
can store a 4-bit word
– So, the total number of bits stored is m 2 n
, i.e.,
64 in the example (very small!) ROM
ROM Example
address data Design amounts to putting
z A0 D0 minterms in the appropriate
y A1 64-bit D1 address location
x A2 ROM D2
'0' A3 D3 No logic simplification
required
address data
(decimal) x y z f D3 D2 D1 D0 Useful if multiple Boolean
functions are to be
0 0 0 0 1 X X X 1
1 0 0 1 1 X X X 1 implemented, e.g., in this
2 0 1 0 1 X X X 1 case we can easily do up to
3 0 1 1 1 X X X 1 4, i.e., 1 for each output line
4 1 0 0 0 X X X 0
5 1 0 1 0 X X X 0 Reasonably efficient if lots of
6 1 1 0 0 X X X 0 minterms need to be
7 1 1 1 1 X X X 1 generated
ROM Implementation
• Can be quite inefficient, i.e., become large in
size with only a few non-zero entries, if the
number of minterms in the function to be
implemented is quite small
• Devices which can overcome these problems
are known as programmable array logic (PAL)
• In PALs, only the required minterms are
generated using a separate AND plane. The
outputs from this plane are ORed together in
a separate OR plane to produce the final
output
Basic PAL Structure
a
b
c
AND plane
f0
Programmed by
OR plane
selectively removing
connections in the AND f1
and OR planes –
controlled by fuses or
memory bits f2
Other Memory Devices
• Non-volatile storage is offered by ROMs (and
some other memory technologies, e.g.,
FLASH), i.e., the data remains intact, even
when the power supply is removed
• Volatile storage is offered by Static Random
Access Memory (SRAM) technology
– Data can be written into and read out of the
SRAM, but is lost once power is removed
Memory Application
• Memory devices are often used in computer
systems
• The central processing unit (CPU) often
makes use of busses (a bunch of wires in
parallel) to access external memory devices
• The address bus is used to specify the
memory location that is being read or written
and the data bus conveys the data too and
from that location
• So, more than one memory device will often
be connected to the same data bus
Bus Contention
• In this case, if the output from the data pin of
one memory was a 0 and the output from the
corresponding data pin of another memory
was a 1, the data on that line of the data bus
would be invalid
• So, how do we arrange for the data from
multiple memories to be connected to the
some bus wires?
Bus Contention
• The answer is:
– Tristate buffers (or drivers)
– Control signals
• A tristate buffer is used on the data output of
the memory devices
– In contrast to a normal buffer which is either 1
or 0 at its output, a tristate buffer can be
electrically disconnected from the bus wire, i.e.,
it will have no effect on any other data currently
on the bus – known as the ‘high impedance’
condition
Tristate Buffer
Symbol Functional
Bus line Bus line
analogy
OE = 1
Output Enable
(OE) = 1 OE = 0
OE = 0
Control Signals
• We have already seen that the memory
devices have an additional control input (OE)
that determines whether the output buffers are
enabled.
• Other control inputs are also provided:
– Write enable (WE). Determines whether data is
written or read (clearly not needed on a ROM)
– Chip select (CS) – determines if the chip is
activated
• Note that these signals can be active low,
depending upon the particular device
Sequential Logic
S R Q0 Q 1 R
R
• A similar diagram can be constructed for the
Q output
• We will see later that state diagrams are a
useful tool for designing sequential systems
Clocks and Synchronous Circuits
• For the RS latch we have just described, we
can see that the output state changes occur
directly in response to changes in the inputs.
This is called asynchronous operation
• However, virtually all sequential circuits
currently employ the notion of synchronous
operation, that is, the output of a sequential
circuit is constrained to change only at a time
specified by a global enabling signal. This
signal is generally known as the system clock
Clocks and Synchronous Circuits
• The Clock: What is it and what is it for?
– Typically it is a square wave signal at a
particular frequency
– It imposes order on the state changes
– Allows lots of states to appear to update
simultaneously
• How can we modify an asynchronous
circuit to act synchronously, i.e., in
synchronism with a clock signal?
Transparent D Latch
• We now modify the RS Latch such that its
output state is only permitted to change when
a valid enable signal (which could be the
system clock) is present
• This is achieved by introducing a couple of
AND gates in cascade with the R and S inputs
that are controlled by an additional input
known as the enable (EN) input.
Transparent D Latch
R Symbol
Q
D Q
EN S Q
EN
D
AND truth table
• See from the AND truth table:
a b y
– if one of the inputs, say a is 0, the output
is always 0 0 0 0
– Output follows b input if a is 1 0 1 0
1 0 0
• The complement function ensures 1 1 1
that R and S can never be 1 at the
same time, i.e., illegal avoided
Transparent D Latch
R
Q
EN S Q
D
D EN Q Q comment
X 0 Q Q RS hold
0 1 0 1 RS reset
1 1 1 0 RS set
Qint
D D Q D Q Q D Q
CLK
Qint
D D Q D Q Q
CLK
CLK
Note propagation delays
D have been neglected in
the timing diagram
Qint
Q
D Flip-Flops
• The Master-Slave configuration has
now been superseded by new F-F
circuits which are easier to implement
and have better performance
• When designing synchronous circuits it
is best to use truly edge triggered F-F
devices
• We will not consider the design of such
F-Fs on this course
Other Types of Flip-Flops
• Historically, other types of Flip-Flops
have been important, e.g., J-K Flip-
Flops and T-Flip-Flops
• However, J-K FFs are a lot more
complex to build than D-types and so
have fallen out of favour in modern
designs, e.g., for field programmable
gate arrays (FPGAs) and VLSI chips
Other Types of Flip-Flops
• Consequently we will only consider
synchronous circuit design using D-type
FFs
• However for completeness we will
briefly look at the truth table for J-K and
T type FFs
J-K Flip-Flop
• The J-K FF is similar in function to a
clocked RS FF, but with the illegal state
replaced with a new ‘toggle’ state
J K Q Q comment Symbol
0 0 Q Q hold J Q
0 1 0 1 reset
1 0 1 0 set K Q
1 1 Q Q toggle
Where Q is the next state
and Q is the current state
T Flip-Flop
• This is essentially a J-K FF with its J
and K inputs connected together and
renamed as the T input
Symbol
T Q Q comment Q
0 Q Q hold T
1 Q Q toggle Q
CLK
Since Q is independent of Q D Q
the characteristic table can 0 0
be rewritten as 1 1
Excitation Table
• The characteristic table can be modified to
give the excitation table. This table tells us
the required FF input value required to
achieve a particular next state from a given
current state
As with the characteristic table it can
Q Q D be seen that Q, does not depend
0 0 0 upon, Q , however this is not
0 1 1 generally true for other FF types, in
1 0 0 which case, the excitation table is
1 1 1 more useful. Clearly for a D-FF,
D Q'
Characteristic and Excitation
Tables
• Characteristic and excitation tables can
be determined for other FF types.
• These should be used in the design
process if D-type FFs are not used
• We will now determine the modified
state transition table for the example 0
to 7 up-counter
Modified State Transition
Table
• In addition to columns representing the
current and desired next states (as in a
conventional state transition table), the
modified table has additional columns
representing the required FF inputs to
achieve the next desired FF states
Modified State Transition Table
• For a 0 to 7 counter, 3 D-type FFs are needed
Current Next FF The procedure is to:
state state inputs Write down the desired
Q2 Q1Q0 Q2' Q1' Q0' D2 D1D0 count sequence in the
0 0 0 0 0 1 0 0 1 current state columns
0 0 1 0 1 0 0 1 0 Write down the required
0 1 0 0 1 1 0 1 1
next states in the next
0 1 1 1 0 0 1 0 0 state columns
1 0 0 1 0 1 1 0 1
1 0 1 1 1 0 1 1 0 Fill in the FF inputs
1 1 0 1 1 1 1 1 1 required to give the
1 1 1 0 0 0 0 0 0 defined next state
Note: Since Q ' D (or D Q ' ) for a D-FF, the
required FF inputs are identical to the Next state
Synchronous Counter Example
• Also note that if we are using D-type FFs, it
is not necessary to explicitly write out the
FF input columns, since we know they are
identical to those for the next state
• To complete the design we now have to
determine appropriate combinational logic
circuits which will generate the required FF
inputs from the current states
• We can do this from inspection, using
Boolean algebra or using K-maps.
Synchronous Counter Example
Current Next FF By inspection,
state state inputs
D0 Q0
Q2 Q1Q0 Q2' Q1' Q0' D2 D1D0
Note: FF0 is toggling
0 0 0 0 0 1 0 0 1 Also, D1 Q0 Q1
0 0 1 0 1 0 0 1 0
0 1 0 0 1 1 0 1 1 Use a K-map for D2 ,
0 1 1 1 0 0 1 0 0 Q1Q0
Q0
1 0 0 1 0 1 1 0 1 Q2 00 01 11 10
1 0 1 1 1 0 1 1 0 0 1
1 1 0 1 1 1 1 1 1 Q2 1 1 1 1
1 1 1 0 0 0 0 0 0
Q1
Q0 .Q2 Q1.Q2 Q0 .Q1.Q2
Synchronous Counter Example
Q0
Q1Q0
Q2 00 01 11 10
So,
0 1
Q2 1 1 1 1
D2 Q0 .Q2 Q1.Q2 Q0 .Q1.Q2
Q1 D2 Q2 .(Q0 . Q1 ) Q0 .Q1.Q2
Q0 .Q2 Q1.Q2 Q0 .Q1.Q2
Q0 Q1 Q2
Q0
Q0
Q1 Combinati-
Q Q onal logic Q
D0 D1 Q1 D2
D D Q2 D
Q Q Q2 Q
CLK
Synchronous Counter
• A similar procedure can be used to design
counters having an arbitrary count sequence
– Write down the state transition table
– Determine the FF excitation (easy for D-types)
– Determine the combinational logic necessary to
generate the required FF excitation from the
current states – Note: remember to take into
account any unused counts since these can be
used as don’t care states when determining the
combinational logic circuits
Shift Register
• A shift register can be implemented
using a chain of D-type FFs
Q0 Q1 Q2
Q Q Q
Din D D D
Q Q Q
CLK
CLK
CLK
Mealy
Current state
Machine
Next state Q
combinational Outputs
Inputs combinational D
n m m logic
logic Q
CLK
Moore vs. Mealy Machines
• Outputs from Mealy Machines depend upon
the timing of the inputs
• Outputs from Moore machines come directly
from clocked FFs so:
– They have guaranteed timing characteristics
– They are glitch free
• Any Mealy machine can be converted to a
Moore machine and vice versa, though their
timing properties will be different
Moore Machine - Example
• We will design a Moore Machine to implement
a traffic light controller
• In order to visualise the problem it is often
helpful to draw the state transition diagram
• This is used to generate the state transition
table
• The state transition table is used to generate
– The next state combinational logic
– The output combinational logic (if required)
Example – Traffic Light Controller
R See we have 4 states
So in theory we could
use a minimum of 2 FFs
However, by using 3 FFs
R
we will see that we do not
A A
need to use any output
combinational logic
So, we will only use 4 of
the 8 possible states
G
In general, state assignment is a
difficult problem and the optimum
choice is not always obvious
Example – Traffic Light Controller
State By using 3 FFs (we will use
100 R D-types), we can assign one
to each of the required
outputs (R, A, G), eliminating
State
the need for output logic
010
R
State We now need to write down
A A
110 the state transition table
We will label the FF outputs
R, A and G
Remember we do not need to
G explicitly include columns for FF
State excitation since if we use D-types
001
these are identical to the next state
Example – Traffic Light Controller
Current Next
State
100 R state state
R AG R ' A' G '
State 1 0 0 1 1 0
010 1 1 0 0 0 1
R 0 0 1 0 1 0
State
A
110
A 0 1 0 1 0 0
Unused states, 000, 011, 101 and
111. Since these states will never
occur, we don’t care what output
the next state combinational logic
G gives for these inputs. These don’t
State care conditions can be used to
001 simplify the required next state
combinational logic
Example – Traffic Light Controller
Current Next We now need to determine the next
state state state combinational logic
R AG R ' A' G ' For the R FF, we need to determine DR
1 0 0 1 1 0 To do this we will use a K-map
1 1 0 0 0 1
0 0 1 0 1 0 AG G
0 1 0 1 0 0 R 00 01 11 10
0 X X 1
Unused states, 000, R 1 1 X X
R. A
011, 101 and 111.
R. A A
DR R. A R.A R A
Example – Traffic Light Controller
Current Next By inspection we can also see:
state state
' ' ' DA A
R AG R AG
1 0 0 1 1 0 and,
1 1 0 0 0 1 DG R. A
0 0 1 0 1 0
0 1 0 1 0 0
Q Q Q
DR DA DG
D D D
Q Q Q
CLK
FSM Problems
CLK
Output
Sequential State Assignment
• Here we simply assign the states in an
increasing natural binary count
• As usual we need to write down the
state transition table. In this case we
need 5 states, i.e., a minimum of 3 FFs
(or state bits). We will designate the 3
FF outputs as c, b, and a
• We can then determine the necessary
next state logic and any output logic.
Sequential State Assignment
Current Next By inspection we can see:
state state
The required output is from FF b
c b a c b a Plot k-maps to determine the
0 0 0 0 0 1 next state logic:
0 0 1 0 1 0
0 1 0 0 1 1 For FF a:
a
0 1 1 1 0 0 ba a.c
1 0 0 0 0 0 c 00 01 11 10
0 1 1
c 1 X X X
Unused states, 101,
110 and 111. b
Da a .c
Sequential State Assignment
For FF b:
a
Current Next ba
c 00 01 11 10 a.b
state state
0 1 1
c b a c b a c 1 X X X
0 0 0 0 0 1 a.b
0 0 1 0 1 0 b
0 1 0 0 1 1 Db a .b a.b a b
0 1 1 1 0 0 For FF c:
1 0 0 0 0 0 ba
a
c 00 01 11 10 a.b
Unused states, 101, 0 1
110 and 111. c 1 X X X
b
Dc a.b
Sliding State Assignment
Current Next By inspection we can see that
state state we can use any of the FF
c b a c b a outputs as the wanted output
0 0 0 0 0 1 Plot k-maps to determine the
0 0 1 0 1 1 next state logic:
0 1 1 1 1 0
1 1 0 1 0 0 For FF a:
a
1 0 0 0 0 0 ba b.c
c 00 01 11 10
0 1 1 X
Unused states, 010, c 1 X X
101, and 111.
b
Da b .c
Sliding State Assignment
Current Next By inspection we can see that:
state state For FF b:
c b a c b a Db a
0 0 0 0 0 1 For FF c:
0 0 1 0 1 1
0 1 1 1 1 0 Dc b
1 1 0 1 0 0
1 0 0 0 0 0
r ra g Q a
Q Q Q
Dr Dra Dg Da
D D D D
Q Q Q Q
CLK
R A G
Tripos Example
• The state diagram for a synchroniser is shown.
It has 3 states and 2 inputs, namely e and r.
The states are mapped using sequential
assignment as shown.
e e.r r FF labels
[s1 s0]
Sync Hunt
[10] [00]
e.r
e.r e.r An output, s should be
r true if in Sync state
Sight
[01]
e
Tripos Example
Current Input Next
r state state
e e.r
s1 s0 e r s1' s0'
Sync Hunt
[10] [00] 0 0 X 0 0 0
e.r 0 0 X 1 0 1
e.r e.r 0 1 0 X 0 1
r 0 1 1 0 0 0
Sight
[01] 0 1 1 1 1 0
e 1 0 0 X 1 0
1 0 1 0 0 0
Unused state 11 1 0 1 1 1 0
1 1 X X X X
From inspection, s s1
Tripos Example
Current Input Next Plot k-maps to determine the
state state next state logic
s1 s0 e r s1' s0' For FF 1:
e
0 0 X 0 0 0 er
0 0 X 1 0 1 s1 s0 00 01 11 10 s0 .e.r
0 1 0 X 0 1 00
0 1 1 0 0 0 01 1 s0
0 1 1 1 1 0
11 X X X X
1 0 0 X 1 0 s1
1 0 1 0 0 0 10 1 1 1
1 0 1 1 1 0 r
s1.e s1.r
1 1 X X X X
D1 s1.e s1.r s0 .e.r
Tripos Example
Current Input Next Plot k-maps to determine the
state state next state logic
s1 s0 e r s1' s0' For FF 0:
e
0 0 X 0 0 0 er
0 0 X 1 0 1 s1 s0 00 01 11 10 s1.s0 .r
0 1 0 X 0 1 00 1 1
0 1 1 0 0 0 01 1 1 s0
0 1 1 1 1 0 11 X X X X
1 0 0 X 1 0 s1
10
1 0 1 0 0 0
1 0 1 1 1 0 s0 .e r
1 1 X X X X
D0 s0 .e s1.s0 .r
Tripos Example
• We will now re-implement the synchroniser
using a 1 hot approach
• In this case we will need 3 FFs
e e.r r FF labels
[s2 s1 s0]
Sync Hunt
[100] [001]
e.r An output, s should be
e.r e.r true if in Sync state
r
Sight From inspection, s s2
[010]
e
Tripos Example
Current Input Next
state state
e e.r r
s2 s1 s0 e r s2' s1' s0'
Sync Hunt 0 0 1 X 0 0 0 1
[100] [001]
e.r 0 0 1 X 1 0 1 0
0 1 0 0 X 0 1 0
e.r e.r r 0 1 0 1 0 0 0 1
Sight 0 1 0 1 1 1 0 0
[010] 1 0 0 0 X 1 0 0
e 1 0 0 1 0 0 0 1
1 0 0 1 1 1 0 0
Remember when interpreting this table, because of the 1-
hot shift structure, only 1 FF is 1 at a time, consequently it
is straightforward to write down the next state equations
Tripos Example
Current Input Next For FF 2:
state state D2 s1.e.r s2 .e s2 .e.r
s2 s1 s0 e r s2' s1' s0' For FF 1:
0 0 1 X 0 0 0 1 D1 s0 .r s1.e
0 0 1 X 1 0 1 0 For FF 0:
0 1 0 0 X 0 1 0
0 1 0 1 0 0 0 1 D0 s0 .r s1.e.r s2 .e.r
0 1 0 1 1 1 0 0
1 0 0 0 X 1 0 0
1 0 0 1 0 0 0 1
1 0 0 1 1 1 0 0
Tripos Example
r Note that it is not strictly
e e.r
necessary to write down the
Sync Hunt state table, since the next state
[100]
e.r [001] equations can be obtained from
the state diagram
e.r e.r r It can be seen that for each
Sight
[010] state variable, the required
e equation is given by terms
representing the incoming arcs
on the graph
For example, for FF 2: D2 s1.e.r s2 .e s2 .e.r
Also note some simplification is possible by noting that:
s2 s1 s0 1 (which is equivalent to e.g., s2 s1 s0 )
Tripos Example
• So in this example, the 1 hot is easier to
design, but it results in more hardware
compared with the sequential state
assignment design
Implementation of FSMs
• We saw previously that programmable logic
can be used to implement combinational logic
circuits, i.e., using PAL devices
• PAL style devices have been modified to
include D-type FFs to permit FSMs to be
implemented using programmable logic
• One particular style is known as Generic
Array Logic (GAL)
GAL Devices
• They are similar in concept to PALs, but
have the option to make use of a D-type flip-
flops in the OR plane (one following each OR
gate). In addition, the outputs from the D-
types are also made available to the AND
plane (in addition to the usual inputs)
– Consequently it becomes possible to build
programmable sequential logic circuits
AND plane
Q
OR plane D
Q
GAL
Device Q
D
Q
FPGA
• Field Programmable Gate Array (FPGA)
devices are the latest type of programmable
logic
• Are a sea of programmable wiring and
function blocks controlled by bits downloaded
from memory
• Function units contain a 4-input 1 output look-
up table with an optional D-FF on the output
3 Flip-Flops
Flip-flops and latches are digital memory circuits that can remain in the
state in which they were set even after the input signals have been
removed. This means that the circuits have a memory function and will
hold a value ( 0 or 1 ) until the circuit is forced to change state.
A latch is a memory device that samples and acts upon its input lines
immediately the input lines change. It does not require any external
timing signals.
A flip-flop is a memory device that samples and acts upon its input lines
only when it is told to do so with a special timing signal called the clock.
This may be in the form of a level or an edge. A level trigger means that
the flip-flop samples its inputs depending upon the voltage level of the
trigger input. An edge trigger means that the flip-flop samples its inputs
depending on a LOW-to-HIGH transition on the trigger line or a HIGH-
to-LOW transistion on a trigger line.
3.1 RS Latches
The latch is a logic block that has 2 stable states (0) or (1).
The RS latch can be forced to hold a 1 when the Set line is asserted.
The RS latch can be forced to hold a 0 when the Reset line is asserted.
The RS latch will hold it current value (state) if the Set and Reset lines
are not asserted.
_
R S
Q Q
_ _
Q _ Q
S R
45
The most noticeable thing about the latch is that it has a feedback path
from the output to the inputs. It is this feedback path which enables it to
hold a value even when the inputs are not asserted.
The NOR type has high active R and S inputs. This means they perform
their prescribed action when the lines are high.
The NAND type has low active R and S inputs. This means they perform
their prescribed action when the lines are low.
S Q S Q
R /Q R /Q
Active High indicates that a high (1) will activate the line.
Active Low indicates that a low (0) will activate the line.
46
3.1.1 Reset Condition
R 1 R 1 1 -> 0
Q Q
A 0 A 0
_ _
B 1 Q B 1 Q
S S
0 0 1 -> 0
Q = 0, /Q = 1 Q = 1, /Q = 0
Analysis:
47
3.1.2 Set Condition
R 0 0->1 R 0
Q Q
A A 1
_ _
B Q B 0 Q
S S
1 1->0 1
Q = 0, /Q = 1 Q = 1, /Q = 0
Analysis:
48
3.1.3 Hold Condition
R 0 R 0
Q Q
A 0 A 1
_ _
B 1 Q B 0 Q
S S
0 0
Q = 0, /Q = 1 Q = 1, /Q = 0
Analysis:
49
3.1.4 Disallowed Condition
R 1 R 1 1->0
Q Q
A 0 A
_ _
B Q B 0 Q
S S
1 1->0 1
Q = 0, /Q = 1 Q = 1, /Q = 0
Analysis:
50
3.1.5 Truth Table for Set – Reset Latch
S R Q /Q Comment
1 0 1 0 Sets latch to 1
0 1 0 1 Resets latch to 0
0 0 hold hold Retains Q & /Q values
1 1 - - Disallowed
Timing Diagram
Initial Q=0, then a momentary Set Pulse, then a momentary Reset Pulse
/Q
A B C D E
Region S R Description Q
A 0 0 Hold 0
B 1 0 Set Latch 1
C 0 0 Hold previous 1
D 0 1 Reset Latch 0
E 0 0 Hold previous 0
51
3.2 Gated RS Latch
0 when Enable = 0
Set
S Q Q
Enable
R /Q /Q
Reset
0 when Enable = 0
The AND gates are used to pass the Set and Reset signals to the latch
when the Enable line is asserted.
The following truth table for the gated SR latch can be constructed using
the following properties of AND gates
X.0=0
X.1=X
52
Timing Diagram
En
Set
Reset
A B C D E
Regions B & D, set and reset the latch since Enable is HIGH.
Symbol
S Q
R /Q
En
S is the Set.
R is the Reset.
En is the Enable (Gate).
Q is the output.
53
3.2.1 Integrated Circuit RS Latch (74279)
Two of the latches are unusual in that they have 2 set lines. For most
applications it is best to tie these lines together.
54
3.3 Gated D Latch
A D latch uses only one input to set and reset the latch.
The NOT guarantees that the unwanted R=S=1 does not occur.
En
Enable
Truth Table
55
Timing Diagram
En
Data
A B C D E
The data is loaded into the latch in regions B & D since Enable is HIGH.
Symbol
D Q
En /Q
D is the Data.
En is the Enable (Gate).
Q is the output.
56
3.3.1 Integrated Circuit D Latch (7475)
57
3.4 Triggering & Clocking
In the gated latches, the trigger is the enable line. Setting the enable
HIGH allows the latch to be set or reset.
A B
C D
Letter Comment
A LOW level
B HIGH level
C Positive Edge (LOW -> HIGH Transition)
D Negative Edge (HIGH -> LOW Transition)
58
3.4.1 Edge Triggering
P
X
/P
S S Q Q
R R /Q /Q
Edge
CLK Detector En
D D Q
Edge
CLK Detector En /Q
59
3.4.2 Symbols
60
3.4.4 Integrated Circuit D Flip-Flop (7474)
There is an asynchronous preset and clear for these flip-flops to allow the
initial state to be set.
61
3.5 Edge Triggered JK Flip-Flop
Toggle means that the output (Q) will change to the opposite state (0 to 1
or 1 to 0) after every clock transition.
J
S /Q /Q
Edge
Detector
CLK R Q Q
Truth Table
CLK J K Result
X 0 0 No change
0 0 No change
1 0 Q=1
0 1 Q=0
1 1 Toggle
62
3.5.1 Illustration of Toggle
CLK
A B C D E F
Region En J K Description Q
A 0 0 0 Initial 1
B 1 1 Toggle 0
C 1 1 Toggle 1
D 1 1 Toggle 0
E 1 1 Toggle 1
F 1 1 Toggle 0
Symbol
J Q
Clk /Q
63
3.5.2 Asynchronous Preset and Clear Inputs
The asynchronous inputs are normally preset and clear, which allows the
flip-flop to be set and reset.
The preset and clear are level triggered, generally LOW active.
CLK
PRE
CLR
A B C D E F
64
3.5.3 Other types of flip-flops from JK Flip-Flops
CLK Clk /Q /Q
R K
D J Q Q
CLK Clk /Q /Q
1 J Q Q
CLK Clk /Q /Q
1 K
65
3.5.4 Integrated Circuit JK Flip-Flop (7476)
There is an asynchronous low active preset (/SD) and clear (/CD) for
these flip-flops to allow the initial state to be set.
When the Clock Pulse input is HIGH, the JK inputs are enabled and data
is accepted. This data will be transferred to the outputs according to the
Truth Table on the HIGH-to-LOW clock transitions.
66
3.6 Master – Slave Flip-Flops
The master flip-flop latches the inputs on the positive edge of the clock
and transfers them to the slave on the negative edge of the clock.
A B
Region Description
A Inputs gated into the Master
B Master transfers inputs to Slave
Eg
RS Master Slave Flip-Flop
MASTER SLAVE
S R Q R Q Q
MR
S /Q S /Q /Q
R MS
En En
CLK
The Master latches the SR inputs on the positive edge of the clock.
The Slave latches the MR and MS inputs and generates the Q and /Q on
the negative edge of the clock.
67
3.7 AC Characteristics
The time taken from the triggering input transition to the corresponding
output transition.
tPLH
50%
INPUT
Q 50%
tPLH
68
tPHL
50%
INPUT
50%
tPHL
The minimum time that the logic levels must be maintained on the inputs
prior to the clock transition.
This guarantees that the inputs are reliably clocked into the flip-flop.
50%
INPUT
CLK
50%
tS
69
Hold Time (th)
The minimum time that the logic levels must be maintained on the inputs
after the clock transition.
This guarantees that the inputs are reliably clocked into the flip-flop.
INPUT 50%
50%
CLK
th
The minimum pulse width for the preset, clear, and clock inputs.
3.8 DC Characteristics
Power Dissipation
70
3.9 Propagation Delay
Propagation delays can cause timing problems with flip-flop circuits. The
propagation delay is the time taken for the flip-flop to respond after
receiving the active clock edge.
CLK
tprop
Vcc
CLK
D Q D Q
CLK CLK
FF1 FF2 Q1
tprop
Q2
The idea is that when the negative edge of the clock pulse occurs, the
output of FF1 is latched in FF2.
This will not happen as expected due to the propagation delay of the FF1.
Instead FF2 will latch output of FF1 before FF1 has had time to change
its output.
The way to fix the timing problem is to make FF1 latch the data on the
positive edge and make FF2 latch the data on the negative edge.
71
3.10 RS Latch circuit to remove contact bounce
A switch circuit is shown below. It is expected that when the when the
switch makes contact with pole 1 the line will go low. However, this is
not the case. Switch bounce can cause the voltage to randomly fluctuate
between Vcc and ground until it finally settles at ground. This can cause
false triggering in digital circuits.
VCC
Vcc
1
Sw
Gnd
1
S Q Sw
R Q
2
When the switch is connected to pole 1, the set line is LOW and the reset
line is HIGH. This sets the latch forcing Sw HIGH. When the switch is
connected to pole 2, the reset line is LOW and the set line is HIGH. This
resets the latch forcing Sw LOW. Contact bounce will not affect this
circuit as long as the initial contact with pole 2 is long enough to assert
the reset.
72