Skip to main content

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

Section 11.1 Logic Gates

Logic gates are the foundation of digital circuits. They process binary inputs to produce specific outputs. The basic logic gates are \(AND\text{,}\) \(OR\text{,}\) and \(NOT\text{.}\) Derived gates include \(NAND\text{,}\) \(NOR\text{,}\) \(XOR\text{,}\) and \(XNOR\text{.}\) Each gate has its own symbol and behavior defined by a truth table.

Subsection 11.1.1 AND Gate

The AND gate produces a 1 only when both inputs are 1.
Figure 11.1.1. AND Gate
Truth table for the AND gate:

Subsection 11.1.2 OR 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:

Subsection 11.1.3 NOT 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:

Subsection 11.1.4 NAND Gate

NAND: Produces 0 only when both inputs are 1.
Figure 11.1.4. NAND Gate

Subsection 11.1.5 NOR Gate

NOR: Produces 1 only when both inputs are 0.
Figure 11.1.5. NOR Gate

Subsection 11.1.6 XOR Gate

XOR: Produces 1 when inputs differ.
Figure 11.1.6. XOR Gate

Subsection 11.1.7 XNOR Gate

XNOR: Produces 1 when inputs are the same.
Figure 11.1.7. XNOR Gate