Write if (marks >= 40) in any program, and somewhere deep inside the processor a small circuit answers one question: is this number at least as big as that one? Every merit list, every sort, every loop that stops at 100 depends on it. A digital door lock does something simpler of the same kind: it opens only when the four digits you pressed are equal to the four digits stored. The circuit that makes such decisions is a magnitude comparator. It takes two binary numbers, A and B, and tells you whether A is bigger than B, equal to B, or smaller than B.
The remarkable thing is how little it needs. A comparator has no memory and no clock. It is a handful of gates, and it grows to any width by chaining small chips together. It can even be built out of two adders.
By the end of this lesson you will be able to design a one-bit and a two-bit comparator, fill in all sixteen rows of the two-bit truth table and check it, and simplify a comparator's single output from a K-map. You'll wire the 7485 chip and cascade chips to compare eight, twelve or more bits. And you'll build a comparator out of full adders by subtraction.
There are two parts. The first compares bit by bit, from one bit to two, with the full truth table. The second goes from the truth table to the answers that exams want: the simplified equation, the 7485 and its cascade, and the comparator built from subtraction.
Why it matters: Exams ask the comparator in two ways. A one-mark MCQ asks which gate tests whether two bits are equal. A written question gives a comparator and asks for its truth table, a simplified equation and a circuit, or asks you to build one out of other blocks, such as two full adders. Every one of these is taught below, together with its reason.
Question (Combined Bank Senior Officer (IT) Exam: 2018 (DU)): When two variables are logically compared, the logic gate that tests the equivalence is-