H446/01 · Computer SystemsSection 1.4

1.4.3 Boolean algebra

Logic gates (AND, OR, NOT, XOR, NAND, NOR), truth tables, Boolean expressions, simplification, Karnaugh maps, D-type flip flops

📚1.4.3 Boolean Algebra

1.4.3(a) Logic Gates

Logic gates are the fundamental building blocks of digital circuits. All computer processors are built from combinations of these simple gates.

Definition
A logic gate is an electronic circuit that performs a logical operation on one or more binary inputs and produces a single binary output.

NOT Gate

Definition
The NOT gate (inverter) has one input and outputs the opposite value.

Example
Truth Table:

ANOT A
01
10
Symbol: Triangle with circle at output
Expression: Q = ¬A

AND Gate

Definition
The AND gate outputs 1 only when ALL inputs are 1.

Example
Truth Table:

ABA AND B
000
010
100
111
Expression: Q = A ∧ B

OR Gate

Definition
The OR gate outputs 1 when AT LEAST ONE input is 1.

Example
Truth Table:

ABA OR B
000
011
101
111
Expression: Q = A ∨ B

XOR Gate (Exclusive OR)

Definition
The XOR gate outputs 1 when inputs are DIFFERENT.

Example
Truth Table:

ABA XOR B
000
011
101
110
Expression: Q = A XOR B

NAND Gate

Definition
The NAND gate is AND followed by NOT - outputs 0 only when ALL inputs are 1.

Example
Truth Table:

ABA NAND B
001
011
101
110
NAND is a "universal gate" - can create any other gate using only NANDs.

NOR Gate

Definition
The NOR gate is OR followed by NOT - outputs 1 only when ALL inputs are 0.

Example
Truth Table:

ABA NOR B
001
010
100
110
NOR is also a "universal gate" - can create any other gate using only NORs.

Key Point
GateOutput ruleExpression
NOTInverts single inputQ = ¬A
AND1 only if all inputs are 1Q = A ∧ B
OR1 if at least one input is 1Q = A ∨ B
XOR1 if inputs are differentQ = A ⊕ B
NANDNOT(AND), 0 only if all inputs are 1Q = ¬(A ∧ B)
NORNOT(OR), 1 only if all inputs are 0Q = ¬(A ∨ B)


1.4.3(b) Boolean Expressions and Algebra

Boolean expressions can be simplified using algebraic rules, making circuits cheaper and faster.

Boolean Algebra Laws

Key Point
Law familyOR formAND form
IdentityA ∨ 0 = AA ∧ 1 = A
NullA ∨ 1 = 1A ∧ 0 = 0
IdempotentA ∨ A = AA ∧ A = A
ComplementA ∨ ¬A = 1A ∧ ¬A = 0
Involution¬¬A = A—
CommutativeA ∨ B = B ∨ AA ∧ B = B ∧ A
Associative(A ∨ B) ∨ C = A ∨ (B ∨ C)(A ∧ B) ∧ C = A ∧ (B ∧ C)
DistributiveA ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C)A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C)
AbsorptionA ∨ (A ∧ B) = AA ∧ (A ∨ B) = A

De Morgan's Laws

Key Point
Original expressionEquivalent expressionIn words
¬(A ∧ B)¬A ∨ ¬BNOT (A AND B) = (NOT A) OR (NOT B)
¬(A ∨ B)¬A ∧ ¬BNOT (A OR B) = (NOT A) AND (NOT B)
Memory trick: Break the bar, change the sign.

Worked Example
Worked Example: Simplifying a Boolean Expression

Simplify: Q = A ∧ B ∨ A ∧ ¬B ∨ ¬A ∧ B

Step 1: Factor out common terms
Q = A ∧ (B ∨ ¬B) ∨ ¬A ∧ B

Step 2: Apply complement law (B + B̅ = 1)
Q = A ∧ 1 ∨ ¬A ∧ B

Step 3: Apply identity law (A.1 = A)
Q = A ∨ ¬A ∧ B

Step 4: Apply absorption (or expand and simplify)
Q = A ∨ ¬A ∧ B
= (A ∨ ¬A) ∧ (A ∨ B) [Distributive law]
= 1 ∧ (A ∨ B) [Complement law]
= A ∨ B [Identity law]

Answer: Q = A ∨ B (much simpler circuit!)


1.4.3(c) Karnaugh Maps

Definition
A Karnaugh map (K-map) is a graphical method for simplifying Boolean expressions by grouping adjacent cells containing 1s.

Key Point
K-Map Rules:
• Group 1s in powers of 2 (1, 2, 4, 8)
• Groups must be rectangular
• Make groups as large as possible
• Groups can wrap around edges
• Each 1 must be in at least one group
• Larger groups = simpler expression

Worked Example
Worked Example: 2-Variable K-Map (clear grouping)

Step 1: Start from the truth table.

ABQ
001
011
100
111
Step 2: Fill the K-map (rows = A, columns = B).

A\B01
011
101
Step 3: Form largest valid groups (powers of 2).

GroupCells usedConstant term
G1 (top row pair)(A=0,B=0) and (A=0,B=1)¬A
G2 (right column pair)(A=0,B=1) and (A=1,B=1)B
Notes:
• Overlap is allowed (cell A=0,B=1 is used in both groups).
• Grouping larger pairs reduces expression size.

Final simplified expression:
Q = ¬A ∨ B


1.4.3(d) D-Type Flip-Flops

Flip-flops are the basic memory units in digital circuits - they can store one bit of data.

Definition
A D-type flip-flop is a memory device that captures the value of the D input at a specific moment (the clock edge) and holds it at the Q output.

Key Point
D Flip-Flop Signals:
• D (Data) - The input value to be stored
• CLK (Clock) - Controls WHEN to capture D
• Q - The output (stored value)
• ¬Q - The inverted output (complement of Q)

Worked Example
Worked Example: D Flip-Flop Behaviour

Rising-edge triggered flip-flop:

Clock edgeD at edgeQ after edge
T1 (↑)11
T2 (↑)00
T3 (↑)11
T4 (↑)11
T5 (↑)00
At each rising edge (↑):
• Q takes the value currently on D
• Q then holds that value until the next clock edge
• Changes to D between clock edges are ignored

Key point: The flip-flop only samples D when the clock edge occurs.

Key Point
Flip-Flop Applications:
• Registers - Store multiple bits (8 flip-flops = 8-bit register)
• Counters - Count clock pulses
• Memory - Building block of RAM
• State machines - Store current state
• Frequency division - Divide clock speed by 2

Exam Tip
D flip-flop exam phrasing:
• "Q takes the value of D on the active clock edge"
• "Q holds that value between edges"
• "Changes on D between edges do not affect Q"