Skip to content
IRC-CodingIRC-Coding
Álgebra BooleanaLogic GatesTablas de VerdadÁlgebra de ConmutaciónElectrónica Digital

Álgebra Booleana: Logic Gates y Tablas de Verdad

Álgebra Booleana con Logic Gates, tablas de verdad y álgebra de conmutación. AND, OR, NOT, NAND, NOR, XOR con ejemplos prácticos.

S

schutzgeist

17 min read
Álgebra Booleana: Logic Gates y Tablas de Verdad

Álgebra Booleana: Puertas Lógicas, Tablas de Verdad y Álgebra de Conmutación

Este artículo es una introducción completa al Álgebra Booleana, incluyendo puertas lógicas, tablas de verdad y álgebra de conmutación con ejemplos prácticos.

En Resumen

El Álgebra Booleana es la matemática de la lógica con solo dos valores: verdadero (1) y falso (0). Constituye la base de todos los circuitos digitales y computadoras.

Descripción Técnica Concisa

El Álgebra Booleana es un sistema algebraico para describir operaciones lógicas. Fue desarrollada por George Boole y forma la base de la electrónica digital.

Operaciones Fundamentales:

AND (Conjunción)

  • Símbolo: ∧, ·, AND
  • Verdad: Solo verdadero si ambas entradas son verdaderas
  • Circuito: Conexión en serie
  • Aplicación: Funciones de seguridad, validación

OR (Disyunción)

  • Símbolo: ∨, +, OR
  • Verdad: Verdadero si al menos una entrada es verdadera
  • Circuito: Conexión en paralelo
  • Aplicación: Decisiones alternativas

NOT (Negación)

  • Símbolo: ¬, ~, NOT, barra superior
  • Verdad: Invierte el valor de verdad
  • Circuito: Inversor
  • Aplicación: Inversión de señales

NAND (NO-Y)

  • Símbolo: ↑, NAND
  • Verdad: Solo falso si ambas entradas son verdaderas
  • Circuito: AND con inversor
  • Aplicación: Puerta universal

NOR (NO-O)

  • Símbolo: ↓, NOR
  • Verdad: Solo verdadero si ambas entradas son falsas
  • Circuito: OR con inversor
  • Aplicación: Puerta universal

XOR (O Exclusivo)

  • Símbolo: ⊕, XOR
  • Verdad: Verdadero si las entradas son diferentes
  • Circuito: Puerta de paridad
  • Aplicación: Detección de errores, criptografía

Puntos Clave para el Examen

  • Álgebra Booleana: Matemática con dos valores (0 y 1)
  • Puertas Lógicas: Circuitos electrónicos para operaciones lógicas
  • Tablas de Verdad: Representación sistemática de todas las combinaciones de entrada posibles
  • Álgebra de Conmutación: Aplicación del Álgebra Booleana a circuitos
  • Puertas Universales: NAND y NOR pueden reemplazar todas las demás puertas
  • Diagrama de Karnaugh: Simplificación de expresiones lógicas
  • Relevancia para IHK: Base de circuitos digitales y programación

Componentes Clave

  1. Variables Booleanas: Solo 0 o 1
  2. Operaciones Lógicas: AND, OR, NOT, NAND, NOR, XOR
  3. Tablas de Verdad: Descripción completa de la función
  4. Álgebra de Conmutación: Leyes y simplificaciones
  5. Puertas Lógicas: Implementación electrónica
  6. Diseño de Circuitos: Circuitos combinacionales y secuenciales
  7. Minimización: Diagramas de Karnaugh, Quine-McCluskey
  8. Aplicaciones: Arquitectura de computadoras, sistemas digitales

Ejemplos Prácticos

1. Puertas Lógicas Fundamentales en Java

public class BoolescheAlgebra {
    
