“The computer was born to solve problems that did not exist before.”

Random Posts

Thursday, September 4, 2025

Magnitude comparator

Comparator in Digital Electronics

Definition

A comparator is a digital combinational circuit that compares two binary numbers and identifies their relationship. The outputs indicate whether the numbers are equal, or which one is greater or smaller.

In short, the purpose of a comparator is to check the magnitudes of two binary inputs and generate logical outputs such as:

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


Example

Consider two 3-bit binary numbers:

  • A = A2 A1 A0
  • B = B2 B1 B0

The two numbers are said to be equal if all corresponding bits are the same, i.e., A2 = B2, A1 = B1, and A0 = B0.

A general comparator produces three outputs:

  • L → (A < B)
  • E → (A = B)
  • G → (A > B)


Types of Comparators

Comparators are classified based on the number of bits they compare:

  1. 1-Bit Comparator

  2. 2-Bit Comparator

  3. 4-Bit Comparator


1-Bit Comparator

A 1-bit comparator compares two binary inputs A and B. The three possible outcomes are:

  • If A = 0 and B = 0, or A = 1 and B = 1 → A = B
  • If A = 0 and B = 1 → A < B
  • If A = 1 and B = 0 → A > B

The block diagram of a 1-bit magnitude comparator is shown in the following figure −

1-Bit Magnitude Comparator

Truth Table:

InputsOutputs
ABL (A < B)E (A = B)G (A > B)
00010
01100
10001
11010

Boolean expressions:
  • A = B → E = A'B' + AB = A ⊙ B
  • A < B → L = A'B
  • A > B → G = AB'

The logic circuit diagram of the 1-bit magnitude comparator is shown in the following figure.

1-Bit Magnitude Comparator

It consists of two AND gates, two NOT gate, and an XNOR gate.


2-Bit Comparator

For two binary numbers:

  • A = A1 A0
  • B = B1 B0

We can understand the operation of the 2-bit magnitude comparator with the help of its truth table given below −

InputsOutputs
A1A0B1B0L (A < B)E (A = B)G (A > B)
0000010
0001100
0010100
0011100
0100001
0101010
0110100
0111100
1000001
1001001
1010010
1011100
1100001
1101001
1110001
1111010

Conditions:

  1. Equal (A = B):
    E = (A1 ⊙ B1)(A0 ⊙ B0)

  2. Less Than (A < B):
    L = A1'B1 + (A1 ⊙ B1)A0'B0

  3. Greater Than (A > B):
    G = A1B1' + (A1 ⊙ B1)A0B0'

The following figure shows the logic circuit diagram of the 2-bit magnitude comparator −

2-bit Magnitude Comparator


4-Bit Comparator

For two binary numbers:

  • A = A3 A2 A1 A0
  • B = B3 B2 B1 B0

Equal Condition:

E = (A3 ⊙ B3)(A2 ⊙ B2)(A1 ⊙ B1)(A0 ⊙ B0)

Less Than Condition:
L = A3'B3 + (A3 ⊙ B3)A2'B2 + (A3 ⊙ B3)(A2 ⊙ B2)A1'B1 + (A3 ⊙ B3)(A2 ⊙ B2)(A1 ⊙ B1)A0'B0

Greater Than Condition:
G = A3B3' + (A3 ⊙ B3)A2B2' + (A3 ⊙ B3)(A2 ⊙ B2)A1B1' + (A3 ⊙ B3)(A2 ⊙ B2)(A1 ⊙ B1)A0B0'

The logic circuit implementation of the 4-bit magnitude comparator is shown in the following figure −

4-bit Magnitude Comparator




Applications of Comparators

  1. Used in arithmetic logic units (ALU) of microprocessors.

  2. Employed in zero-crossing detectors in control circuits.

  3. Used in analog-to-digital converters (ADCs).

  4. Helpful in voltage level detection and signal conditioning.

  5. Applied in automation and digital communication systems.


Conclusion

A comparator is an essential combinational circuit that checks whether two binary numbers are equal or determines which one is greater. Depending on bit size, comparators can be designed as 1-bit, 2-bit, or 4-bit circuits, or implemented using ICs like 7485. They play a vital role in decision-making processes within microprocessors, digital systems, and control applications.



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages

SoraTemplates

Best Free and Premium Blogger Templates Provider.

Buy This Template