Skip to main content

Discrete Math with SageMath: Learn math with open-source software

Section 11.1 Basic Logic GatesNOT GateDerived Gates

Logic gates are the foundation of digital circuits. They process binary inputs (0s and 1s) to produce specific outputs, defined by truth tables. The basic logic gates are AND, OR, and NOT which correspond to the logical operators reviewed in previous sections. Other commonly used gates as NAND, NOR, XOR, and XNOR are composites of the basic ones. Each gate has its own symbol and truth table representing outputs for all combinations of inputs. These gates combine to form complex systems such as CPUs and memory circuits.
The AND gate produces a 1 only when both inputs are 1.
Figure 11.1.1. AND Gate
Truth table for the AND gate:
The OR gate produces a 1 if at least one input is 1.
Figure 11.1.2. OR Gate
Truth table for the OR gate:
The NOT gate inverts the input: 1 becomes 0, and 0 becomes 1.
Figure 11.1.3. NOT Gate
Truth table for the NOT gate:
NAND: Produces 0 only when both inputs are 1.
Figure 11.1.4. NAND Gate
NOR: Produces 1 only when both inputs are 0.
Figure 11.1.5. NOR Gate
XOR: Produces 1 when inputs differ.
Figure 11.1.6. XOR Gate
XNOR: Produces 1 when inputs are the same.
Figure 11.1.7. XNOR Gate