Logic gates are fundamental building blocks of digital circuits. They perform basic logical operations on binary inputs (0 or 1) to produce binary outputs. The most common types of logic gates are:
1. AND gate: Outputs 1 only if all inputs are 1.
2. OR gate: Outputs 1 if at least one input is 1.
3. NOT gate: Inverts the input (0 becomes 1, 1 becomes 0).
4. NAND gate: Opposite of AND; outputs 0 only if all inputs are 1.
5. NOR gate: Opposite of OR; outputs 0 if at least one input is 1.
6. XOR gate: Outputs 1 if inputs are different, 0 if they're the same.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 400">
<rect x="0" y="0" width="600" height="400" fill="#f0f0f0"/>
<!-- AND Gate -->
<path d="M50,50 L90,50 Q110,50 110,70 L110,90 Q110,110 90,110 L50,110 Z" fill="#ff9999" stroke="black"/>
<text x="80" y="85" font-family="Arial" font-size="14" text-anchor="middle">AND</text>
<line x1="30" y1="60" x2="50" y2="60" stroke="black"/>
<line x1="30" y1="100" x2="50" y2="100" stroke="black"/>
<line x1="110" y1="80" x2="130" y2="80" stroke="black"/>
<!-- OR Gate -->
<path d="M50,150 Q90,150 110,170 L110,190 Q90,210 50,210 Q70,180 50,150 Z" fill="#99ff99" stroke="black"/>
<text x="80" y="185" font-family="Arial" font-size="14" text-anchor="middle">OR</text>
<line x1="30" y1="160" x2="55" y2="160" stroke="black"/>
<line x1="30" y1="200" x2="55" y2="200" stroke="black"/>
<line x1="110" y1="180" x2="130" y2="180" stroke="black"/>
<!-- NOT Gate -->
<path d="M250,50 L290,80 L250,110 Z" fill="#9999ff" stroke="black"/>
<circle cx="295" cy="80" r="5" fill="none" stroke="black"/>
<text x="270" y="85" font-family="Arial" font-size="14" text-anchor="middle">NOT</text>
<line x1="230" y1="80" x2="250" y2="80" stroke="black"/>
<line x1="300" y1="80" x2="320" y2="80" stroke="black"/>
<!-- NAND Gate -->
<path d="M250,150 L290,150 Q310,150 310,170 L310,190 Q310,210 290,210 L250,210 Z" fill="#ffff99" stroke="black"/>
<circle cx="315" cy="180" r="5" fill="none" stroke="black"/>
<text x="280" y="185" font-family="Arial" font-size="14" text-anchor="middle">NAND</text>
<line x1="230" y1="160" x2="250" y2="160" stroke="black"/>
<line x1="230" y1="200" x2="250" y2="200" stroke="black"/>
<line x1="320" y1="180" x2="340" y2="180" stroke="black"/>
<!-- NOR Gate -->
<path d="M450,50 Q490,50 510,70 L510,90 Q490,110 450,110 Q470,80 450,50 Z" fill="#ff99ff" stroke="black"/>
<circle cx="515" cy="80" r="5" fill="none" stroke="black"/>
<text x="480" y="85" font-family="Arial" font-size="14" text-anchor="middle">NOR</text>
<line x1="430" y1="60" x2="455" y2="60" stroke="black"/>
<line x1="430" y1="100" x2="455" y2="100" stroke="black"/>
<line x1="520" y1="80" x2="540" y2="80" stroke="black"/>
<!-- XOR Gate -->
<path d="M450,150 Q470,150 490,170 L490,190 Q470,210 450,210 Q470,180 450,150 Z" fill="#99ffff" stroke="black"/>
<path d="M440,150 Q460,180 440,210" fill="none" stroke="black"/>
<text x="470" y="185" font-family="Arial" font-size="14" text-anchor="middle">XOR</text>
<line x1="430" y1="160" x2="450" y2="160" stroke="black"/>
<line x1="430" y1="200" x2="450" y2="200" stroke="black"/>
<line x1="490" y1="180" x2="510" y2="180" stroke="black"/>
</svg>