Skip to main content

2.1 Basic Logic Gates: Operations, Truth Tables & Switch Models

📚Module 02: Logic Gates & Universal ImplementationTopic 2.1⏱️14 min read
🎯High-Yield For:University Semester Exams • Hardware Engineering Rounds • Foundational Computing

💡 Core Intuition: The Valve and Switch Network​

Every digital computer, from an 8-bit microcontroller to a multi-core cloud processor, is built entirely from tiny physical switches called logic gates. A logic gate is an electronic circuit with one or more binary inputs and exactly one binary output that enforces a specific Boolean operation.

🍳 The Everyday Analogy: Water Pipes and Light Switches​

Imagine an irrigation pipe network controlled by mechanical ball valves:

  • Switches in Series (AND Gate): Water flows to the crops only if Valve AA AND Valve BB are both turned open. If either valve (or both) is closed, water flow stops completely (00).
  • Switches in Parallel (OR Gate): Water reaches the crops if Valve AA OR Valve BB (or both) is turned open. Water flow is blocked only when every single valve along all paths is shut (00).
  • The Spring-Loaded Vent Valve (NOT Gate): A normally open pressure-relief valve. Pushing the lever down (applying input 1) seals the vent (output drops to 0). Releasing the lever (input 0) allows water to discharge freely (output is 1).

💻 Bridging to Computer Science​

In modern silicon microchips, these valves are constructed using MOSFET transistors (Metal-Oxide-Semiconductor Field-Effect Transistors).

  • An NMOS transistor acts like a switch that closes when input voltage is HIGH (11).
  • A PMOS transistor acts like a switch that closes when input voltage is LOW (00).

By combining PMOS transistors in pull-up networks and NMOS transistors in pull-down networks, digital logic gates execute millions of discrete mathematical operations every nanosecond with zero mechanical wear.



⚡ The Inverter (NOT Gate)​

The NOT gate (commonly called an inverter) is a single-input, single-output gate that computes the logical complement of its input signal.

📖Definition 2.1: Inverter Algebraic Operatordefinition
Y=Aˉ=A′Y = \bar{A} = A'

1. Truth Table & Functional Behavior​

The output YY is always the inverse of input AA:

Input AAOutput Y=AˉY = \bar{A}Physical Voltage Mapping (5V5\text{V} Logic)
0011Input at 0V0\text{V} (GND)   ⟹  \implies Output pulled to +5V+5\text{V} (VDDV_{DD})
1100Input at +5V+5\text{V} (VDDV_{DD})   ⟹  \implies Output shorted to 0V0\text{V} (GND)

