Skip to content
LAM
Read Home Blog
Make Projects HTML Tools Games
Touch grass Notes Resume Links
Home Blog HTML Projects
Tools Games Notes Resume Links
Back EEE 120 Final Exam - Ultimate Cheat Sheet Electronics
Download Open
Show description 2,401 chars · Electronics

EEE 120 Final Exam - Ultimate Cheat Sheet

EEE 120 Final Exam - Ultimate Cheat Sheet




🎓 EEE 120 Final Exam Cheat Sheet

Digital Logic Fundamentals - Complete Reference Guide





1. Basic Logic Functions
▼



Truth Tables & Gate Symbols




AND Gate


A
B
OUT


0
0
0


0
1
0


1
0
0


1
1
1



OUT = A · B





OR Gate


A
B
OUT


0
0
0


0
1
1


1
0
1


1
1
1



OUT = A + B





NOT Gate


A
OUT


0
1


1
0



OUT = A'





NAND Gate


A
B
OUT


0
0
1


0
1
1


1
0
1


1
1
0



OUT = (A · B)'





NOR Gate


A
B
OUT


0
0
1


0
1
0


1
0
0


1
1
0



OUT = (A + B)'





XOR Gate


A
B
OUT


0
0
0


0
1
1


1
0
1


1
1
0



OUT = A ⊕ B = A'B + AB'






DeMorgan's Laws



First Law: (A · B)' = A' + B'
NAND can be drawn as OR with inverted inputs



Second Law: (A + B)' = A' · B'
NOR can be drawn as AND with inverted inputs






💡 Key Concept: NAND and NOR gates are universal - you can build ANY logic function using only NAND gates or only NOR gates!










2. Boolean Functions & Minimization
▼



Representation Forms




Sum of Products (SOP)

OR of AND terms

F = A'B'C + AB'C + ABC

Each product term is a minterm





Product of Sums (POS)

AND of OR terms

