Lecture 23 Final Review 3

Download Report

Transcript Lecture 23 Final Review 3

Counter Example
• 3-bit synchronous binary counter using D FF’s
• Step (1): State Diagram
• Step (2): State Assignment
– Use variables (A,B,C) and 3-bit binary assignment
• Step (3): State Transition Table
• Step (4): Derivation of Next State Equations
• Step (5): Logic Diagram
Sequence Detector
• Design sequence detector (for 1101) using J-K FF
• Step (1): State Diagram
• Steps (2) and (3): State Assignment & State
Transition Table
Transition
J Input
K Input
0 -> 0
0
x
0 -> 1
1
x
1 -> 0
x
1
1 -> 1
x
0
• Step (4): Derivation of Next State and Output
Equations
• Step (5): Logic Diagram
Conversion to NAND-Gate Circuits
A + BC + DE'F
A
A
B
C
B
C
D
E'
F
A
B
C
D
E'
F
D
E'
F
Simplification Goals
• Goal -- minimize the cost of realizing a switching function
• Cost measures and other considerations
–
–
–
–
–
Number of gates
Number of levels
Gate fan in and/or fan out
Interconnection complexity
Preventing hazards
• Two-level realizations
– Minimize the number of gates (terms in switching function)
– Minimize the fan in (literals in switching function)
Example
Determine the form and the number of terms and literals in each of the following.
g(A,B,C) = AB + A B + AC
Two-level form, three products , two sums, six literals.
--------------------
f(X,Y,Z) = X Y(Z + Y X) + Y Z
Four-level form, four products, two sums, seven literals.
Minimization Methods
• Commonly used techniques
– Boolean algebra postulates and theorems
– Karnaugh maps
– Quine-McCluskey method
Minimum SOP and POS Representations
• The minimum sum of products (MSOP) of a function, f, is a SOP
representation of f that contains the fewest number of product terms
and fewest number of literals of any SOP representation of f.
• Example -- f(a,b,c,d) = m(3,7,11,12,13,14,15) = ab + acd + acd
= ab + cd
• The minimum product of sums (MPOS) of a function, f, is a POS
representation of f that contains the fewest number of sum terms and
the fewest number of literals of any POS representation of f.
• Example -- f(a,b,c,d) = M(0,1,2,4,5,6,8,9,10)
= (a + c)(a + d)(a + b + d)(b + c + d)
= (a +c)(a + d)(b + c)(b + d)
Karnaugh Maps
• Karnaugh maps (K-maps) -- convenient tool for representing switching
functions of up to six variables.
• K-maps form the basis of useful heuristics for finding MSOP and
MPOS representations.
• An n-variable K-map has 2n cells with each cell corresponding to a
row of an n-variable truth table.
• K-map cells are labeled with the corresponding truth-table row.
• K-map cells are arranged such that adjacent cells correspond to truth
rows that differ in only one bit position (logical adjacency).
• Switching functions are mapped (or plotted) by placing the function’s
value (0,1,d) in each cell of the map.
Figure Venn diagram and equivalent K-map
for two variables
A
A
m
A
B
AB
B
AB
AB
(a)
B
0
AB
2
3
m
m
0
2
m
m
1
A
A
0
0
2
1
0
2
1
3
0
1
3
1
B
3
(d)
(e)
(f)
A
B
0
0
1
1
AB
2
0
3
1
(g)
m
(c)
B
1
m
(b)
A
B
m
00
01
10
11
f(AB)
Figure Venn diagram and equivalent K-map
for three variables
A
A
A
B
B
B
ABC
ABC
ABC
ABC
m4
ABC ABC
ABC
C
m2
m6
m7
m3
m5
m1
m0
ABC
C
(a)
(b)
A
m2
m6
m1
m3
m7
2
6
m5
AB
C
00
4
01
11
10
0
2
6
4
1
3
7
5
0
m4
1
C
(c)
A
0
m0
C
3
7
5
1
C
B
B
(d)
(e)
(f)
Plotting (Mapping) Functions in Canonical Form
on a K-map
• Let f be a switching function of n variables where n  6.
• Assume that the cells of the K-map are numbered from 0
to 2n where the numbers correspond to the rows of the
truth table of f.
• If mi is a minterm of f, then place a 1 in cell i of the K-map.
• Example -- f(A,B,C) = m(0,3,5)
• If Mi is a maxterm of f, then place a 0 in cell i.
• Example -- f(A,B,C) = M(1,2,4,6,7)
• If di is a don’t care of f, then place a d in cell i.
Figure Plotting functions on K-maps
f(A,B,C) = m(0,3,5) = M(1,2,4,6,7)
A
AB
A
C
00
0
0
1
6
0
0
01
11
6
10
C
00
4
0
01
7
1
5
1
B
(c)
6
0
1
C 1
11
2
0
3
1
A
AB
1
1
C 1
5
0
(b)
A
2
0
B
AB
0
4
7
1
(a)
00
10
0
3
0
B
C
11
2
1
C 1
C
01
10
4
0
3
7
0
5
0
B
(d)
0
Figure K-maps for f(a,b,Q,G)
(a) Minterm form. (b) Maxterm form.
f(a,b,Q,G) = m(0,3,5,7,10,11,12,13,14,15) = M(1,2,4,6,8,9)
a
Q ab
G
00
0
00
01
4
12
1
1
5
11
7
1
2
8
13
1
3
10
0
1
6
9
1
10
G
12
10
8
5
0
13
9
0
7
15
11
14
10
11
Q
1
11
0
3
1
10
1
4
1
11
14
01
0
01
1
15
00
00
1
01
Q
11
a
Q ab
G
2
10
6
0
0
b
b
(a)
(b)
G
Figure : f(Q,G,b,a).
f(Q,G,b,a) = m(0,12,6,14,9,13,3,7,11,15) = m(0,3,6,7,9,11,12,13,14,15)
Q
G
Q
ba
00
0
00
01
4
11
12
1
1
5
13
9
1
3
11
7
1
2
10
8
1
01
b
10
15
1
6
1
1
14
1
1
10
1
G
a
11
(a) Venn diagram form. (b) Sum of minterms. (c) Maxterms.
f(A,B,C) = AB + BC
Universal set
A
BC
C
B
AB
(a)
A
BC
AB
C
00
0
01
11
2
0
6
1
1
10
3
C
00
4
0
0
1
7
C 1
A
AB
5
11
6
0
3
0
7
0
(b)
5
0
AB
B
10
4
0
1
C 1
1
01
2
B
(c)
.
(a) Maxterms, (b) Minterms, (c) Minterms of f .
f(A,B,C,D) = (A + C)(B + C)(B + C + D)
A
(A + C)
AB
CD
00
0
00
01
4
0
1
01
5
00
13
0
00
0
01
9
15
D
11
2
(B + C + D)
6
14
0
5
C
10
13
7
1
6
14
(a)
(b)
00
A
0
00
4
1
1
01
BC
01
11
12
10
8
1
5
1
1
13
9
1
3
7
2
6
1
15
11
11
C
10
14
1
BCD
10
1
B
(c)
1
10
1
B
CD
D
11
1
1
B
AC
9
15
1
2
10
AB
10
8
1
3
0
11
12
1
11
10
4
1
11
C
01
0
0
7
CD
10
8
0
0
3
11
12
A
AB
(B + C)
D
.
(a) K-map of f, (b) K-map of f.
f(A,B,C,D)= (A+B)(A+C+D)(B+C+D)
A
AB
CD
00
0
01
4
11
12
00
1
5
13
7
11
0
00
9
15
1
2
6
11
14
D
1
C
10
8
1
13
9
15
11
1
7
1
2
10
12
5
3
11
1
1
11
10
4
1
1
01
1
01
1
10
00
8
1
3
C
CD
10
1
01
A
AB
1
6
1
D
14
1
10
1
B
B
(a)
(b)
Simplification of Switching Functions
Using K-maps
• K-map cells that are physically adjacent are also logically
adjacent. Also, cells on an edge of a K-map are logically
adjacent to cells on the opposite edge of the map.
• If two logically adjacent cells both contain logical 1s, the
two cells can be combined to eliminate the variable that
has value 1 in one cell’s label and value 0 in the other.
• This is equivalent to the algebraic operation, aP + aP =P
where P is a product term not containing a or a.
• Example -- f(A,B,C,D) = m(1,2,4,6,9)
f(A,B,C,D) = m(1,2,4,6,9)
Step 2
A
AB
CD
00
0
01
4
00
11
10
12
8
13
9
1
01
5
1
1
3
7
15
11
2
6
14
10
11
C
10
Step 1
1
1
Step 3
1
B
D
Simplification Guidelines for K-maps
• Each cell of an n-variable K-map has n logically adjacent cells.
• Cells may be combined in groups of 2,4,8,…,2k.
• A group of cells can be combined only if all cells in the group have the
same value for some set of variables.
• Always combine as many cells in a group as possible. This will result
in the fewest number of literals in the term that represents the group.
• Make as few groupings as possible to cover all minterms. This will
result in the fewest product terms.
• Always begin with the “loneliest” cells.
Figure 3.11 K-map illustrating implicants
A
AB
C
00
0
01
2
0
6
1
1
C
11
1
3
1
10
4
1
7
1
5
1
B
Minterms: {AB C, A BC, A BC, ABC, ABC}
Groups of two minterms: {A B, AB, A C, BC, BC}
Groups of four minterms: {B}
MSOP = A C + B
f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)
A
AB
CD
00
0
01
4
00
1
5
3
13
7
1
2
10
9
15
6
D
1
11
12
5
3
7
1
2
14
4
1
D
11
5
3
C
1
10
8
1
13
7
1
2
10
12
1
11
10
11
1
01
1
1
01
00
9
15
A
0
1
1
6
1
00
8
13
10
AB
CD
10
1
1
11
14
1
B
1
01
6
D
11
1
(b)
A
00
15
1
B
01
4
2
9
1
(a)
AB
0
13
7
1
10
1
00
5
3
C
10
10
8
1
1
11
1
CD
10
1
11
11
12
1
01
1
14
01
4
00
1
1
00
0
1
1
11
C
10
8
1
01
C
11
12
A
AB
CD
15
1
6
9
1
D
11
1
14
1
10
1
B
B
(c)
(d)
f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)
A
AB
CD
00
0
01
4
00
1
5
13
11
7
1
2
6
0
9
15
14
4
1
D
11
5
3
C
1
1
14
01
4
00
9
1
D
11
5
3
C
1
13
7
1
2
10
10
8
1
1
11
10
11
12
1
01
1
1
00
0
1
1
6
CD
10
1
15
A
AB
8
13
7
2
10
12
1
11
10
11
1
01
1
1
01
00
1
1
00
8
1
1
3
10
12
CD
10
1
01
C
11
A
AB
15
1
6
9
1
D
11
1
14
1
10
1
B
B
B
(a)
(b)
(c)
Use a K-MAP to simplify the
following function
F  a, b, c, d    m 1,7,8,12   d 3,6,9,10 
Four-variable K-Map
ab
00
cd
01
00
01
1
11
d
10
11
10
1
1
d
1
d
d
F  a, b, c, d    m 1,7,8,12   d 3,6,9,10 
Four-variable K-Map
ab
00
cd
01
00
01
1
11
d
10
11
10
1
1
d
1
d
d
F  a, b, c, d   abd  acd  acd
f(A,B,C,D) = m(0,5,7,8,10,12,14,15)
A
AB
CD
00
0
00
01
4
1
1
5
CD
10
13
0
00
1
9
3
7
15
1
2
6
01
4
1
D
11
14
10
5
13
7
2
6
(b)
AB
00
01
4
1
5
13
CD
10
3
7
00
1
9
6
01
4
15
1
D
11
14
5
10
1
1
13
1
9
1
3
C
10
10
8
1
7
11
1
11
12
1
01
1
2
00
0
1
11
A
AB
8
1
01
C
11
12
1
1
B
A
00
10
1
(a)
0
D
11
1
14
B
CD
9
15
1
10
1
1
1
3
C
10
1
10
8
1
11
1
11
12
1
01
1
11
00
8
1
01
C
11
12
A
AB
15
1
2
6
D
11
1
14
10
10
1
B
B
(c)
(d)
1
f(A,B,C,D) = m(1,2,3,6) = AC + BC
A
AB
C
00
0
01
2
0
1
6
1
1
C
11
3
1
10
4
1
7
1
B
5
f(A,B,C,D) = BD + BC + BCD
A
AB
00
CD
0
00
01
4
01
8
1
5
13
9
1
3
1
7
11
15
1
2
10
12
10
1
1
C
11
6
D
11
1
14
1
10
1
B
f(A,B,C,D) = m(0,4,5,7,8,10,14,15)
A
AB
CD
00
0
00
01
4
1
1
10
5
0
00
1
13
9
7
11
15
1
2
6
01
4
1
1
D
11
5
14
10
1
7
11
C
10
1
10
6
0
00
1
9
01
4
1
1
15
D
11
14
5
10
1
7
11
C
10
1
10
8
1
13
9
15
11
1
3
1
11
12
1
01
1
2
00
CD
8
13
A
AB
1
3
1
11
12
1
01
1
3
00
CD
8
1
01
C
11
12
A
AB
1
2
6
D
1
14
10
10
1
B
B
B
(a)
(b)
(c)
1
Find the minimum POS form of the function
f(A,B,C,D) = M(0,1,2,3,6,9,14)
A
AB
CD
00
0
00
4
01
12
CD
10
8
13
0
9
0
11
15
11
01
D
11
6
0
14
0
10
0
C
10
4
12
8
5
13
9
0
7
15
11
6
14
10
0
2
10
11
0
3
0
01
0
1
0
7
2
00
00
5
3
10
11
0
1
C
01
A
AB
0
0
0
B
B
(a)
(b)
D
Algorithm -- Finding MPOS of f from f
1. Plot the complement function f on the K-map.
2. Produce a MSOP of f.
3. Complement f and use DeMorgan’s theorem to produce a
MSOP of f.
Find the MPOS of the following function
f(A,B,C,D) = M(0,1,2,3,6,9,14)
A
AB
CD
00
0
00
4
01
12
CD
10
8
13
0
9
1
11
15
11
01
D
11
6
1
14
1
10
1
B
(a)
K-map of f
C
10
4
12
8
5
13
9
1
7
15
11
6
14
10
1
2
10
11
1
3
1
01
1
1
1
7
2
00
00
5
3
10
11
1
1
C
01
A
AB
1
1
1
B
(b)
f = A B + B C D + BCD
f = (A + B)(B + C + D )(B + C + D)
D
Example 3.19 -- Minimum covers of
f(A,B,C,D) =  M (3,4,6,8,9,11,12,14) and its complement.
A
AB
CD
00
0
01
4
00
11
12
0
1
5
13
11
7
9
15
14
0
10
0
11
12
1
5
10
8
1
13
1
9
01
D
1
3
11
0
6
4
1
11
01
00
0
0
2
10
0
0
3
00
8
01
C
CD
10
0
A
AB
C
B
(a)
15
1
6
14
1
10
1
B
(b)
Figure 3.21
D
11
1
2
10
7
Figure Deriving POS and SOP forms of a function.
A
AB
CD
00
0
00
01
4
11
12
0
1
5
11
C
7
13
2
10
0
00
9
15
0
14
D
C
B
(a)
7
0
9
15
14
B
(b)
4
1
D
11
10
10
8
1
13
9
15
11
1
7
11
C
12
5
1
3
1
11
1
01
1
D
1
2
10
1
01
00
1
6
00
8
13
1
2
CD
10
1
11
10
0
12
A
AB
1
5
3
0
10
4
11
1
1
11
01
01
0
0
6
00
8
0
3
CD
10
0
01
A
AB
6
14
1
10
1
B
(c)
1
Example -- Minimizing a Function with Don’t Cares.
f(A,B,C,D) = m(1,3,4,7,11) + d(5,12,13,14,15)
= M(0,2,6,8,9,10)  D(5,12,13,14,15)
A
AB
CD
00
0
01
4
00
12
1
1
01
5
1
3
11
C
11
1
2
6
00
9
15
d
10
SOP
12
d
7
0
9
d
15
0
D
11
d
2
10
8
13
11
C
10
d
5
3
1
10
d
B
(a)
D
11
0
01
11
14
01
4
1
d
1
00
0
d
d
7
CD
10
8
13
A
AB
6
0
14
0
10
d
B
(b)
POS
0
Example Design a circuit to distinguish
BCD digits  5 from those  5.
ABCD
A
B
C
D
Logic
circuit
(a)
f
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Minterm
f(A, B, C, D)
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
0
0
0
0
1
1
1
1
1
d
d
d
d
d
d
(b)
Figure block diagram and truth table.
Example
A
AB
CD
00
0
01
4
11
12
00
1
5
01
3
7
11
C
2
10
14
B
(a)
d
10
8
d
13
9
d
7
15
0
2
10
12
0
11
C
11
0
5
3
d
10
d
0
01
D
11
01
4
1
1
d
1
00
9
15
6
0
1
d
1
00
8
13
1
CD
10
d
A
AB
d
6
14
0
D
11
d
10
d
d
B
(b)
MSOP
MPOS
Figure 3.26 Use of don’t cares for SOP and POS forms.
f(A,B,C,D) = A + BD + BC; f(A,B,C,D) = (A + B)(A + C + D)
A
A
1
1
1
1
1
1
1
1
D
1
D
1
C
1
1
C
B
(a)
B
(b)
WHAT IS A DECODER
Decoders and Multiplexers
• In older days, the (good) printers used to be like typewriters:
– To print “A”, a wheel turned, brought the “A” key up,
which then was struck on the paper.
• Letters are encoded as 8 bit codes inside the computer.
– When the particular combination of bits that encodes “A”
is detected, we want to activate the output line
corresponding to A
– (Not actually how the wheels worked)
• How to do this “detection” : decoder
• General idea: given a k bit input,
– Detect which of the 2^k combinations is represented
– Produce 2^k outputs, only one of which is “1”.
WHAT A DECODER DOES
S1
0
0
1
1
S0
0
1
0
1
Q0
1
0
0
0
Q1
0
1
0
0
Q2
0
0
1
0
Q3
0
0
0
1
• For instance, if the input S1 S0 = 10 (decimal 2), then output Q2 is true, and Q0,
Q1, Q3 are all false.
• This circuit “decodes” a binary number into a “one-of-four” code.
Decoders and Multiplexers
• A n-to-2n decoder takes an n-bit input and produces 2n outputs. The n
inputs represent a binary number that determines which of the 2n
outputs is uniquely true.
• A 2-to-4 decoder operates according to the following truth table.
– The 2-bit input is called S1S0, and the four outputs are Q0-Q3.
– If the input is the binary number i, then output Qi is uniquely true.
ENABLE INPUTS
EN
0
0
0
0
1
1
1
1
S1
0
0
1
1
0
0
1
1
S0
0
1
0
1
0
1
0
1
Q0
0
0
0
0
1
0
0
0
Q1
0
0
0
0
0
1
0
0
Q2
0
0
0
0
0
0
1
0
Q3
0
0
0
0
0
0
0
1
Decoders and Multiplexers
• Many devices have an additional enable input, which is used to “activate” or
“deactivate” the device.
• For a decoder,
– EN=1 activates the decoder, so it behaves as specified earlier. Exactly one
of the outputs will be 1.
– EN=0 “deactivates” the decoder. By convention, that means all of the
decoder’s outputs are 0.
• We can include this additional input in the decoder’s truth table:
BLOCKS AND ABSTRACTION
Q0
Q1
Q2
Q3
= S1’ S0’
= S1’ S0
= S1 S0’
= S1 S0
• A decoder block provides abstraction:
– You can use the decoder as long as you know its truth table or
equations, without knowing exactly what’s inside.
– It makes diagrams simpler by hiding the internal circuitry.
– It simplifies hardware reuse. You don’t have to keep rebuilding the
decoder from scratch every time you need it.
• These blocks are like functions in programming!
Decoders and Multiplexers
• Decoders are common enough that we want to encapsulate
them and treat them as an individual entity.
• Block diagrams for 2-to-4 decoders are shown here. The
names of the inputs and outputs, not their order, is what
matters.
A 3-TO-8 DECODER
S2
0
0
0
0
1
1
1
1
S1
0
0
1
1
0
0
1
1
S0
0
1
0
1
0
1
0
1
Q0
1
0
0
0
0
0
0
0
Q1
0
1
0
0
0
0
0
0
Q2
0
0
1
0
0
0
0
0
Q3
0
0
0
1
0
0
0
0
Q4
0
0
0
0
1
0
0
0
Q5
0
0
0
0
0
1
0
0
Q6
0
0
0
0
0
0
1
0
Q7
0
0
0
0
0
0
0
1
Q0
Q1
Q2
Q3
Q4
Q5
Q6
Q7
= S2’ S1’ S0’
= S2’ S1’ S0
= S2’ S1 S0’
= S2’ S1 S0
= S2 S1’ S0’
= S2 S1’ S0
= S2 S1 S0’
= S2 S1 S0
Decoders and Multiplexers
• Larger decoders are similar. Here is a 3-to-8 decoder.
– The block symbol is on the right.
– A truth table (without EN) is below.
– Output equations are at the bottom right.
• Again, only one output is true for any input combination.
• A n-to-2n decoder generates the minterms of an n-variable
function.
– As such, decoders can be used to implement arbitrary
functions.
– Later on we’ll see other uses for decoders too.
• Some variations of the basic decoder include:
– Adding an enable input.
– Using active-low inputs and outputs to generate maxterms.
• We also talked about:
– Applying our circuit analysis and design techniques to
understand and work with decoders.
– Using block symbols to encapsulate common circuits like
decoders.
– Building larger decoders from smaller ones.
SUMMARY
Decoders and Multiplexers
• A 2n-to-1 multiplexer sends one of 2n input lines to a single
output line.
– A multiplexer has two sets of inputs:
MULTIPLEXERS
– The mux output is a single bit, which is one of the 2n data
inputs.
• The simplest example is a 2-to-1 mux:
Q = S’ D0 + S D1
Decoders and Multiplexers
• 2n data input lines
• n select lines, to pick one of the 2n data inputs
• The select bit S controls which of the data bits D0-D1 is chosen:
– If S=0, then D0 is the output (Q=D0).
– If S=1, then D1 is the output (Q=D1).
MORE TRUTH TABLE
ABBREVIATIONS
• Here is a full truth table for this 2-to-1 mux, based on the
equation:
Q
0
1
0
1
0
0
1
1
S
0
1
Q
D0
D1
• Here is another kind of abbreviated truth table.
– Input variables appear in the output column.
– This table implies that when S=0, the output Q=D0, and
Decoders and Multiplexers
Q = S’ D0 + S D1
S D1 D0
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
A 4-TO-1 MULTIPLEXER
0
0
0
0
1
0
0
1
1
x
0
1
0
1
x
D0
D1
D2
D3
1
Q = S1’ S0’ D0 + S1’ S0 D1 + S1 S0’ D2 + S1 S0 D3
Decoders and Multiplexers
• Here is a block diagram and abbreviated truth table for a 4to-1 mux.
• Be careful! In LogicWorks the multiplexer has an activelow EN input signal. When EN’ = 1, the mux always
outputs 1.
EN’ S1 S0 Q
IMPLEMENTING FUNCTIONS
WITH MULTIPLEXERS
1
1
1
1
0
0
1
1
0
1
0
1
0
0
1
1
Decoders and Multiplexers
• Muxes can be used to implement arbitrary functions.
• One way to implement a function of n variables is to use
an n-to-1 mux:
– For each minterm mi of the function, connect 1 to mux
data input Di. Each data input corresponds to one row of
the truth table.
– Connect the
input variables to the mux select
x function’s
y z f
0 0 are
0 used
0 to indicate a particular input
inputs. These
0 0 1 1
combination.
0 1 0 1
• For example,0 let’s
1 1look
0 at f(x,y,z) = m(1,2,6,7).
59
z
0
1
0
1
0
1
0
1
A
MORE
EFFICIENT
WAY
• We can actually implement f(x,y,z) =
m(1,2,6,7) with just a 4-to-1 mux, instead
of an 8-to-1.
• Step 1: Find the truth table for the function,
and group the rows into pairs. Within each
pair of rows, x and y are the same, so f is a
function of z only.
–
–
–
–
When xy=00, f=z
When xy=01, f=z’
When xy=10, f=0
When xy=11, f=1
• Step 2: Connect the first two input
f
0
1
1
0
0
0
1
1
Decoders and Multiplexers
y
0
0
1
1
0
0
1
1
June 18th, 2008
x
0
0
0
0
1
1
1
1
n
n
Decoders and Multiplexers
• A 2 -to-1 multiplexer routes one of 2 input lines to a single
output line.
• Just like decoders,
– Muxes are common enough to be supplied as stand-alone
devices for use in modular designs.
– Muxes can implement arbitrary functions.
• We saw some variations of the standard multiplexer:
– Smaller muxes can be combined to produce larger ones.
– We can add active-low or active-high enable inputs.
• As always, we use truth tables and Boolean algebra to
analyze things.
June 18th, 2008
SUMMARY
SIGNED MAGNITUDE
REPRESENTATION
0100 = 4
(a 4-bit unsigned number)
• Examples:
2
10
0 0100 = +410
1 0100 = -410
(a positive number in 5-bit signed magnitude)
(a negative number in 5-bit signed magnitude)
Subtraction
11012 = 1310
(a 4-bit unsigned number)
–0 1101
A 0 =sign
represents
a 5-bit
positive
number.
+1310 bit
(a positive
number in
signed magnitude)
-1310 bit
(a negative
numberain negative
5-bit signed magnitude)
–1 1101
A 1 =sign
represents
number.
June 24th, 2004
• Humans use a signed-magnitude system:
we add + or - in front of a magnitude to
indicate the sign.
• We could do this in binary as well, by
adding an extra sign bit to the front of our
numbers. By convention:
11012 = 1310
0 1101 = +1310
1 0010 = -1310
(a 4-bit unsigned number)
(a positive number in 5-bit one’s complement)
(a negative number in 5-bit one’s complement)
01002 = 410
0 0100 = +410
1 1011 = -410
(a 4-bit unsigned number)
(a positive number in 5-bit one’s complement)
(a negative number in 5-bit one’s complement)
Subtraction
numbers by complementing each bit of the number.
• We keep the sign bits: 0 for positive numbers, and 1 for
negative. The sign bit is complemented along with the
rest of the bits.
• Examples:
June 24th, 2004
ONE’S COMPLEMENT
REPRESENTATION
• A different approach, one’s complement, negates
11012
0 1101
1 0010
1 0011
= 1310
= +1310
= -1310
= -1310
(a 4-bit unsigned number)
(a positive number in 5-bit two’s complement)
(a negative number in 5-bit ones’ complement)
(a negative number in 5-bit two’s complement)
01002
0 0100
1 1011
1 1100
= 410
= +410
= -410
= -410
(a 4-bit unsigned number)
(a positive number in 5-bit two’s complement)
(a negative number in 5-bit ones’ complement)
(a negative number in 5-bit two’s complement)
Subtraction
negate a number, complement each bit (just
as for ones’ complement) and then add 1.
• Examples:
June 24th, 2004
TWO’S
COMPLEMENT
• Our final idea is two’s complement. To
– You
can
1 0 0subtract
1 1 (-1310an
) n-bit two’s 1complement
1 1 0 0 (-410) number from
n
2.
– You can complement all of the bits to the left of the
rightmost 1.
01101 = +1310
complement)
10011 = -13
(a positive number in two’s
(a negative number in
Subtraction
• Two other equivalent ways to negate two’s
100000
100000
complement
numbers:
- 0 1 1 0 1 (+1310)
- 0 0 1 0 0 (+410)
June 24th, 2004
MORE ABOUT TWO’S
COMPLEMENT
– Do unsigned addition on A and B, including their sign
bits.
0111
+ 1100
– Ignore any carry out.
10011
• For example, to find 0111 + 1100, or (+7) + (4):
– First add 0111 + 1100 as unsigned numbers:
Subtraction
• Negating a two’s complement number takes a
bit of work, but addition is much easier than
with the other two systems.
• To find A + B, you just have to:
June 24th, 2004
TWO’S COMPLEMENT
ADDITION