Digital Comparator


Digital Comparator, also called Binary Comparator, is a digital circuit which performs comparison between the magnitudes of two binary numbers. It is used for testing whether the one binary number is greater than, less than or equal to the other binary number. A digital comparator is widely used in combinational system.  

There are two basic type of comparators used in combinational system:

  • Equality comparators
  • Magnitude comparators


Identity Comparator

Identity comparator only compares the equality of two applied signals at its inputs. It has 2 input and only 1 output. The output is high when the two values are equal otherwise it's low,i.e.,

For two inputs P and Q, if P = Q then output HIGH and if P ≠ Q then output LOW


Magnitude Comparator

Magnitude comparator considers all the factors and then makes the comparison. It compares and shows results for either greater, equal or lesser than value by comparing the magnitude of two inputs. Hence unlike the identity comparator, it contains 3 output pins and accordingly, any one of the 3 output pins of a magnitude comparator becomes high,i.e., Let P and Q are the two inputs of magnitude comparator. And the 3 outputs will be P > Q, P = Q and P < Q. And depending upon the comparison performed, any one of the given outputs will be high.

The figure below shows the block diagram of an n-bit magnitude comparator having 2 inputs P and Q:


Some examples of magnitude comparator are explained with their logic circuits below. 

  • 1-bit magnitude comparator
  • 2-bit magnitude comparator
  • 4-Bit magnitude comparator

One -bit Magnitude Comparator

1-bit magnitude comparator is used to compare two 1-bit binary numbers. It has two binary inputs P, Q and three binary outputs: greater than, equal and less than relations. Below given is the truth table of a 1-bit magnitude comparator.


The Boolean functions describing the 1-bit magnitude comparator according to the truth table are:




(A > B) = A'B 

(A = B) = A'B' + AB= (A⊕B)'

(A < B ) = AB'


The logic circuit for 1-bit binary comparator implemented by XOR and other basic logic gates is shown below



Two -bit Magnitude Comparator

2-bit magnitude comparator is used to compare two 2-bit numbers. It has 4 binary inputs (number P: P1P0, number Q:Q1Q0) and 3 binary outputs: greater than, equal and less than relations.

Below given is the truth table of a two bit magnitude comparator:


Using K-map, the simplified Boolean expression for the outputs P>Q, P=Q and P<Q is shown below:




Based on the Boolean expressions for the three outputs P>Q, P=Q and P<Q, the logic circuit of the 2-bit magnitude comparator is given below. (A1=P1, A0=P0, B1=Q1, B0=Q0)



Four-bit Magnitude Comparator

4-bit magnitude comparator is used to compare two 4-bit numbers. The two 4-bit numbers are word P: P3 P2 P1 P0, and word Q: Q3 Q2 Q1 Q0). So the circuit has 8 inputs and 3 binary outputs: P>Q, P=Q and P<Q.


This comparator generates an output of 1 at one of three comparison outputs such that:

  • If word P is bigger than word Q; P>Q output is “1”,
  • If word P is smaller than word Q; P<Q output is “1”,
  • If word P is equal to word Q; P=Q output is “1”.


How 4-bit comparator works

Equality: Word P equal word Q iff: P3=Q3, P2=Q2, P1=Q1, P0=Q0.

Inequality:

  • If P3 = 1 and Q3 = 0, then P is greater than Q (P>Q). Or
  • If P3 and Q3 are equal, and if P2 = 1 and Q2 = 0, then P > Q. Or
  • If P3 and Q3 are equal & P2 and Q2 are equal, and if P1 = 1, and Q1 = 0, then P>Q. Or
  • If P3 and Q3 are equal, P2 and Q2 are equal and P1 and Q1 are equal, and if P0 = 1 and Q0 = 0, then P > Q.
  • If P3 = 0 and Q3 = 1, then P is less than Q (P<Q). Or
  • If P3 and Q3 are equal, and if P2 = 0 and Q2 = 1, then P < Q. Or
  • If P3 and Q3 are equal & P2 and Q2 are equal, and if P1 = 0, and Q1 = 1, then P<Q. Or
  • If P3 and Q3 are equal, P2 and Q2 are equal and P1 and Q1 are equal, and if P0 = 0 and Q0 = 1, then P < Q.

Applications of comparators

  • Comparators are used in various control applications in which the binary numbers resenting physical variables such as temperature, position, etc. are compared with a reference value. 
  • In addition, comparators are also used in ALU, MCUs.
  • They are used in Analog to Digital Converters (ADC)
  • They are also used in process control applications and servo motor control.
  • They are very useful in password verification, biometric applications, for searching and surfing.

Post a Comment

0 Comments