Comparator compares binary numbers.
Logic comparing 2 bits: a and b
Comparator compares binary numbers 4-bit Magnitude Comparator:
Inputs: A3A2A1A0 & B3B2B1B0
Outputs: Y A>B, Y A<B, Y A=B For each bit, let:
Si = AiBi + Ai’Bi’ = (AiBi’ + Ai’Bi)’
Si is true when Ai = Bi
For A = B, we must have:
A3=B3 and A2=B2 and A1=B1 and A0=B0
Hence, Y A=B = S3•S2•S1•S0 136
Logic For A > B
For A > B, there are 4 cases:
1. A3B3 is 10 and A2A1A0 & B2B1B0 can be anything:
2. A3=B3 and A2B2 is 10 and A1A0 & B1B0 can be anything: A=11xx, B=10xx or A=01xx, B=00xx
3. A3=B3 and A2=B2 and A1B1=10 and A0B0 is xx: e.g.
4. A3=B3 and A2=B2 and A1=B1 and A0B0 is 10: e.g. A=1011, B=1010
Logic For A < B
For A < B, there are also 4 cases:
1) A3B3 is 01 and A2A1A0 & B2B1B0 can be anything:
2) A3=B3 and A2B2 is 01 and A1A0 & B1B0 can be
anything: A=10xx, B=11xx or A=00xx, B=01xx
3) A3=B3 and A2=B2 and A1B1=01 and A0B0 is xx: e.g.
4) A3=B3 and A2=B2 and A1=B1 and A0B0 is 01: e.g.
Y A<B=A3 ’B3+S3A2 ’B2+S3S2A1 ’ B1+S3S2S1A0 ’ B0
MSI: 7485 4-bit Magnitude Comparator