0% found this document useful (0 votes)
8 views

13 Comparators

Uploaded by

engmanalf98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

13 Comparators

Uploaded by

engmanalf98
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Digital Logic Design

-Magnitude Comparator-
Comparing Bits

A comparator is used to compare magnitudes of two binary numbers

How could you test if two bits are equal ?

A B O
0 0 1
0 1 0
1 0 0
1 1 1
AB + A’B’ = XNOR gate

Instr: Dr. Awais M. Kamboh. 2


Comparing Numbers

Comparator is used to compare magnitudes of two binary numbers


A simple comparator can test for equality of 2 numbers using XNOR gates.

How could you test two 4-bit numbers for equality?

AND the outputs of four XNOR gates.

A3
A B O B3
0 0 1 A2
B2 Output
0 1 0
A1
1 0 0 B1
1 1 1 A0
B0
Instr: Dr. Awais M. Kamboh. 3
Comparing Bits
A comparator is used to compare magnitudes of two binary numbers
How could you test if two bits are equal ?
A B O
0 0 1
0 1 0
1 0 0
1 1 1 AB + A’B’ = XNOR gate
How could you test if bit A is greater than bit B ?
A B O
0 0 0 A
0 1 0 B
1 0 1
1 1 0
How could you test if bit B is greater than bit A ?
A
B
Instr: Dr. Awais M. Kamboh. 4
Comparators

Assuming a single bit we want to check if A > B, A==B, A<B

A B A > B A < B A = = B

0 0 0 0 1

0 1 0 1 0

1 0 1 0 0

1 1 0 0 1

Instr: Dr. Awais M. Kamboh. 5


Comparators
4 bit Comparator for judging if two binary numbers are equal

Compare fourth, third, second and first bits of A and B


If all four bits are equal then numbers are equal, Use 4 input AND

Bit 3

Bit 2

Bit 1

Bit 0
Instr: Dr. Awais M. Kamboh. 6
Comparators Determine if binary number A is smaller than B
Check if MSB bit-3 of A is smaller , if yes then A <B
OR Check if bit-3 of A == B and if bit-2 of A < B, if yes A < B
OR Check if bits 3 and 2 of A == B and if bit-1 of A < B, if yes A < B
OR Check if bits 3, 2, and 1 of A == B and if bit-0 of A < B, if yes A < B
Bit 3

Bit 2

Bit 1

Bit 0
Instr: Dr. Awais M. Kamboh. 7
Comparator

Instr: Dr. Awais M. Kamboh. 8


Comparators

IC comparators provide outputs to indicate which of the numbers is larger or


if they are equal. The bits are numbered starting at 0. Cascading inputs are
provided to expand the comparator to larger numbers.

COMP
A0 0
A1 A
A2
A3 3
Cascading A>B A>B
A=B A=B Outputs
inputs
A<B A<B
B0 0
B1 A
B2
B3 3
The IC shown is the
4-bit 74LS85.

Instr: Dr. Awais M. Kamboh. 9

You might also like