2081 2

BIT103 ยท 2081 ยท 10 marks

Define magnitude comparator?Design a 4-bit magnitude comparator circuit.[2+8]

Define magnitude comparator?Design a 4-bit magnitude comparator circuit.[2+8]

Digital LogicChapter 4: Combinational Logic CircuitsMagnitude comparator circuits

Quick answer

A magnitude comparator is a combinational logic circuit that compares two binary numbers and determines their relative magnitudes.

Magnitude Comparator

Definition (2 marks)

A magnitude comparator is a combinational logic circuit that compares two binary numbers and determines their relative magnitudes. Given two n-bit numbers A and B, the comparator produces three output signals:

  • A > B (output is HIGH when A is greater than B)
  • A = B (output is HIGH when A equals B)
  • A < B (output is HIGH when A is less than B)

Design of 4-bit Magnitude Comparator (8 marks)

Given

Two 4-bit numbers:

  • A = Aโ‚ƒAโ‚‚Aโ‚Aโ‚€
  • B = Bโ‚ƒBโ‚‚Bโ‚Bโ‚€

Step 1: Basic Bit Comparison

For each bit position i, define:

ConditionExpression
Aแตข = Bแตขxแตข = AแตขBแตข + ฤ€แตข Bฬ„แตข (XNOR)
Aแตข > BแตขAแตขBฬ„แตข
Aแตข < Bแตขฤ€แตขBแตข

So define equality bits:

xโ‚ƒ = Aโ‚ƒBโ‚ƒ + ฤ€โ‚ƒBฬ„โ‚ƒ
xโ‚‚ = Aโ‚‚Bโ‚‚ + ฤ€โ‚‚Bฬ„โ‚‚
xโ‚ = Aโ‚Bโ‚ + ฤ€โ‚Bฬ„โ‚
xโ‚€ = Aโ‚€Bโ‚€ + ฤ€โ‚€Bฬ„โ‚€

Step 2: Derive Output Expressions

Equality Output: (A = B)

All bit pairs must be equal:

(A = B) = xโ‚ƒ ยท xโ‚‚ ยท xโ‚ ยท xโ‚€

Greater Than Output: (A > B)

A > B if the most significant differing bit of A is 1 and B is 0:

(A > B) = Aโ‚ƒBฬ„โ‚ƒ
         + xโ‚ƒยทAโ‚‚Bฬ„โ‚‚
         + xโ‚ƒยทxโ‚‚ยทAโ‚Bฬ„โ‚
         + xโ‚ƒยทxโ‚‚ยทxโ‚ยทAโ‚€Bฬ„โ‚€

Less Than Output: (A < B)

A < B if the most significant differing bit of B is 1 and A is 0:

(A < B) = ฤ€โ‚ƒBโ‚ƒ
         + xโ‚ƒยทฤ€โ‚‚Bโ‚‚
         + xโ‚ƒยทxโ‚‚ยทฤ€โ‚Bโ‚
         + xโ‚ƒยทxโ‚‚ยทxโ‚ยทฤ€โ‚€Bโ‚€

Note: Alternatively, (A < B) = NOT(A > B) + NOT(A = B), i.e., (A < B) = (A > B)' ยท (A = B)'


Step 3: Logic Circuit Block Diagram

Aโ‚ƒ,Bโ‚ƒ โ”€โ”€โ–บ [XNOR]โ”€โ”€โ–บ xโ‚ƒ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
Aโ‚‚,Bโ‚‚ โ”€โ”€โ–บ [XNOR]โ”€โ”€โ–บ xโ‚‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ| AND โ”€โ”€โ–บ (A=B)
Aโ‚,Bโ‚ โ”€โ”€โ–บ [XNOR]โ”€โ”€โ–บ xโ‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
Aโ‚€,Bโ‚€ โ”€โ”€โ–บ [XNOR]โ”€โ”€โ–บ xโ‚€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|

For (A > B):
Aโ‚ƒBฬ„โ‚ƒ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
xโ‚ƒยทAโ‚‚Bฬ„โ‚‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ| OR โ”€โ”€โ–บ (A>B)
xโ‚ƒยทxโ‚‚ยทAโ‚Bฬ„โ‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
xโ‚ƒยทxโ‚‚ยทxโ‚ยทAโ‚€Bฬ„โ‚€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|

For (A < B):
ฤ€โ‚ƒBโ‚ƒ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
xโ‚ƒยทฤ€โ‚‚Bโ‚‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ| OR โ”€โ”€โ–บ (A<B)
xโ‚ƒยทxโ‚‚ยทฤ€โ‚Bโ‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|
xโ‚ƒยทxโ‚‚ยทxโ‚ยทฤ€โ‚€Bโ‚€ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ|

Step 4: Verification Example

Let A = 1010 (10) and B = 0110 (6):

BitABxแตข
3100
2010
1111
0001
  • (A = B) = xโ‚ƒยทxโ‚‚ยทxโ‚ยทxโ‚€ = 0ยท0ยท1ยท1 = 0 โœ“
  • (A > B) = Aโ‚ƒBฬ„โ‚ƒ = 1ยท1 = 1 โœ“ (since MSB of A is 1, MSB of B is 0)
  • (A < B) = ฤ€โ‚ƒBโ‚ƒ = 0ยท0 = 0 โœ“

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.