Design of 1 Bit & 2 Bit Comparator Circuit using Logic Gates A Comparator is a combinational circuit that gives output in terms of A>B, A<B, and A=B. This is entirely expected from the name. A digital comparator’s purpose is to compare numbers and represent their relationship with each other. In this post, we will make different types of comparators using digital logic gates. We will begin by designing a simple 1-bit and 2-bit comparators. The circuit for a 4-bit comparator will get slightly more complex. Let’s begin. How to design a simple 1-bit comparator? A 1-bit comparator compares two single bits. A B A>B A<B A=B 0 00 0 1 0 10 1 0 1 01 0 0 1 10 0 1 Let’s apply a shortcut to find the equations for each of the cases. Normally, we can use a K-map. But this shortcut is efficient and handy when you understand it. For A>B, there is only one case when the output is high when A=1 and B=0. Let’s call this X. We can write the equation as follows X(which stands for A>B) = AB’ Similarly, denote A<B with Y and A=B with Z. Since Y is high when A=0 and B=1, we get the following equation Y = A’B Since Z is high in two cases, there will be an OR gate. This is because the logic behind an OR gate is that a high output can be achieved in one or more cases. Z is high when A=0 and B=0, it is also high when A=1 and B=1. Therefore, Z = A’B’ + AB This is similar to the equation of an EXNOR gate. Hence, Z = AoB The logic circuit of a 1-bit comparator How to design a 2-bit comparator? Let’s plot the truth table for a 2-bit comparator A1 A0 B1 B0 A>B A<B A=B 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 1 1 0 1 0 1 1 0 0 1 0 0 1 1 0 1 1 0 0 1 1 1 0 1 0 0 1 1 1 1 0 0 1 The shortcut that we saw above can be used here too. But notice that since we have four variables (A1, A0, B1, B0) and each of the three outputs is high at least four times, the equations that we will get will have four terms of 4 variables. At least. So, though applying the shortcut is possible, we won’t. K-maps come in handy in situations like these. Because it is possible to achieve the most straightforward equation using them, and remember, the simpler the equation, the lesser the logic gates required. That is the aim of any designing process – to obtain the simplest hardware implementation. Using K-maps we get the following equations A>B = A1B1′ + B0′(A0B1′ + A0A1) A<B = B1A1′ + B0B1A0′ + A1’A0’B0 A=B = ? The logic circuit of a 2-bit comparator