1
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.