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: is the minuend bit (the bit subtracted from), is the subtrahend bit (the bit being subtracted), is the difference, and is the borrow.
How it works
- Start from the known XOR circuit: output is the exclusive-OR of the inputs and ( stays unchanged).
- The first gate is a NAND with inputs and : output (by De Morgan).
- The next gate takes this signal and as inputs and performs AND followed by complement (NAND): . The intermediate node therefore carries .
- This intermediate signal is fed to a final gate that complements again: .
- Truth-table check of : only for , ; for all other combinations .
- This behaviour (1 only when , ) is exactly the borrow output of a half subtractor, so the circuit is definitely a half subtractor.
Formulas
- — NAND identity (De Morgan)
- — intermediate node
- — final borrow output
- — difference (exclusive-OR, unchanged from the XOR circuit)
- = minuend bit, = subtrahend bit, = difference, = borrow
Worked examples
Derivation of from the gate structure:
- Gate 1 (NAND of , ): output
- Gate 2 (NAND of that output with ): output
- Gate 3 (complement):
Truth table of the half subtractor ( minus ):
| Difference | Borrow | Reasoning | ||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | , no borrow needed |
| 0 | 1 | 1 | 1 | not possible directly; borrow 1, number becomes 2, , borrow = 1 |
| 1 | 0 | 1 | 0 | , no borrow needed |
| 1 | 1 | 0 | 0 | , no borrow needed |
Borrow reasoning for the 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 .
- So the difference is 1 and a borrow of 1 is generated (borrow output = 1).
Comparison
| Circuit | Operation | Inputs | Outputs |
|---|---|---|---|
| Half adder | Addition of two bits | 2 bits | Sum, Carry |
| Full adder | Addition of three bits | 3 bits | Sum, Carry |
| Half subtractor | Subtraction of two bits | 2 bits (, ) | Difference (), Borrow () |
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: stays (difference) and becomes (borrow).
- Borrow is 1 only for , ; in every other case borrow = 0.
- The case is handled by borrowing 1, which makes the bit value 2, so with borrow = 1.
- Gate-level result: NAND(,) → NAND with → final complement gives ; the whole half subtractor uses NAND gates plus the XOR structure.
- Shortcut: is 1 only when and — read the borrow directly from the input combination instead of re-deriving the gates.
Previous-year exam insights
- Full subtractor: difference = P ⊕ Q ⊕ ;
borrow-out = P'Q + P' + (equivalently P'Q + (P ⊕ Q)').
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.