Lec 14 Carry Propagation, Comparator

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

DIGITAL LOGIC DESIGN

LEC 12: ADJACENT 1’S AND COMPARATOR

LECTURER MUHAMMAD SOHAIL ABBAS


Adjacent 1s Detector Circuit
• SOP Implementation
• Directly from function table
• Simplified implementation
• Implementation using NAND gates
Adjacent 1s Detector Function
Input Output Input Output

A B C D F A B C D F
0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 1 0
0 0 1 0 0 1 0 1 0 0
0 0 1 1 1 1 0 1 1 1
0 1 0 0 0 1 1 0 0 1
0 1 0 1 0 1 1 0 1 1
0 1 1 0 1 1 1 1 0 1
0 1 1 1 1 1 1 1 1 1
SOP Implementation
A
B
C
D

F
SOP Expression Simplification

AB\CD 00 01 11 10

00 0 0 1 0

01 0 0 1 1

11 1 1 1 1

10 0 0 1 0
SOP based Simplified Circuit
A
B

C
D F
NAND based Implementation
A
B

C
D F

A
B

C
D F
Adjacent 1s Detector Circuit
• POS Implementation
• Directly from function table
• Simplified Implementation
• Implementation using NOR Gates
POS Implementation
A
B
C
D

F
POS Expression Simplification
AB\CD 00 01 11 10

00 0 0 1 0

01 0 0 1 1

11 1 1 1 1

10 0 0 1 0
POS based Simplified Circuit
A
C

B
D F
NOR based Implementation
A
C

B
D F

A
C

B
D F
Operation of Circuit
• Represented through a timing diagram
• Timing diagram of 8 time intervals
• Each interval representing a new input
POS based Simplified Circuit
A
1
C

B
D 2 F

3
Operation of Circuit
D

t0 t1 t2 t3 t4 t5 t6 t7 t8

F
MAGNITUDE COMPARATOR
• Thecomparison of two numbers is an operation that
determines whether one number is greater than, less
than, or equal to the other number. A magnitude
comparator is a combinational circuit that compares
two numbers A and B and determines their relative
magnitudes. The outcome of the comparison is
specified by three binary variables that indicate
whether A > B, A = B, or A < B.

• thecircuit for comparing two n -bit numbers has 22n


entries in the truth table
Comparator Circuit
• Inputs two 2-bit binary numbers A and B
• Has three outputs
• A>B
• A=B
• A<B
Function Table for A>B

Inputs Output Inputs Output


A1 A0 B1 B0 A>B A1 A0 B1 B0 A>B
0 0 0 0 0 1 0 0 0 1
0 0 0 1 0 1 0 0 1 1
0 0 1 0 0 1 0 1 0 0
0 0 1 1 0 1 0 1 1 0
0 1 0 0 1 1 1 0 0 1
0 1 0 1 0 1 1 0 1 1
0 1 1 0 0 1 1 1 0 1
0 1 1 1 0 1 1 1 1 0
Function Table for A=B

Inputs Output Inputs Output


A1 A0 B1 B0 A=B A1 A0 B1 B0 A=B
0 0 0 0 1 1 0 0 0 0
0 0 0 1 0 1 0 0 1 0
0 0 1 0 0 1 0 1 0 1
0 0 1 1 0 1 0 1 1 0
0 1 0 0 0 1 1 0 0 0
0 1 0 1 1 1 1 0 1 0
0 1 1 0 0 1 1 1 0 0
0 1 1 1 0 1 1 1 1 1
Function Table for A<B

Inputs Output Inputs Output


A1 A0 B1 B0 A<B A1 A0 B1 B0 A<B
0 0 0 0 0 1 0 0 0 0
0 0 0 1 1 1 0 0 1 0
0 0 1 0 1 1 0 1 0 0
0 0 1 1 1 1 0 1 1 1
0 1 0 0 0 1 1 0 0 0
0 1 0 1 0 1 1 0 1 0
0 1 1 0 1 1 1 1 0 0
0 1 1 1 1 1 1 1 1 0
Karnaugh Map for A>B
A 1 B1  A 0 B 1 B 0  A 1 A 0 B 0
A1A0/
00 01 11 10
B1B0

