Digital Logic & CMOSBeginner11 min read · November 2026

Digital Logic Gates Tutorial: Truth Tables, De Morgan Duality & CMOS Switching

Every CPU arithmetic logic unit, microcontroller timer register, and memory flip-flop reduces physically to billions of microscopic semiconductor switches computing Boolean algebra—turning continuous analog currents into crisp binary 0 V (LOW) and +Vdd (HIGH) voltage levels. Rather than treating digital gates as mysterious black boxes, inspecting them inside an analog SPICE simulator exposes how threshold switching, propagation delay, static noise margins, and De Morgan universality operate down at voltage and current physics! In this tutorial you will review truth tables across core gates, prove why NAND and NOR are "universal" gates capable of building ANY digital circuit alone, inspect real CMOS transistor pull-up/pull-down symmetry, and trace live logic pulses in NodeSim.

Launch This Pre-Wired Circuit in NodeSim
Opens directly inside the ngspice WebAssembly workbench with sources and probes attached — zero signup required.
Simulate Live Circuit →
Active Semiconductor / Resonant Circuit Block & ResponseExcitationVin / BiasActive Stagengspice MNAInput vs Output SPICE Probe Trace
Logic gate digital pulse block diagram and synchronized voltage transition timing traces in ngspice.

1. Core Logic Gates, Voltage Thresholds & Truth Tables

Digital gates abstract voltages strictly into logic LOW (0, typically < 0.3·Vdd) and logic HIGH (1, typically > 0.7·Vdd) using sharp non-linear transistor gain across the undefined transition window. An AND gate outputs HIGH strictly when EVERY input reads HIGH (A · B), ideal for hardware clock gating or interlock enables. An OR gate outputs HIGH whenever AT LEAST ONE input reads HIGH (A + B), while an Inverter (NOT gate) flips HIGH cleanly to LOW and vice versa.

Putting an inverter bubble directly after AND and OR creates NAND and NOR—the workhorses of silicon layout! Notice why integrated CMOS chips favor inverting gates naturally: single-stage transistor inverters, NANDs, and NORs invert signal sense inherently! Building a non-inverting AND gate in real CMOS physically consists of one NAND stage chained right into a NOT inverter (taking 6 MOSFETs instead of just 4 MOSFETs!).

AND:  Y = A · B          (HIGH only when A=1 AND B=1)
OR:   Y = A + B          (HIGH when A=1 OR B=1)
NAND: Y = NOT(A · B)     (LOW only when A=1 AND B=1; 4 CMOS FETs)
NOR:  Y = NOT(A + B)     (LOW when A=1 OR B=1; 4 CMOS FETs)
XOR:  Y = A ⊕ B = A·B' + A'·B   (HIGH when inputs differ — equality comparator)

Because CMOS stages naturally invert once, NAND/NOR gates require 33% fewer transistors and switch significantly faster than bare non-inverting AND/OR gates!

2. De Morgan's Theorems & Universal Gate Synthesis

Augustus De Morgan discovered two algebraic duality identities that unlock universal circuit synthesis: inverting the output of an AND gate is mathematically identical to OR-ing the inverted inputs: NOT(A · B) = (NOT A) + (NOT B). Conversely, inverting an OR equals AND-ing inverted inputs: NOT(A + B) = (NOT A) · (NOT B).

Notice what follows cleanly from De Morgan duality: NAND alone (and NOR alone) is functionally complete ("Universal Gates")! Tie both inputs of a 2-input NAND together to build an Inverter (NOT); follow one NAND with that NAND-inverter to get an AND gate; invert both inputs ahead of a NAND using two NAND-inverters to synthesize an OR gate via De Morgan! Apollo Guidance Computers flew to the Moon built exclusively out of thousands of identical 3-input NOR chips purely for reliability uniformity.

De Morgan 1: (A · B)' = A' + B'    ⇒   NAND ≡ Bubbled-Input OR
De Morgan 2: (A + B)' = A' · B'    ⇒   NOR  ≡ Bubbled-Input AND
Universal NAND Construction Recipes:
  NOT(A)    = NAND(A, A)
  AND(A,B)  = NAND(NAND(A,B), NAND(A,B))
  OR(A,B)   = NAND(NAND(A,A), NAND(B,B))
  • Static Power Near Zero in Steady CMOS: Inside a static CMOS inverter or NAND gate, either the top PMOS network OR the bottom NMOS network conducts—NEVER both at steady 0 V / +Vdd levels! Zero steady static current leaks except tiny nanoamps, burning energy strictly during switching edges (P_dyn = C·Vdd²·f).
  • Never Leave Unused CMOS Inputs Floating: Letting an unused 74HC00 input float around Vdd/2 turns BOTH PMOS and NMOS partially ON simultaneously—causing milliamps of destructive crowbar current and wild static oscillation! Tie unused AND/NAND inputs to +Vdd and OR/NOR inputs to GND.

