Magnitude comparator implementation

comparatordigital-logic

I have stuck on implementing magnitude comparator for 2-bit numbers (three functions – greater, equal, less).

It is pretty easy to implement it with AND and OR gates, but the point is the task is to implement it with AND and XOR gates only. A little bit of help will be appreciated.

Thanks in advance.

Best Answer

It should be easier to implement "equals" with XOR than with AND and OR. Take a look at the Karnaugh map for a single bit of "equals" and then look at the Karnaugh map for XOR.

I assume you have NOT as well (at least for your variables? (otherwise I don't know how you did it with AND and OR alone.)) If you don't have NOT, then XOR can be used to fake one: A XOR 1 = NOT A.

For the "greater" and the "less": In the worst case you can take your answer in sum-of-products form and turn it into all NAND gates (by DeMorgan AB+CD = (A NAND B) NAND (C NAND D)). But you can probably do better. Again: look at the Karnaugh map for your problem. Then look at the Karnaugh map for (2-bit) XOR. Any time you have a checkerboard-like pattern in your Karnaugh map you can probably put an XOR to good use.

Related Topic