    public static void main(String[] args) {
        // Eingangswerte
        boolean a = true;   // 1
        boolean b = false;  // 0
        
        System.out.println("=== Grundlegende Logik-Operationen ===");
        System.out.println("a = " + a + " (1), b = " + b + " (0)");
        
        // AND (Konjunktion)
        boolean and = a && b;
        System.out.println("a AND b = " + and + " (" + (and ? 1 : 0) + ")");
        
        // OR (Disjunktion)
        boolean or = a || b;
        System.out.println("a OR b = " + or + " (" + (or ? 1 : 0) + ")");
        
        // NOT (Negation)
        boolean notA = !a;
        boolean notB = !b;
        System.out.println("NOT a = " + notA + " (" + (notA ? 1 : 0) + ")");
        System.out.println("NOT b = " + notB + " (" + (notB ? 1 : 0) + ")");
        
        // NAND (Nicht-UND)
        boolean nand = !(a && b);
        System.out.println("a NAND b = " + nand + " (" + (nand ? 1 : 0) + ")");
        
        // NOR (Nicht-ODER)
        boolean nor = !(a || b);
        System.out.println("a NOR b = " + nor + " (" + (nor ? 1 : 0) + ")");
        
        // XOR (Exklusiv-ODER)
        boolean xor = a ^ b;
        System.out.println("a XOR b = " + xor + " (" + (xor ? 1 : 0) + ")");
        
        // Wahrheitstabellen
        wahrheitstabellen();
        
        // Schaltalgebra-Gesetze
        schaltalgebraGesetze();
        
        // Praktische Anwendungen
        praktischeAnwendungen();
    }
    
    private static void wahrheitstabellen() {
        System.out.println("\n=== Wahrheitstabellen ===");
        
        System.out.println("A B | AND | OR | XOR | NAND | NOR");
        System.out.println("---+-----+----+-----+------+----");
        
        for (int a = 0; a <= 1; a++) {
            for (int b = 0; b <= 1; b++) {
                boolean aBool = a == 1;
                boolean bBool = b == 1;
                
                int and = (aBool && bBool) ? 1 : 0;
                int or = (aBool || bBool) ? 1 : 0;
                int xor = (aBool ^ bBool) ? 1 : 0;
                int nand = !(aBool && bBool) ? 1 : 0;
                int nor = !(aBool || bBool) ? 1 : 0;
                
                System.out.printf("%d %d |  %d  | %d  |  %d  |  %d   | %d%n", 
                                a, b, and, or, xor, nand, nor);
            }
        }
    }
    
    private static void schaltalgebraGesetze() {
        System.out.println("\n=== Schaltalgebra-Gesetze ===");
        
        boolean x = true;
        boolean y = false;
        boolean z = true;
        
        // Kommutativgesetze
        System.out.println("Kommutativgesetze:");
        System.out.println("x AND y = y AND x: " + ((x && y) == (y && x)));
        System.out.println("x OR y = y OR x: " + ((x || y) == (y || x)));
        
        // Assoziativgesetze
        System.out.println("\nAssoziativgesetze:");
        System.out.println("(x AND y) AND z = x AND (y AND z): " + 
                          ((x && y) && z == x && (y && z)));
        System.out.println("(x OR y) OR z = x OR (y OR z): " + 
                          ((x || y) || z == x || (y || z)));
        
        // Distributivgesetze
        System.out.println("\nDistributivgesetze:");
        System.out.println("x AND (y OR z) = (x AND y) OR (x AND z): " + 
                          (x && (y || z) == (x && y) || (x && z)));
        System.out.println("x OR (y AND z) = (x OR y) AND (x OR z): " + 
                          (x || (y && z) == (x || y) && (x || z)));
        
        // De Morgansche Gesetze
        System.out.println("\nDe Morgansche Gesetze:");
        System.out.println("NOT (x AND y) = NOT x OR NOT y: " + 
                          (!(x && y) == (!x || !y)));
        System.out.println("NOT (x OR y) = NOT x AND NOT y: " + 
                          (!(x || y) == (!x && !y)));
        
        // Idempotenzgesetze
        System.out.println("\nIdempotenzgesetze:");
        System.out.println("x AND x = x: " + (x && x == x));
        System.out.println("x OR x = x: " + (x || x == x));
        
        // Nullgesetze
        System.out.println("\nNullgesetze:");
        System.out.println("x AND 0 = 0: " + (x && false == false));
        System.out.println("x OR 1 = 1: " + (x || true == true));
        
        // Einsgesetze
        System.out.println("\nEinsgesetze:");
        System.out.println("x AND 1 = x: " + (x && true == x));
        System.out.println("x OR 0 = x: " + (x || false == x));
        
        // Komplementärgesetze
        System.out.println("\nKomplementärgesetze:");
        System.out.println("x AND NOT x = 0: " + (x && !x == false));
        System.out.println("x OR NOT x = 1: " + (x || !x == true));
        System.out.println("NOT (NOT x) = x: " + (!(!x) == x));
    }
    
