๐Ÿ”ŒIntro to Electrical Engineering

Digital Logic Gates

Study smarter with Fiveable

Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.

Get Started

Why This Matters

Digital logic gates are the fundamental decision-makers of every electronic system you'll encounter in this course. When you're analyzing circuits, designing control systems, or understanding how a computer processes information, you're working with combinations of these basic building blocks. The gates themselves implement Boolean algebra physically, turning abstract logical operations into real voltage levels that drive everything from smartphones to spacecraft.

You're being tested on more than just memorizing truth tables. Exam questions will ask you to recognize functional equivalence between gate combinations, identify universal gates that can build any circuit, and apply gates to practical problems like error detection, arithmetic operations, and signal conditioning. Don't just memorize what each gate outputs. Know why you'd choose one gate over another and how gates combine to create complex logic functions.


Basic Logic Operations

These three gates form the foundation of Boolean algebra. Every other gate can be built from some combination of AND, OR, and NOT, so mastering them is the key to analyzing any digital circuit.

AND Gate

  • Outputs HIGH (1) only when ALL inputs are HIGH. Think of it as a series circuit where every switch must be closed for current to flow.
  • Boolean expression: Aโ‹…BA \cdot B or simply ABAB. The multiplication analogy helps here: any zero input "zeroes out" the result.
  • Used when multiple conditions must ALL be satisfied. Common applications include safety interlocks, enable signals, and permission logic in control systems.

Truth table for a 2-input AND:

AABBAโ‹…BA \cdot B
000
010
100
111

OR Gate

  • Outputs HIGH (1) when ANY input is HIGH. Like a parallel circuit where any closed switch completes the path.
  • Boolean expression: A+BA + B. The addition analogy works, but remember this is not arithmetic addition: 1+1=11 + 1 = 1 in Boolean logic, not 2.
  • Essential for alert systems and redundancy. Fire alarms, fault detection, or any application where multiple triggers should produce the same response.

Truth table for a 2-input OR:

AABBA+BA + B
000
011
101
111

