Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

How to build a half subtractor using only NOR gates

A half subtractor can be built from five NOR gates. The second gate, NOR(A, NOR(A, B)), is already the borrow Bout = NOT A AND B, and four NORs make an XNOR that a fifth NOR inverts into the difference D = A XOR B.

NOR gates naturally make XNOR rather than XOR: N1 = NOR(A, B), N2 = NOR(A, N1) and N3 = NOR(B, N1), and NOR(N2, N3) is A XNOR B. Expanding N2 shows the bonus: NOT (A OR NOT (A OR B)) = NOT A AND (A OR B) = NOT A AND B, exactly the borrow, so the borrow costs no extra gate. The fifth NOR, with both inputs tied together, inverts the XNOR into the difference. Compare the half subtractor from NAND gates, also five gates, where the fifth one is needed to invert the borrow instead, and the half adder from NOR gates.

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 →

What you need

Step by step

  1. Place inputs A and B.
  2. N1 = NOR(A, B), then N2 = NOR(A, N1) and N3 = NOR(B, N1).
  3. Probe N2 as Bout: it is NOT A AND B.
  4. NOR N2 with N3 to get A XNOR B, then NOR that with itself to get D = A XOR B.
  5. Try all four rows: only A = 0, B = 1 borrows.

Half subtractor truth table

ABDBout
0000
0111
1010
1100

N2 is the borrow on its own: it is 1 only in the row A = 0, B = 1. All four rows are checked on the live circuit before the page is built.

You can also read the full theory in the lesson on the half subtractor. 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

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adderMealy machine (1011 detector)master-slave JK flip-flop (NAND)1-to-8 demultiplexerexcess-3 to BCD code convertervending machine FSM4-bit carry-save adder3-bit synchronous counter (JK)CMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxes

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 half subtractor from NOR gates in the lab →

Frequently asked

How many NOR gates are needed for a half subtractor?

Five. Four NORs make A XNOR B and the fifth inverts it into the difference; the borrow comes for free from the second NOR.

Why do NOR gates make XNOR more easily than XOR?

The four-gate NOR network is the dual of the four-gate NAND XOR, and the dual of XOR is XNOR. So with NOR gates you get XNOR in four gates and need a fifth to turn it into XOR.

Can a full subtractor be built from NOR gates?

Yes. NOR is a universal gate, so any circuit can be built from it. A full subtractor is two half subtractors plus an OR for the borrows, and each of those can be made from NOR gates.