    private static void praktischeAnwendungen() {
        System.out.println("\n=== Praktische Anwendungen ===");
        
        // Sicherheitssystem: Mehrere Bedingungen müssen erfüllt sein
        boolean passwortKorrekt = true;
        boolean biometrieErfolgreich = true;
        boolean zugriffErlaubt = passwortKorrekt && biometrieErfolgreich;
        System.out.println("Zugriff erlaubt (AND): " + zugriffErlaubt);
        
        // Notausgang: Mindestens eine Bedingung muss erfüllt sein
        boolean feuerMeldung = false;
        boolean notausGedrueckt = true;
        boolean alarmAktiv = feuerMeldung || notausGedrueckt;
        System.out.println("Alarm aktiv (OR): " + alarmAktiv);
        
        // Paritätsprüfung: XOR für Fehlererkennung
        int daten = 0b1011001;  // 7 Bit
        int paritaetsbit = 0;
        for (int i = 0; i < 7; i++) {
            paritaetsbit ^= (daten >> i) & 1;  // XOR für Parität
        }
        System.out.println("Paritätsbit: " + paritaetsbit + " (gerade Parität)");
        
        // Multiplexer-Auswahl
        int auswahl = 2;  // 0, 1, 2, oder 3
        boolean auswahl0 = (auswahl & 1) == 0 && (auswahl & 2) == 0;
        boolean auswahl1 = (auswahl & 1) == 1 && (auswahl & 2) == 0;
        boolean auswahl2 = (auswahl & 1) == 0 && (auswahl & 2) == 2;
        boolean auswahl3 = (auswahl & 1) == 1 && (auswahl & 2) == 2;
        
        System.out.println("Multiplexer-Auswahl " + auswahl + ":");
        System.out.println("  Ausgang 0: " + auswahl0);
        System.out.println("  Ausgang 1: " + auswahl1);
        System.out.println("  Ausgang 2: " + auswahl2);
        System.out.println("  Ausgang 3: " + auswahl3);
    }
}

2. Puertas lógicas como circuitos (Python)

class LogicGates:
    """Implementación de puertas lógicas"""
    
    @staticmethod
    def and_gate(a, b):
        """Puerta AND"""
        return a and b
    
    @staticmethod
    def or_gate(a, b):
        """Puerta OR"""
        return a or b
    
    @staticmethod
    def not_gate(a):
        """Puerta NOT (Inversor)"""
        return not a
    
    @staticmethod
    def nand_gate(a, b):
        """Puerta NAND"""
        return not (a and b)
    
    @staticmethod
    def nor_gate(a, b):
        """Puerta NOR"""
        return not (a or b)
    
    @staticmethod
    def xor_gate(a, b):
        """Puerta XOR"""
        return a != b
    
    @staticmethod
    def xnor_gate(a, b):
        """Puerta XNOR (Equivalencia)"""
        return a == b

