Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Building a digital comparator

Status
Not open for further replies.

digitalrain

New Member
Hello, I'm pretty new to electronics, and I need to construct a 2-bit digital comparator using TTL devices. I've really thought about this problem, but for some reason I think I'm just missing something. I assume that it would rely heavily on XOR gates, but I need some help.
Thanks
 
digitalrain said:
Hello, I'm pretty new to electronics, and I need to construct a 2-bit digital comparator using TTL devices. I've really thought about this problem, but for some reason I think I'm just missing something. I assume that it would rely heavily on XOR gates, but I need some help.
Thanks

Hi,
Do you mean a 2 BYTE digital comparator?, if Yes, look at the HEF4585 magnitude comparator ic.
 
As simple as it should be, I actually mean a 2-bit comparator. This is a pretty early project in a course of mine.
I've looked other places online, and this seems to be so basic and obsolete that it's not really covered anywhere.
 
If you just want to check for the two 2 bit numbers being the same then 2 XOR gates feeding a NOR gate will work.

Mike.
 
I'm sorry for being so vague; I'll try to state more clearly what my problem is.

I have four inputs; A0 and A1, and B0 and B1. Each input is connected to a switch so that they are either HI or LO. I need to build a device that will output HI (light an LED) only when A is higher than B. So, the truth table will look like:

A0A1\B0B1\Q
----------------
0 0 | 0 0 | 0
x 1 | 0 0 |1
1 x | 0 0 |1
0 0 | 1 x |0

and so on.
 
Last edited:
There are a couple of simple ways to break this down. If A>B, then either
A=1 and B=0
or
A=2 and B=0 or 1
or
A=3 and B=0 or 1 or 2

Another way to look at it: either
A1=1 and B1=0
or
(A1 XOR B1)=0 (MSBs are equal) and A0=1, B0=0.

Can you work out the logic from there?
 
Last edited:
Use a LS7485 comparator it will give you an output of A=B A>B A<B
its 2 bit
i just had this question on a test building a 8 bit comparator, all you need is an EXNOR gate for a 2 bit
 
Last edited:
I think where I'm having problems is translating the logic of truth tables into circuit diagrams. I've mentally gotten to complete the truth table and logic that follows, but I can't seem to imagine what gates would be required. As far as EXNOR goes, I don't believe we have those in our lab, and I'm pretty sure we wouldn't be advised to use them. (Unless by EXNOR you're just referring to a combination of XOR and NOR)
 
Last edited:
Roff said:
Another way to look at it: either
A1=1 and B1=0
or
(A1 XOR B1)=0 (MSBs are equal) and A0=1, B1=0.

Can you work out the logic from there?

I assume that is a typo and you meant B0.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top