Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

CMOS XNOR gate: twelve transistors, live

A static CMOS XNOR gate uses twelve transistors: two inverters make NOT A and NOT B, and an eight-transistor complex gate pulls the output low when A and B differ and high when they are equal, so Y is 1 exactly when A = B.

The pull-down network has two NMOS paths from Y to ground: A in series with NOT B, and NOT A in series with B. One of them conducts exactly when A and B differ, giving Y = 0. The pull-up network is its dual: PMOS on A and NOT B in parallel, in series with PMOS on NOT A and B in parallel, which conducts exactly when A = B. It is the CMOS XOR with NOT B and B swapped in both networks, so it costs the same twelve transistors, two fewer than an XOR followed by an inverter. Equality checks are where XNOR earns its keep: a 1-bit comparator's EQ output is an XNOR, and an n-bit equality test is n XNORs feeding an AND. Compare the gate-level truth table on the XNOR truth table page.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “CMOS XNOR gate”, https://digiwleea.wleeaf.dev/tools/build/cmos-xnor/

What you need

Step by step

  1. Place a VDD rail, a GND rail, inputs A and B, and a probe Y; build two CMOS inverters for NOT A and NOT B.
  2. Pull-down: NMOS A in series with NMOS NOT B from Y to GND, and in parallel NMOS NOT A in series with NMOS B. Either path conducts when A and B differ.
  3. Pull-up: PMOS A and PMOS NOT B in parallel from VDD to a middle node, then PMOS NOT A and PMOS B in parallel from that node to Y. It conducts when A and B are equal.
  4. Step through the four rows: Y is 1 for 00 and 11, and 0 for 01 and 10.

CMOS XNOR truth table

ABPull-down onPull-up onY
00noyes1
01yesno0
10yesno0
11noyes1

All four rows of the live circuit are checked before the page is built. In every row exactly one of the two networks conducts, so Y is always driven and VDD never connects to GND.

You can also read the full theory in the lesson on XOR at the transistor level. 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.

More builds: Gates from transistors (CMOS)

All 246 build guides, by topic

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 CMOS XNOR gate in the lab →

Frequently asked

How many transistors are in a CMOS XNOR gate?

Twelve in this static design: four for the two input inverters and eight for the complex gate. Transmission-gate and pass-transistor versions use fewer, at some cost in drive strength.

What is the difference between a CMOS XOR and XNOR?

They use the same structure; the XNOR swaps B and NOT B in both networks, so its output is high when the inputs are equal instead of when they differ.

Why is XNOR called an equality gate?

Because its output is 1 exactly when its two inputs are equal. Comparators use one XNOR per bit and AND the results to test whether two numbers are equal.