Topic 03 — Digital Electronics

Logic Gates & Universal Gate Theory

From transistor physics to CMOS VLSI — the complete guide to every logic gate, universal gate implementations, performance metrics, and an interactive gate simulator.

AND · OR · NOT NAND · NOR (Universal) XOR · XNOR CMOS vs TTL Interactive Simulator

1. The Philosophy of Digital Logic

In an analog world of infinite gradients, digital logic imposes a strict binary order. A logic gate is both an idealized mathematical model and a physical semiconductor device. Conceptually, gates are the axioms of Boolean algebra. Physically, they are MOSFET transistors acting as voltage-controlled switches.

The key insight that powers all of computing is abstraction. An engineer designing an ALU doesn't need to know the exact drain current equations of each transistor — they rely on deterministic gate behavior to compose complex hierarchies from simple primitives.

The Radix-2 Constraint: All standard logic gates operate on Base-2 (Binary). Two voltage levels give maximum noise margin — signals can degrade significantly before being misread. A 10-level system (decimal gates) would require 5× more precision from every transistor, making it impractical at scale.

2. The Triumvirate: AND, OR, NOT

Any Boolean expression — however complex — can be decomposed into combinations of AND, OR, and NOT. These three are called the functionally complete set.

AND Gate (Conjunction)
Y = A · B
ABY
Output HIGH only if ALL inputs are HIGH. Physically equivalent to switches in series. Used in address decoding and masking operations.
OR Gate (Disjunction)
Y = A + B
ABY
Output HIGH if ANY input is HIGH. Switches in parallel. Used in interrupt logic and error flag aggregation.
NOT Gate (Inverter)
Y = A'
AY
Inverts the input. Single transistor in CMOS. The bubble symbol indicates inversion. Essential in complementary logic pairs.

Truth Tables for AND, OR, NOT

