Comparators

From Digital Logic Wiki
Jump to: navigation, search

A comparator takes two binary inputs (A and B) and compares them. One of three outputs is generated: A = B, A > B, or A < B.

A one-bit comparator satisfies these three Boolean equations:

One Bit Comparator
A = B LaTeX: (A \oplus B)'
A > B LaTeX: AB'
A < B LaTeX: A'B


The following circuit satisfies the requirements for a one-bit comparator:


One-Bit Comparator


It is possible to cascade one-bit comparators to compare larger numbers; however, as the number of input bits increases the comparator's logic becomes more complex. As with most circuits, it is easier to use an IC to do this job rather than attempt to create a comparator from discreet gates. Following is a functional logic diagram for the 74F85 4-bit comparator. NOTE: this diagram is intended to show the logic function of the 74F85, it is not an accurate representation of the pinout on a physical IC.


74F85 4-Bit Comparator


This device takes two 4-bit inputs and compares them. The appropriate output goes high while the others stay low. For example, if A = B then output A = B will be high while A < B and A > B will be low, as illustrated. Additionally, this IC can input the result of a previous comparison (the three input terminals in the center are labeled A < B, A = B, and A > B) so these ICs can be cascaded to create a comparator for binary numbers greater than 4-bits. NOTE: The 74F85 IC is designed in such a way that a constant high (or 1) must be present on the A=B input in order for the circuit to function; the two other inputs have been tied to ground (a constant 0) in order to keep them from floating.

To create an 8-bit comparator, two 74F85 ICs are cascaded. The four low order bits are fed into the first IC and the four high order bits are fed into the second IC:


74F85 4-Bit Comparators Cascaded
Personal tools