A digital comparator or magnitude comparator is a hardware electronic device that takes two numbers as input in binary form and determines whether one number is greater than, less than or equal to the other number. Comparators are used in central processing units (CPUs) and microcontrollers (MCUs). Examples of digital comparator include the CMOS 4063 and 4585 and the TTL 7485 and 74682.

An XNOR gate is a basic comparator, because its output is "1" only if its two input bits are equal.

The analog equivalent of digital comparator is the voltage comparator. Many microcontrollers have analog comparators on some of their inputs that can be read or trigger an interrupt.

Implementation

edit
Digital comparator using multiplexers

Consider two 4-bit binary numbers A and B so

One-bit binary comparator, with outputs for equality, greater than, and less than.

Here each subscript represents one of the digits in the numbers.

Equality

The binary numbers A and B will be equal if all the pairs of significant digits of both numbers are equal, i.e.,

, , and

Since the numbers are binary, the digits are either 0 or 1 and the boolean function for equality of any two digits and can be expressed as

we can also replace it by XNOR gate in digital electronics.

is 1 only if and are equal.

For the equality of A and B, all variables (for i=0,1,2,3) must be 1.

So the equality condition of A and B can be implemented using the AND operation as

The binary variable (A=B) is 1 only if all pairs of digits of the two numbers are equal.

Inequality

In order to manually determine the greater of two binary numbers, we inspect the relative magnitudes of pairs of significant digits, starting from the most significant bit, gradually proceeding towards lower significant bits until an inequality is found. When an inequality is found, if the corresponding bit of A is 1 and that of B is 0 then we conclude that A>B.[1]

This sequential comparison can be expressed logically as:

(A > B) and (A < B) are output binary variables, which are equal to 1 when A > B or A < B respectively.

One-bit binary full comparator, equality, inequality, greater than, less than at gate level. Created using CircuitLab
alternative comparator without using XNOR (using NOR gate)

See also

edit

References

edit
  1. ^ Kosako, Hideo; Oshima, Katsuya; Kojima, Yoshiaki (1967). "Digital Comparator" (PDF). Transactions of the Institute of Electronics and Communication Engineers of Japan. 50 (6): 452–458. doi:10.1109/T-ECJ.1967.12345.


edit

📚 Artikel Terkait di Wikipedia

Comparator

In electronics, a comparator is a device that compares two voltages or currents and outputs a digital signal indicating which is larger. It has two analog

Analog-to-digital converter

and the DAC both go to a comparator. The comparator controls the counter. The circuit uses negative feedback from the comparator to adjust the counter until

Optical comparator

An optical comparator (often called just a comparator in context) or profile projector is a device that applies the principles of optics to the inspection

Comparator (disambiguation)

Comparator may refer to: A biological comparator system An electrical comparator various data comparators including cmp and diff A digital comparator

Schmitt trigger

Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential

Successive-approximation ADC

the comparator to provide the DAC with a digital code whose accuracy increases with each successive iteration. A DAC that supplies the comparator with

Blink comparator

A blink comparator is a viewing apparatus formerly used by astronomers to find differences between two photographs of the night sky. It permits rapid switching

Flash ADC

direct-conversion ADC) is a type of analog-to-digital converter that uses a linear voltage ladder with a comparator at each "rung" of the ladder to compare