You are on page 1of 14

Comparators

Unit-3
Combinational Logic

Reference: Chapter 1, Digital design by M. Morris Mano 5 th edition Pearson


Comparator

Definition
The comparator is comparison of A<B (Less than)
A
two numbers i.e. an operation Comparator A=B (Equal)
B
that determines whether one
A>B (Greater than)
number is greater than, less than,
or equal to the other number. Block Diagram of A Normalized Comparator
Single bit Comparator
Truth Table for single bit comparator

A<B
A
A B A>B A=B A<B
A=B
0 0 0 1 0
B
A>B 0 1 0 0 1
Logic Diagram
1 0 1 0 0
1 1 0 1 0

Note: Word ‘A’ or ‘B’ is a single bit i.e. ‘0’ or ‘1’


Magnitude Comparator

Definition
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.
Two-Bit Magnitude Comparator
A1 A0 B1 B0 A>B A=B A<B
0 0 0 0 0 1 0
Two-Bit Magnitude Comparator 0 0 0 1 0 0 1
0 0 1 0 0 0 1
0 0 1 1 0 0 1
0 1 0 0 1 0 0
A - A0 A1
B – B0 B1 0 1 0 1 0 1 0
0 1 1 0 0 0 1
0 1 1 1 0 0 1
A>B =Σm(4, 8, 9, 12, 13, 14)
1 0 0 0 1 0 0
A=B =Σm(0, 5, 10, 15) 1 0 0 1 1 0 0

A<B =Σm(1, 2, 3, 6, 7, 11) 1 0 1 0 0 1 0


1 0 1 1 0 0 1
1 1 0 0 1 0 0
1 1 0 1 1 0 0
1 1 1 0 1 0 0

For More Details: https://www.youtube.com/watch?v=BhUUmbz76P0 1 1 1 1 0 1 0


A>B = Σm(4, 8, 9, 12, 13, 14) A=B =Σm(0, 5, 10, 15) A<B =Σm(1, 2, 3, 6, 7, 11)

B1’B0’ B1’B0 B1B0 B1B0’ B1’B0’ B1’B0 B1B0 B1B0’ B1’B0’ B1’B0 B1B0 B1B0’

A1’A0’ A1’A0’ 1 A1’A0’ 1 1 1

A1’A0 1 A1’A0 1 A1’A0 1 1

A1A0 1 1 1 A1A0 1 A1A0

A1A0’ 1 1 A1A0’ 1 A1A0’ 1

A>B

A=B

A<B
Solution

Logic Diagram Boolean functions for 3 cases


Four-bit magnitude comparator
Four-bit magnitude comparator
M.S.B. L.S.B. M.S.B. L.S.B.
Word - A A3 A2 A1 A0 1 1 0 0

B3 B2 B1 B0 1 0 0 0
Word -B M.S.B. L.S.B. M.S.B. L.S.B.

Which bit has more value (Weight)?

M.S.B.? L.S.B.?
Four-bit magnitude comparator
A3 A2 A1 A0 B3 B2 B1 B0 A>B A=B A<B

0 1 1 1 1 0 o 0 0 0 1

Answer is
First check A3 = B3
A3=0 and B3 = 1, so that A3<B3.
So no necessity to Check (a2,b2), (a1,b1), (a0,b0)
A<B
8 4 2 1 8 4 2 1
1 0 0 0 0 1 1 1
Four-bit magnitude comparator
A3 A2 A1 A0 B3 B2 B1 B0 A>B A=B A<B

1 1 0 1 1 0 o 0 1 0 0

Answer is
First check A3 B3, if it equal then
check A2, B2.
Here A2 =1 and B2=0.
so that A2>B2 A>B
No necessity to check remaining bits
Four-bit magnitude comparator
A3 A2 A1 A0 B3 B2 B1 B0 A>B A=B A<B

0 1 1 1 0 1 1 1 0 1 0

Answer is
First check A3 = B3
then Check A2=B2
then check A1=B1
then check A0=B0
A=B
Four-bit
Magnitude
Comparator

You might also like