2. Operational Properties of the NOT Gate​

  1. Involution Law: Inverting a signal twice restores the original identity: (A′)′=A(A')' = A
  2. Complementarity: A+Aˉ=1andA⋅Aˉ=0A + \bar{A} = 1 \qquad\text{and}\qquad A \cdot \bar{A} = 0
  3. Constants: 0′=1and1′=00' = 1 \qquad\text{and}\qquad 1' = 0

➕ The Logical Disjunction (OR Gate)​

The OR gate implements logical addition (disjunction). It accepts two or more binary inputs and produces an output of 11 if at least one of its inputs is 11.

📖Definition 2.2: Two-Input OR Gate Operatordefinition
Y=A+BY = A + B

1. Truth Table & Switch Analogy​

In an electrical circuit, an OR gate behaves identically to two mechanical switches connected in parallel:

Input AAInput BBOutput Y=A+BY = A + BSwitch Circuit Equivalent
000000Switch AA open, Switch BB open   ⟹  \implies No current to load
001111Switch AA open, Switch BB closed   ⟹  \implies Current flows through branch BB
110011Switch AA closed, Switch BB open   ⟹  \implies Current flows through branch AA
111111Both switches closed   ⟹  \implies Current flows through both branches

2. Fundamental Algebraic Laws Satisfied by OR Gates​

The OR operation satisfies all three primary algebraic consistency laws:

⚡Law 2.1: Algebraic Laws of the OR Gatelaw
A+A=A[Idempotent Law]A+B=B+A[Commutative Law](A+B)+C=A+(B+C)[Associative Law]\begin{aligned} A + A &= A \quad &&\text{[Idempotent Law]} \\ A + B &= B + A \quad &&\text{[Commutative Law]} \\ (A + B) + C &= A + (B + C) \quad &&\text{[Associative Law]} \end{aligned}

3. Constant Input Interactions​

  • OR with ZERO (Identity Element): A+0=AA + 0 = A Feeding a constant 00 to one input makes the OR gate act as a transparent buffer for signal AA.
  • OR with ONE (Dominance / Annihilator Element): A+1=1A + 1 = 1 Feeding a constant 11 forces the output permanently HIGH, inhibiting the data signal AA.

✖️ The Logical Conjunction (AND Gate)​

The AND gate implements logical multiplication (conjunction). It accepts two or more binary inputs and produces an output of 11 if and only if all inputs are simultaneously 11.

📖Definition 2.3: Two-Input AND Gate Operatordefinition
Y=A⋅B=ABY = A \cdot B = AB

1. Truth Table & Switch Analogy​

In an electrical circuit, an AND gate behaves identically to two mechanical switches connected in series:

Input AAInput BBOutput Y=A⋅BY = A \cdot BSwitch Circuit Equivalent
000000Both switches open   ⟹  \implies Circuit broken
001100Switch AA open, Switch BB closed   ⟹  \implies Circuit broken at switch AA
110000Switch AA closed, Switch BB open   ⟹  \implies Circuit broken at switch BB
111111Both switches closed   ⟹  \implies Unbroken electrical path to load

2. Fundamental Algebraic Laws Satisfied by AND Gates​

⚡Law 2.2: Algebraic Laws of the AND Gatelaw
A⋅A=A[Idempotent Law]A⋅B=B⋅A[Commutative Law](A⋅B)⋅C=A⋅(B⋅C)[Associative Law]\begin{aligned} A \cdot A &= A \quad &&\text{[Idempotent Law]} \\ A \cdot B &= B \cdot A \quad &&\text{[Commutative Law]} \\ (A \cdot B) \cdot C &= A \cdot (B \cdot C) \quad &&\text{[Associative Law]} \end{aligned}

3. Constant Input Interactions​

  • AND with ZERO (Dominance / Annihilator Element): A⋅0=0A \cdot 0 = 0 Holding one input at 00 forces the output permanently LOW, inhibiting (blocking) data line AA.
  • AND with ONE (Identity Element): A⋅1=AA \cdot 1 = A Holding one input at 11 allows data line AA to pass through completely unaltered (enabling transmission).

🕹️ Interactive Logic Gate Simulator​

Toggle the binary input pins below to observe real-time voltage propagation (5V5\text{V} emerald glow vs 0V0\text{V} slate ground) and track the active row in the truth table:

Digital Logic SimulatorY = A · B

Fundamental Logic Gate Simulator

Select AND, OR, or NOT to inspect vector IEEE symbols, circuit switch analogies, and live truth table tracking

ABY
Output Y =0(LOW / 0V)
📊 Live Truth Table
Input AInput BOutput Y
000
010
100
111
💡 Physics & Switch Analogy:
Switches in Series: Current flows only when both Switch A AND Switch B are closed.

🎛️ Enable & Inhibit Data Gating Mechanics​

In microprocessor architectures and bus routers, control lines frequently need to permit or prevent data streams from passing onto a shared bus. This technique is called data gating:

Data Gating Architectures: AND vs. OR Control

How control signals steer, pass, or clamp digital data streams

AND Gating

Active-High Enable Gate

🚪
Dominant Architecture / DomainMicroprocessor Bus Multiplexing
  • •Control = 1 (Enable): Output Y = Data · 1 = Data (Signal passes unaltered)
  • •Control = 0 (Inhibit): Output Y = Data · 0 = 0 (Output clamped LOW)
  • •Widely used for clock gating in low-power mobile CPUs
  • •Prevents downstream capacitive charging when idle
"Data passes when control is asserted HIGH."
OR Gating

Active-Low Enable Gate

🛡️
Dominant Architecture / DomainFault Bus & Alarm Monitoring
  • •Control = 0 (Enable): Output Y = Data + 0 = Data (Signal passes unaltered)
  • •Control = 1 (Inhibit): Output Y = Data + 1 = 1 (Output clamped HIGH)
  • •Used extensively in active-low interrupt lines (IRQ)
  • •Default resting state is high-rail V_DD
"Data passes when control is asserted LOW."

🏭 Real-World Production Context: CMOS Inversion & Delay​

In textbooks, AND and OR gates are introduced as the primary building blocks. However, in physical CMOS (Complementary MOS) silicon fabrication, pure inverting gates are fundamentally cheaper, faster, and more natural than non-inverting gates!

1. Why Silicon Is Naturally Inverting​

A basic CMOS transistor stage connects PMOS pull-up transistors to VDDV_{DD} and NMOS pull-down transistors to GNDGND:

  • When input voltage is HIGH, NMOS conducts to GNDGND, pulling output LOW.
  • When input voltage is LOW, PMOS conducts to VDDV_{DD}, pulling output HIGH.

Because CMOS stages inherently invert signals, a physical CMOS NAND gate requires only 4 transistors, whereas a CMOS AND gate requires 6 transistors (a 4-transistor NAND followed by a 2-transistor Inverter stage)!

  • A physical AND gate is slower than a NAND gate because signals must traverse two sequential transistor stages (tpd,AND=tpd,NAND+tpd,INVt_{pd,\text{AND}} = t_{pd,\text{NAND}} + t_{pd,\text{INV}}).

2. Propagation Delay (tpdt_{pd}) & Critical Path​

Every physical gate exhibits a finite propagation delay caused by internal parasitic capacitances charging through transistor channel resistance:

  • tpLHt_{pLH} (Low-to-High Delay): Time required for the output to transition from 10% to 90% of VDDV_{DD}.

  • tpHLt_{pHL} (High-to-Low Delay): Time required for the output to transition from 90% to 10% of VDDV_{DD}.

  • Average Delay: tpd=tpLH+tpHL2t_{pd} = \frac{t_{pLH} + t_{pHL}}{2}

In hyper-scale ASICs running at 4 GHz4\text{ GHz}, the clock cycle period is a mere 250 ps250\text{ ps}. Designers must ensure the longest combinational path (critical path) contains no more than 1515–2020 gate delays to avoid setup time violations.


📐 Numerical Applications & Worked Examples​

Example 1: Critical Path Propagation Delay in Cascaded Logic​

Problem Statement:
A combinational logic network implements the function Y=(A⋅B)+(C⋅D)+EY = (A \cdot B) + (C \cdot D) + E.
The hardware realization uses two 2-input AND gates driving a 3-input OR gate. The individual gate propagation delays are specified as:

  • 2-input AND gate: tpd,AND=1.8 nst_{pd,\text{AND}} = 1.8\text{ ns}
  • 3-input OR gate: tpd,OR=2.4 nst_{pd,\text{OR}} = 2.4\text{ ns}
  • Output load wiring delay: twire=0.3 nst_{wire} = 0.3\text{ ns}

Compute the maximum propagation delay (critical path delay) from the input pins to the primary output pin YY.

Step-by-Step Solution:

  1. Identify the Parallel Circuit Paths:

    • Path 1: From inputs A,B  ⟹  AND Gate 1  ⟹  OR Gate  ⟹  YA, B \implies \text{AND Gate 1} \implies \text{OR Gate} \implies Y.
    • Path 2: From inputs C,D  ⟹  AND Gate 2  ⟹  OR Gate  ⟹  YC, D \implies \text{AND Gate 2} \implies \text{OR Gate} \implies Y.
    • Path 3: Direct input E  ⟹  OR Gate  ⟹  YE \implies \text{OR Gate} \implies Y.
  2. Calculate the Delay for Each Path:

📐Path Delay Calculationsformula
TPath 1=tpd,AND1+tpd,OR+twire=1.8 ns+2.4 ns+0.3 ns=4.5 nsTPath 2=tpd,AND2+tpd,OR+twire=1.8 ns+2.4 ns+0.3 ns=4.5 nsTPath 3=tpd,OR+twire=2.4 ns+0.3 ns=2.7 ns\begin{aligned} T_{\text{Path 1}} &= t_{pd,\text{AND1}} + t_{pd,\text{OR}} + t_{wire} = 1.8\text{ ns} + 2.4\text{ ns} + 0.3\text{ ns} = 4.5\text{ ns} \\ T_{\text{Path 2}} &= t_{pd,\text{AND2}} + t_{pd,\text{OR}} + t_{wire} = 1.8\text{ ns} + 2.4\text{ ns} + 0.3\text{ ns} = 4.5\text{ ns} \\ T_{\text{Path 3}} &= t_{pd,\text{OR}} + t_{wire} = 2.4\text{ ns} + 0.3\text{ ns} = 2.7\text{ ns} \end{aligned}
  1. Determine the Critical Path:
    The critical path is the maximum delay among all signal routes:

    Tcritical=max⁡(TPath 1,TPath 2,TPath 3)=4.5 nsT_{\text{critical}} = \max(T_{\text{Path 1}}, T_{\text{Path 2}}, T_{\text{Path 3}}) = 4.5\text{ ns}

    Therefore, the maximum frequency of operation for this circuit stage is:

    fmax=1Tcritical=14.5×10−9 s≈222.2 MHzf_{max} = \frac{1}{T_{\text{critical}}} = \frac{1}{4.5 \times 10^{-9}\text{ s}} \approx 222.2\text{ MHz}

Example 2: Equivalent Mechanical Switch Network Extraction​

Problem Statement:
Analyze the mechanical relay switch network described below and determine the simplified Boolean algebraic equation for current flow between terminal T1T_1 and terminal T2T_2:

  • Branch 1 contains Switch AA in series with Switch BB.
  • Branch 2 contains Switch AA in series with Switch CC.
  • Branch 3 contains Switch BB in series with Switch CC.
  • All three branches are wired in parallel across terminals T1T_1 and T2T_2.

Step-by-Step Solution:

  1. Formulate the Raw Boolean Expression from Circuit Topology:

    • Series connections represent logical AND (⋅\cdot).
    • Parallel connections represent logical OR (++).
    Y=(A⋅B)+(A⋅C)+(B⋅C)=AB+AC+BCY = (A \cdot B) + (A \cdot C) + (B \cdot C) = AB + AC + BC
  2. Evaluate for Algebraic Minimization:
    Examine the expression AB+AC+BCAB + AC + BC:

    • All three variables are in true form (no complemented literals).
    • Since no variable appears both true and complemented, the Consensus Theorem cannot eliminate any term.
    • Factoring common terms:
🔍Algebraic Factoring of Switch Networkproof
Y=A(B+C)+BC\begin{aligned} Y &= A(B + C) + BC \end{aligned}
  1. Physical Interpretation:
    Current flows from T1T_1 to T2T_2 whenever any two or more switches are closed simultaneously. This circuit is physically equivalent to a 3-input majority logic voter circuit.

Example 3: Clock Gating & Inhibit Control Analysis​

Problem Statement:
A power-management unit controls an on-chip clock tree. The system clock signal is CLK(t)CLK(t) with a square wave frequency of 100 MHz100\text{ MHz}. A designer uses a 2-input logic gate where Input 1 is CLKCLK and Input 2 is an active-high sleep control signal SLEEPSLEEP.

  1. If an AND gate is used (Y=CLK⋅SLEEPY = CLK \cdot SLEEP), what is the output YY when SLEEP=0SLEEP = 0 (normal sleep mode) vs SLEEP=1SLEEP = 1 (wake mode)?
  2. If the sleep signal is active-low (SLEEP‾\overline{SLEEP}), which basic logic gate must be used to keep the clock wire clamped to 00 during sleep mode?

Step-by-Step Solution:

  1. Evaluate the AND Gating Scheme:

    • When SLEEP=0SLEEP = 0:
      Y=CLK⋅0=0 (Constant Ground)Y = CLK \cdot 0 = 0\text{ (Constant Ground)}
      The clock waveform is completely extinguished. No downstream flip-flops toggle, eliminating dynamic switching power dissipation Pdyn=CV2fP_{dyn} = C V^2 f.
    • When SLEEP=1SLEEP = 1:
      Y=CLK⋅1=CLKY = CLK \cdot 1 = CLK
      The full 100 MHz100\text{ MHz} clock pulses pass through to the core.
  2. Evaluate Active-Low Control Requirement:
    If the control line is active-low (SLEEP‾\overline{SLEEP}, where sleep mode is denoted by SLEEP‾=1\overline{SLEEP} = 1 and wake mode by SLEEP‾=0\overline{SLEEP} = 0):

    • During wake mode (SLEEP‾=0\overline{SLEEP} = 0), we require Y=CLKY = CLK.
    • During sleep mode (SLEEP‾=1\overline{SLEEP} = 1), we require Y=1Y = 1 or clamped state.
      If we use an OR gate:
      Y=CLK+SLEEP‾Y = CLK + \overline{SLEEP}
    • When awake (SLEEP‾=0\overline{SLEEP} = 0): Y=CLK+0=CLKY = CLK + 0 = CLK (Clock passes!).
    • When asleep (SLEEP‾=1\overline{SLEEP} = 1): Y=CLK+1=1Y = CLK + 1 = 1 (Clock clamped HIGH, dynamic power zero).

🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions
  • Can a multi-input logic gate have more than two inputs in physical CMOS?
    Yes, but with strict physical limits. A 4-input CMOS NAND gate stacks 4 NMOS transistors in series between output and ground. Since transistor channel resistances add in series, high-fan-in gates exhibit severely degraded fall times (tpHLt_{pHL}). In modern VLSI libraries, gates rarely exceed 44 inputs; wider fan-in logic is broken into tree cascades of 2-input and 3-input gates.

  • Why is an open/floating input pin dangerous on high-impedance CMOS gates?
    CMOS transistor gates are insulated by a microscopic silicon dioxide layer, presenting near-infinite input impedance (∼1012 Ω\sim 10^{12}\,\Omega). An unconnected (floating) input pin acts as an antenna that accumulates ambient static charge, floating into the intermediate threshold zone (VIL<V<VIHV_{IL} < V < V_{IH}). This turns both PMOS and NMOS transistors ON simultaneously, causing catastrophic shoot-through current and erratic output oscillations.

Common Interview Traps
  • Trap: Assuming AND and OR gates are universal.
    AND and OR gates can only generate monotonically non-decreasing Boolean functions. Without the NOT operation, you can never create an inversion (0→10 \to 1). Therefore, {AND,OR}\{AND, OR\} is NOT a functionally complete set.

  • Trap: Confusing the Enable states of AND vs OR gates.
    Remember:

    • An AND gate is enabled by 11 (A⋅1=AA \cdot 1 = A) and inhibited by 00 (A⋅0=0A \cdot 0 = 0).
    • An OR gate is enabled by 00 (A+0=AA + 0 = A) and inhibited by 11 (A+1=1A + 1 = 1).

💬

Discussion & Doubts