class CircuitDesign:
    """Diseño de circuitos digitales"""
    
    @staticmethod
    def half_adder(a, b):
        """Semisumador: suma y acarreo"""
        sum_output = LogicGates.xor_gate(a, b)
        carry = LogicGates.and_gate(a, b)
        return sum_output, carry
    
    @staticmethod
    def full_adder(a, b, c_in):
        """Sumador completo: con acarreo de entrada"""
        # Primer semisumador
        sum1, carry1 = CircuitDesign.half_adder(a, b)
        
        # Segundo semisumador
        sum2, carry2 = CircuitDesign.half_adder(sum1, c_in)
        
        # Acarreo final
        carry_out = LogicGates.or_gate(carry1, carry2)
        
        return sum2, carry_out
    
    @staticmethod
    def multiplexer(a, b, s):
        """Multiplexor de 2 a 1"""
        # Si s=0, salida=a; si s=1, salida=b
        not_s = LogicGates.not_gate(s)
        output_a = LogicGates.and_gate(a, not_s)
        output_b = LogicGates.and_gate(b, s)
        return LogicGates.or_gate(output_a, output_b)
    
    @staticmethod
    def demultiplexer(d, s):
        """Demultiplexor de 1 a 2"""
        # Si s=0, y0=d, y1=0; si s=1, y0=0, y1=d
        not_s = LogicGates.not_gate(s)
        y0 = LogicGates.and_gate(d, not_s)
        y1 = LogicGates.and_gate(d, s)
        return y0, y1
    
    @staticmethod
    def rs_flipflop(r, s, q_prev):
        """Flip-flop RS (asincrónico)"""
        # Q_nuevo = (S OR (NOT R AND Q_anterior))
        not_r = LogicGates.not_gate(r)
        temp = LogicGates.and_gate(not_r, q_prev)
        q_new = LogicGates.or_gate(s, temp)
        q_bar_new = LogicGates.not_gate(q_new)
        return q_new, q_bar_new

def print_truth_table(gate_name, gate_function):
    """Imprime la tabla de verdad para una puerta"""
    print(f"\n=== {gate_name} ===")
    print("A B | Salida")
    print("---+--------")
    
    for a in [False, True]:
        for b in [False, True]:
            result = gate_function(a, b)
            print(f"{int(a)} {int(b)} |   {int(result)}")

def main():
    """Programa principal con demostraciones"""
    
    # Tablas de verdad
    print_truth_table("AND", LogicGates.and_gate)
    print_truth_table("OR", LogicGates.or_gate)
    print_truth_table("NAND", LogicGates.nand_gate)
    print_truth_table("NOR", LogicGates.nor_gate)
    print_truth_table("XOR", LogicGates.xor_gate)
    print_truth_table("XNOR", LogicGates.xnor_gate)
    
    # Demostraciones de diseño de circuitos
    print("\n=== Semisumador ===")
    for a in [False, True]:
        for b in [False, True]:
            sum_output, carry = CircuitDesign.half_adder(a, b)
            print(f"{int(a)} + {int(b)} = Suma: {int(sum_output)}, Acarreo: {int(carry)}")
    
    print("\n=== Sumador completo ===")
    for a in [False, True]:
        for b in [False, True]:
            for c_in in [False, True]:
                sum_output, carry = CircuitDesign.full_adder(a, b, c_in)
                print(f"{int(c_in)}{int(a)} + {int(b)} = Suma: {int(sum_output)}, Acarreo: {int(carry)}")
    
    print("\n=== Multiplexor ===")
    for s in [False, True]:
        output = CircuitDesign.multiplexer(True, False, s)
        print(f"Select {int(s)}: Salida = {int(output)}")
    
    print("\n=== Flip-flop RS ===")
    q_prev = False
    print(f"Q_anterior = {int(q_prev)}")
    
    # Establecer
    q_new, q_bar_new = CircuitDesign.rs_flipflop(False, True, q_prev)
    print(f"S=1, R=0: Q={int(q_new)}, Q_bar={int(q_bar_new)}")
    
    # Mantener
    q_new, q_bar_new = CircuitDesign.rs_flipflop(False, False, q_new)
    print(f"S=0, R=0: Q={int(q_new)}, Q_bar={int(q_bar_new)}")
    
    # Restablecer
    q_new, q_bar_new = CircuitDesign.rs_flipflop(True, False, q_new)
    print(f"S=0, R=1: Q={int(q_new)}, Q_bar={int(q_bar_new)}")

if __name__ == "__main__":
    main()

3. Álgebra booleana con operaciones de bits (C++)

#include <iostream>
#include <bitset>
#include <string>

class BooleanAlgebraCPP {
public:
    // Operaciones de bits para puertas lógicas
    static bool and_gate(bool a, bool b) {
        return a & b;
    }
    
    static bool or_gate(bool a, bool b) {
        return a | b;
    }
    
    static bool not_gate(bool a) {
        return !a;
    }
    
    static bool nand_gate(bool a, bool b) {
        return !(a & b);
    }
    
    static bool nor_gate(bool a, bool b) {
        return !(a | b);
    }
    
    static bool xor_gate(bool a, bool b) {
        return a ^ b;
    }
    
    // Funciones booleanas con múltiples entradas
    static bool and_n(bool inputs[], int n) {
        bool result = true;
        for (int i = 0; i < n; i++) {
            result &= inputs[i];
        }
        return result;
    }
    
    static bool or_n(bool inputs[], int n) {
        bool result = false;
        for (int i = 0; i < n; i++) {
            result |= inputs[i];
        }
        return result;
    }
    
    // Verificación de paridad
    static bool even_parity(unsigned int value) {
        bool parity = false;
        while (value > 0) {
            parity ^= (value & 1);
            value >>= 1;
        }
        return !parity;  // Paridad par
    }
    
    // Conversión a código Gray
    static unsigned int decimal_to_gray(unsigned int decimal) {
        return decimal ^ (decimal >> 1);
    }
    
    static unsigned int gray_to_decimal(unsigned int gray) {
        unsigned int decimal = 0;
        while (gray > 0) {
            decimal ^= gray;
            gray >>= 1;
        }
        return decimal;
    }
    
    // Ayuda para diagrama de Karnaugh
    static void print_karnaugh_diagram() {
        std::cout << "\n=== Diagrama de Karnaugh (2 variables) ===\n";
        std::cout << "  AB\\CD  00  01  11  10\n";
        std::cout << "  -----------------------\n";
        
        // Función de ejemplo: F = A'B + AB'
        for (int a = 0; a <= 1; a++) {
            for (int b = 0; b <= 1; b++) {
                std::string ab = std::to_string(a) + std::to_string(b);
                std::cout << "    " << ab << "   ";
                
                for (int c = 0; c <= 1; c++) {
                    for (int d = 0; d <= 1; d++) {
                        // F = A'B + AB'
                        bool f = (!a && b) || (a && !b);
                        std::cout << " " << f << "  ";
                    }
                }
                std::cout << "\n";
                break;  // Solo una fila para 2 variables
            }
        }
    }
};

