Comparing two 2-bit binary numbers

18.4k Views Asked by At

In order to compare two 2-bit numbers, I need to create a truth table, develop the equation for the equal more or less case, optimize the equations the the Karnaugh maps, and then develop the circuits.

The circuit needs to be developed to define if the numbers are equal, or one number is more or less than the other.

In order to test this circuit, I need to use binary switches and binary probes to set up two numbers and exercise all possible cases to make sure the developed circuits covers all the possible relations between two 2-bit binary numbers.

Can someone please help me out with this. I use LogicsWork4 to create circuits on the computer just to let you know.

3

There are 3 best solutions below

2
On

You better have a look at the digital comparator. The functions are derived for a 4-bit comparator and ready to use. I think you can build your circuit for 2 bit binary numbers after reading the wiki.

2
On

Since two binary numbers are only equal if and only if all digits are equal, your question reduces to designing a circuit that compares one digit numbers - this is the XNOR gate. To get the final result, use an AND gate on the result.

Let the first number be $A,B$ and the second $C,D$. Then your circuit simply reads: $$(A \odot C)\cdot(B \odot D)$$

0
On

Hint: Let $a = a_n a_{n-1} \dots a_1$ and $b = b_n b_{n-1} \dots b_1$ be two unsigned $n$-bit binary numbers, such that $a_n$ and $b_n$ are their most significant bits, $a_{n-1}$ and $b_{n-1}$ the second most significant bits, and so on down to the least significant bits $a_1$ and $b_1$. Then $a > b$ if and only if either:

  1. $a_n = 1$ and $b_n = 0$, or
  2. $a_n = b_n$ and $a_{n-1} \dots a_1 > b_{n-1} \dots b_1$.