3. Analog Reality Inside Digital Signals: Fan-Out & Propagation Delay

Run a fast pulse waveform through multiple gates inside ngspice and the illusion of instant rectangular square edges vanishes! Every wire trace and downstream CMOS gate input acts like picofarads of load capacitance C_L driven through finite PMOS/NMOS channel resistance R_on. Charging and discharging C_L slows vertical transitions into finite nanosecond RC rise/fall edges—producing finite propagation delay t_pd between input crossing Vdd/2 and output answering.

Wiring ten gate inputs onto one output driver (high Fan-Out) stacks capacitance tenfold, stretching delay proportionally and dropping switching speed—unless a buffered high-drive bus stage or buffer splits load cleanly.

4. Stepping Binary Timing Diagrams Live in NodeSim

Launch NodeSim's pre-wired digital logic gate testbench and run Transient (.tran) simulation cleanly. Two staggered binary square pulse generators drive inputs A and B across all four binary combinations sequentially: (0,0), (0,1), (1,0), and (1,1).

Line up traces A, B, and Gate Output stacked synchronously along the time axis: scan vertical cursor lines straight down every quarter-period column to verify exact hardware truth-table behavior across every logic combination simultaneously!

Reference Component Values & Bill of Materials

Part / DesignatorNominal ValueRole in Circuit
U1, U2 (Logic Gates)AND / OR / NAND StagesEvaluates combinational Boolean operations across stepped binary voltage trains
Vin_A (Pulse Bit 0)0–5 V Fast SquareGenerates alternating 0/1 test sequence (fast toggle rate)
Vin_B (Pulse Bit 1)0–5 V Half-Rate SquareToggles at half frequency of Vin_A cleanly covering 00, 01, 10, 11 states
R_pull / C_loadOptional 10k / 10pFModels output interconnect capacitance or pull-up load for delay checks

Expected Waveforms & Simulation Verification

Probe / NodeAnalysis TypeExpected WaveformEngineering Check
Inputs (A & B)Transient (.tran)Staggered 2:1 binary square waves spanning all 4 input tuplesProduces complete automated truth-table timing test in one transient run
Y_AND OutputTransient (.tran)HIGH (+5 V) strictly during overlapping (1,1) quadrantsVerifies logical conjunction across real analog threshold crossovers
Y_OR OutputTransient (.tran)LOW (0 V) strictly when both A=0 and B=0 simultaneouslyConfirms logical disjunction and clean logic-level regeneration

Troubleshooting Common SPICE & Bench Mistakes

Output hovers ambiguously near mid-rail (~2.5 V) or outputs noise spikes
Check for an ungrounded reference or open output contention! Never wire TWO active logic outputs straight together fighting HIGH against LOW—that causes bus contention shorts.
Transistor-level CMOS NAND gate fails on rising edge cleanly
Verify PMOS pull-up transistors sit in PARALLEL to Vdd while NMOS pull-down transistors sit in SERIES to GND! Swapping series vs parallel implements NOR instead of NAND.
Microsecond glitches ("hazards") flash briefly at binary transitions
Slightly staggered input edge times (e.g. A falling 10 ns ahead of B rising) create momentary transient overlap states! Check pulse phase delays cleanly or add synchronous flip-flop sampling.

Hands-On Lab Exercises in NodeSim

  1. Place an inverting stage cleanly behind the AND output in NodeSim to convert it into a NAND gate and verify its output matches NOT(A AND B) across all 4 binary quarters.
  2. Wire three NAND-equivalent blocks following De Morgan formula NAND(NAND(A,A), NAND(B,B)) and confirm its truth table waveform matches OR(A,B) identically.
  3. Add a heavy capacitive load on a MOSFET inverter gate output and measure nanosecond 10%–90% propagation edge slowing cleanly with Transient zoom.
Ready to run your own numbers?
Open this schematic live in NodeSim or export an IEEE PDF lab report.
Related Guides:MOSFET Digital Switch PhysicsNMOS Digital Inverter LabSchmitt Trigger Noise Cleaning555 Clock GeneratorPWM Switching Control