Digital Logic Basics — Number Systems, Boolean Algebra, K-Maps
968 words
5 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Digital Logic Basics — Number Systems, Boolean Algebra, K-Maps ## 🎯 Learning Objectives - Convert between binary, decimal, hexadecimal, octal - Perform binary arithmetic (addition, subtraction using 2s complement) - Simplify Boolean expressions using Boolean algebra - Minimize logic functions using K-maps * * * #...

Digital Logic Basics — Number Systems, Boolean Algebra, K-Maps
🎯 Learning Objectives
- Convert between binary, decimal, hexadecimal, octal
- Perform binary arithmetic (addition, subtraction using 2s complement)
- Simplify Boolean expressions using Boolean algebra
- Minimize logic functions using K-maps
1. Number Systems
1.1 Common Bases
| Base | System | Digits | Example |
|---|---|---|---|
| 2 | Binary | 0,1 | 1011₂ = 11₁₀ |
| 8 | Octal | 0-7 | 13₈ = 11₁₀ |
| 10 | Decimal | 0-9 | 11₁₀ |
| 16 | Hexadecimal | 0-9, A-F | B₁₆ = 11₁₀ |
1.2 Base Conversion
Binary to Decimal: Sum of bit × 2^position
10112=1×23+0×22+1×21+1×20=8+0+2+1=1110
Decimal to Binary: Repeated division by 2
pseudo11 ÷ 2 = 5 remainder 1 (LSB) 5 ÷ 2 = 2 remainder 1 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1 (MSB) Result: 1011₂
1.3 Signed Numbers: Two's Complement
Range for n bits: −2n−1 to 2n−1−1
For 8 bits: -128 to 127
Negation algorithm:
- Invert all bits
- Add 1 Example: Represent -5 in 8-bit 2's complement:
pseudo+5 = 0000 0101 Invert = 1111 1010 Add 1 = 1111 1011 → -5
1.4 Binary Addition
pseudo1 1 1 1 1 1 0 1 1 0 (6) + 0 1 1 1 (7) ---------- 1 1 0 1 (13)
Overflow detection: If carry into sign bit ≠ carry out of sign bit → overflow.
2. Boolean Algebra
2.1 Basic Laws
| Law | AND Form | OR Form |
|---|---|---|
| Identity | 1⋅A=A | 0+A=A |
| Null | 0⋅A=0 | 1+A=1 |
| Idempotent | A⋅A=A | A+A=A |
| Complement | A⋅A=0 | A+A=1 |
| Commutative | A⋅B=B⋅A | A+B=B+A |
| Associative | A⋅(B⋅C)=(A⋅B)⋅C | A+(B+C)=(A+B)+C |
| Distributive | A⋅(B+C)=A⋅B+A⋅C | A+B⋅C=(A+B)(A+C) |
| De Morgan | A⋅B=A+B | A+B=A⋅B |
| Absorption | A⋅(A+B)=A | A+A⋅B=A |
2.2 Boolean Function Simplification
Example: Simplify F=A⋅B+A⋅B+A⋅B
pseudoF = A·B + A·¬B + ¬A·B = A·(B + ¬B) + ¬A·B (Distributive) = A·1 + ¬A·B (Complement) = A + ¬A·B (Identity) = A + B (Absorption: A + ¬A·B = A + B)
2.3 Canonical Forms
SOP (Sum of Products): F=A⋅B+A⋅B
POS (Product of Sums): F=(A+B)⋅(A+B)
Minterm notation: F=∑m(1,2) (for A=0,B=1 and A=1,B=0)
Maxterm notation: F=∏M(0,3)
3. Karnaugh Maps (K-Maps)
3.1 2-Variable K-Map
pseudoB=0 B=1 A=0 | m0 | m1 | A=1 | m2 | m3 |
Example: F=A⋅B+A⋅B=A
pseudoB=0 B=1 A=0 | 0 | 0 | A=1 | 1 | 1 |
Group: A=1 covers both B=0 and B=1 → F=A
3.2 3-Variable K-Map
pseudoBC 00 01 11 10 A=0 | m0 | m1 | m3 | m2 | A=1 | m4 | m5 | m7 | m6 |
Example: F=∑m(0,1,2,6)
pseudoBC 00 01 11 10 A=0 | 1 | 1 | 0 | 1 | A=1 | 0 | 0 | 0 | 1 |
Groups:
- m0, m1, m2 → A⋅B (A=0, B covers 00,01,10)
- m2, m6 → B⋅C (B=1, C=0) Simplified: F=A⋅B+B⋅C
3.3 Don't Care Conditions
Mark "don't care" cells with X. Use them to create larger groups if helpful.
4. Logic Gates
(Diagram)
NAND and NOR are universal gates — any Boolean function can be implemented using only NAND (or only NOR) gates.
5. 📝 Practice Questions
Q1: Convert 237₁₀ to binary, octal, and hexadecimal.Answer:
- Binary: 11101101₂ (128+64+32+0+8+4+0+1)
- Octal: 355₈ (group bits: 011 101 101)
- Hexadecimal: ED₁₆ (1110=E, 1101=D) Q2: Simplify using Boolean algebra: F = A·B + A·¬B·C + ¬A·B·C
Answer: F = A·B + A·¬B·C + ¬A·B·C = A·B + C·(A·¬B + ¬A·B) = A·B + C·(A⊕B) Q3: Minimize using K-map: F = Σm(0, 2, 4, 5, 6) for 3 variables.Answer:pseudoBC 00 01 11 10 A=0 | 1 | 0 | 0 | 1 | A=1 | 1 | 1 | 0 | 1 |Groups: m0,m4 → ¬C; m4,m5,m6 → A; m0,m2 → ¬A·¬B·¬D? No, it's 3 variables. Groups: m0,m2,m4,m6 → ¬C (all cells with C=0); m4,m5 → A·¬B F = ¬C + A·¬B Q4: Compute 25 + (-18) using 8-bit 2's complement.Answer: +25 = 00011001 -18 = 11101110 (¬00010010 + 1) Add: 00011001 + 11101110 = 00000111 = +7 ✓ Q5: Prove De Morgan's law for 2 variables using a truth table.Answer:
| A | B | ¬(A·B) | ¬A+¬B | ¬(A+B) | ¬A·¬B |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 |
Columns match → De Morgan's law verified.
6. 🔗 Cross-References
- Week 2 - Combinational Circuits: Building circuits from gates
- Week 3 - Sequential Circuits: Adding state to logic
- BSCS4022 (OS): Computer organization fundamentals Join Discord NextBoolean Algebra & K-Maps