NOT Gate (Inverter)

  • Outputs the logical complement of its input. HIGH becomes LOW, LOW becomes HIGH.
  • Boolean expression: Aห‰\bar{A} (also written Aโ€ฒA' or ยฌA\neg A). This is the simplest gate, with only one input and one output.
  • Creates active-low signals and enables complementary logic. Critical for level shifting, signal conditioning, and building more complex gates from simpler ones.
AAAห‰\bar{A}
01
10

Compare: AND vs. OR. Both combine multiple inputs, but AND requires unanimous agreement while OR requires only one vote. If an exam asks about fail-safe design, OR gates trigger on any fault; AND gates require all conditions to align.


Universal Gates

These gates earn the "universal" designation because you can construct ANY logic function using only one type. This isn't just a theoretical curiosity. Manufacturing efficiency and circuit standardization make universal gates incredibly practical, since a factory only needs to produce one type of gate to build any circuit.

NAND Gate

  • Outputs LOW (0) only when ALL inputs are HIGH. Functionally, it's an AND gate followed by a NOT gate.
  • Boolean expression: Aโ‹…Bโ€พ\overline{A \cdot B}. The "NOT-AND" name tells you exactly what it does.
  • Universal gate status means any circuit can be built from NANDs alone. This simplifies manufacturing and is why NAND-based designs dominate integrated circuits.
AABBAโ‹…Bโ€พ\overline{A \cdot B}
001
011
101
110

Notice the output column is the exact inverse of the AND truth table.

NOR Gate

  • Outputs HIGH (1) only when ALL inputs are LOW. Functionally, it's an OR gate followed by a NOT gate.
  • Boolean expression: A+Bโ€พ\overline{A + B}. It outputs the opposite of what an OR gate would.
  • Also a universal gate with historical significance. The Apollo Guidance Computer was built entirely from approximately 5,600 NOR gates.
AABBA+Bโ€พ\overline{A + B}
001
010
100
110

Compare: NAND vs. NOR. Both are universal, but NAND gates typically require fewer transistors in CMOS technology, making them the industry standard. Know both for exams, but recognize NAND's practical dominance.

Building Other Gates from NAND (A Common Exam Topic)

To prove NAND is universal, you need to show it can replicate NOT, AND, and OR. Here's how:

  1. NOT from NAND: Connect both inputs of a NAND gate to the same signal AA. The output is Aโ‹…Aโ€พ=Aห‰\overline{A \cdot A} = \bar{A}.
  2. AND from NAND: Take the output of a NAND gate and feed it into a second NAND wired as a NOT (step 1). You get Aโ‹…Bโ€พโ€พ=Aโ‹…B\overline{\overline{A \cdot B}} = A \cdot B.
  3. OR from NAND: First invert each input using NAND-as-NOT gates, then feed those inverted signals into a third NAND gate. By De Morgan's theorem, Aห‰โ‹…Bห‰โ€พ=A+B\overline{\bar{A} \cdot \bar{B}} = A + B.

Since NOT, AND, and OR can produce any Boolean function, and NAND can produce all three, NAND alone can build anything.


Exclusive Operations

These gates handle parity and equality. You use them when you care about whether inputs match or differ, not just whether they're high or low. They're essential for arithmetic circuits and data integrity checking.

XOR Gate (Exclusive OR)

  • Outputs HIGH (1) when inputs are DIFFERENT. For more than two inputs, it outputs HIGH when an odd number of inputs are HIGH.
  • Boolean expression: AโŠ•BA \oplus B, which is equivalent to (Aโ‹…Bห‰)+(Aห‰โ‹…B)(A \cdot \bar{B}) + (\bar{A} \cdot B).
  • Critical for binary addition and parity checking. The sum bit in a half-adder is just an XOR gate. Error detection codes (like parity bits) rely heavily on XOR operations.
AABBAโŠ•BA \oplus B
000
011
101
110

XNOR Gate (Exclusive NOR)

  • Outputs HIGH (1) when inputs are THE SAME. It's the complement of XOR.
  • Boolean expression: AโŠ•Bโ€พ\overline{A \oplus B}, also written as AโŠ™BA \odot B.
  • Functions as an equality comparator. It outputs 1 when A=BA = B, making it the go-to gate for digital comparators and error correction circuits. If an exam asks you to design a single-bit comparator, XNOR is your answer.
AABBAโŠ™BA \odot B
001
010
100
111

Compare: XOR vs. XNOR. They're logical complements. XOR detects difference (useful for finding errors), while XNOR detects equality (useful for confirming matches).


Quick Reference Table

ConceptBest Examples
Basic Boolean OperationsAND, OR, NOT
Universal GatesNAND, NOR
Exclusive/Parity OperationsXOR, XNOR
Requires ALL inputs HIGH to activateAND (output HIGH), NAND (output LOW)
Requires ANY input HIGH to activateOR (output HIGH), NOR (output LOW)
Equality/Difference DetectionXNOR (same = HIGH), XOR (different = HIGH)
Binary Arithmetic ApplicationsXOR (sum bit), AND (carry bit)
Error DetectionXOR, XNOR

Self-Check Questions

  1. Which two gates are classified as universal gates, and what does "universal" mean in this context?

  2. You need a gate that outputs HIGH only when exactly one of two inputs is HIGH. Which gate do you use, and what is its Boolean expression?

  3. Compare and contrast the AND and NAND gates: How do their truth tables relate to each other, and why might a designer choose NAND over AND in manufacturing?

  4. If you're designing a circuit to check whether two binary signals are equal, which gate serves as a single-bit comparator? Write the Boolean condition it implements.

  5. Implement an OR gate using only NAND gates. Describe the configuration step by step, and explain why this demonstrates NAND's universal property.