00 0 0 0 0

01 1 0 0 0

11 1 1 0 1

10 1 1 0 0
Karnaugh Map for A=B
A 1 A 0 B1 B 0  A 1 A 0 B1B 0  A 1 A 0B1B 0  A 1 A 0B1 B 0
A1A0/
00 01 11 10
B1B0

00 1 0 0 0

01 0 1 0 0

11 0 0 1 0

10 0 0 0 1
Karnaugh Map for A<B
A 1B1  A 1 A 0B 0  A 0B1B 0
A1A0/
00 01 11 10
B1B0

00 0 1 1 1

01 0 0 1 1

11 0 0 0 0

10 0 0 1 0
COMPARATOR
• Consider two numbers, A and B , with four digits each.
Write the coefficients of the numbers in descending order
of significance:

A = A3 A2 A1 A0
B = B3 B2 B1 B0

• Thetwo numbers are equal if all pairs of significant digits


are equal: A3 = B3, A2 = B2, A1 = B1, and A0 = B0. When
the numbers are binary, the digits are either 1 or 0, and the
equality of each pair of bits can be expressed logically with
an exclusive-NOR function as

xi = AiBi + A’i B’i for i = 0, 1, 2, 3


COMPARATOR
•The equality of the two numbers A and B is
displayed in a combinational circuit by an
output binary variable that we designate by
the symbol 1A = B2 . This binary variable is
equal to 1 if the input numbers, A and B , are
equal, and is equal to 0 otherwise. For
equality to exist, all xi variables must be
equal to 1, a condition that dictates an AND
operation of all variables:
(A = B) = x3x2x1x0
COMPARATOR
•To determine whether A is greater or less
than B , we inspect the relative magnitudes
of pairs of significant digits, starting from the
most significant position. If the two digits of a
pair are equal, we compare the next lower
significant pair of digits. The comparison
continues until a pair of unequal digits is
reached. If the corresponding digit of A is 1
and that of B is 0, we conclude that A > B. If
the corresponding digit of A is 0 and that of B
is 1, we have A < B.
COMPARATOR
• Thesequential comparison can be expressed logically
by the two Boolean functions
(A > B) = A3B’3 + x3 A 2B’2 + x3x2A1B’1 + x3x2x1A0B’0
• In
a 4-bit comparator the condition of A>B can be
possible in the following four cases:
• If A3 = 1 and B3 = 0
• If A3 = B3 and A2 = 1 and B2 = 0
• If A3 = B3, A2 = B2 and A1 = 1 and B1 = 0
• If A3 = B3, A2 = B2, A1 = B1 and A0 = 1 and B0 = 0
COMPARATOR
• Thesequential comparison can be expressed logically
by the two Boolean functions
(A < B) = A’3B3 + x3 A’2B2 + x3x2A’1B1 + x3x2x1A’0B0

• In
a 4-bit comparator the condition of A<B can be
possible in the following four cases:

• If A3 = 0 and B3 = 1
• If A3 = B3 and A2 = 0 and B2 = 1
• If A3 = B3, A2 = B2 and A1 = 0 and B1 = 1
• If A3 = B3, A2 = B2, A1 = B1 and A0 = 0 and B0 = 1
12-bit Comparator
0 A<B in A<B out A<B in A<B out A<B in A<B out

+5v A=B in A=B out A=B in A=B out A=B in A=B out
74X85 74X85 74X85
0 A>B in A>B out A>B in A>B out A>B in A>B out

A0 A4 A8
A0 A0 A0
B0 B4 B8
B0 B0 B0
A1 A5 A9
A1 A1 A1
B1 B5 B9
B1 B1 B1
A2 A6 A10
A2 A2 A2
B2 B6 B10
B2 B2 B2
A3 Comparator1 A7 Comparator2 A11 Comparator3
A3 A3 A3
B3 B7 B11
B3 B3 B3

A(0-11)

B(0-11)

You might also like