1. Gyanastra
  2. Digital Logic
  3. Adders and Subtractors
  4. Half Subtractor from XOR and NAND Gates
Free lesson, no account needed 5 min read 8 practice questions after it
Asked in past papers1 time
  • ISRO2016

Digital Logic · Adders and Subtractors

Half Subtractor from XOR and NAND Gates

Overview

A half subtractor is a combinational circuit that subtracts one bit from another, producing a difference and a borrow. It can be built by making small modifications to the XOR circuit, with the borrow output realised using NAND gates.

Key concepts

  • Half subtractor: a combinational circuit that performs subtraction on only two bits (one bit subtracted from another). It produces a difference output and a borrow output.
  • Adder family comparison: a half adder adds two bits; a full adder adds three bits. The half subtractor is the subtractor counterpart of the half adder.
  • Construction from XOR: the half subtractor is obtained by modifying the XOR circuit — only a few changes are needed, and the resulting circuit is built from NAND gates.
  • Inputs and outputs: PP is the minuend bit (the bit subtracted from), QQ is the subtrahend bit (the bit being subtracted), F1F_1 is the difference, and F2F_2 is the borrow.

How it works

  1. Start from the known XOR circuit: output F1F_1 is the exclusive-OR of the inputs PP and QQ (F1F_1 stays unchanged).
  2. The first gate is a NAND with inputs PP and QQ: output (PQ)′=P′+Q′(PQ)' = P' + Q' (by De Morgan).
  3. The next gate takes this signal and QQ as inputs and performs AND followed by complement (NAND): [(P′+Q′)⋅Q]′=(P′Q)′[(P' + Q')\cdot Q]' = (P'Q)'. The intermediate node therefore carries (P′Q)′(P'Q)'.
  4. This intermediate signal is fed to a final gate that complements again: F2=((P′Q)′)′=P′QF_2 = ((P'Q)')' = P'Q.
  5. Truth-table check of F2=P′QF_2 = P'Q: F2=1F_2 = 1 only for P=0P = 0, Q=1Q = 1; for all other combinations F2=0F_2 = 0.
  6. This behaviour (1 only when P=0P = 0, Q=1Q = 1) is exactly the borrow output of a half subtractor, so the circuit is definitely a half subtractor.

Formulas

  • (P⋅Q)′=P′+Q′(P\cdot Q)' = P' + Q' — NAND identity (De Morgan)
  • [(P′+Q′)⋅Q]′=(P′Q)′[(P' + Q')\cdot Q]' = (P'Q)' — intermediate node
  • F2=((P′Q)′)′=P′QF_2 = ((P'Q)')' = P'Q — final borrow output
  • F1=P⊕QF_1 = P \oplus Q — difference (exclusive-OR, unchanged from the XOR circuit)
  • PP = minuend bit, QQ = subtrahend bit, F1F_1 = difference, F2F_2 = borrow

Worked examples

Derivation of F2F_2 from the gate structure:

  • Gate 1 (NAND of PP, QQ): output =(PQ)′=P′+Q′= (PQ)' = P' + Q'
  • Gate 2 (NAND of that output with QQ): output =[(P′+Q′)⋅Q]′=(P′Q)′= [(P' + Q')\cdot Q]' = (P'Q)'
  • Gate 3 (complement): F2=((P′Q)′)′=P′QF_2 = ((P'Q)')' = P'Q

Truth table of the half subtractor (PP minus QQ):

PPQQDifference F1=P⊕QF_1 = P \oplus QBorrow F2=P′QF_2 = P'QReasoning
00000−0=00 - 0 = 0, no borrow needed
01110−10 - 1 not possible directly; borrow 1, number becomes 2, 2−1=12 - 1 = 1, borrow = 1
10101−0=11 - 0 = 1, no borrow needed
11001−1=01 - 1 = 0, no borrow needed

Borrow reasoning for the 0−10 - 1 case (the only exception):

  • From 0 you cannot subtract 1 unless you borrow a 1.
  • Borrowing 1 makes the 0 effectively 2 in that bit position; then 2−1=12 - 1 = 1.
  • So the difference is 1 and a borrow of 1 is generated (borrow output = 1).

Comparison

CircuitOperationInputsOutputs
Half adderAddition of two bits2 bitsSum, Carry
Full adderAddition of three bits3 bitsSum, Carry
Half subtractorSubtraction of two bits2 bits (PP, QQ)Difference (P⊕QP \oplus Q), Borrow (P′QP'Q)

Revision summary

  • A half subtractor subtracts only two bits; a full subtractor also exists and subtracts three bits (minuend, subtrahend and borrow-in).
  • The half subtractor is the XOR circuit with small modifications: F1F_1 stays P⊕QP \oplus Q (difference) and F2F_2 becomes P′QP'Q (borrow).
  • Borrow is 1 only for P=0P = 0, Q=1Q = 1; in every other case borrow = 0.
  • The 0−10 - 1 case is handled by borrowing 1, which makes the bit value 2, so 2−1=12 - 1 = 1 with borrow = 1.
  • Gate-level result: NAND(PP,QQ) → NAND with QQ → final complement gives F2=P′QF_2 = P'Q; the whole half subtractor uses NAND gates plus the XOR structure.
  • Shortcut: F2=P′QF_2 = P'Q is 1 only when P=0P = 0 and Q=1Q = 1 — read the borrow directly from the input combination instead of re-deriving the gates.

Previous-year exam insights

  • Full subtractor: difference = P ⊕ Q ⊕ BinB_{in};
    borrow-out = P'Q + P'BinB_{in} + QBin\mathrm{QB}_{in} (equivalently P'Q + (P ⊕ Q)'BinB_{in}).
    Asked inISRO 2016
  • Half subtractor outputs in canonical SOP: Difference = P'Q + PQ' (= P ⊕ Q);
    Borrow = P'Q.
    Asked inISRO 2016
  • A half subtractor can be built from a half adder by inverting the minuend before the carry gate: difference is the same XOR, borrow = P'·Q.
  • A full subtractor can be implemented with two half subtractors and one OR gate (borrow-out = OR of the two half-subtractor borrows).
  • NAND is a universal gate: any combinational circuit (including XOR, half and full subtractors) can be realised using only NAND gates.
  • Borrow in subtraction is the counterpart of carry in addition: for P − Q, borrow = 1 exactly when P < Q.
Pages 1–2 of 2