ABAND (A·B)OR (A+B)NOT A (A')
00001
01011
10010
11110

3. Derived Gates: XOR & XNOR

XOR (Exclusive-OR) and XNOR are derived from the basic triumvirate and perform operations critical to arithmetic and comparison circuits.

XOR — Exclusive-OR
Y = A ⊕ B = A'B + AB'
ABY
HIGH only when inputs DIFFER. The Sum bit in a Half Adder. Also used in parity generators and cryptographic XOR ciphers.
XNOR — Exclusive-NOR
Y = (A ⊕ B)' = AB + A'B'
ABY
HIGH only when inputs are IDENTICAL. The basis of magnitude comparators. Used to check equality of multi-bit values.
ABXOR (A⊕B)XNOR (A⊙B)
0001
0110
1010
1101

4. Universal Gate Theory

A gate is universal (or functionally complete) if any Boolean function can be implemented using only that gate type. This matters enormously for chip manufacturing — one optimized cell type can be used everywhere.

Why NAND in CMOS? A CMOS NAND gate requires 4 transistors (2 PMOS in parallel, 2 NMOS in series). An AND gate requires a NAND followed by an inverter — 6 transistors. Since NAND + inversion is the fundamental CMOS operation, NAND-based design minimizes silicon area and switching delay simultaneously. Over 80% of standard cell libraries are NAND-dominated.

Proof of universality requires showing that AND, OR, and NOT can each be derived from a single gate type. Both NAND and NOR satisfy this requirement. XOR alone does NOT — it cannot produce a NOT gate independently.

5. The NAND Gate — Complete Implementation

NAND Gate
Y = (A · B)' = A' + B'
ABY

NAND is the complement of AND — its output is LOW only when ALL inputs are HIGH. Using De Morgan's theorem: (A·B)' = A' + B'. Deriving all basic gates from NAND:

NOT from NAND

Tie both inputs together.

Y = (A·A)' = A'

AND from NAND

NAND → NAND inverter.

Y = ((A·B)')' = A·B

OR from NAND

Invert both inputs, then NAND.

Y = (A'·B')' = A+B

NOR from NAND

OR-from-NAND, then invert output.

Y = (A+B)' using 5 NAND

XOR from NAND

Classic 4-NAND implementation.

Y = A⊕B (4 gates)
ABNAND (Y)
001
011
101
110

6. The NOR Gate — Complete Implementation

NOR Gate
Y = (A + B)' = A' · B'
ABY

NOR is the dual of NAND. Its output is HIGH only when ALL inputs are LOW. While also universal, NOR gates in CMOS require larger PMOS transistors (lower hole mobility), making NOR-based designs slower and larger than equivalent NAND designs.

NOT from NOR

Tie both inputs together.

Y = (A+A)' = A'

OR from NOR

NOR → NOR inverter.

Y = ((A+B)')' = A+B

AND from NOR

Invert both inputs, then NOR.

Y = (A'+B')' = A·B

7. CMOS vs TTL Logic Families

TTL (Transistor-Transistor Logic)

TTL uses Bipolar Junction Transistors (BJTs). Current flows through the base-emitter junction to switch between states. Standardized at 5V supply voltage. Advantages: fast switching, high drive strength, good noise immunity. Disadvantages: significant static power consumption even when idle, limited supply voltage range.

CMOS (Complementary Metal-Oxide-Semiconductor)

CMOS uses complementary pairs of PMOS and NMOS transistors. When PMOS is ON, NMOS is OFF, and vice versa — creating a low-resistance path to either VDD or GND, with ideally no DC path between them. This means near-zero static power. Power is only consumed during transitions (charging/discharging parasitic capacitances).

ParameterTTL (74LS)CMOS (74HC)CMOS (3.3V)
Supply Voltage5V2–6V3.3V
Static Power~1 mW/gate<0.1 µW/gate<0.01 µW/gate
Propagation Delay~10 ns~7 ns~4 ns
Noise Margin0.4V1.0V0.9V
Fan-Out10 TTL loads50+ CMOS50+ CMOS
Sub-7nm Era: In modern FinFET and GAA (Gate-All-Around) transistors used in 5nm/3nm chips, leakage current has become a dominant power concern. Nearly half the power budget in mobile chips goes to static leakage, not dynamic switching. This drives techniques like power gating, multi-Vth cells, and adaptive voltage scaling.

8. Engineering Performance Metrics

tpd
Propagation Delay
Nmax
Fan-Out Limit
PDP
Power-Delay Product
VNM
Noise Margin
  • Propagation Delay (tpd): Time from input change to output settling. Defined at the 50% crossing. CMOS: 1–10 ns typical. Critical path delay limits max clock frequency.
  • Fan-Out: Max number of gate inputs one output can drive without violating VOL/VOH spec. Exceeding fan-out degrades noise margin and increases propagation delay.
  • Power-Delay Product (PDP): Energy per switching event = P × tpd. Lower is better. The figure of merit for comparing logic families.
  • Noise Margin: VNMH = VOH,min − VIH,min and VNML = VIL,max − VOL,max. The guaranteed voltage margin before a logic level is misinterpreted.
  • Rise/Fall Time (tr/tf): Time for output to transition from 10% to 90% (or 90% to 10%) of supply voltage. Faster transitions reduce short-circuit power.

9. Positive vs. Negative Logic

The mapping of voltages to logic values is a design convention, not a physical fact. Under positive logic: HIGH voltage = 1, LOW = 0. Under negative logic: HIGH = 0, LOW = 1.

Under negative logic, an AND gate physically behaves as an OR gate (provable by De Morgan's theorem). This duality is exploited in active-low signals — common in control buses where asserting a signal means pulling it LOW. The CS# (chip select) and WE# (write enable) signals in DRAM are active-low, meaning the hardware performs a NOR-like check: "if CS# is low AND WE# is low, write."

10. Building Combinational Circuits

Logic gates combine into combinational circuits where outputs depend only on current inputs (no memory). The design process:

  1. Specify: Define inputs, outputs, and the functional requirement in words.
  2. Truth Table: Enumerate all 2n input combinations and desired outputs.
  3. Simplify: Use K-Maps or Boolean algebra to minimize the expression.
  4. Realize: Map the simplified expression to gates — typically NAND-NAND or NOR-NOR for standard cells.
Half Adder = XOR + AND: The simplest arithmetic circuit — XOR gives the Sum bit, AND gives the Carry. Cascading Full Adders (which handle carry-in) produces Ripple Carry Adders, and ultimately Carry Look-ahead Adders in modern CPUs.

11. Logic Gates in Modern VLSI

Modern chips don't place individual transistors; engineers work with standard cell libraries — pre-characterized gate cells (AND2, NAND3, OAI21, etc.) with known timing, power, and area specs. Synthesis tools map RTL (Verilog/VHDL) → gate netlist → layout automatically.

  • Complex gates (AOI/OAI): AND-OR-INVERT and OR-AND-INVERT gates implement 2-level logic in fewer transistors than cascaded simple gates.
  • Multi-drive cells: The same logic function in X1, X2, X4, X8 drive strengths — synthesis picks the right size based on fan-out and timing needs.
  • LUTs in FPGAs: FPGA "gates" are 4–6 input Look-Up Tables (LUTs) — small RAMs storing any truth table. One LUT can implement any 4-input Boolean function.
  • Transmission gates: A PMOS + NMOS pair passing signal bidirectionally, used in multiplexers, flip-flops, and XOR implementations for lower gate count.

12. Deep Engineering FAQ

Why are NAND gates preferred over NOR in CMOS VLSI?

In a CMOS NAND gate, the NMOS transistors (pull-down) are in series. NMOS has high electron mobility — series NMOS is fast. In a NOR gate, the PMOS transistors (pull-up) are in series. PMOS has lower hole mobility (~half of NMOS), requiring physically larger transistors to match speed, consuming more area and power.

What is a Schmitt Trigger input?

A Schmitt Trigger uses hysteresis — two different threshold voltages for rising and falling edges (VT+ and VT−). Noisy slow signals that hover near a threshold cause multiple toggles on standard inputs. The Schmitt Trigger fires once cleanly. Used in touch sensors, button debouncing, and communication receivers.

What is an Open-Drain output?

The gate can only pull output LOW (drive to GND), never HIGH. An external pull-up resistor supplies the HIGH state. Multiple open-drain outputs on the same wire perform a "Wired-AND" — if any gate drives LOW, the bus is LOW. This is the basis of I²C and one-wire protocols.

Explain the race condition in gate logic.

When input signals travel through paths of different lengths (gate counts), they arrive at a final gate at different times. The transient incorrect output during this propagation window is called a glitch. In clocked synchronous design, glitches are tolerated because the output is only sampled after all transients settle. In asynchronous logic, glitches can cause incorrect latching.

What is the Power-Delay Product and why does it matter?

PDP = Power × Propagation Delay = energy consumed per switching event. It's the fundamental trade-off metric: faster gates dissipate more power, power-efficient gates are slower. Sub-threshold CMOS operates below Vth for ultra-low power at the cost of 1000× slower speed.

Can XOR gates alone implement any Boolean function?

No. XOR gates are not functionally complete. The XOR function is self-dual and cannot produce a constant output independent of inputs — meaning NOT cannot be reliably implemented from XOR alone. You need at least one gate capable of producing a constant (NAND, NOR, or AND+NOT) to achieve functional completeness.

Interactive Lab

Logic Gate Simulator — 3 Tools

Gate Truth Table · Universal NAND Builder · Expression Evaluator

Gate Type
Input A
0
Input B
0
Output Y
0

Select which gate to build from NAND gates only. Toggle inputs A and B to verify the output matches the target gate.

Target Gate
Input A
0
Input B
0
Output Y
0

Toggle A and B to evaluate all expressions simultaneously.

A
0
B
0
← Boolean Law Combinational Circuits →

Related VLSI Topics

CMOS Logic Design
Every logic gate (NAND, NOR, NOT) is physically built from CMOS transistors — see how gate-level logic maps to silicon using PMOS pull-up and NMOS pull-down networks.
Verilog HDL
Gate-level logic in Verilog — how AND, OR, NOT, NAND, NOR, and XOR primitives are expressed as RTL operators and how synthesis maps them back to standard cells.