Sub topic 1
Number Systems, Boolean Algebra and Minimization
Prerequisites
This chapter assumes you can read binary and hexadecimal numbers, know the AND, OR and NOT operators, and handle basic algebra. Each new term is defined where it first appears.
Number systems and 2's complement
In 2's complement, an n-bit word stores signed values from -2^(n-1) to 2^(n-1) - 1. To negate a value, invert every bit and add 1. For 8 bits, +20 is 00010100. Inverting gives 11101011, and adding 1 gives 11101100, which is -20.
Binary-Coded Decimal (BCD) stores each decimal digit in its own 4-bit group. Decimal 47 becomes 0100 0111. Gray code is a binary code in which adjacent values differ in exactly one bit.
def to_twos(value, bits):
return format(value & ((1 << bits) - 1), f"0{bits}b")
def gray(n):
return n ^ (n >> 1)
print(to_twos(-5, 8)) # 11111011
print(format(gray(4), "03b")) # 110
print(format(gray(5), "03b")) # 111Boolean algebra and duality
A Boolean function maps binary inputs to a binary output. The dual of an expression swaps AND with OR and swaps 0 with 1. Any identity stays true after dualizing it.
Minterms, maxterms and canonical forms
A minterm is an AND term that is 1 for exactly one input row. A maxterm is an OR term that is 0 for exactly one row. The canonical sum-of-products (SOP) form ORs the minterms where the function is 1. The canonical product-of-sums (POS) form ANDs the maxterms where the function is 0.
Simplifying with Karnaugh maps
A Karnaugh map (K-map) arranges truth table cells so that neighbors differ in one variable. Group 1s in blocks of 1, 2, 4 or 8 cells. Each group removes the variables that change within it.
For f = Σm(0, 1, 2, 3, 6, 7) with inputs A, B, C, the group of m0 to m3 covers A = 0, giving A'. The group m6 and m7 covers A = 1 and B = 1, giving AB. So f = A' + AB = A' + B.
Building circuits from NAND only
NAND outputs 0 only when both inputs are 1. Tying both inputs together gives NOT, so NAND(x, x) = x'. Using these, f = A' + B becomes NAND(A, NAND(B, B)).
Exercise
What is the 8-bit 2's complement representation of -20?
Show answer
Start from 00010100 (+20). Invert to 11101011, then add 1 to get 11101100.