# Designing a 2 bit magnitude comparator [duplicate]

As a foreword I would like to say that I am asking this question as part of a computer science course assignment, and any responses here might be referenced in my report. I am ideally looking for hints and tips to get me on the right track rather than straight up solutions.

What I am trying to get my head around is a 2 bit magnitude comparator circuit that takes in 2 sets of inputs. For example set A would contain a0 and a1, and set B would contain b0 and b1. The only output I am interested in is A > B which means the sum of all inputs in set A is bigger than set B so a0 = 1 , a1 = 1, b0 = 1, b1 = 0 would overall output a 0 and so on.

I understand how a 1 bit comparator works :

this is the most basic circuit I came up with that takes in 2 inputs and gives out an output if A > B.

However, I have been stuck for several hours trying to increase the number of inputs. My initial plan was to somehow reuse the 1 bit comparator and reuse it 3 times but every time I end up with something that ends up with an overly complicated version of the initial 1 bit circuit where the 3 inputs actually only give out 1 output and so in the end you are going in a circle and comparing 2 numbers rather than 4.

Any advice an tips on this would be very appreciated.

• Compare the "higher" inputs first. Only if they are equal, compare the "lower" inputs. – Flovdis Nov 2 '14 at 19:15
• I am unsure what you mean by higher and lower inputs, could you elaborate a little please? – Lukasz Medza Nov 2 '14 at 19:18

Lets examine what a comparator should do:

If A1 is greater than B1 then output 1, otherwise continue. If A0 is greater than B0 then output 1, otherwise output 0.

So now we can break this into parts.

If A1 is greater than B1

$X_1 = A_1 \overline{B_1}$

If A0 is greater than B0

Second verse, same as the first.

$X_0 = A_0 \overline{B_0}$

... then output 1, otherwise continue. ... then output 1, otherwise output 0.

Let's put up a truth table for this.

X1 X0  O
1  X   1
0  1   1
0  0   0


$O = X_1 + X_0$

So altogether we have:

$O = A_1 \overline{B_1} + A_0 \overline{B_0}$

And you're done.

• Thank you, this really helped me to picture the problem and get the solution. – Lukasz Medza Nov 2 '14 at 19:53