The Repair LibraryRead · Learn · Master

Logic Gates and Boolean Algebra

The pivot to digital — two states instead of infinite, the seven logic gates and their truth tables, the Boolean algebra that describes them, and the noise immunity that makes it all robust.

IntermediateLow Risk28 min read

What You Will Learn

  • You will learn how digital differs from analog — two discrete states with logic levels and a noise margin that makes digital robust — and what HIGH and LOW mean.
  • You will learn the seven basic logic gates (NOT, AND, OR, NAND, NOR, XOR, XNOR) and how to read and write their truth tables.
  • You will learn the basics of Boolean algebra — the AND/OR/NOT operations, the core identities, and De Morgan's theorem.
  • You will learn why NAND and NOR are universal gates and how logic is built into real IC families like TTL and CMOS.

What You Will Be Able To Do

  • You will be able to explain the difference between analog and digital and what logic levels and noise margin mean.
  • You will be able to state the truth table of any of the seven basic logic gates.
  • You will be able to apply the basic Boolean identities and De Morgan's theorem.
  • You will be able to explain why NAND and NOR are universal and identify the common logic families.

Required Tools

No physical tools required. This is a conceptual section.

Section Overview

Everything so far has been analog — signals that vary continuously and, as Chapter 5 showed, drift, pick up noise, and distort. This chapter turns to the opposite world: digital, where a signal is only ever one of two states. That single restriction changes everything. A digital signal is HIGH or LOW, 1 or 0, true or false — and because it only has to be recognizably one or the other, it shrugs off the noise and drift that plague analog. This section introduces the two-state idea and the logic levels and noise margin behind it, then the seven basic logic gates and their truth tables, the Boolean algebra that is the math of logic (including De Morgan's theorem), why NAND and NOR are "universal," and how all of this lives inside real logic ICs. It's the foundation the rest of digital electronics is built on.

Why This Matters

Digital electronics runs the modern world — every processor, memory, controller, and communication link is built from the logic in this section. For a repair technician, the shift to digital changes what you're looking at and how you diagnose it: instead of measuring a continuously varying signal, you're checking whether a line is HIGH or LOW, whether a gate's output matches what its inputs should produce, whether a signal is stuck. Understanding logic gates and their truth tables lets you predict what a digital circuit should do and spot where it doesn't. Boolean algebra is the language that describes it, De Morgan's theorem is a tool you'll use to make sense of inverted logic, and knowing the logic families tells you what voltages to expect. This section is the entry point to digital repair — and to the flip-flops, timing, and buses that follow.

Required Prerequisites

No consumables required. A few logic-gate ICs (a 7400 quad-NAND, a 4001 quad-NOR) make ideal, reusable practice material, but nothing is used up.

  • Optional: a couple of logic-gate ICs (a 74xx TTL or 40xx CMOS gate), a breadboard, a low-voltage supply (5 V or 3.3 V), some switches for inputs, and LEDs to show outputs
  • A multimeter or logic probe to read HIGH and LOW levels
  • No special hardware is required; the section stands on truth tables and Boolean reasoning

Real-World Applications

Logic gates are the atoms of every digital system. Combined by the millions, they form the processors, memory, and controllers in every computer and phone. In discrete form they still appear everywhere on real boards: a gate combining a few signals to enable a function, an inverter flipping a control line, logic decoding an address or interlocking a safety condition. Digital communication, arithmetic, and control all reduce to gates and Boolean logic. For the repair technician, recognizing a logic IC, knowing its gate's truth table, and checking whether its output is correct for its inputs is a core digital-diagnosis skill — the same reasoning whether the logic is one 7400 chip or a billion gates inside a processor.

Common Challenges

  • Thinking in analog voltages instead of states. A digital line isn't "3.1 volts" in any meaningful way — it's HIGH or LOW. The exact voltage only matters for deciding which state it is; the logic works in 1s and 0s.
  • Confusing similar gates. AND vs NAND, OR vs NOR, XOR vs XNOR differ only by an inversion, and it's easy to mix them up. Anchoring each to its truth table keeps them straight.
  • Reading De Morgan's backwards. De Morgan's theorem swaps AND for OR (and vice versa) and inverts each term. Applying only half the change — swapping the operation but forgetting to invert the inputs, or the reverse — is the classic error.

Safety Notes

Risk Level: Low. Logic circuits are low-voltage, signal-level, and safe to study and probe. Two practical notes.

Professional Tips Before Starting

  • Think in states, then check the voltage only to decide the state. A logic line is HIGH or LOW; you measure the voltage only to classify it, using the family's thresholds. This is the opposite of analog, where the exact voltage is the information.
  • Learn the truth tables cold. The seven gates are the alphabet of digital; knowing each gate's table by heart lets you predict any combinational circuit and instantly see when an output is wrong for its inputs.
  • Keep De Morgan's in your toolkit. Inverted logic (NAND/NOR everywhere) is far easier to reason about once you can flip NOT(A AND B) into (NOT A) OR (NOT B) at will — it turns confusing negations into familiar shapes.

Understanding Logic Gates and Boolean Algebra

From Analog to Digital: Logic Levels and Noise Margin

Analog signals vary continuously and carry their information in their exact value — which is why noise and drift corrupt them. Digital takes the opposite approach: a signal is only ever one of two states, called HIGH and LOW (also 1 and 0, or true and false). A circuit doesn't care about the exact voltage, only which of the two states it represents.

The two states are defined by logic levels: a range of voltages counts as a valid HIGH, another range counts as a valid LOW, and a forbidden band sits between them that a good signal should pass through quickly and never rest in. In a 5 V system, for example, a voltage near 5 V is HIGH and a voltage near 0 V (ground) is LOW. The gap between the ranges is the source of digital's superpower: the noise margin. Because any voltage in the wide HIGH band reads as HIGH, a HIGH signal can pick up a fair amount of noise or droop and still be read correctly — the noise has to be large enough to push it across the forbidden band before it causes an error. This tolerance is why digital shrugs off the noise and drift that ruin analog signals, and why a digital signal can be regenerated perfectly at every stage.

The Logic Gates and Their Truth Tables

A logic gate is a circuit that takes one or more digital inputs and produces a digital output according to a fixed logical rule. Its behavior is captured completely by a truth table: a table listing the output for every possible combination of inputs. There are seven gates to know.

The NOT gate (inverter) has one input and flips it:

| A | NOT A | |---|-------| | 0 | 1 | | 1 | 0 |

The AND gate outputs HIGH only when all inputs are HIGH; the OR gate outputs HIGH when any input is HIGH:

| A | B | A AND B | A OR B | |---|---|---------|--------| | 0 | 0 | 0 | 0 | | 0 | 1 | 0 | 1 | | 1 | 0 | 0 | 1 | | 1 | 1 | 1 | 1 |

The NAND and NOR gates are simply AND and OR with the output inverted — NAND is HIGH unless all inputs are HIGH, and NOR is HIGH only when all inputs are LOW:

| A | B | A NAND B | A NOR B | |---|---|----------|---------| | 0 | 0 | 1 | 1 | | 0 | 1 | 1 | 0 | | 1 | 0 | 1 | 0 | | 1 | 1 | 0 | 0 |

The XOR (exclusive-OR) gate outputs HIGH when its inputs differ; the XNOR gate outputs HIGH when they are the same:

| A | B | A XOR B | A XNOR B | |---|---|---------|----------| | 0 | 0 | 0 | 1 | | 0 | 1 | 1 | 0 | | 1 | 0 | 1 | 0 | | 1 | 1 | 0 | 1 |

Notice the pattern: NAND, NOR, and XNOR are just the inverses of AND, OR, and XOR — flip every output bit and you turn one into the other.

Boolean Algebra and De Morgan's Theorem

Boolean algebra is the mathematics of these two-state logic values, and it maps neatly onto the gates: AND behaves like multiplication (often written A · B), OR behaves like addition (A + B), and NOT is complement (written as "NOT A"). A handful of identities are worth knowing, and each just reads off a truth table:

  • A AND 1 = A, and A AND 0 = 0 (an AND with a 1 passes the other input; an AND with a 0 forces 0).
  • A OR 0 = A, and A OR 1 = 1 (an OR with a 0 passes the other input; an OR with a 1 forces 1).
  • A AND A = A, and A OR A = A (combining a value with itself changes nothing).
  • A AND (NOT A) = 0, and A OR (NOT A) = 1 (a value and its opposite are always false together and always true apart).

The single most useful rule is De Morgan's theorem, which relates AND, OR, and NOT:

NOT(A AND B) = (NOT A) OR (NOT B) NOT(A OR B) = (NOT A) AND (NOT B)

In words: to invert an AND, change it to an OR and invert both inputs; to invert an OR, change it to an AND and invert both inputs. This lets you rewrite any inverted-logic expression into the other form — invaluable because so much real logic is built from NAND and NOR gates, and De Morgan's is how you translate between "a NAND of the inputs" and "an OR of the inverted inputs."

Universal Gates

Here is a remarkable fact: the NAND gate alone can build any logic function — NOT, AND, OR, and everything made from them — and so can the NOR gate alone. A gate that can build all logic by itself is called a universal gate, and NAND and NOR are the two. (For example, tying a NAND's inputs together makes an inverter; a NAND followed by an inverter makes an AND; and De Morgan's shows how a NAND relates to an OR of inverted inputs.) This universality is why NAND and NOR gates are the workhorses of digital design and among the most common logic chips — a single type of gate can implement a whole system.

Logic Families and Physical Chips

Gates are real circuits inside ICs, built from transistors acting as switches. Two classic logic families you'll meet by their part numbers are the 7400 series (originally TTL — transistor-transistor logic, bipolar-transistor based) and the 4000 series (CMOS — complementary MOSFET based). Modern logic is overwhelmingly CMOS, prized for its very low power (it draws almost no current except when switching) and, from Chapter 4, its high input impedance and ESD sensitivity. A logic IC runs from a supply — commonly 5 V for older TTL and 3.3 V (or lower) for modern CMOS — and a gate's HIGH output sits near the supply voltage while its LOW output sits near ground. Knowing the family tells you the supply voltage and therefore what HIGH and LOW should measure, which is exactly what you check when diagnosing a logic circuit.

Common Mistakes

  • Judging a line by its exact voltage. A digital line is HIGH or LOW; the voltage only classifies the state against the family's thresholds. Don't treat a logic level like an analog value.
  • Mixing up a gate with its inverse. NAND is not AND; NOR is not OR; XNOR is not XOR. Each pair differs by an output inversion — check the truth table.
  • Half-applying De Morgan's. Inverting an AND/OR means both swapping the operation and inverting each input. Doing only one is wrong.
  • Assuming all logic is 5 V. Modern CMOS often runs at 3.3 V or lower; check the family and supply before deciding what HIGH and LOW should be.

Troubleshooting Guidance

Digital diagnosis is, at its core, checking whether reality matches the truth table. First establish the supply and the family so you know what HIGH and LOW should measure — a logic IC with the wrong or missing supply can't produce valid levels at all (the check-power-first habit from the analog chapters carries straight over). Then, at a suspect gate, read its inputs, look up what the output should be from the gate's truth table, and compare it to the actual output: a mismatch means the gate (or its connections) is faulty, while a match sends you upstream to whatever is driving its inputs. Watch for the digital-specific failure signs: a line stuck HIGH or stuck LOW that never changes (a shorted output, a driver that's failed, or a short to supply or ground), a line sitting in the forbidden band between valid levels (a floating input, a weak driver, or contention where two outputs fight), and inputs left floating on CMOS (which can read as random states and cause erratic behavior — CMOS inputs must be driven or tied). Because digital signals are two-state, a logic probe or even a multimeter comparing input states against the expected output localizes many faults quickly — the truth table is your known-good reference. Deeper digital diagnosis (timing, buses, and the failure modes ahead) builds on exactly this compare-to-the-truth-table method.

Verification & Testing Methods

Check your understanding before moving on:

  • [ ] Explain how digital differs from analog and what logic levels and noise margin provide.
  • [ ] Write the truth table for each of the seven gates (NOT, AND, OR, NAND, NOR, XOR, XNOR).
  • [ ] Apply the basic Boolean identities and both forms of De Morgan's theorem.
  • [ ] Explain why NAND and NOR are universal and name the TTL and CMOS logic families.

Then try the practice exercises below — truth-table and Boolean reasoning, no powered work required.

Practice Exercises

  1. Fill the truth tables (10 minutes, pen and paper). From memory, write the full truth table for: (a) a NOR gate; (b) an XOR gate; (c) a NAND gate. Then state in words the rule each one follows.
  2. Apply De Morgan's (5 minutes, pen and paper). Rewrite each using De Morgan's theorem: (a) NOT(A OR B); (b) NOT(X AND Y). Show the swapped operation and the inverted inputs.
  3. Boolean identities (5 minutes, reasoning). Simplify each: (a) A AND 1; (b) A OR 1; (c) A AND (NOT A); (d) B OR 0. State the identity used.
  4. Universal gates (10 minutes, reasoning). Explain in your own words what makes NAND a universal gate, and describe how you would make a NOT (inverter) and an AND gate using only NAND gates.

These core ideas — the two-state digital model and noise margin, the seven gate truth tables, the Boolean identities and De Morgan's theorem, universal gates, and the logic families — are tested in the Chapter Quiz at the end of this chapter, where a score of 80% is required to continue.

Key Takeaways

  • Digital uses only two states — HIGH/1 and LOW/0 — defined by logic level ranges with a forbidden band between; the resulting noise margin makes digital robust against the noise and drift that corrupt analog.
  • A logic gate produces a digital output from its inputs by a fixed rule, fully described by its truth table. The seven gates: NOT (invert), AND (HIGH only if all inputs HIGH), OR (HIGH if any input HIGH), NAND (HIGH unless all HIGH), NOR (HIGH only if all LOW), XOR (HIGH if inputs differ), XNOR (HIGH if inputs the same).
  • Boolean algebra is the math of logic: AND like multiply (A · B), OR like add (A + B), NOT as complement, with identities such as A AND 1 = A, A OR 1 = 1, and A AND (NOT A) = 0.
  • De Morgan's theorem: NOT(A AND B) = (NOT A) OR (NOT B), and NOT(A OR B) = (NOT A) AND (NOT B) — invert an AND/OR by swapping the operation and inverting every input.
  • NAND and NOR are universal gates — either one alone can build any logic function — which is why they are the most common logic building blocks.
  • Gates live in IC logic families: the 7400 series (TTL) and 4000 series (CMOS), with modern logic mostly CMOS (low power, ESD-sensitive), running at 5 V or 3.3 V so HIGH sits near the supply and LOW near ground.

Skills Learned

  • You can now explain the analog-to-digital shift and what logic levels and noise margin mean.
  • You can now state the truth table of any of the seven basic logic gates.
  • You can now apply the basic Boolean identities and De Morgan's theorem.
  • You can now explain why NAND and NOR are universal and identify the common logic families.
  • You can now diagnose a logic gate by comparing its output against what its truth table predicts.

Glossary Additions

  • logic gate — a digital circuit that produces a two-state (HIGH/LOW) output from one or more two-state inputs according to a fixed logical rule; the seven basic gates are NOT, AND, OR, NAND, NOR, XOR, and XNOR.
  • truth table — a table that lists a logic gate's or circuit's output for every possible combination of its inputs, completely describing its logical behavior.
  • logic level — the defined voltage range that represents a digital HIGH or LOW, with a forbidden band between them; a signal in the HIGH range reads as 1 and one in the LOW range reads as 0, and the gap gives the noise margin that makes digital robust.
  • Boolean algebra — the mathematics of two-state (true/false) logic values, in which AND acts like multiplication, OR like addition, and NOT is complement; it describes and simplifies the behavior of logic circuits.
  • De Morgan's theorem — the Boolean rule that NOT(A AND B) equals (NOT A) OR (NOT B), and NOT(A OR B) equals (NOT A) AND (NOT B); to invert an AND or OR, swap the operation and invert each input.

Suggested Next Sections

Must read next:

  • Flip-Flops and Sequential Logic — gates that remember: adding memory to logic so a circuit's output depends on its past as well as its present, the basis of counters, registers, and state machines.

Recommended: