# DIGITAL LOGIC FUNDAMENTALS
## Materi Lengkap dengan Contoh

---

# 1. NUMBER SYSTEMS (Sistem Bilangan)

## 1.1 Pengenalan Sistem Bilangan

### Konsep Dasar
Komputer menggunakan berbagai sistem bilangan untuk merepresentasikan data. Sistem bilangan utama yang digunakan:

| Sistem | Basis | Digit yang Digunakan | Contoh |
|--------|-------|----------------------|---------|
| **Decimal** | 10 | 0-9 | 125₁₀ |
| **Binary** | 2 | 0-1 | 1111101₂ |
| **Octal** | 8 | 0-7 | 175₈ |
| **Hexadecimal** | 16 | 0-9, A-F | 7D₁₆ |

---

## 1.2 Binary (Biner) - Basis 2

### Definisi
Sistem bilangan yang hanya menggunakan 2 digit: **0** dan **1**

### Konsep Posisi (Positional Value)
```
Binary: 1 0 1 1 0 1
Posisi: 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
Nilai:  32 16  8  4  2  1
```

### Contoh 1: Binary ke Decimal
**Konversi 101101₂ ke Decimal**

```
  1    0    1    1    0    1
  ↓    ↓    ↓    ↓    ↓    ↓
 2⁵   2⁴   2³   2²   2¹   2⁰
 32 +  0 +  8 +  4 +  0 +  1 = 45₁₀
```

**Jawaban: 101101₂ = 45₁₀**

### Contoh 2: Decimal ke Binary
**Konversi 75₁₀ ke Binary**

Metode: Bagi dengan 2, catat sisanya dari bawah ke atas
```
75 ÷ 2 = 37 sisa 1  ←─┐
37 ÷ 2 = 18 sisa 1    │
18 ÷ 2 = 9  sisa 0    │ Baca dari
9  ÷ 2 = 4  sisa 1    │ bawah ke atas
4  ÷ 2 = 2  sisa 0    │
2  ÷ 2 = 1  sisa 0    │
1  ÷ 2 = 0  sisa 1  ──┘
```

**Jawaban: 75₁₀ = 1001011₂**

### Latihan Binary
1. Konversi ke decimal: 11010₂ = ?
2. Konversi ke binary: 50₁₀ = ?
3. Berapa nilai 10000000₂?

---

## 1.3 Hexadecimal (Basis 16)

### Digit Hexadecimal
```
Decimal: 0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15
Hex:     0  1  2  3  4  5  6  7  8  9   A   B   C   D   E   F
```

### Contoh 3: Hexadecimal ke Decimal
**Konversi 2A3₁₆ ke Decimal**

```
  2      A      3
  ↓      ↓      ↓
 16²    16¹    16⁰
 256     16      1

= (2 × 256) + (10 × 16) + (3 × 1)
= 512 + 160 + 3
= 675₁₀
```

### Contoh 4: Binary ke Hexadecimal (PENTING!)
**Konversi 11010110₂ ke Hex**

Metode: Kelompokkan 4 bit dari kanan
```
Binary:  1101  0110
         ↓     ↓
Decimal: 13    6
         ↓     ↓
Hex:     D     6

Jawaban: D6₁₆
```

### Contoh 5: Hexadecimal ke Binary
**Konversi F4₁₆ ke Binary**

```
F        4
↓        ↓
15       4
↓        ↓
1111     0100

Jawaban: 11110100₂
```

### Aplikasi Praktis Hex
- **Alamat Memori**: 0x7FFF (32767)
- **Warna Web**: #FF5733 (Orange)
- **MAC Address**: A4:5E:60:E2:3F:01

---

## 1.4 Octal (Basis 8)

### Contoh 6: Binary ke Octal
**Konversi 101110011₂ ke Octal**

Kelompokkan 3 bit dari kanan:
```
Binary:  101  110  011
         ↓    ↓    ↓
Decimal: 5    6    3
         ↓    ↓    ↓
Octal:   5    6    3

Jawaban: 563₈
```

---

## 1.5 Representasi Data

### Signed Numbers (Bilangan Bertanda)