int main() {
    std::cout << "=== Álgebra booleana en C++ ===\n";
    
    // Operaciones básicas
    bool a = true;
    bool b = false;
    
    std::cout << "a = " << a << ", b = " << b << "\n";
    std::cout << "a AND b = " << BooleanAlgebraCPP::and_gate(a, b) << "\n";
    std::cout << "a OR b = " << BooleanAlgebraCPP::or_gate(a, b) << "\n";
    std::cout << "NOT a = " << BooleanAlgebraCPP::not_gate(a) << "\n";
    std::cout << "a XOR b = " << BooleanAlgebraCPP::xor_gate(a, b) << "\n";
    
    // Múltiples entradas
    std::cout << "\n=== Múltiples entradas ===\n";
    bool inputs[4] = {true, false, true, false};
    std::cout << "AND de todas las entradas: " << BooleanAlgebraCPP::and_n(inputs, 4) << "\n";
    std::cout << "OR de todas las entradas: " << BooleanAlgebraCPP::or_n(inputs, 4) << "\n";
    
    // Verificación de paridad
    std::cout << "\n=== Verificación de paridad ===\n";
    unsigned int values[] = {0b1011001, 0b1101101, 0b1110000};
    for (unsigned int value : values) {
        std::cout << "Valor: " << std::bitset<7>(value) 
                  << ", paridad par: " << BooleanAlgebraCPP::even_parity(value) << "\n";
    }
    
    // Código Gray
    std::cout << "\n=== Conversión a código Gray ===\n";
    for (unsigned int i = 0; i < 8; i++) {
        unsigned int gray = BooleanAlgebraCPP::decimal_to_gray(i);
        unsigned int back = BooleanAlgebraCPP::gray_to_decimal(gray);
        std::cout << i << " -> " << std::bitset<3>(gray) 
                  << " -> " << back << "\n";
    }
    
    // Manipulación de bits
    std::cout << "\n=== Manipulación de bits ===\n";
    unsigned int register_value = 0b10101010;
    
    std::cout << "Original: " << std::bitset<8>(register_value) << "\n";
    
    // Establecer bit
    unsigned int bit_set = register_value | (1 << 3);
    std::cout << "Establecer bit 3: " << std::bitset<8>(bit_set) << "\n";
    
    // Limpiar bit
    unsigned int bit_cleared = register_value & ~(1 << 5);
    std::cout << "Limpiar bit 5: " << std::bitset<8>(bit_cleared) << "\n";
    
    // Alternar bit
    unsigned int bit_toggled = register_value ^ (1 << 1);
    std::cout << "Alternar bit 1: " << std::bitset<8>(bit_toggled) << "\n";
    
    // Verificar bit
    bool bit_4_set = (register_value & (1 << 4)) != 0;
    std::cout << "Bit 4 establecido: " << bit_4_set << "\n";
    
    // Diagrama de Karnaugh
    BooleanAlgebraCPP::print_karnaugh_diagram();
    
    return 0;
}

4. Álgebra de Boole y simplificación

public class Schaltalgebra {
    
    // Boolesche Ausdrücke als Methoden
    public static boolean ausdruck1(boolean a, boolean b, boolean c) {
        // Original: (A AND B) OR (A AND C)
        return (a && b) || (a && c);
    }
    
    public static boolean ausdruck1Vereinfacht(boolean a, boolean b, boolean c) {
        // Vereinfacht: A AND (B OR C)  (Distributivgesetz)
        return a && (b || c);
    }
    
    public static boolean ausdruck2(boolean a, boolean b, boolean c) {
        // Original: (A OR B) AND (A OR C) AND (NOT B OR C)
        return (a || b) && (a || c) && (!b || c);
    }
    
    public static boolean ausdruck2Vereinfacht(boolean a, boolean b, boolean c) {
        // Vereinfacht: A AND (NOT B OR C) OR (B AND C)
        return (a && (!b || c)) || (b && c);
    }
    
    public static boolean ausdruck3(boolean a, boolean b) {
        // Original: (A AND NOT B) OR (NOT A AND B)
        return (a && !b) || (!a && b);
    }
    
    public static boolean ausdruck3Vereinfacht(boolean a, boolean b) {
        // Vereinfacht: A XOR B
        return a ^ b;
    }
    
