ARITHMETIC & COMPARISON CIRCUITS
Digital Magnitude Comparators (1-bit, 2-bit & IC 74LS85)
A Digital Magnitude Comparator is a combinational logic circuit that compares two binary numbers, A and B, and determines their relative magnitude by evaluating whether A > B, A = B, or A < B.
Figure 1: General Block Diagram of an n-Bit Magnitude Comparator
1. 1-Bit Magnitude Comparator
A 1-bit magnitude comparator compares two single binary digits, A and B. Since each input has 2 possible values (0 or 1), there are \(2^2 = 4\) total combinations.
Truth Table of 1-Bit Comparator
| Input A | Input B | A > B | A = B | A < B |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 0 |
Boolean Equations & Derivations
(True only when A = 1 AND B = 0)
(XNOR Gate acts as the coincidence equality detector)
(True only when A = 0 AND B = 1)
Figure 2: Complete Logic Gate Schematic for 1-Bit Comparator
2. 2-Bit Magnitude Comparator
A 2-bit comparator compares two 2-bit words: A = (A₁A₀) and B = (B₁B₀), representing decimal values from 0 to 3.
Step 1 Compare MSBs (A₁ vs B₁):
• If A₁ > B₁ (i.e. A₁=1, B₁=0), then A > B regardless of A₀ and B₀.
• If A₁ < B₁ (i.e. A₁=0, B₁=1), then A < B regardless of A₀ and B₀.
Step 2 If MSBs are Equal (A₁ = B₁):
Let the bit-1 equality flag be x₁ = A₁ ⊙ B₁. If x₁ = 1, compare LSBs:
• If A₀ > B₀ (A₀=1, B₀=0), then A > B.
• If A₀ < B₀ (A₀=0, B₀=1), then A < B.
Step 3 Overall Equality:
If both bit positions are identical: A = B = x₁ · x₀.
Complete 16-Row Truth Table
| Input A | Input B | Dec A | Dec B | A > B | A = B | A < B | ||
|---|---|---|---|---|---|---|---|---|
| A₁ | A₀ | B₁ | B₀ | |||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 | 0 | 2 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 | 0 | 3 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 2 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 3 | 0 | 0 | 1 |
| 1 | 0 | 0 | 0 | 2 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 2 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 2 | 2 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 2 | 3 | 0 | 0 | 1 |
| 1 | 1 | 0 | 0 | 3 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 3 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 | 3 | 2 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 3 | 3 | 0 | 1 | 0 |
K-Map Simplifications (With Cell Minterms & Groupings)
K-Map for A > B
| B₁B₀A₁A₀ | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m00 | m10 | m30 | m20 |
| 01 | m41 | m50 | m70 | m60 |
| 11 | m121 | m131 | m150 | m141 |
| 10 | m81 | m91 | m110 | m100 |
K-Map for A < B
| B₁B₀A₁A₀ | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m00 | m11 | m31 | m21 |
| 01 | m40 | m50 | m71 | m61 |
| 11 | m120 | m130 | m150 | m140 |
| 10 | m80 | m90 | m111 | m100 |
Let x₁ = A₁ ⊙ B₁ = A₁̅·B₁̅ + A₁·B₁ (MSB equality detector)
Let x₀ = A₀ ⊙ B₀ = A₀̅·B₀̅ + A₀·B₀ (LSB equality detector)
Figure 3: Complete Logic Gate Schematic of 2-Bit Magnitude Comparator
3. 4-Bit Magnitude Comparator (IC 74LS85)
The IC 74LS85 is the standard monolithic 4-bit magnitude comparator in a 16-pin DIP package. It compares two 4-bit nibbles: A = (A₃, A₂, A₁, A₀) and B = (B₃, B₂, B₁, B₀).
IC 74LS85 Hardware Pinout (DIP-16)
IC 74LS85 DIP-16
.-----\_/-----.
(Bit 3) B3 | 1 16 | VCC (+5V Power)
(Cascade) IAB | 4 13 | A2 (Bit 2)
(Output) OA>B | 5 12 | A1 (Bit 1)
(Output) OA=B | 6 11 | B1 (Bit 1)
(Output) OA
Internal Bit-by-Bit Logic Equations
4. Multi-Stage Cascading (Building 8-Bit & 16-Bit Comparators)
When comparing words wider than 4 bits (e.g., 8-bit bytes or 16-bit integers), multiple 74LS85 ICs are connected in cascade.
Figure 4: 8-Bit Comparator Cascading Architecture (2 x IC 74LS85)
- Least Significant Stage (IC 1): Tie IA=B to VCC (+5V / Logic 1) and tie IA>B and IA<B to GND (0V / Logic 0).
- Cascade Linkage: Outputs of IC 1 (\(OA>B, OA=B, OAB, IA=B, IA
- Final Decision: Outputs of the Most Significant Stage (IC 2) provide the authoritative final comparison results.
5. Worked Step-by-Step Examples
Example 1 4-Bit Comparison
Compare A = 1101₂ (13₁₀) and B = 1100₂ (12₁₀):
- Bit 3: A₃ = 1, B₃ = 1 → Equal (x₃ = 1). Proceed to Bit 2.
- Bit 2: A₂ = 1, B₂ = 1 → Equal (x₂ = 1). Proceed to Bit 1.
- Bit 1: A₁ = 0, B₁ = 0 → Equal (x₁ = 1). Proceed to Bit 0.
- Bit 0: A₀ = 1, B₀ = 0 → A₀ > B₀!
- Result: Output A > B = 1 (A=B is 0, A<B is 0).
Example 2 4-Bit Comparison
Compare A = 0110₂ (6₁₀) and B = 1000₂ (8₁₀):
- Bit 3 (MSB): A₃ = 0, B₃ = 1.
- Since A₃ < B₃ at the MSB, lower bits (Bits 2, 1, 0) do not need to be evaluated.
- Result: Output A < B = 1 immediately!
6. Real-World Applications of Digital Comparators
1. CPU Arithmetic & Logic Units
Used in microprocessors to execute comparison instructions (like CMP in x86/ARM) and generate conditional jump flags (Zero flag ZF, Sign flag SF).
2. Digital Thermostats & Controls
Compares sensor-measured room temperature against the target setpoint to automatically switch heaters or air conditioners on/off.
3. Flash ADC Converters
High-speed analog-to-digital converters use banks of voltage comparators to instantaneously quantize analog signals into digital binary values.