#### **Sign-Magnitude**
```
8-bit: X XXX XXXX
       ↑ ↑______↑
       │    │
       │    └── Magnitude (nilai absolut)
       └── Sign bit (0=positif, 1=negatif)

Contoh:
+25 = 0 0011001
-25 = 1 0011001
```

#### **Two's Complement** (Paling Umum!)
```
Positif: sama seperti biasa
Negatif: invert bits + 1

Contoh: -25 dalam 8-bit
1. +25 = 00011001
2. Invert = 11100110
3. +1     = 11100111 ← ini adalah -25
```

### Contoh 7: Two's Complement
**Tentukan nilai 11011010₂ (8-bit Two's Complement)**

```
Bit pertama = 1, berarti negatif

1. Invert: 11011010 → 00100101
2. +1:     00100101 → 00100110
3. Konversi ke decimal: 32+4+2 = 38
4. Tambah tanda: -38

Jawaban: 11011010₂ = -38₁₀
```

### Range Representasi

| Tipe | 8-bit Range | 16-bit Range |
|------|-------------|--------------|
| Unsigned | 0 hingga 255 | 0 hingga 65,535 |
| Signed (2's comp) | -128 hingga 127 | -32,768 hingga 32,767 |

---

## 1.6 Codes (Pengkodean)

### BCD (Binary Coded Decimal)
Setiap digit decimal dikodekan dengan 4 bit

**Contoh 8: BCD**
```
Decimal: 295
         ↓
BCD:     0010  1001  0101
         (2)   (9)   (5)
```

### ASCII (American Standard Code for Information Interchange)
7-bit code untuk karakter

```
Karakter  │  ASCII (Binary)  │  Hex
─────────────────────────────────
   'A'    │    1000001       │  41
   'B'    │    1000010       │  42
   'a'    │    1100001       │  61
   '0'    │    0110000       │  30
   '9'    │    0111001       │  39
```

**Contoh 9: Encode "Hi"**
```
'H' = 1001000 = 0x48
'i' = 1101001 = 0x69

"Hi" dalam binary: 1001000 1101001
```

---

# 2. BOOLEAN ALGEBRA

## 2.1 Operasi Dasar

### Tiga Operasi Fundamental

#### **AND (·) atau (∧)**
```
Truth Table:
A  B  │  A·B
─────────────
0  0  │   0
0  1  │   0
1  0  │   0
1  1  │   1

Hasil 1 hanya jika SEMUA input 1
```

#### **OR (+) atau (∨)**
```
Truth Table:
A  B  │  A+B
─────────────
0  0  │   0
0  1  │   1
1  0  │   1
1  1  │   1

Hasil 1 jika SALAH SATU input 1
```

#### **NOT (¬) atau (̄)**
```
Truth Table:
A  │  Ā
────────
0  │  1
1  │  0

Membalik nilai input
```

---

## 2.2 Operasi Tambahan

### XOR (Exclusive OR) - ⊕
```
A  B  │  A⊕B
──────────────
0  0  │   0
0  1  │   1
1  0  │   1
1  1  │   0

Hasil 1 jika input BERBEDA
```

### NAND (NOT AND)
```
A  B  │  A↑B (NAND)
────────────────────
0  0  │   1
0  1  │   1
1  0  │   1
1  1  │   0

NAND adalah Universal Gate!
```

### NOR (NOT OR)
```
A  B  │  A↓B (NOR)
───────────────────
0  0  │   1
0  1  │   0
1  0  │   0
1  1  │   0

NOR juga Universal Gate!
```

---

## 2.3 Hukum-Hukum Boolean

### Hukum Dasar
```
1. Identity Law (Identitas)
   A + 0 = A
   A · 1 = A

2. Null Law
   A + 1 = 1
   A · 0 = 0

3. Idempotent Law
   A + A = A
   A · A = A

4. Complement Law
   A + Ā = 1
   A · Ā = 0
   
5. Involution (Double Negation)
   (Ā̄) = A
```

### Hukum Kombinatif
```
6. Commutative (Komutatif)
   A + B = B + A
   A · B = B · A

7. Associative (Asosiatif)
   (A + B) + C = A + (B + C)
   (A · B) · C = A · (B · C)

8. Distributive
   A · (B + C) = (A · B) + (A · C)
   A + (B · C) = (A + B) · (A + C)
```

### Hukum De Morgan (SANGAT PENTING!)
```
9. De Morgan's Theorems
   (A + B)̄ = Ā · B̄
   (A · B)̄ = Ā + B̄

   Dalam kata: 
   - NOT dari OR = AND dari NOT
   - NOT dari AND = OR dari NOT
```

---

## 2.4 Penyederhanaan Boolean

### Contoh 10: Simplifikasi Sederhana
**Sederhanakan: F = AB + AB̄**

```
F = AB + AB̄
  = A(B + B̄)      [Distributive]
  = A · 1          [Complement Law: B + B̄ = 1]
  = A              [Identity Law]

Jawaban: F = A
```

### Contoh 11: Menggunakan De Morgan
**Sederhanakan: F = (A + B)̄ · (Ā · B̄)̄**

```
Langkah 1: Aplikasikan De Morgan pada (A + B)̄
(A + B)̄ = Ā · B̄

Langkah 2: Aplikasikan De Morgan pada (Ā · B̄)̄
(Ā · B̄)̄ = A + B

Langkah 3: Substitusi
F = (Ā · B̄) · (A + B)

Langkah 4: Ekspansi (Distributive)
F = Ā·B̄·A + Ā·B̄·B
F = 0 + 0         [A·Ā = 0 dan B·B̄ = 0]
F = 0

Jawaban: F = 0 (selalu false)
```

### Contoh 12: Penyederhanaan Kompleks
**Sederhanakan: F = ABC + AB̄C + ĀBC**

```
F = ABC + AB̄C + ĀBC
  = AC(B + B̄) + ĀBC      [Faktorkan AC dari 2 term pertama]
  = AC·1 + ĀBC           [B + B̄ = 1]
  = AC + ĀBC
  = C(A + ĀB)            [Faktorkan C]
  = C(A + Ā)(A + B)      [Distributive]
  = C·1·(A + B)          [A + Ā = 1]
  = C(A + B)

Jawaban: F = AC + BC
```

---

# 3. LOGIC GATES (Gerbang Logika)

## 3.1 Basic Gates

### Simbol dan Fungsi

```
AND Gate:
    A ──┐
        │╲
          ╲──── A·B
        │╱
    B ──┘

OR Gate:
    A ──┐
        │)
         )──── A+B
        │)
    B ──┘

NOT Gate (Inverter):
    A ───▷○── Ā

NAND Gate:
    A ──┐
        │╲
          ╲○──── (AB)̄
        │╱
    B ──┘

NOR Gate:
    A ──┐
        │)
         )○──── (A+B)̄
        │)
    B ──┘

XOR Gate:
    A ──┐
        │)
         )──── A⊕B
        │)
    B ──┘

XNOR Gate:
    A ──┐
        │)
         )○──── (A⊕B)̄
        │)
    B ──┘
```

---

## 3.2 Universal Gates

### NAND sebagai Universal Gate

**Semua gate bisa dibuat dari NAND!**

```
NOT dari NAND:
A ──NAND── Ā (kedua input dihubungkan)
    ─┘

AND dari NAND:
A ─┐        ┌─ NOT
   NAND─────┤       ── A·B
B ─┘        └─

OR dari NAND:
A ── NOT ─┐
          NAND── A+B
B ── NOT ─┘
```

### Contoh 13: Implementasi dengan NAND
**Implementasikan F = AB + C dengan NAND saja**

```
Langkah 1: Aplikasikan De Morgan dua kali
F = AB + C
  = (AB + C)̄̄
  = ((AB)̄ · C̄)̄    [De Morgan]

Implementasi:
A ─┐
   NAND─┐
B ─┘    │
        NAND── F
C ─NOT──┘

(3 NAND gate total: 2 untuk input, 1 untuk output)
```

---

## 3.3 Timing Diagrams

### Contoh 14: Analisis Timing
**Diberikan: F = A·B + C**

```
Timing Diagram:

     ┌───┐       ┌───────┐
A    │   │       │       │
   ──┘   └───────┘       └──

         ┌───────┐
B        │       │
   ──────┘       └──────────

 ┌───┐               ┌───┐
C│   │               │   │
 ┘   └───────────────┘   └─

         ┌───────┐   ┌───┐
F        │       │   │   │
   ──────┘       └───┘   └─
   (F aktif saat AB=1 atau C=1)
```

---

# 4. COMBINATIONAL CIRCUITS

## 4.1 Pengertian
**Combinational Circuit**: Output hanya bergantung pada input SAAT INI, tidak ada memori/storage.

```
Karakteristik:
✓ Tidak ada feedback loop
✓ Tidak ada elemen penyimpanan
✓ Output = f(Input saat ini)
```

---

## 4.2 Sum of Products (SOP) & Product of Sums (POS)

### Sum of Products (SOP) - Bentuk Normal

**Contoh 15: Dari Truth Table ke SOP**

```
Truth Table:
A  B  C  │  F
──────────────
0  0  0  │  0
0  0  1  │  1  ← minterm m₁
0  1  0  │  0
0  1  1  │  1  ← minterm m₃
1  0  0  │  1  ← minterm m₄
1  0  1  │  0
1  1  0  │  1  ← minterm m₆
1  1  1  │  0

SOP Form:
F = Ā·B̄·C + Ā·B·C + A·B̄·C̄ + A·B·C̄
F = m₁ + m₃ + m₄ + m₆
F = Σ(1,3,4,6)
```

### Product of Sums (POS)

**Contoh 16: Dari Truth Table ke POS**

```
Gunakan baris dimana F = 0

F = (A+B+C)·(A+B̄+C)·(A+B̄+C̄)·(Ā+B̄+C)
F = M₀·M₂·M₅·M₇
F = Π(0,2,5,7)
```

---

## 4.3 Karnaugh Map (K-Map) - Tool Penyederhanaan

### K-Map 2 Variabel
```
     B
    0  1
  ┌────────
A 0│ m₀ m₁
  1│ m₂ m₃
```

### K-Map 3 Variabel

**Contoh 17: Simplifikasi dengan K-Map 3 variabel**

```
F(A,B,C) = Σ(1,3,4,6)

      BC
     00 01 11 10
   ┌──────────────
A 0│  0  1  1  0
  1│  1  0  0  1

Grouping:
- Grup 1: BC (posisi 01 dan 11 di baris A=0) → Ā·C
- Grup 2: AC̄ (posisi 00 dan 10 di baris A=1) → A·C̄

F = Ā·C + A·C̄ = A⊕C
```

### K-Map 4 Variabel

**Contoh 18: K-Map 4 Variabel**

```
F(A,B,C,D) = Σ(0,1,2,5,8,9,10)

       CD
      00 01 11 10
    ┌──────────────
AB 00│ 1  1  0  1
   01│ 0  1  0  0
   11│ 0  0  0  0
   10│ 1  1  0  1

Grouping (catat: boleh wrap around!)
- Grup 1 (size 4): Ā·C̄ (pojok kiri)
- Grup 2 (size 2): Ā·B·D̄

F = Ā·C̄ + Ā·B·D̄
  = Ā(C̄ + B·D̄)
```

### Aturan K-Map
```
1. Grouping harus 1, 2, 4, 8, 16... (power of 2)
2. Makin besar grup, makin sederhana
3. Boleh overlap
4. Boleh wrap around (edge ke edge)
5. Pilih minimal jumlah grup
```

---

## 4.4 Rangkaian Kombinasional Standar

### Half Adder
**Menjumlahkan 2 bit**

```
Input: A, B
Output: Sum (S), Carry (C)

Truth Table:
A  B  │  S  C
─────────────
0  0  │  0  0
0  1  │  1  0
1  0  │  1  0
1  1  │  0  1

Equations:
Sum (S) = A ⊕ B
Carry (C) = A · B

Circuit:
A ──┬──XOR── S
    │
B ──┼──┐
    │  AND── C
    └──┘
```

### Full Adder
**Menjumlahkan 3 bit (A + B + Cᵢₙ)**

```
Truth Table:
A  B  Cᵢₙ │  S  Cₒᵤₜ
─────────────────────
0  0   0  │  0   0
0  0   1  │  1   0
0  1   0  │  1   0
0  1   1  │  0   1
1  0   0  │  1   0
1  0   1  │  0   1
1  1   0  │  0   1
1  1   1  │  1   1

Equations:
S = A ⊕ B ⊕ Cᵢₙ
Cₒᵤₜ = AB + BCᵢₙ + ACᵢₙ = AB + Cᵢₙ(A⊕B)
```

### Multiplexer (MUX)
**Memilih 1 dari N input**

**Contoh 19: MUX 4-to-1**
```
Input: I₀, I₁, I₂, I₃
Select: S₁, S₀
Output: Y

S₁ S₀ │  Y
──────────
0  0  │ I₀
0  1  │ I₁
1  0  │ I₂
1  1  │ I₃

Logic:
Y = S̄₁S̄₀I₀ + S̄₁S₀I₁ + S₁S̄₀I₂ + S₁S₀I₃
```

### Decoder
**Mengkonversi n bit menjadi 2ⁿ output**

**Contoh 20: Decoder 2-to-4**
```
Input: A₁, A₀
Output: Y₀, Y₁, Y₂, Y₃

A₁ A₀ │ Y₃ Y₂ Y₁ Y₀
───────────────────
0  0  │  0  0  0  1
0  1  │  0  0  1  0
1  0  │  0  1  0  0
1  1  │  1  0  0  0

Equations:
Y₀ = Ā₁·Ā₀
Y₁ = Ā₁·A₀
Y₂ = A₁·Ā₀
Y₃ = A₁·A₀
```

### Encoder
**Kebalikan Decoder: 2ⁿ input → n bit**

**Contoh 21: Priority Encoder 4-to-2**
```
Input: I₀, I₁, I₂, I₃ (priority: I₃ > I₂ > I₁ > I₀)
Output: A₁, A₀, V (valid)

I₃ I₂ I₁ I₀ │ A₁ A₀  V
─────────────────────
0  0  0  0  │  X  X  0
0  0  0  1  │  0  0  1
0  0  1  X  │  0  1  1
0  1  X  X  │  1  0  1
1  X  X  X  │  1  1  1
```

---

# 5. SEQUENTIAL CIRCUITS

## 5.1 Perbedaan dengan Combinational

```
Combinational:
Input → [Logic] → Output

Sequential:
Input → [Logic] ⇄ [Memory] → Output
           ↑_______↓
        Feedback/State
```

**Sequential Circuit**: Output bergantung pada input SAAT INI + STATE sebelumnya

---

## 5.2 Latches (Level-Triggered)

### SR Latch (Set-Reset)

```
Truth Table:
S  R  │  Q  Q̄  │  Action
───────────────────────────
0  0  │  Q  Q̄  │  Hold (no change)
0  1  │  0  1  │  Reset
1  0  │  1  0  │  Set
1  1  │  X  X  │  Invalid!

Circuit (NOR-based):
    ┌───NOR───┐
S ──┤         ├── Q
    │    ┌────┘
    └────┼───┐
         │   │
    ┌────┼───┤
R ──┤    │   ├── Q̄
    └───NOR──┘
```

### D Latch (Data Latch)
**Eliminasi kondisi invalid SR**

```
Input: D (Data), En (Enable)
Output: Q

En  D  │  Q
────────────
0   X  │  Q (hold)
1   0  │  0
1   1  │  1

"When Enable=1, Q follows D"

Circuit:
D ──┬─────────── S
    │           │
    │      ┌───SR Latch──── Q
    │      │    │
En─AND─────┘    │
    │           │
    └──NOT─AND── R
```

---

## 5.3 Flip-Flops (Edge-Triggered)

### D Flip-Flop
**Paling umum digunakan!**

```
Symbol:
      ──┐
D ────┤D  Q├──── Q
      │    │
Clk ─▷│>   │
      │   Q̄├──── Q̄
      ──┘

Truth Table:
Clk  D  │  Q(next)
─────────────────
 ↑   0  │   0
 ↑   1  │   1
 ─   X  │   Q (hold)

↑ = positive edge (rising edge)
```

### JK Flip-Flop
**Universal flip-flop**

```
Truth Table:
Clk  J  K  │  Q(next)  │  Action
─────────────────────────────────
 ─   X  X  │     Q     │  No change
 ↑   0  0  │     Q     │  Hold
 ↑   0  1  │     0     │  Reset
 ↑   1  0  │     1     │  Set
 ↑   1  1  │     Q̄     │  Toggle

Characteristic Equation:
Q(next) = JQ̄ + K̄Q
```

### T Flip-Flop (Toggle)

```
Truth Table:
Clk  T  │  Q(next)
──────────────────
 ─   X  │    Q
 ↑   0  │    Q
 ↑   1  │    Q̄

"T=1 untuk toggle"

Dari JK: J=K=T
```

---

## 5.4 Registers (Storage)

### Parallel Load Register

**Contoh 22: 4-bit Register**
```
Circuit:
        ┌─────┐
D₀ ────┤D   Q├──── Q₀
        │     │
        ├─────┤
D₁ ────┤D   Q├──── Q₁
        │     │
Clk ──▷│>    │
        ├─────┤
D₂ ────┤D   Q├──── Q₂
        │     │
        ├─────┤
D₃ ────┤D   Q├──── Q₃
        └─────┘

Saat clock edge: D₀D₁D₂D₃ → Q₀Q₁Q₂Q₃
```

### Shift Register

**Contoh 23: 4-bit Shift Register (Kanan)**
```
        ┌─────┐   ┌─────┐   ┌─────┐   ┌─────┐
Din ───┤D   Q├──┤D   Q├──┤D   Q├──┤D   Q├─── Qout
        │     │   │     │   │     │   │     │
Clk ──▷│>    │ ▷│>    │ ▷│>    │ ▷│>    │
        └─────┘   └─────┘   └─────┘   └─────┘
          FF₃       FF₂       FF₁       FF₀

Operasi:
Clock 0: Din=1 → [1 0 0 0]
Clock 1: Din=1 → [1 1 0 0]
Clock 2: Din=0 → [0 1 1 0]
Clock 3: Din=0 → [0 0 1 1]
```

---

## 5.5 Counters (Pencacah)

### Asynchronous Counter (Ripple Counter)

**Contoh 24: 3-bit Ripple Counter**
```
Circuit:
        ┌──┐    ┌──┐    ┌──┐
Clk ──▷│T │Q──▷│T │Q──▷│T │Q
        │  │    │  │    │  │
        └──┘    └──┘    └──┘
         Q₀      Q₁      Q₂

Sequence (0-7):
Count │ Q₂ Q₁ Q₀
──────┼─────────
  0   │  0  0  0
  1   │  0  0  1
  2   │  0  1  0
  3   │  0  1  1
  4   │  1  0  0
  5   │  1  0  1
  6   │  1  1  0
  7   │  1  1  1
  0   │  0  0  0 (repeat)
```

### Synchronous Counter

**Contoh 25: 3-bit Synchronous Up Counter**
```
Design menggunakan JK FF:

Q₂ Q₁ Q₀ │ Q₂⁺ Q₁⁺ Q₀⁺ │ J₂ K₂ J₁ K₁ J₀ K₀
─────────┼────────────┼──────────────────
0  0  0  │  0  0  1  │  0  X  0  X  1  X
0  0  1  │  0  1  0  │  0  X  1  X  X  1
0  1  0  │  0  1  1  │  0  X  X  0  1  X
0  1  1  │  1  0  0  │  1  X  X  1  X  1
1  0  0  │  1  0  1  │  X  0  0  X  1  X
1  0  1  │  1  1  0  │  X  0  1  X  X  1
1  1  0  │  1  1  1  │  X  0  X  0  1  X
1  1  1  │  0  0  0  │  X  1  X  1  X  1

Equations (dari K-Map):
J₀ = 1,  K₀ = 1
J₁ = Q₀, K₁ = Q₀
J₂ = Q₁Q₀, K₂ = Q₁Q₀
```

### BCD Counter (Decade Counter)

**Contoh 26: Counter 0-9**
```
Modulo-10 counter

Hanya count: 0000 → 1001 (0-9)
Clear saat mencapai 10 (1010)

Logic tambahan:
Clear = Q₃·Q₁ 
(aktif saat 1010, reset ke 0000)
```

---

## 5.6 State Machines

### Finite State Machine (FSM)

**Contoh 27: Sequence Detector "101"**

Deteksi urutan 101 dalam bitstream

```
State Diagram:
           0
    ┌──────────┐
    ↓          │
   S0 ─1→ S1 ─0→ S2 ─1→ S3 (output=1)
    ↑     │         │
    │     └─1───────┘
    └──────0─────────┘

State Table:
Present │ Input │ Next  │ Output
State   │       │ State │
────────┼───────┼───────┼────────
  S0    │   0   │  S0   │   0
  S0    │   1   │  S1   │   0
  S1    │   0   │  S2   │   0
  S1    │   1   │  S1   │   0
  S2    │   0   │  S0   │   0
  S2    │   1   │  S3   │   1
  S3    │   0   │  S2   │   0
  S3    │   1   │  S1   │   0

State Assignment (2-bit):
S0 = 00
S1 = 01
S2 = 10
S3 = 11
```

**Implementasi dengan D FF:**
```
State Encoding:
Q₁ Q₀ = State

Next State Equations (dari K-map):
D₁ = Q₁Q₀X̄ + Q̄₁QX
D₀ = Q̄₁Q̄₀X + Q₁QX̄

Output Equation:
Z = Q₁Q₀X
```

---

# LATIHAN SOAL KOMPREHENSIF

## Soal 1: Konversi Number System
1. Konversi 10110101₂ ke Hexadecimal
2. Berapa decimal value dari 3A7₁₆?
3. Representasikan -45 dalam 8-bit Two's Complement

## Soal 2: Boolean Algebra
Sederhanakan:
- F = ABC + ABC̄ + ĀBC
- G = (A+B)(A+C)(B+C)
- H = (A+B̄)(Ā+B)

## Soal 3: K-Map
Minimalisasi F(A,B,C,D) = Σ(0,1,3,7,8,9,11,15)

## Soal 4: Circuit Design
Desain Full Subtractor (A - B - Borrow_in)

## Soal 5: Sequential
Desain modulo-6 synchronous counter menggunakan JK flip-flops

## Soal 6: FSM
Desain FSM untuk vending machine:
- Harga: 15 cent
- Koin: 5 cent, 10 cent
- Output: Dispense saat ≥15 cent

---

# TIPS BELAJAR

## Untuk Number Systems:
✓ Hafalkan powers of 2: 2⁰=1, 2¹=2, 2²=4, ..., 2¹⁰=1024
✓ Binary ↔ Hex: kelompokkan 4 bit
✓ Praktik konversi setiap hari

## Untuk Boolean Algebra:
✓ Hafalkan hukum dasar + De Morgan
✓ Latih simplifikasi bertahap
✓ Gunakan K-Map untuk 3+ variabel

## Untuk Sequential:
✓ Pahami perbedaan Latch vs Flip-Flop
✓ Pahami timing: level vs edge triggered
✓ Untuk counter: mulai dari T-FF, JK-FF untuk kontrol lebih

## Untuk Circuit Design:
✓ Mulai dari truth table
✓ Buat SOP/POS
✓ Simplifikasi dengan K-Map
✓ Implementasi dengan gates

---

# REFERENSI & TOOLS

## Online Simulators:
1. **Logisim-evolution** - rangkaian digital
2. **CircuitVerse** - web-based simulator
3. **Digital** - modern logic simulator
4. **Falstad Circuit Simulator**

## Kalkulator:
- Programmer Calculator (Windows)
- Binary Calculator online

## Video Tutorials:
- Neso Academy (Sequential circuits)
- Ben Eater (Digital electronics)
- NandGame (learn from NAND gates)

---

**Selamat Belajar Digital Logic! 🔌⚡**

*Practice makes perfect - Kerjakan banyak soal!*