    // Wahrheitstabellen für Vergleich
    public static void vergleicheAusdruecke() {
        System.out.println("=== Ausdrucksvergleiche ===");
        System.out.println("A B C | Orig1 | Simp1 | Orig2 | Simp2 | Orig3 | Simp3");
        System.out.println("-------+-------+-------+-------+-------+-------+-------");
        
        for (boolean a : new boolean[]{false, true}) {
            for (boolean b : new boolean[]{false, true}) {
                for (boolean c : new boolean[]{false, true}) {
                    boolean orig1 = ausdruck1(a, b, c);
                    boolean simp1 = ausdruck1Vereinfacht(a, b, c);
                    boolean orig2 = ausdruck2(a, b, c);
                    boolean simp2 = ausdruck2Vereinfacht(a, b, c);
                    boolean orig3 = ausdruck3(a, b);
                    boolean simp3 = ausdruck3Vereinfacht(a, b);
                    
                    System.out.printf("%d %d %d |  %d    |  %d    |  %d    |  %d    |  %d    |  %d%n",
                                    a?1:0, b?1:0, c?1:0,
                                    orig1?1:0, simp1?1:0,
                                    orig2?1:0, simp2?1:0,
                                    orig3?1:0, simp3?1:0);
                }
            }
        }
    }
    
    // NAND-NOR Implementierung (universelle Gatter)
    public static boolean andMitNand(boolean a, boolean b) {
        // AND = NOT(NAND(A,B))
        return !(!(a && b));
    }
    
    public static boolean orMitNand(boolean a, boolean b) {
        // OR = NOT(NAND(NOT(A), NOT(B)))
        return !(!a && !b);
    }
    
    public static boolean notMitNand(boolean a) {
        // NOT = NAND(A,A)
        return !(a && a);
    }
    
    public static boolean xorMitNand(boolean a, boolean b) {
        // XOR = NAND(NAND(A,NAND(A,B)), NAND(B,NAND(A,B)))
        boolean nand_ab = !(a && b);
        boolean nand_a_nandab = !(a && nand_ab);
        boolean nand_b_nandab = !(b && nand_ab);
        return !(nand_a_nandab && nand_b_nandab);
    }
    
    // NOR Implementierung
    public static boolean andMitNor(boolean a, boolean b) {
        // AND = NOR(NOR(A,A), NOR(B,B))
        return !(!a || !b);
    }
    
    public static boolean orMitNor(boolean a, boolean b) {
        // OR = NOT(NOR(A,B))
        return !(a || b);
    }
    
    public static boolean notMitNor(boolean a) {
        // NOT = NOR(A,A)
        return !(a || a);
    }
    
    public static void universaleGatterDemo() {
        System.out.println("\n=== Universale Gatter Demonstration ===");
        
        boolean a = true;
        boolean b = false;
        
        System.out.println("a = " + a + ", b = " + b);
        
        // NAND-Implementierungen
        System.out.println("\nNAND-Implementierungen:");
        System.out.println("AND mit NAND: " + andMitNand(a, b));
        System.out.println("OR mit NAND: " + orMitNand(a, b));
        System.out.println("NOT mit NAND: " + notMitNand(a));
        System.out.println("XOR mit NAND: " + xorMitNand(a, b));
        
        // NOR-Implementierungen
        System.out.println("\nNOR-Implementierungen:");
        System.out.println("AND mit NOR: " + andMitNor(a, b));
        System.out.println("OR mit NOR: " + orMitNor(a, b));
        System.out.println("NOT mit NOR: " + notMitNor(a));
    }
    
    public static void main(String[] args) {
        vergleicheAusdruecke();
        universaleGatterDemo();
        
        // Komplexere Schaltung: 4-zu-1 Multiplexer
        multiplexerDemo();
    }
    
    private static void multiplexerDemo() {
        System.out.println("\n=== 4-zu-1 Multiplexer ===");
        
        boolean d0 = true, d1 = false, d2 = true, d3 = false;
        boolean s0 = true, s1 = false;  // Select-Leitungen
        
        // Multiplexer-Logik
        boolean y = (d0 && !s0 && !s1) || 
                   (d1 && s0 && !s1) || 
                   (d2 && !s0 && s1) || 
                   (d3 && s0 && s1);
        
        System.out.println("Daten: D0=" + d0 + ", D1=" + d1 + ", D2=" + d2 + ", D3=" + d3);
        System.out.println("Select: S0=" + s0 + ", S1=" + s1);
        System.out.println("Ausgang Y: " + y);
    }
}