F = (A+B+C)(A+B'+C)(A'+B+C')

Each sum term is a maxterm





Sum of Minterms

F = Σm(1, 3, 5, 7)

List row numbers where output = 1





Product of Maxterms

F = ΠM(0, 2, 4, 6)

List row numbers where output = 0






Boolean Algebra Laws


Identity: A + 0 = A, A · 1 = A
Null: A + 1 = 1, A · 0 = 0
Idempotent: A + A = A, A · A = A
Complement: A + A' = 1, A · A' = 0
Involution: (A')' = A
Commutative: A + B = B + A, A · B = B · A
Associative: (A + B) + C = A + (B + C)
Distributive: A(B + C) = AB + AC, A + BC = (A + B)(A + C)
Absorption: A + AB = A, A(A + B) = A
DeMorgan: (A + B)' = A'B', (AB)' = A' + B'



Interactive K-Map Tool (4-variable)


Click cells to toggle (1/0) - K-Map for 4 variables





00

01

11

10




00

0

0

0

0




01

0

0

0

0




11

0

0

0

0




10

0

0

0

0





K-Map Tips:
• Group 1s in powers of 2 (1, 2, 4, 8, 16)
• Groups can wrap around edges
• Groups can overlap
• Minimize number of groups
• Each group becomes one product term





Universal Gate Implementation


Using ONLY NAND gates:
• NOT: Connec…

EEE 120 Final Exam - Ultimate Cheat Sheet

74,126 bytes · HTML source
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EEE 120 Final Exam - Ultimate Cheat Sheet</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
            color: #e0e0e0;
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            background: rgba(20, 20, 30, 0.95);
            border-radius: 15px;
            padding: 40px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
        }

        h1 {
            text-align: center;
            color: #00d4ff;
            font-size: 2.5em;
            margin-bottom: 10px;
            text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
        }

        .subtitle {
            text-align: center;
            color: #888;
            margin-bottom: 40px;
            font-size: 1.1em;
        }

        .section {
            margin-bottom: 30px;
            background: rgba(30, 30, 45, 0.8);
            border-radius: 10px;
            padding: 25px;
            border-left: 4px solid #00d4ff;
        }

        .section h2 {
            color: #00d4ff;
            margin-bottom: 20px;
            font-size: 1.8em;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .section h3 {
            color: #4db8ff;
            margin: 20px 0 15px 0;
            font-size: 1.3em;
        }

        .toggle-icon {
            transition: transform 0.3s ease;
            font-size: 0.8em;
        }

        .toggle-icon.collapsed {
            transform: rotate(-90deg);
        }

        .section-content {
            max-height: 10000px;
            overflow: hidden;
            transition: max-height 0.3s ease;
        }

        .section-content.collapsed {
            max-height: 0;
        }

        .truth-table {
            display: inline-block;
            margin: 15px 20px 15px 0;
            border-collapse: collapse;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 8px;
            overflow: hidden;
        }

        .truth-table th {
            background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
            color: #000;
            padding: 10px 15px;
            font-weight: bold;
        }

        .truth-table td {
            padding: 8px 15px;
            text-align: center;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .truth-table tr:nth-child(even) {
            background: rgba(255, 255, 255, 0.05);
        }

        .gate-symbol {
            display: inline-block;
            margin: 10px 15px;
            text-align: center;
        }

        .gate-symbol svg {
            width: 100px;
            height: 60px;
        }

        .gate-label {
            display: block;
            margin-top: 5px;
            color: #00d4ff;
            font-weight: bold;
        }

        .formula {
            background: rgba(0, 212, 255, 0.1);
            padding: 15px;
            border-radius: 8px;
            margin: 15px 0;
            border-left: 3px solid #00d4ff;
            font-family: 'Courier New', monospace;
            font-size: 1.1em;
        }

        .kmap {
            display: inline-block;
            margin: 20px;
            border-collapse: collapse;
        }

        .kmap td {
            width: 60px;
            height: 60px;
            border: 2px solid #00d4ff;
            text-align: center;
            vertical-align: middle;
            background: rgba(0, 0, 0, 0.3);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .kmap td:hover {
            background: rgba(0, 212, 255, 0.2);
            transform: scale(1.05);
        }

        .kmap td.selected {
            background: rgba(0, 212, 255, 0.4);
            font-weight: bold;
        }

        .kmap th {
            padding: 10px;
            color: #00d4ff;
            font-weight: bold;
        }

        .interactive-tool {
            background: rgba(0, 0, 0, 0.4);
            padding: 20px;
            border-radius: 10px;
            margin: 20px 0;
            border: 2px solid #00d4ff;
        }

        .tool-title {
            color: #00d4ff;
            font-size: 1.2em;
            margin-bottom: 15px;
            font-weight: bold;
        }

        input[type="text"], input[type="number"], select {
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid #00d4ff;
            color: #e0e0e0;
            padding: 10px;
            border-radius: 5px;
            margin: 5px;
            font-size: 1em;
        }

        button {
            background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
            color: #000;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            cursor: pointer;
            font-weight: bold;
            margin: 5px;
            transition: all 0.3s ease;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 212, 255, 0.4);
        }

        .output {
            background: rgba(0, 212, 255, 0.1);
            padding: 15px;
            border-radius: 5px;
            margin-top: 10px;
            min-height: 40px;
            font-family: 'Courier New', monospace;
        }

        .grid-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }

        .card {
            background: rgba(0, 0, 0, 0.3);
            padding: 20px;
            border-radius: 10px;
            border: 1px solid rgba(0, 212, 255, 0.3);
            transition: all 0.3s ease;
        }

        .card:hover {
            border-color: #00d4ff;
            box-shadow: 0 5px 20px rgba(0, 212, 255, 0.2);
            transform: translateY(-3px);
        }

        .card h4 {
            color: #00d4ff;
            margin-bottom: 10px;
        }

        .highlight {
            color: #00ff88;
            font-weight: bold;
        }

        .warning {
            color: #ff6b6b;
            font-weight: bold;
        }

        .note {
            background: rgba(255, 193, 7, 0.1);
            border-left: 3px solid #ffc107;
            padding: 15px;
            margin: 15px 0;
            border-radius: 5px;
        }

        .glossary-term {
            background: rgba(0, 212, 255, 0.1);
            padding: 15px;
            margin: 10px 0;
            border-radius: 8px;
            border-left: 3px solid #00d4ff;
        }

        .glossary-term strong {
            color: #00d4ff;
            font-size: 1.1em;
        }

        ul, ol {
            margin-left: 20px;
            margin-top: 10px;
        }

        li {
            margin: 8px 0;
        }

        .flip-flop-diagram {
            background: rgba(0, 0, 0, 0.3);
            padding: 20px;
            border-radius: 10px;
            margin: 15px 0;
            text-align: center;
        }

        .timing-diagram {
            width: 100%;
            height: 200px;
            background: rgba(0, 0, 0, 0.4);
            border: 2px solid #00d4ff;
            border-radius: 8px;
            margin: 15px 0;
        }

        @media (max-width: 768px) {
            .container {
                padding: 20px;
            }
            
            h1 {
                font-size: 1.8em;
            }
            
            .grid-container {
                grid-template-columns: 1fr;
            }
        }

        .quick-ref {
            background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(0, 153, 204, 0.1) 100%);
            padding: 15px;
            border-radius: 8px;
            margin: 10px 0;
            border: 2px solid #00d4ff;
        }

        code {
            background: rgba(0, 0, 0, 0.5);
            padding: 2px 6px;
            border-radius: 3px;
            color: #00ff88;
            font-family: 'Courier New', monospace;
        }

        .fsm-table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }

        .fsm-table th, .fsm-table td {
            border: 1px solid rgba(0, 212, 255, 0.3);
            padding: 10px;
            text-align: center;
        }

        .fsm-table th {
            background: rgba(0, 212, 255, 0.2);
            color: #00d4ff;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎓 EEE 120 Final Exam Cheat Sheet</h1>
        <p class="subtitle">Digital Logic Fundamentals - Complete Reference Guide</p>

        <!-- SECTION 1: BASIC LOGIC FUNCTIONS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                1. Basic Logic Functions
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Truth Tables & Gate Symbols</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>AND Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>OUT</th></tr>
                            <tr><td>0</td><td>0</td><td>0</td></tr>
                            <tr><td>0</td><td>1</td><td>0</td></tr>
                            <tr><td>1</td><td>0</td><td>0</td></tr>
                            <tr><td>1</td><td>1</td><td>1</td></tr>
                        </table>
                        <div class="formula">OUT = A · B</div>
                    </div>

                    <div class="card">
                        <h4>OR Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>OUT</th></tr>
                            <tr><td>0</td><td>0</td><td>0</td></tr>
                            <tr><td>0</td><td>1</td><td>1</td></tr>
                            <tr><td>1</td><td>0</td><td>1</td></tr>
                            <tr><td>1</td><td>1</td><td>1</td></tr>
                        </table>
                        <div class="formula">OUT = A + B</div>
                    </div>

                    <div class="card">
                        <h4>NOT Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>OUT</th></tr>
                            <tr><td>0</td><td>1</td></tr>
                            <tr><td>1</td><td>0</td></tr>
                        </table>
                        <div class="formula">OUT = A'</div>
                    </div>

                    <div class="card">
                        <h4>NAND Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>OUT</th></tr>
                            <tr><td>0</td><td>0</td><td>1</td></tr>
                            <tr><td>0</td><td>1</td><td>1</td></tr>
                            <tr><td>1</td><td>0</td><td>1</td></tr>
                            <tr><td>1</td><td>1</td><td>0</td></tr>
                        </table>
                        <div class="formula">OUT = (A · B)'</div>
                    </div>

                    <div class="card">
                        <h4>NOR Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>OUT</th></tr>
                            <tr><td>0</td><td>0</td><td>1</td></tr>
                            <tr><td>0</td><td>1</td><td>0</td></tr>
                            <tr><td>1</td><td>0</td><td>0</td></tr>
                            <tr><td>1</td><td>1</td><td>0</td></tr>
                        </table>
                        <div class="formula">OUT = (A + B)'</div>
                    </div>

                    <div class="card">
                        <h4>XOR Gate</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>OUT</th></tr>
                            <tr><td>0</td><td>0</td><td>0</td></tr>
                            <tr><td>0</td><td>1</td><td>1</td></tr>
                            <tr><td>1</td><td>0</td><td>1</td></tr>
                            <tr><td>1</td><td>1</td><td>0</td></tr>
                        </table>
                        <div class="formula">OUT = A ⊕ B = A'B + AB'</div>
                    </div>
                </div>

                <h3>DeMorgan's Laws</h3>
                <div class="quick-ref">
                    <div class="formula">
                        <strong>First Law:</strong> (A · B)' = A' + B'<br>
                        <span style="color: #888">NAND can be drawn as OR with inverted inputs</span>
                    </div>
                    <div class="formula">
                        <strong>Second Law:</strong> (A + B)' = A' · B'<br>
                        <span style="color: #888">NOR can be drawn as AND with inverted inputs</span>
                    </div>
                </div>

                <div class="note">
                    <strong>💡 Key Concept:</strong> NAND and NOR gates are universal - you can build ANY logic function using only NAND gates or only NOR gates!
                </div>
            </div>
        </div>

        <!-- SECTION 2: BOOLEAN FUNCTIONS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                2. Boolean Functions & Minimization
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Representation Forms</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Sum of Products (SOP)</h4>
                        <p>OR of AND terms</p>
                        <div class="formula">F = A'B'C + AB'C + ABC</div>
                        <p style="color: #888; margin-top: 10px;">Each product term is a minterm</p>
                    </div>

                    <div class="card">
                        <h4>Product of Sums (POS)</h4>
                        <p>AND of OR terms</p>
                        <div class="formula">F = (A+B+C)(A+B'+C)(A'+B+C')</div>
                        <p style="color: #888; margin-top: 10px;">Each sum term is a maxterm</p>
                    </div>

                    <div class="card">
                        <h4>Sum of Minterms</h4>
                        <div class="formula">F = Σm(1, 3, 5, 7)</div>
                        <p style="color: #888; margin-top: 10px;">List row numbers where output = 1</p>
                    </div>

                    <div class="card">
                        <h4>Product of Maxterms</h4>
                        <div class="formula">F = ΠM(0, 2, 4, 6)</div>
                        <p style="color: #888; margin-top: 10px;">List row numbers where output = 0</p>
                    </div>
                </div>

                <h3>Boolean Algebra Laws</h3>
                <div class="quick-ref">
                    <strong>Identity:</strong> A + 0 = A, A · 1 = A<br>
                    <strong>Null:</strong> A + 1 = 1, A · 0 = 0<br>
                    <strong>Idempotent:</strong> A + A = A, A · A = A<br>
                    <strong>Complement:</strong> A + A' = 1, A · A' = 0<br>
                    <strong>Involution:</strong> (A')' = A<br>
                    <strong>Commutative:</strong> A + B = B + A, A · B = B · A<br>
                    <strong>Associative:</strong> (A + B) + C = A + (B + C)<br>
                    <strong>Distributive:</strong> A(B + C) = AB + AC, A + BC = (A + B)(A + C)<br>
                    <strong>Absorption:</strong> A + AB = A, A(A + B) = A<br>
                    <strong>DeMorgan:</strong> (A + B)' = A'B', (AB)' = A' + B'
                </div>

                <h3>Interactive K-Map Tool (4-variable)</h3>
                <div class="interactive-tool">
                    <div class="tool-title">Click cells to toggle (1/0) - K-Map for 4 variables</div>
                    <table class="kmap">
                        <tr>
                            <th></th>
                            <th>00</th>
                            <th>01</th>
                            <th>11</th>
                            <th>10</th>
                        </tr>
                        <tr>
                            <th>00</th>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                        </tr>
                        <tr>
                            <th>01</th>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                        </tr>
                        <tr>
                            <th>11</th>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                        </tr>
                        <tr>
                            <th>10</th>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                            <td onclick="toggleKmapCell(this)">0</td>
                        </tr>
                    </table>
                    <div style="margin-top: 15px; color: #888;">
                        <strong>K-Map Tips:</strong><br>
                        • Group 1s in powers of 2 (1, 2, 4, 8, 16)<br>
                        • Groups can wrap around edges<br>
                        • Groups can overlap<br>
                        • Minimize number of groups<br>
                        • Each group becomes one product term
                    </div>
                </div>

                <h3>Universal Gate Implementation</h3>
                <div class="note">
                    <strong>Using ONLY NAND gates:</strong><br>
                    • NOT: Connect inputs together: A NAND A = A'<br>
                    • AND: NAND followed by NAND inverter<br>
                    • OR: DeMorgan's law: (A' NAND B') = A + B<br><br>
                    
                    <strong>Using ONLY NOR gates:</strong><br>
                    • NOT: Connect inputs together: A NOR A = A'<br>
                    • OR: NOR followed by NOR inverter<br>
                    • AND: DeMorgan's law: (A' NOR B') = A · B
                </div>
            </div>
        </div>

        <!-- SECTION 3: NUMBER SYSTEMS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                3. Number Systems & Conversions
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Base Conversion Quick Reference</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Binary (Base-2)</h4>
                        <div class="formula">1010₂ = 8 + 2 = 10₁₀</div>
                        <p style="color: #888;">Powers of 2: 8, 4, 2, 1</p>
                    </div>

                    <div class="card">
                        <h4>Octal (Base-8)</h4>
                        <div class="formula">52₈ = 5×8 + 2 = 42₁₀</div>
                        <p style="color: #888;">Group binary in 3s: 101|010</p>
                    </div>

                    <div class="card">
                        <h4>Decimal (Base-10)</h4>
                        <div class="formula">42₁₀ = normal numbers</div>
                        <p style="color: #888;">Standard counting system</p>
                    </div>

                    <div class="card">
                        <h4>Hexadecimal (Base-16)</h4>
                        <div class="formula">2A₁₆ = 2×16 + 10 = 42₁₀</div>
                        <p style="color: #888;">Group binary in 4s: 0010|1010<br>A=10, B=11, C=12, D=13, E=14, F=15</p>
                    </div>
                </div>

                <h3>2's Complement (Signed Numbers)</h3>
                <div class="quick-ref">
                    <strong>2's Complement Representation:</strong><br>
                    • Most significant bit (MSB) is the sign bit<br>
                    • 0 = positive, 1 = negative<br>
                    • Range for n bits: -2^(n-1) to 2^(n-1) - 1<br>
                    • Example (4 bits): -8 to +7<br><br>

                    <strong>2's Complement Operation:</strong><br>
                    1. Invert all bits (1's complement)<br>
                    2. Add 1<br><br>

                    <strong>Example:</strong> 5 in binary = 0101<br>
                    1's complement: 1010<br>
                    Add 1: 1011 = -5 in 2's complement
                </div>

                <div class="note">
                    <strong class="warning">⚠️ Overflow Detection:</strong><br>
                    Overflow occurs when:<br>
                    • Adding two positive numbers gives negative result<br>
                    • Adding two negative numbers gives positive result<br>
                    • XOR of carry into MSB and carry out of MSB = 1<br><br>
                    
                    <strong>NO overflow when:</strong><br>
                    • Adding numbers with different signs<br>
                    • Subtracting numbers with same sign
                </div>

                <h3>Number Converter Tool</h3>
                <div class="interactive-tool">
                    <div class="tool-title">Multi-Base Number Converter</div>
                    <input type="text" id="numInput" placeholder="Enter number">
                    <select id="fromBase">
                        <option value="2">Binary</option>
                        <option value="8">Octal</option>
                        <option value="10" selected>Decimal</option>
                        <option value="16">Hex</option>
                    </select>
                    <button onclick="convertNumber()">Convert</button>
                    <div class="output" id="convOutput">Results will appear here...</div>
                </div>
            </div>
        </div>

        <!-- SECTION 4: HIGHER ORDER LOGIC BLOCKS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                4. Higher Order Logic Blocks
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Adders & Subtractors</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Half Adder</h4>
                        <table class="truth-table">
                            <tr><th>A</th><th>B</th><th>Sum</th><th>Carry</th></tr>
                            <tr><td>0</td><td>0</td><td>0</td><td>0</td></tr>
                            <tr><td>0</td><td>1</td><td>1</td><td>0</td></tr>
                            <tr><td>1</td><td>0</td><td>1</td><td>0</td></tr>
                            <tr><td>1</td><td>1</td><td>0</td><td>1</td></tr>
                        </table>
                        <div class="formula">
                            Sum = A ⊕ B<br>
                            Carry = A · B
                        </div>
                    </div>

                    <div class="card">
                        <h4>Full Adder</h4>
                        <div class="formula">
                            Sum = A ⊕ B ⊕ Cin<br>
                            Cout = AB + Cin(A ⊕ B)
                        </div>
                        <p style="color: #888; margin-top: 10px;">Used for multi-bit addition<br>Cascade Cout to next bit's Cin</p>
                    </div>

                    <div class="card">
                        <h4>Subtractor</h4>
                        <p>Use 2's complement:</p>
                        <div class="formula">
                            A - B = A + (-B)<br>
                            = A + B' + 1
                        </div>
                        <p style="color: #888; margin-top: 10px;">Invert B and set Cin = 1</p>
                    </div>

                    <div class="card">
                        <h4>Adder/Subtractor</h4>
                        <p>Controlled by mode bit M:</p>
                        <div class="formula">
                            M=0: Add (A + B)<br>
                            M=1: Sub (A - B)
                        </div>
                        <p style="color: #888; margin-top: 10px;">XOR B with M, use M as Cin</p>
                    </div>
                </div>

                <h3>Multiplexers (MUX)</h3>
                <div class="quick-ref">
                    <strong>2-to-1 MUX:</strong> F = S'A + SB<br>
                    <strong>4-to-1 MUX:</strong> F = S1'S0'I0 + S1'S0 I1 + S1 S0'I2 + S1 S0 I3<br><br>

                    <strong>Implementing Boolean Functions with MUX:</strong><br>
                    • Connect inputs to data lines<br>
                    • Use select lines for variables<br>
                    • n-variable function needs 2^n-to-1 MUX<br>
                    • Can reduce: use n-1 variables as select, apply remaining variable/constants to data inputs
                </div>

                <h3>Decoders</h3>
                <div class="quick-ref">
                    <strong>n-to-2^n Decoder:</strong><br>
                    • Converts binary input to one-hot output<br>
                    • Each output represents one minterm<br>
                    • 2-to-4 decoder: 4 outputs (00, 01, 10, 11)<br><br>

                    <strong>Implementing Boolean Functions:</strong><br>
                    • Each output is a minterm<br>
                    • OR together the minterms where F=1<br>
                    • Example: F = m1 + m3 + m5 → OR outputs Y1, Y3, Y5
                </div>

                <h3>ROM Implementation</h3>
                <div class="note">
                    <strong>Programmable ROM (PROM):</strong><br>
                    • Address lines = input variables<br>
                    • Data lines = function outputs<br>
                    • Store truth table directly in ROM<br>
                    • Can implement multiple functions simultaneously<br><br>

                    <strong>Example:</strong> 3-input function needs 2^3 = 8 addresses<br>
                    Program ROM with output values for each address
                </div>

                <h3>ALU (Arithmetic Logic Unit)</h3>
                <div class="quick-ref">
                    <strong>Components:</strong><br>
                    • Arithmetic unit (adder/subtractor)<br>
                    • Logic unit (AND, OR, NOT, XOR)<br>
                    • Function select lines<br>
                    • Status flags (Zero, Carry, Overflow, Negative)<br><br>

                    <strong>Common Operations:</strong><br>
                    • ADD, SUB, INC, DEC<br>
                    • AND, OR, XOR, NOT<br>
                    • Shift left/right<br>
                    • Compare (subtract and check flags)
                </div>
            </div>
        </div>

        <!-- SECTION 5: MEMORY BLOCKS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                5. Memory Blocks - Latches & Flip-Flops
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>SR Latch (Set-Reset)</h3>
                <div class="grid-container">
                    <div class="card">
                        <h4>SR Latch Truth Table</h4>
                        <table class="truth-table">
                            <tr><th>S</th><th>R</th><th>Q(t+1)</th><th>Action</th></tr>
                            <tr><td>0</td><td>0</td><td>Q(t)</td><td>Hold</td></tr>
                            <tr><td>0</td><td>1</td><td>0</td><td>Reset</td></tr>
                            <tr><td>1</td><td>0</td><td>1</td><td>Set</td></tr>
                            <tr><td>1</td><td>1</td><td class="warning">X</td><td>Invalid</td></tr>
                        </table>
                        <div class="note">
                            <strong class="warning">⚠️ Never set S=1 and R=1!</strong><br>
                            Creates unstable state
                        </div>
                    </div>

                    <div class="card">
                        <h4>D Latch</h4>
                        <table class="truth-table">
                            <tr><th>D</th><th>EN</th><th>Q(t+1)</th></tr>
                            <tr><td>X</td><td>0</td><td>Q(t)</td></tr>
                            <tr><td>0</td><td>1</td><td>0</td></tr>
                            <tr><td>1</td><td>1</td><td>1</td></tr>
                        </table>
                        <div class="formula">
                            Level-triggered:<br>
                            Q follows D when EN=1
                        </div>
                    </div>
                </div>

                <h3>Flip-Flops (Edge-Triggered)</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>D Flip-Flop</h4>
                        <table class="truth-table">
                            <tr><th>D</th><th>CLK</th><th>Q(t+1)</th></tr>
                            <tr><td>0</td><td>↑</td><td>0</td></tr>
                            <tr><td>1</td><td>↑</td><td>1</td></tr>
                        </table>
                        <div class="formula">Q(t+1) = D</div>
                        <p style="color: #888;">Stores data on clock edge</p>
                    </div>

                    <div class="card">
                        <h4>T Flip-Flop (Toggle)</h4>
                        <table class="truth-table">
                            <tr><th>T</th><th>CLK</th><th>Q(t+1)</th></tr>
                            <tr><td>0</td><td>↑</td><td>Q(t)</td></tr>
                            <tr><td>1</td><td>↑</td><td>Q'(t)</td></tr>
                        </table>
                        <div class="formula">Q(t+1) = T ⊕ Q(t)</div>
                        <p style="color: #888;">Toggles when T=1</p>
                    </div>

                    <div class="card">
                        <h4>JK Flip-Flop</h4>
                        <table class="truth-table">
                            <tr><th>J</th><th>K</th><th>CLK</th><th>Q(t+1)</th></tr>
                            <tr><td>0</td><td>0</td><td>↑</td><td>Q(t)</td></tr>
                            <tr><td>0</td><td>1</td><td>↑</td><td>0</td></tr>
                            <tr><td>1</td><td>0</td><td>↑</td><td>1</td></tr>
                            <tr><td>1</td><td>1</td><td>↑</td><td>Q'(t)</td></tr>
                        </table>
                        <div class="formula">Q(t+1) = JQ' + K'Q</div>
                        <p style="color: #888;">Most versatile flip-flop</p>
                    </div>
                </div>

                <h3>Excitation Tables (Flip-Flop Design)</h3>
                <div class="quick-ref">
                    <strong>When designing sequential circuits, use these to find required inputs:</strong>
                    
                    <div class="grid-container" style="margin-top: 15px;">
                        <div class="card">
                            <h4>D FF Excitation</h4>
                            <table class="truth-table">
                                <tr><th>Q(t)</th><th>Q(t+1)</th><th>D</th></tr>
                                <tr><td>0</td><td>0</td><td>0</td></tr>
                                <tr><td>0</td><td>1</td><td>1</td></tr>
                                <tr><td>1</td><td>0</td><td>0</td></tr>
                                <tr><td>1</td><td>1</td><td>1</td></tr>
                            </table>
                        </div>

                        <div class="card">
                            <h4>T FF Excitation</h4>
                            <table class="truth-table">
                                <tr><th>Q(t)</th><th>Q(t+1)</th><th>T</th></tr>
                                <tr><td>0</td><td>0</td><td>0</td></tr>
                                <tr><td>0</td><td>1</td><td>1</td></tr>
                                <tr><td>1</td><td>0</td><td>1</td></tr>
                                <tr><td>1</td><td>1</td><td>0</td></tr>
                            </table>
                        </div>

                        <div class="card">
                            <h4>JK FF Excitation</h4>
                            <table class="truth-table">
                                <tr><th>Q(t)</th><th>Q(t+1)</th><th>J</th><th>K</th></tr>
                                <tr><td>0</td><td>0</td><td>0</td><td>X</td></tr>
                                <tr><td>0</td><td>1</td><td>1</td><td>X</td></tr>
                                <tr><td>1</td><td>0</td><td>X</td><td>1</td></tr>
                                <tr><td>1</td><td>1</td><td>X</td><td>0</td></tr>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="note">
                    <strong>Asynchronous Set/Reset:</strong><br>
                    • Override clock signal<br>
                    • Active immediately (not edge-triggered)<br>
                    • Set: Forces Q=1<br>
                    • Reset/Clear: Forces Q=0<br>
                    • Usually active-low signals<br>
                    • Used for initialization
                </div>

                <h3>Timing Diagrams</h3>
                <div class="note">
                    <strong>Key Concepts:</strong><br>
                    • Clock edge (↑ rising, ↓ falling)<br>
                    • Setup time: Data must be stable BEFORE clock edge<br>
                    • Hold time: Data must be stable AFTER clock edge<br>
                    • Propagation delay: Time from clock edge to output change<br><br>

                    <strong>Reading Timing Diagrams:</strong><br>
                    1. Mark clock edges<br>
                    2. Check inputs at each edge<br>
                    3. Determine next state<br>
                    4. Draw output (delayed by propagation)<br>
                    5. Watch for setup/hold violations
                </div>
            </div>
        </div>

        <!-- SECTION 6: MEMORY DEVICES -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                6. Memory Devices - Counters & Registers
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Synchronous Counters</h3>
                
                <div class="quick-ref">
                    <strong>Key Features:</strong><br>
                    • All flip-flops clock simultaneously<br>
                    • Same clock signal to all stages<br>
                    • Faster than ripple counters<br>
                    • More complex logic but predictable timing<br><br>

                    <strong>Counter Design Steps:</strong><br>
                    1. Create state diagram/table<br>
                    2. Choose flip-flop type (usually T or JK)<br>
                    3. Build excitation table<br>
                    4. Derive input equations using K-maps<br>
                    5. Implement circuit
                </div>

                <div class="grid-container">
                    <div class="card">
                        <h4>4-bit Up Counter</h4>
                        <div class="formula">
                            Count: 0→1→2→3→...→15→0<br><br>
                            Using T flip-flops:<br>
                            T0 = 1<br>
                            T1 = Q0<br>
                            T2 = Q0·Q1<br>
                            T3 = Q0·Q1·Q2
                        </div>
                    </div>

                    <div class="card">
                        <h4>Modulo-N Counter</h4>
                        <div class="formula">
                            Counts 0 to N-1<br><br>
                            Add reset logic:<br>
                            When count = N,<br>
                            async reset to 0
                        </div>
                        <p style="color: #888;">Example: Mod-10 counter for decimal</p>
                    </div>

                    <div class="card">
                        <h4>Up/Down Counter</h4>
                        <div class="formula">
                            Control bit U/D:<br>
                            U/D=1: Count up<br>
                            U/D=0: Count down<br><br>
                            Modify T equations<br>
                            with U/D control
                        </div>
                    </div>

                    <div class="card">
                        <h4>Counter with Load</h4>
                        <div class="formula">
                            Parallel load input<br>
                            Load data when<br>
                            LOAD=1<br><br>
                            Use D FFs or<br>
                            modified JK/T FFs
                        </div>
                    </div>
                </div>

                <h3>Registers</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Parallel-In/Parallel-Out (PIPO)</h4>
                        <p>All bits loaded/read simultaneously</p>
                        <div class="formula">
                            Used in microprocessor<br>
                            for data storage<br><br>
                            D0-D3 → Q0-Q3<br>
                            (on clock edge)
                        </div>
                        <p style="color: #888;">Simple D flip-flops in parallel</p>
                    </div>

                    <div class="card">
                        <h4>Serial-In/Parallel-Out (SIPO)</h4>
                        <p>Shift register - data enters one bit at a time</p>
                        <div class="formula">
                            Shift: D → Q0 → Q1 → Q2 → Q3<br><br>
                            After 4 clocks,<br>
                            all bits available<br>
                            in parallel
                        </div>
                        <p style="color: #888;">Used for serial-to-parallel conversion</p>
                    </div>

                    <div class="card">
                        <h4>Shift Register Operations</h4>
                        <ul style="text-align: left; color: #888;">
                            <li>Shift left: multiply by 2</li>
                            <li>Shift right: divide by 2</li>
                            <li>Rotate: circular shift</li>
                            <li>Serial data transmission</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Universal Shift Register</h4>
                        <p>Can perform multiple operations:</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Hold (no change)</li>
                            <li>Shift left</li>
                            <li>Shift right</li>
                            <li>Parallel load</li>
                        </ul>
                        <p style="margin-top: 10px;">Select via control bits</p>
                    </div>
                </div>

                <div class="note">
                    <strong>💡 Register Applications:</strong><br>
                    • CPU registers (accumulator, program counter)<br>
                    • Data buffering<br>
                    • Data alignment<br>
                    • Arithmetic operations (shift = multiply/divide by 2)<br>
                    • Serial communication
                </div>
            </div>
        </div>

        <!-- SECTION 7: FINITE STATE MACHINES -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                7. Finite State Machines (FSM)
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Mealy vs Moore Machines</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Moore Machine</h4>
                        <div class="formula">
                            Output = f(Current State)<br><br>
                            Output depends ONLY<br>
                            on current state
                        </div>
                        <p style="color: #888; margin-top: 10px;">
                            • Outputs change on clock edge<br>
                            • More states usually needed<br>
                            • Synchronized outputs<br>
                            • Easier timing analysis
                        </p>
                    </div>

                    <div class="card">
                        <h4>Mealy Machine</h4>
                        <div class="formula">
                            Output = f(Current State, Input)<br><br>
                            Output depends on<br>
                            state AND input
                        </div>
                        <p style="color: #888; margin-top: 10px;">
                            • Outputs can change asynchronously<br>
                            • Fewer states needed<br>
                            • Faster response<br>
                            • More complex timing
                        </p>
                    </div>
                </div>

                <h3>FSM Analysis Steps</h3>
                <div class="quick-ref">
                    <strong>Given state diagram/table, predict behavior:</strong><br><br>
                    
                    1. <strong>Identify current state</strong><br>
                    2. <strong>Check input value</strong><br>
                    3. <strong>Find next state</strong> from state transition table/diagram<br>
                    4. <strong>Determine output:</strong><br>
                       - Moore: Look at next state only<br>
                       - Mealy: Look at current state + input<br>
                    5. <strong>Update state</strong> on clock edge<br>
                    6. <strong>Repeat</strong> for next clock cycle
                </div>

                <h3>State Table Example</h3>
                <table class="fsm-table">
                    <tr>
                        <th rowspan="2">Current State</th>
                        <th colspan="2">Next State</th>
                        <th colspan="2">Output (Mealy)</th>
                    </tr>
                    <tr>
                        <th>X=0</th>
                        <th>X=1</th>
                        <th>X=0</th>
                        <th>X=1</th>
                    </tr>
                    <tr>
                        <td>S0</td>
                        <td>S0</td>
                        <td>S1</td>
                        <td>0</td>
                        <td>0</td>
                    </tr>
                    <tr>
                        <td>S1</td>
                        <td>S2</td>
                        <td>S0</td>
                        <td>0</td>
                        <td>1</td>
                    </tr>
                    <tr>
                        <td>S2</td>
                        <td>S0</td>
                        <td>S2</td>
                        <td>1</td>
                        <td>0</td>
                    </tr>
                </table>

                <div class="note">
                    <strong>FSM Design Process:</strong><br>
                    1. Define problem and identify inputs/outputs<br>
                    2. Draw state diagram<br>
                    3. Create state table<br>
                    4. Choose state encoding (binary, Gray, one-hot)<br>
                    5. Select flip-flop type<br>
                    6. Create excitation table<br>
                    7. Derive next-state and output equations (K-maps)<br>
                    8. Implement circuit
                </div>

                <div class="quick-ref">
                    <strong>Common FSM Applications:</strong><br>
                    • Sequence detectors (pattern recognition)<br>
                    • Traffic light controllers<br>
                    • Vending machines<br>
                    • Communication protocols<br>
                    • CPU control units<br>
                    • Game state management
                </div>
            </div>
        </div>

        <!-- SECTION 8: MICROPROCESSOR -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                8. Microprocessor Architecture
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>Fetch-Execute Cycle</h3>
                
                <div class="quick-ref">
                    <strong>Two-phase operation cycle:</strong><br><br>

                    <strong class="highlight">FETCH Phase:</strong><br>
                    1. Program Counter (PC) → Address Bus<br>
                    2. Memory outputs instruction<br>
                    3. Instruction → Instruction Register (IR)<br>
                    4. PC = PC + 1 (point to next instruction)<br><br>

                    <strong class="highlight">EXECUTE Phase:</strong><br>
                    5. Decode instruction<br>
                    6. Read operands from memory/registers<br>
                    7. Perform operation in ALU<br>
                    8. Write result to destination<br>
                    9. Update flags (Z, C, V, N)<br>
                    10. Return to FETCH
                </div>

                <h3>Microprocessor Components</h3>
                
                <div class="grid-container">
                    <div class="card">
                        <h4>Program Counter (PC)</h4>
                        <p>Holds address of next instruction</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Increments each cycle</li>
                            <li>Can be loaded (JMP, CALL)</li>
                            <li>Points to instruction memory</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Instruction Register (IR)</h4>
                        <p>Holds current instruction</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Loaded during FETCH</li>
                            <li>Decoded by control unit</li>
                            <li>Contains opcode + operands</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Accumulator (ACC)</h4>
                        <p>Primary register for ALU operations</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Stores ALU results</li>
                            <li>One operand source</li>
                            <li>Can read/write to memory</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>ALU (Arithmetic Logic Unit)</h4>
                        <p>Performs all computations</p>
                        <ul style="text-align: left; color: #888;">
                            <li>ADD, SUB operations</li>
                            <li>Logic operations</li>
                            <li>Sets status flags</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Data Bus</h4>
                        <p>Bidirectional data transfer</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Shared by all components</li>
                            <li>Tri-state buffers control access</li>
                            <li>One active driver at a time</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Address Bus</h4>
                        <p>Selects memory location</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Unidirectional (CPU → Memory)</li>
                            <li>Determines address space</li>
                            <li>n bits → 2^n addresses</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Control Unit</h4>
                        <p>Coordinates all operations</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Decodes instructions</li>
                            <li>Generates control signals</li>
                            <li>FSM implementation</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4>Memory</h4>
                        <p>Stores instructions and data</p>
                        <ul style="text-align: left; color: #888;">
                            <li>Unified memory space</li>
                            <li>READ/WRITE operations</li>
                            <li>Addressed by PC or IR</li>
                        </ul>
                    </div>
                </div>

                <h3>Data Bus Sharing</h3>
                <div class="note">
                    <strong>Tri-State Control:</strong><br>
                    • Multiple components connect to data bus<br>
                    • Only ONE can drive bus at a time<br>
                    • Others must be in high-impedance (Z) state<br>
                    • Control unit enables appropriate driver<br><br>

                    <strong>Example Bus Operations:</strong><br>
                    1. Memory Read: Memory drives bus → Register reads<br>
                    2. Memory Write: Register drives bus → Memory reads<br>
                    3. ALU Output: ALU drives bus → Accumulator reads<br><br>

                    <strong class="warning">⚠️ Bus Conflict:</strong> Multiple drivers = undefined state!
                </div>

                <h3>Memory Addressing</h3>
                <div class="quick-ref">
                    <strong>Addressing Modes:</strong><br><br>

                    <strong>Immediate:</strong> Operand is in instruction<br>
                    Example: LOAD #5 → ACC = 5<br><br>

                    <strong>Direct:</strong> Address in instruction<br>
                    Example: LOAD 100 → ACC = Memory[100]<br><br>

                    <strong>Indirect:</strong> Address points to address<br>
                    Example: LOAD @100 → ACC = Memory[Memory[100]]<br><br>

                    <strong>Indexed:</strong> Base + offset<br>
                    Example: LOAD 100,X → ACC = Memory[100 + X]
                </div>

                <h3>Instruction Format</h3>
                <div class="formula">
                    Typical instruction:<br>
                    | OPCODE | MODE | ADDRESS/OPERAND |<br>
                    | 4 bits | 2 bits | 10 bits |<br><br>

                    OPCODE: Operation (ADD, SUB, LOAD, etc.)<br>
                    MODE: Addressing mode<br>
                    ADDRESS: Memory address or immediate value
                </div>

                <div class="note">
                    <strong>Key Microprocessor Concepts:</strong><br>
                    • Von Neumann architecture (shared memory for instructions/data)<br>
                    • Sequential execution (fetch → execute → fetch...)<br>
                    • Stored program concept<br>
                    • Register transfer level (RTL) operations<br>
                    • Clock synchronization<br>
                    • Control signals coordinate all actions
                </div>
            </div>
        </div>

        <!-- SECTION 9: QUICK FORMULAS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                9. Quick Formula Reference
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <div class="grid-container">
                    <div class="card">
                        <h4>Boolean Algebra</h4>
                        <div class="formula">
                            A + 0 = A<br>
                            A + 1 = 1<br>
                            A + A = A<br>
                            A + A' = 1<br>
                            A · 0 = 0<br>
                            A · 1 = A<br>
                            A · A = A<br>
                            A · A' = 0<br>
                            (A')' = A<br>
                            A + AB = A<br>
                            A(A + B) = A
                        </div>
                    </div>

                    <div class="card">
                        <h4>DeMorgan's Laws</h4>
                        <div class="formula">
                            (A · B)' = A' + B'<br>
                            (A + B)' = A' · B'<br><br>
                            (ABC)' = A' + B' + C'<br>
                            (A+B+C)' = A'·B'·C'
                        </div>
                    </div>

                    <div class="card">
                        <h4>XOR Properties</h4>
                        <div class="formula">
                            A ⊕ 0 = A<br>
                            A ⊕ 1 = A'<br>
                            A ⊕ A = 0<br>
                            A ⊕ A' = 1<br>
                            A ⊕ B = B ⊕ A<br>
                            (A ⊕ B)' = A ⊕ B' = A' ⊕ B
                        </div>
                    </div>

                    <div class="card">
                        <h4>Number Conversions</h4>
                        <div class="formula">
                            Binary → Decimal:<br>
                            Sum of (bit × 2^position)<br><br>
                            
                            Decimal → Binary:<br>
                            Divide by 2, read remainders<br><br>
                            
                            2's Complement:<br>
                            Invert bits, add 1
                        </div>
                    </div>

                    <div class="card">
                        <h4>Flip-Flop Equations</h4>
                        <div class="formula">
                            D FF: Q(t+1) = D<br>
                            T FF: Q(t+1) = T ⊕ Q<br>
                            JK FF: Q(t+1) = JQ' + K'Q<br>
                            SR Latch: Q(t+1) = S + R'Q
                        </div>
                    </div>

                    <div class="card">
                        <h4>Adder Equations</h4>
                        <div class="formula">
                            Half Adder:<br>
                            Sum = A ⊕ B<br>
                            Carry = A · B<br><br>
                            
                            Full Adder:<br>
                            Sum = A ⊕ B ⊕ Cin<br>
                            Cout = AB + Cin(A⊕B)
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- SECTION 10: GLOSSARY -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                10. Glossary of Terms
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <div class="glossary-term">
                    <strong>Minterm:</strong> Product term where each variable appears once (normal or complemented). For n variables, there are 2^n minterms. Example: A'B'C is minterm m0.
                </div>

                <div class="glossary-term">
                    <strong>Maxterm:</strong> Sum term where each variable appears once. Example: (A+B+C) is maxterm M0.
                </div>

                <div class="glossary-term">
                    <strong>SOP (Sum of Products):</strong> Boolean expression as OR of AND terms. Also called disjunctive normal form.
                </div>

                <div class="glossary-term">
                    <strong>POS (Product of Sums):</strong> Boolean expression as AND of OR terms. Also called conjunctive normal form.
                </div>

                <div class="glossary-term">
                    <strong>Don't Care:</strong> Output value that doesn't matter (X). Can be treated as 0 or 1 for optimization.
                </div>

                <div class="glossary-term">
                    <strong>Karnaugh Map (K-map):</strong> Visual method for Boolean function minimization using adjacent cell grouping.
                </div>

                <div class="glossary-term">
                    <strong>Prime Implicant:</strong> Largest possible group in K-map. Essential prime implicants must be included in minimized function.
                </div>

                <div class="glossary-term">
                    <strong>Propagation Delay:</strong> Time for signal to travel through circuit. Causes output change after input change.
                </div>

                <div class="glossary-term">
                    <strong>Setup Time:</strong> Minimum time data must be stable BEFORE clock edge for reliable capture.
                </div>

                <div class="glossary-term">
                    <strong>Hold Time:</strong> Minimum time data must be stable AFTER clock edge for reliable capture.
                </div>

                <div class="glossary-term">
                    <strong>Tri-State Buffer:</strong> Buffer with three output states: 0, 1, and high-impedance (Z). Used for bus sharing.
                </div>

                <div class="glossary-term">
                    <strong>Multiplexer (MUX):</strong> Selects one of many inputs based on select lines. Data selector.
                </div>

                <div class="glossary-term">
                    <strong>Demultiplexer (DEMUX):</strong> Routes single input to one of many outputs. Data distributor.
                </div>

                <div class="glossary-term">
                    <strong>Decoder:</strong> Converts binary input to one-hot output. n inputs → 2^n outputs.
                </div>

                <div class="glossary-term">
                    <strong>Encoder:</strong> Opposite of decoder. 2^n inputs → n outputs. Priority encoder handles multiple active inputs.
                </div>

                <div class="glossary-term">
                    <strong>Latch:</strong> Level-sensitive memory element. Output follows input when enabled.
                </div>

                <div class="glossary-term">
                    <strong>Flip-Flop:</strong> Edge-triggered memory element. Changes output only on clock edge (↑ or ↓).
                </div>

                <div class="glossary-term">
                    <strong>Synchronous:</strong> All changes occur on clock edge. All flip-flops share same clock.
                </div>

                <div class="glossary-term">
                    <strong>Asynchronous:</strong> Changes occur immediately, not synchronized to clock. Example: async reset.
                </div>

                <div class="glossary-term">
                    <strong>Moore Machine:</strong> FSM where output depends only on current state.
                </div>

                <div class="glossary-term">
                    <strong>Mealy Machine:</strong> FSM where output depends on current state AND input.
                </div>

                <div class="glossary-term">
                    <strong>State Diagram:</strong> Visual representation of FSM showing states, transitions, and outputs.
                </div>

                <div class="glossary-term">
                    <strong>Excitation Table:</strong> Shows required inputs to flip-flop for desired state transition. Used in FSM design.
                </div>

                <div class="glossary-term">
                    <strong>Overflow:</strong> Result too large for representation. In 2's complement: adding two positives gives negative, or vice versa.
                </div>

                <div class="glossary-term">
                    <strong>Carry:</strong> Bit generated when sum exceeds bit width. C flag set when unsigned overflow.
                </div>

                <div class="glossary-term">
                    <strong>Ripple Counter:</strong> Asynchronous counter where each FF clocks the next. Slow due to cumulative delay.
                </div>

                <div class="glossary-term">
                    <strong>Synchronous Counter:</strong> All FFs clock simultaneously. Faster but more complex logic.
                </div>

                <div class="glossary-term">
                    <strong>Register:</strong> Group of flip-flops storing multi-bit value. Parallel load/read.
                </div>

                <div class="glossary-term">
                    <strong>Shift Register:</strong> Register where data shifts left or right each clock. Serial data transfer.
                </div>

                <div class="glossary-term">
                    <strong>PROM:</strong> Programmable Read-Only Memory. Stores truth table. Address = inputs, data = outputs.
                </div>

                <div class="glossary-term">
                    <strong>Von Neumann Architecture:</strong> Computer architecture with shared memory for instructions and data.
                </div>

                <div class="glossary-term">
                    <strong>Harvard Architecture:</strong> Separate memory spaces for instructions and data.
                </div>

                <div class="glossary-term">
                    <strong>Opcode:</strong> Operation code. Specifies instruction type (ADD, SUB, LOAD, etc.).
                </div>

                <div class="glossary-term">
                    <strong>RTL (Register Transfer Level):</strong> Hardware description specifying data transfer between registers.
                </div>

                <div class="glossary-term">
                    <strong>Bus:</strong> Shared communication pathway. Multiple devices, one active driver at a time.
                </div>

                <div class="glossary-term">
                    <strong>Addressing Mode:</strong> Method of specifying operand location (immediate, direct, indirect, indexed).
                </div>
            </div>
        </div>

        <!-- SECTION 11: EXAM TIPS -->
        <div class="section">
            <h2 onclick="toggleSection(this)">
                11. Exam Strategy & Tips
                <span class="toggle-icon">▼</span>
            </h2>
            <div class="section-content">
                <h3>General Strategy</h3>
                <div class="note">
                    <strong>Before the exam:</strong><br>
                    • Review all truth tables - memorize basic gates<br>
                    • Practice K-maps until automatic<br>
                    • Know flip-flop excitation tables cold<br>
                    • Understand timing diagram interpretation<br>
                    • Review your lab 4 microprocessor thoroughly<br><br>

                    <strong>During the exam:</strong><br>
                    • Read entire problem before starting<br>
                    • Draw diagrams for complex problems<br>
                    • Show all work for partial credit<br>
                    • Check your work if time permits<br>
                    • Watch for overflow conditions in arithmetic<br>
                    • Verify K-map groupings are powers of 2
                </div>

                <h3>Common Mistakes to Avoid</h3>
                <div class="grid-container">
                    <div class="card">
                        <h4 class="warning">⚠️ K-Map Errors</h4>
                        <ul style="text-align: left; color: #888;">
                            <li>Non-power-of-2 groups</li>
                            <li>Missing wraparound groups</li>
                            <li>Overlapping when unnecessary</li>
                            <li>Missing essential prime implicants</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4 class="warning">⚠️ Number System Errors</h4>
                        <ul style="text-align: left; color: #888;">
                            <li>Forgetting to check overflow</li>
                            <li>2's complement vs 1's complement</li>
                            <li>Wrong sign bit interpretation</li>
                            <li>Base conversion arithmetic errors</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4 class="warning">⚠️ Timing Errors</h4>
                        <ul style="text-align: left; color: #888;">
                            <li>Setup/hold time violations</li>
                            <li>Confusing edge vs level triggering</li>
                            <li>Propagation delay effects</li>
                            <li>Async vs sync operations</li>
                        </ul>
                    </div>

                    <div class="card">
                        <h4 class="warning">⚠️ Logic Errors</h4>
                        <ul style="text-align: left; color: #888;">
                            <li>Incorrect DeMorgan application</li>
                            <li>SR latch invalid state (S=R=1)</li>
                            <li>Bus contention (multiple drivers)</li>
                            <li>State machine transition errors</li>
                        </ul>
                    </div>
                </div>

                <h3>Quick Pre-Exam Checklist</h3>
                <div class="quick-ref">
                    ✓ Can you draw all 6 basic gate symbols?<br>
                    ✓ Do you know all 6 truth tables?<br>
                    ✓ Can you apply DeMorgan's laws instantly?<br>
                    ✓ Can you minimize a 3 or 4 variable function with K-map?<br>
                    ✓ Do you know 2's complement operation?<br>
                    ✓ Can you detect overflow conditions?<br>
                    ✓ Do you understand D, T, JK flip-flop operations?<br>
                    ✓ Can you complete timing diagrams?<br>
                    ✓ Do you know excitation tables for all FFs?<br>
                    ✓ Can you analyze Moore vs Mealy FSMs?<br>
                    ✓ Do you understand fetch-execute cycle?<br>
                    ✓ Can you trace microprocessor data flow?<br>
                    ✓ Do you understand bus sharing with tri-states?<br>
                    ✓ Can you design a simple counter?
                </div>

                <div class="note">
                    <strong class="highlight">🎯 Final Advice:</strong><br>
                    This exam tests understanding, not just memorization. Focus on WHY things work, not just HOW. Draw pictures, use truth tables, and think step-by-step. You've built a microprocessor in lab - you understand these concepts deeply. Trust your knowledge and work systematically through each problem.
                    <br><br>
                    <strong>Good luck! You've got this! 💪</strong>
                </div>
            </div>
        </div>

    </div>

    <script>
        // Toggle section visibility
        function toggleSection(header) {
            const content = header.nextElementSibling;
            const icon = header.querySelector('.toggle-icon');
            
            content.classList.toggle('collapsed');
            icon.classList.toggle('collapsed');
        }

        // K-Map cell toggle
        function toggleKmapCell(cell) {
            const currentValue = parseInt(cell.textContent);
            const newValue = currentValue === 0 ? 1 : 0;
            cell.textContent = newValue;
            
            if (newValue === 1) {
                cell.classList.add('selected');
            } else {
                cell.classList.remove('selected');
            }
        }

        // Number converter
        function convertNumber() {
            const input = document.getElementById('numInput').value.trim();
            const fromBase = parseInt(document.getElementById('fromBase').value);
            const output = document.getElementById('convOutput');
            
            if (!input) {
                output.textContent = 'Please enter a number.';
                return;
            }
            
            try {
                // Parse input number
                const decimalValue = parseInt(input, fromBase);
                
                if (isNaN(decimalValue)) {
                    output.textContent = 'Invalid number for selected base.';
                    return;
                }
                
                // Convert to all bases
                const binary = decimalValue.toString(2);
                const octal = decimalValue.toString(8);
                const decimal = decimalValue.toString(10);
                const hex = decimalValue.toString(16).toUpperCase();
                
                output.innerHTML = `
                    <strong>Conversions:</strong><br>
                    Binary (base-2): ${binary}<br>
                    Octal (base-8): ${octal}<br>
                    Decimal (base-10): ${decimal}<br>
                    Hexadecimal (base-16): ${hex}
                `;
            } catch (error) {
                output.textContent = 'Error converting number.';
            }
        }

        // Allow Enter key for converter
        document.addEventListener('DOMContentLoaded', function() {
            const input = document.getElementById('numInput');
            if (input) {
                input.addEventListener('keypress', function(e) {
                    if (e.key === 'Enter') {
                        convertNumber();
                    }
                });
            }
        });
    </script>
</body>
</html>