Quiz 2

Digital Logic Basics — Number Systems, Boolean Algebra, K-Maps

968 words
5 min read
Python Week 1: the first filter for runtime behavior
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

BaseSystemDigitsExample
2Binary0,11011₂ = 11₁₀
8Octal0-713₈ = 11₁₀
10Decimal0-911₁₀
16Hexadecimal0-9, A-FB₁₆ = 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=11101011_2 = 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 8 + 0 + 2 + 1 = 11_{10} Decimal to Binary: Repeated division by 2
pseudo
11 ÷ 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: 2n1-2^{n-1} to 2n112^{n-1}-1 For 8 bits: -128 to 127 Negation algorithm:
  1. Invert all bits
  2. 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

pseudo
  1 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

LawAND FormOR Form
Identity1A=A1 \cdot A = A0+A=A0 + A = A
Null0A=00 \cdot A = 01+A=11 + A = 1
IdempotentAA=AA \cdot A = AA+A=AA + A = A
ComplementAA=0A \cdot \overline{A} = 0A+A=1A + \overline{A} = 1
CommutativeAB=BAA \cdot B = B \cdot AA+B=B+AA + B = B + A
AssociativeA(BC)=(AB)CA \cdot (B \cdot C) = (A \cdot B) \cdot CA+(B+C)=(A+B)+CA + (B + C) = (A + B) + C
DistributiveA(B+C)=AB+ACA \cdot (B + C) = A\cdot B + A \cdot CA+BC=(A+B)(A+C)A + B \cdot C = (A+B)(A+C)
De MorganAB=A+B\overline{A \cdot B} = \overline{A} + \overline{B}A+B=AB\overline{A + B} = \overline{A} \cdot \overline{B}
AbsorptionA(A+B)=AA \cdot (A + B) = AA+AB=AA + A \cdot B = A

2.2 Boolean Function Simplification

Example: Simplify F=AB+AB+ABF = A \cdot B + A \cdot \overline{B} + \overline{A} \cdot B
pseudo
F = 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=AB+ABF = \overline{A} \cdot B + A \cdot \overline{B} POS (Product of Sums): F=(A+B)(A+B)F = (A + B) \cdot (\overline{A} + \overline{B}) Minterm notation: F=m(1,2)F = \sum m(1, 2) (for A=0,B=1 and A=1,B=0) Maxterm notation: F=M(0,3)F = \prod M(0, 3)

3. Karnaugh Maps (K-Maps)

3.1 2-Variable K-Map

pseudo
       B=0   B=1
A=0  | m0 | m1 |
A=1  | m2 | m3 |
Example: F=AB+AB=AF = A \cdot B + A \cdot \overline{B} = A
pseudo
       B=0   B=1
A=0  |  0  |  0  |
A=1  |  1  |  1  |
Group: A=1 covers both B=0 and B=1 → F=AF = A

3.2 3-Variable K-Map

pseudo
         BC
       00  01  11  10
A=0  | m0 | m1 | m3 | m2 |
A=1  | m4 | m5 | m7 | m6 |
Example: F=m(0,1,2,6)F = \sum m(0, 1, 2, 6)
pseudo
         BC
       00  01  11  10
A=0  | 1  | 1  | 0  | 1  |
A=1  | 0  | 0  | 0  | 1  |
Groups:
  • m0, m1, m2 → AB\overline{A} \cdot \overline{B} (A=0, B covers 00,01,10)
  • m2, m6 → BCB \cdot \overline{C} (B=1, C=0) Simplified: F=AB+BCF = \overline{A} \cdot \overline{B} + B \cdot \overline{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:
pseudo
         BC
       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:
AB¬(A·B)¬A+¬B¬(A+B)¬A·¬B
001111
011100
101100
110000
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
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.