Digital Comparators |
Navigation |
|
|
The Digital Comparator
Another common and very useful combinational logic circuit is that of the Digital Comparator
circuit. Digital or Binary Comparators are made up from standard AND,
NOR and NOT gates that compare the digital signals at their input
terminals and produces an output depending upon the condition of the inputs. For example, whether input
A is greater than, smaller than or equal to input B etc.
Digital Comparators can compare a variable or unknown number for example
A (A1, A2, A3, .... An, etc) against that of a constant or known value
such as B (B1, B2, B3, .... Bn, etc) and produce an output depending upon the result. For example,
a comparator of 1-bit, (A and B) would produce the following three
output conditions.

This is useful if we want to compare two values and produce an output when the condition is achieved.
For example, produce an output from a counter when a certain count number is reached. Consider the simple 1-bit comparator below.
1-bit Comparator
Then the operation of a 1-bit digital comparator is given in the following Truth Table.
Truth Table
| Inputs | Outputs |
| B | A | A > B | A = B | A < B |
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 |
You may notice two distinct features about the comparator from the above truth table. Firstly, the circuit
does not distinguish between either two "0" or two "1"'s as an output A = B is produced when they
are both equal, either A = B = "0" or A = B = "1". Secondly, the output
condition for A = B resembles that of a commonly available logic gate, the
Exclusive-NOR or Ex-NOR gate giving
Q = A ⊕ B
Digital comparators actually use Exclusive-NOR gates within their design for
comparing the respective pairs of bits in each of the two words with single bit comparators cascaded together to produce
Multi-bit comparators so that larger words can be compared.
Magnitude Comparators
As well as comparing individual bits, multi-bit comparators can be constructed to compare whole binary
or BCD words to produce an output if one word is larger, equal to or less than the other. A very good example of this is
the 4-bit Magnitude Comparator. Here, two 4-bit words ("nibbles") are compared to produce the relevant output with
one word connected to inputs A and the other to be compared against connected to input
B as shown below.
4-bit Magnitude Comparator
Some commercially available Magnitude Comparators such as the 7485 have additional input terminals that
allow more individual comparators to be "cascaded" together to compare words larger than 4-bits with magnitude comparators
of "n"-bits being produced. These cascading inputs are connected directly to the corresponding outputs of the previous
comparator as shown to compare 8, 16 or even 32-bit words.
8-bit Word Comparator
|