Title: DLD Lecture 15 Magnitude Comparators and Multiplexers
1DLDLecture 15Magnitude Comparators and
Multiplexers
2Overview
- Discussion of two digital building blocks
- Magnitude comparators
- Compare two multi-bit binary numbers
- Create a single bit comparator
- Use repetitive pattern
- Multiplexers
- Select one out of several bits
- Some inputs used for selection
- Also can be used to implement logic
3Comparators
- Comparing two binary words is a common operation
in computers. - A circuit that compares 2 binary words and
indicates whether they are equal is a comparator. - Some comparators interpret their input as signed
or unsigned numbers and also indicate an
arithmetic relationship (greater or less than)
between the words. - These circuits are often called magnitude
comparators. - XOR and XNOR gates can be viewed as 1-bit
comparators. - Comparator is a combinational logic circuit that
compares the magnitudes of two binary quantities
to determine which one has the greater magnitude. - In other word, a comparator determines the
relationship of two binary quantities.
4Designing Comparators Functionally
5Designing Comparators Functionally
6Build a four-bit Comparator (from four one-bit
ones)
7Comparing 2-bit Numbers - Specification
- Lets design a circuit that compares two 2-bit
numbers, A and B. The - circuit should have three outputs
- G (Greater) should be 1 only when A gt B
- E (Equal) should be 1 only when A B
- L (Lesser) should be 1 only when A lt B
- Make sure you understand the problem
- Inputs A and B will be 00, 01, 10, or 11 (0, 1, 2
or 3 in decimal) - For any inputs A and B, exactly one of the three
outputs will be 1
8Comparing 2-bit Numbers - Specification
- Two 2-bit numbers means a total of four inputs
- We should name each of them
- Lets say the first number consists of digits A1
and A0 from left to - right, and the second number is B1 and B0
- The problem specifies three outputs G, E and L
9Comparing 2-bit Numbers - Formulation
- For this problem, its probably easiest to start
with a truth table. This way, we can explicitly
show the relationship (gt, , lt) between inputs - A four-input function has a sixteen-row truth
table - Its usually clearest to put the truth table rows
in binary numeric order in this case, from 0000
to 1111 for A1, A0, B1 and B0 - Example 01 lt 10, so the sixth row of the truth
table (corresponding to inputs A01 and B10)
shows that output L1, while G and E are both 0.
10Comparing 2-bit Numbers - Formulation
11Comparing 2-bit Numbers - Optimization
- Lets use K-maps. There are three functions (each
with the same inputs - (A1 A0 B1 B0), so we need three K-maps
G(A1,A0,B1,B0) A1 A0 B0 A0 B1 B0 A1 B1
12Comparing 2-bit Numbers - Optimization
E(A1,A0,B1,B0) A1 A0 B1 B0 A1 A0 B1 B0
A1 A0 B1 B0 A1 A0 B1 B0
13Comparing 2-bit Numbers - Optimization
L(A1,A0,B1,B0) A1 A0 B0 A0 B1 B0 A1 B1
14Comparing 2-bit Numbers - Optimization
G A1 A0 B0 A0 B1 B0 A1 B1 E A1 A0
B1 B0 A1 A0 B1 B0 A1 A0 B1 B0 A1A0 B1
B0 L A1 A0 B0 A0 B1 B0 A1 B1
15Comparing 2-bit Numbers - Optimization
E A1 A0 B1 B0 A1 A0 B1 B0 A1 A0 B1
B0 A1A0 B1 B0
You can show,
16N-bit Equal Comparator
171-bit comparator
- If two input bits are not equal, its output is a
1. But if two input bits are equal, its output is
a 0. - So exclusive?OR gate can be used as a 2?bit
Comparator.
181-bit comparator
Design a logic circuit which will compute F
(A B)
X
Z
Y
XNOR
19Magnitude Comparator
- The comparison of two numbers
- outputs AgtB, AB, AltB
- Design Approaches
- the truth table
- 22n entries - too cumbersome for large n
- use inherent regularity of the problem
- reduce design efforts
- reduce human errors
A lt B
A3..0
Magnitude Compare
A B
B3..0
A gt B
20Magnitude Comparator
How can we find A gt B?
How many rows would a truth table have?
28 256
21Magnitude Comparator
Find A gt B
Because A3 gt B3 i.e. A3 . B3 1
If A 1001 and B 0111 is A gt B? Why?
Therefore, one term in the logic equation for A gt
B is A3 . B3
22Magnitude Comparator
If A 1010 and B 1001 is A gt B? Why?
23Magnitude Comparison
- Algorithm -gt logic
- A A3A2A1A0 B B3B2B1B0
- AB if A3B3, A2B2, A1B1and A1B1
- Test each bit
- equality xi AiBiAi'Bi'
- (AB) x3x2x1x0
- More difficult to test less than/greater than
- (AgtB) A3B3'x3A2B2'x3x2A1B1'x3x2x1 A0B0'
- (AltB) A3'B3x3A2'B2x3x2A1'B1x3x2x1 A0'B0
- Start comparisons from high-order bits
- Implementation
- xi (AiBi'Ai'Bi)
24Magnitude Comparison
25Magnitude Comparator
- Real-world application
- Thermostat controller
26Multiplexers (Data Selectors)
- A multiplexer (MUX) is a device that allows
several low-speed signals to be sent over one
high-speed output line. - Select lines are used to specify which input
signal is sent to the output. - A demultiplexer (DEMUX) performs the opposite
task as the multiplexer it divides one
high-speed input signal into several low-speed
components. - Multiplexers and demultiplexers must be
synchronized so that the proper signals are
selected. - This type of multiplexing is referred to as
time-division multiplexing (TDM). Another type
of multiplexing is frequency-division
multiplexing (FDM) - Multiplexed signals are typically transmitted in
precisely organized manners according to a set of
rules for transmission called a protocol.
27Multiplexers
- A multiplexer has
- N control inputs
- 2N data inputs
- 1 output
- A multiplexer routes (or connects) the selected
data input to the output. - The value of the control inputs determines the
data input that is selected.
28Multiplexers
Data inputs
Z A'.I0 A.I1
Control input
29Multiplexers
A B F
0 0 I0
0 1 I1
1 0 I2
1 1 I3
Z A'.B'.I0 A'.B.I1 A.B'.I2 A.B.I3
30Multiplexers
A B C F
0 0 0 I0
0 0 1 I1
0 1 0 I2
0 1 1 I3
1 0 0 I4
1 0 1 I5
1 1 0 I6
1 1 1 I7
Z A'.B'.C'.I0 A'.B'.C.I1 A'.B.C'.I2
A'.B.C.I3 A.B'.C'.I0 A.B'.C.I1
A'.B.C'.I2 A.B.C.I3
31Multiplexers
Logic equation for the 2n-to-1 MUX
32Multiplexers
- A multiplexer (MUX) selects one data line from
two or more input lines and routes data from the
selected line to the output. The particular data
line that is selected is determined by the select
inputs. - Select an input value with one or more select
bits - Use for transmitting data
- Allows for conditional transfer of data
- Sometimes called a mux
334 to 1- Line Multiplexer
34Quadruple 2to1-Line Multiplexer
- Notice enable bit
- Notice select bit
- 4 bit inputs
35Multiplexer as combinational modules
- Connect input variables to select inputs of
multiplexer (n-1 for n variables) - Set data inputs to multiplexer equal to values of
function for corresponding assignment of select
variables - Using a variable at data inputs reduces size of
the multiplexer
36Implementing a Four- Input Function with a
Multiplexer
37Typical multiplexer uses
38Three-state gates
- A multiplexer can be constructed with three-state
gates - Output state 0, 1, and high-impedance (open
ckts) - If the select input (E) is 0, the three-state
gate has no output
Opposite true here, No output if E is 1
39Three-State Buffers
- 3-State buffer makes use of the output of two or
more gates or other logic devices can be
connected to each other. - Enable Signal B 1 the output C A
- Enable Signal B 0 the output C Open
40Three-State Buffers
- Four kinds of three-state buffers
- Can not operate Output ZUnclear output
Output X
(b)
(c)
(d)
(a)
41Three-state gates
- A multiplexer can be constructed with three-state
gates - Output state 0, 1, and high-impedance (open
ckts) - If the select input is low, the three-state gate
has no output
42Summary
- Magnitude comparators allow for data comparison
- Can be built using and-or gates
- Greater/less than requires more hardware than
equality - Multiplexers are fundamental digital components
- Can be used for logic
- Useful for datapaths
- Scalable
- Tristate buffers have three types of outputs
- 0, 1, high-impedence (Z)
- Useful for datapaths