Tablas de verdad de compuertas lógicas

Compuertas básicas (2 entradas)

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

Compuerta NOT (1 entrada)

ANOT
01
10

Leyes del álgebra de Boole

Leyes conmutativas

A ∧ B = B ∧ A
A ∨ B = B ∨ A

Leyes asociativas

(A ∧ B) ∧ C = A ∧ (B ∧ C)
(A ∨ B) ∨ C = A ∨ (B ∨ C)

Leyes distributivas

A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)

Leyes de De Morgan

¬(A ∧ B) = ¬A ∨ ¬B
¬(A ∨ B) = ¬A ∧ ¬B

Leyes de idempotencia

A ∧ A = A
A ∨ A = A

Leyes del elemento nulo y del uno

A ∧ 0 = 0
A ∨ 1 = 1
A ∧ 1 = A
A ∨ 0 = A

Leyes del complemento

A ∧ ¬A = 0
A ∨ ¬A = 1
¬(¬A) = A

Símbolos de compuertas lógicas

Símbolos ANSI/IEEE

  • AND: Compuerta en forma de D
  • OR: Compuerta en forma de arco
  • NOT: Triángulo con círculo
  • NAND: AND con círculo
  • NOR: OR con círculo
  • XOR: OR con línea adicional

Símbolos DIN (Europeos)

  • AND: Rectángulo con &
  • OR: Rectángulo con ≥1
  • NOT: Rectángulo con 1
  • NAND: Rectángulo con &
  • NOR: Rectángulo con ≥1
  • XOR: Rectángulo con =1

Circuitos combinacionales

Sumadores

  • Semisumador: 2 bits → suma + acarreo
  • Sumador completo: 3 bits → suma + acarreo
  • Sumador con acarreo en cascada: Múltiples sumadores completos

Multiplexores y demultiplexores

  • Multiplexor: Selector entre varias entradas
  • Demultiplexor: Distribuidor hacia varias salidas
  • Aplicaciones: Buses de datos, direccionamiento

Codificadores y decodificadores

  • Codificador: Múltiples entradas → código binario
  • Decodificador: Código binario → múltiples salidas
  • Aplicaciones: Teclados, pantallas de 7 segmentos

Ventajas e inconvenientes

Ventajas del álgebra booleana

  • Simplicidad: Solo dos estados
  • Confiabilidad: Circuitos digitales robustos
  • Simplificación: La lógica compleja puede minimizarse
  • Automatización: Ideal para diseño de computadoras

Inconvenientes

  • Abstracción: No intuitiva para problemas complejos
  • Limitación: Solo lógica binaria
  • Complejidad: Los circuitos grandes se vuelven confusos

Preguntas típicas de examen

  1. Crea la tabla de verdad para XOR XOR es verdadero cuando las entradas son distintas.

  2. ¿Qué establecen las leyes de De Morgan? ¬(A ∧ B) = ¬A ∨ ¬B y ¬(A ∨ B) = ¬A ∧ ¬B

  3. ¿Por qué NAND y NOR son puertas universales? Todas las demás funciones lógicas pueden realizarse solo con NAND o NOR.

  4. ¿Cuál es la diferencia entre un semisumador y un sumador completo? El semisumador tiene 2 entradas, el sumador completo tiene 3 entradas (incluido el acarreo).

Fuentes principales

  1. https://de.wikipedia.org/wiki/Boolesche_Algebra
  2. https://de.wikipedia.org/wiki/Logikgatter
  3. https://www.tutorialspoint.com/digital_electronics/
Volver al blog
Share:

Entradas relacionadas