7485 (74LS85): the 4-bit magnitude comparator chip, live
The 7485 compares two 4-bit numbers, A3 to A0 and B3 to B0, and raises one of three outputs: A greater than B, A less than B, or A equal to B. Three cascade inputs carry in the result from a chip handling lower bits, so 7485s chain to compare 8, 12 or more bits. The 74LS85 has the same pinout. This live circuit is the whole chip.
TI's datasheet says it plainly: "These four-bit magnitude comparators perform comparison of straight binary and straight BCD (8-4-2-1) codes. Three fully decoded decisions about two 4-bit words (A, B) are made and are externally available at three outputs." The comparison runs from the top bit down, like the 4-bit magnitude comparator: if A3 and B3 differ they decide, otherwise A2 and B2, and so on. Only when all four bits are equal do the cascade inputs matter, and then the chip passes on the decision of the chip below it: for a longer word, the A>B, A<B and A=B outputs of the stage with the less significant bits go to the matching inputs of the next stage, and the datasheet asks for a high level on the A=B input of the lowest stage. This circuit is built from the datasheet's function table, including its two odd rows: with the words equal and both A>B in and A<B in high, every output is low, and with all three cascade inputs low, A>B out and A<B out are both high. The live chip opens with A = B = 0000 and A=B in high, so A=B out is lit; change any A or B bit. All 2,048 combinations of the eight data inputs and three cascade inputs are checked before the page is built.
Open this circuit in the lab →
What you need
- 4× XNOR: the equality of each bit pair, Ai = Bi
- 8× AND + 8 NOT: A AND NOT B and NOT A AND B for each bit
- 9× AND + 6 OR: A > B and A < B, decided from the top bit down, and A = B across all four bits
- 5× AND + 2 OR + 3 NOT: the cascade inputs, which decide only when the two words are equal
Step by step
- Place inputs
A3toA0,B3toB0,A>Bin,A<BinandA=Bin, and probesA>Bout,A<BoutandA=Bout. - For each bit, build Ai XNOR Bi (equal), Ai AND NOT Bi (A bigger) and NOT Ai AND Bi (B bigger).
- A > B if bit 3 says so, or bit 3 is equal and bit 2 says so, and so on down; the same for A < B. A = B when all four bits are equal.
- When A = B, let the cascade inputs decide: A>Bout = NOT A<Bin AND NOT A=Bin, A<Bout = NOT A>Bin AND NOT A=Bin, A=Bout = A=Bin. For one chip, tie A=Bin high.
7485 function table
| A and B | A>B in | A<B in | A=B in | A>B out | A<B out | A=B out |
|---|---|---|---|---|---|---|
| A > B | X | X | X | 1 | 0 | 0 |
| A < B | X | X | X | 0 | 1 | 0 |
| A = B | 1 | 0 | 0 | 1 | 0 | 0 |
| A = B | 0 | 1 | 0 | 0 | 1 | 0 |
| A = B | X | X | 1 | 0 | 0 | 1 |
| A = B | 1 | 1 | 0 | 0 | 0 | 0 |
| A = B | 0 | 0 | 0 | 1 | 1 | 0 |
7485 pinout
| Pin | Name | Pin | Name |
|---|---|---|---|
| 1 | B3 | 16 | VCC |
| 2 | A<B in | 15 | A3 |
| 3 | A=B in | 14 | B2 |
| 4 | A>B in | 13 | A2 |
| 5 | A>B out | 12 | A1 |
| 6 | A=B out | 11 | B1 |
| 7 | A<B out | 10 | A0 |
| 8 | GND | 9 | B0 |
X means the input does not matter; A > B or A < B means the four data bits already decide. The function table and the 16-pin pinout are from TI's SN7485 / SN74LS85 datasheet (SDLS123), checked 2026-10-25. For a single chip, or the lowest chip of a chain, tie A=B in high: then the other two cascade inputs do not matter.
You can also read the full theory in the lesson on comparators. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
Build more parts from gates
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the 7485 4-bit magnitude comparator in the lab →Frequently asked
What does the 7485 do?
It compares two 4-bit binary numbers, A and B, and sets exactly one of its outputs A>B, A<B or A=B (for normal cascade inputs). Three cascade inputs let several 7485s compare longer numbers.
How do you cascade two 7485 comparators?
Wire the A>B, A<B and A=B outputs of the chip comparing the lower 4 bits to the A>B, A<B and A=B inputs of the chip comparing the upper 4 bits, and tie the lower chip's A=B input high. The upper chip's outputs then compare all 8 bits.
What is the 7485 pinout?
Pin 1 B3, 2 A<B in, 3 A=B in, 4 A>B in, 5 A>B out, 6 A=B out, 7 A<B out, 8 GND, 9 B0, 10 A0, 11 B1, 12 A1, 13 A2, 14 B2, 15 A3, 16 VCC.
Can the 7485 compare BCD numbers?
Yes. TI's datasheet says it compares straight binary and straight BCD (8-4-2-1) codes: a BCD digit is just a 4-bit binary number from 0 to 9.