SECTION 01 / 5

Building Blocks and Equality Comparators

3 min read
On this page 4 headings

Start here Nobody builds a house one grain of sand at a time. Builders use bricks, doors and windows: ready-made parts. Circuit designers work the same way. Instead of placing every gate by hand, they use ready-made building blocks like comparators, decoders and multiplexers. This week you meet the most common ones.

Bricks, doors and windows are ready-made parts for houses. Comparators, decoders and multiplexers are ready-made parts for circuits.
Bricks, doors and windows are ready-made parts for houses. Comparators, decoders and multiplexers are ready-made parts for circuits.
Open image ↗
Ready-made parts

What is a building block?

A combinational building block is a group of gates that does one common job. It usually has tens to hundreds of transistors. (This size was once called MSI: Medium Scale Integration.)

Why use them? They hide the gate-level details. You only need to know what the block does, not how every gate inside is wired.

The five standard blocks in this course. Weeks 4 and 5 cover them one by one.
The five standard blocks in this course. Weeks 4 and 5 cover them one by one.
Open image ↗
The common building blocks
Block Its job in one line Week
Comparator Are two numbers equal? 4
Decoder Turn an n-bit code into “exactly one line on” 4
Encoder The opposite: turn “one line on” into a code 4
Multiplexer (MUX) Pick one of many inputs and send it to the output 4
Full adder Add bits 5
PLA A programmable AND–OR grid for any function 5

The 1-bit equality comparator

Question: are bits x and y the same?

x y x⊕yx \oplus y (x⊕y)‾=\overline{\left(x \oplus y\right)} = equal?
0 0 0 1
0 1 1 0
1 0 1 0
1 1 0 1
  • XOR gives 1 when the bits are different.
  • XNOR (XOR⁡+NOT⁡)\left(\operatorname{XOR} + \operatorname{NOT}\right) gives 1 when the bits are equal.

So a 1-bit equality comparator is just an XNOR gate.

Comparing two N-bit numbers

Two numbers are equal only if every pair of matching bits is equal.

  1. Put one XNOR on each bit pair (A0A_{0} with B0,A1B_{0} , A_{1} with B1,…B_{1} , \ldots ).
  2. AND all the XNOR outputs together.
Four XNORs check the four bit pairs. The AND gate says “equal” only if all four agree.
Four XNORs check the four bit pairs. The AND gate says “equal” only if all four agree.
Open image ↗
4-bit equality comparator

Lecture example — 11 vs 9 A=11=A = 1 1 = 1011, B=9=B = 9 = 1001

Bit 3 2 1 0
A 1 0 1 1
B 1 0 0 1
XNOR 1 1 0 1

One XNOR gives 0 (bit 1 differs), so the AND gives 0 → A ≠ B.

Everyday example: checking a 4-digit door lock code. The lock opens only if every digit matches. One wrong digit and it stays shut. That’s the AND of all the “digit matches” checks.

In one line: Building blocks are ready-made gate groups. An equality comparator is one XNOR per bit, all ANDed together. Exam words: combinational building block, MSI, comparator, equality comparator, XNOR, N-bit comparison.


Quick check

Which single gate is a 1-bit equality comparator? XNOR (1 when both bits are equal).
How many XNOR gates does an 8-bit equality comparator need? 8 (one per bit pair), plus an AND to join them.
A=0110,B=0110A = 0 1 1 0 , B = 0 1 1 0. What does the comparator output?
  1. All four XNORs give 1, so the AND gives 1.
YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