Computer ScienceCore24 min read

Boolean Algebra and Logic Circuits

Simplifying a circuit on paper before building it in silicon

This topic appears in:

01

Algebra where everything is 0 or 1

Boolean algebra is ordinary algebra's stricter cousin: variables take only two values, and the operations are AND, OR and NOT rather than plus and times. Its purpose is practical — a simplified expression means fewer logic gates, which means a cheaper, smaller and faster circuit.

Many of the laws look familiar, which helps, but two do not exist in ordinary algebra at all. A + A = A and A · A = A hold here because there is nothing between 0 and 1 to accumulate. Those idempotent laws do much of the simplifying work.

LawAND formOR form
IdentityA · 1 = AA + 0 = A
NullA · 0 = 0A + 1 = 1
IdempotentA · A = AA + A = A
InverseA · Ā = 0A + Ā = 1
AbsorptionA · (A + B) = AA + A·B = A
De Morgan(A·B)‾ = Ā + B̄(A+B)‾ = Ā · B̄

De Morgan's laws, in words

Break the bar, change the sign. (A·B)‾ = Ā + B̄ — "not (both)" is the same as "either one is not". (A+B)‾ = Ā·B̄ — "not (either)" is the same as "neither". These are the laws that let a circuit be rebuilt entirely from NAND gates, which matters because NAND is the cheapest gate to manufacture.

02

Karnaugh maps

Algebraic simplification works but needs inspiration — you have to see which law to apply. A Karnaugh map makes simplification mechanical instead, which is why it is the method examined.

The map is a truth table drawn as a grid, with the crucial feature that the headings run in Gray code order — 00, 01, 11, 10 — so that adjacent cells differ in exactly one variable. That is what makes grouping valid: any variable that changes within a group cannot matter, so it drops out of the expression.

headings run 00, 01, 11, 10(Gray code)rules for grouping:• groups must contain 1, 2, 4, 8 … cells• groups must be rectangular• make groups as LARGE as possible• groups may overlap• the map wraps: edges and corners are adjacent• every 1 must be covered at least oncea bigger group means a simpler term — always take the largest
Gray code
the heading orderso adjacent cells differ in one variable only
group of 2
eliminates 1 variable
group of 4
eliminates 2 variablesalways prefer it to two groups of 2
wrapping
edges are adjacentthe corners of a 4×4 map form a valid group of 4
Worked example

Simplify the expression that is 1 for the minterms ĀB̄, ĀB, AB (that is, everything except AB̄) using a Karnaugh map.

  1. Draw a 2×2 map with A across and B down, and place 1s in three cells, leaving AB̄ as 0.Placing the 1s correctly is where most errors happen — check each minterm against its cell.
  2. Group the two cells where A = 0 (ĀB̄ and ĀB). B changes within the group, so it drops out, leaving Ā.A variable that changes inside a group cannot affect the output, so it is eliminated.
  3. Group the two cells where B = 1 (ĀB and AB). A changes within this group, so it drops out, leaving B.Groups may overlap — ĀB is used twice, which is allowed and often necessary.
  4. Every 1 is covered, so the simplified expression is Ā + B.The groups are combined with OR. Two gates instead of the four the original needed.

Ā + B

Take the largest groups, and use the wrap

Two groups of two give a longer expression than one group of four covering the same cells. And the map wraps round: the leftmost and rightmost columns are adjacent, as are the top and bottom rows, so the four corners of a 4×4 map form a legitimate group. Missing the wrap is the most common reason for an answer that is correct but not fully simplified — and questions usually ask for the simplest form.

03

Building circuits from one kind of gate

NAND and NOR are described as functionally complete: any logic circuit whatsoever can be built from copies of either one alone. This matters commercially, because a factory that makes only NAND gates can produce any chip.

The constructions follow from De Morgan's laws. A NAND with both inputs tied together gives NOT. A NAND followed by that NOT gives AND. And by De Morgan, an OR is a NAND fed with both inputs inverted.

The constructions worth knowing

  1. NOT from NAND: tie both inputs together.
  2. AND from NAND: a NAND followed by a NAND used as NOT — three gates in total.
  3. OR from NAND: invert both inputs first, then NAND them.
  4. A half adder produces sum = A XOR B and carry = A AND B.
  5. A full adder takes a carry in as well and is built from two half adders plus an OR.
  6. Simplifying first always reduces the gate count, and gate count is what costs money.
04

From a problem description to a circuit

The most demanding question in this topic gives a situation in words and asks for a logic circuit. The route is always the same four steps, and doing them in order is what makes it manageable.

First, identify the inputs and give each a letter, being explicit about what 1 means — a sensor that reads 1 when a door is open behaves quite differently from one that reads 1 when it is closed. Second, build the truth table, covering every combination of inputs. Third, write the Boolean expression by taking each row that outputs 1 and ORing those terms together. Fourth, simplify with a Karnaugh map and draw the result.

from a truth table to an expression:take every row whose output is 1write the AND term describing that row(variable if 1, complemented if 0)OR the terms togetherA=0 B=1 → Ā·BA=1 B=1 → A·Bexpression: Ā·B + A·Bwhich simplifies to Bthis is called sum-of-products form
each 1 row
one AND terma product of all the inputs
OR between them
the sumhence sum-of-products
simplify after
a Karnaugh mapthe raw form is never the simplest

Define what 1 means before anything else

An alarm should sound when the door is open and the system is armed. If the door sensor gives 1 for closed, then the expression needs , not D — and every later step inherits the mistake. Writing "D = 1 means the door is closed" at the top of the answer costs one line and prevents the most expensive error in the topic.

Practice questions

5 questions · 15 marks · full working on every one

Try each one on paper first, then open the working. The marks are shown where they are actually awarded, because that is where they are actually lost.

Short questions

4 · 9 marks

Two marks each, in the style of the short-question section of the paper. Answer in two or three lines.

SQ1[2 marks]
State De Morgan's two laws.
Model answer

(A · B)‾ = Ā + B̄ and (A + B)‾ = Ā · B̄. In words: break the bar and change the operation between the terms.

Examiner tip. One mark each. Both must be written correctly, including the change of operator.

SQ2[2 marks]
Explain why the headings on a Karnaugh map are arranged in the order 00, 01, 11, 10 rather than 00, 01, 10, 11.
Model answer

This is Gray code order, in which adjacent headings differ in exactly one variable. That adjacency is what makes grouping valid: within a group only one variable changes, so it can be eliminated. With ordinary binary order, neighbouring cells would differ in two variables and grouping would not simplify correctly.

Examiner tip. Naming Gray code alone is not enough — the reason for needing single-variable adjacency is the second mark.

SQ3[3 marks]
State three rules for forming groups on a Karnaugh map.
Model answer

Groups must contain a number of cells that is a power of two (1, 2, 4, 8…); groups must be rectangular and as large as possible; groups may overlap, and the map wraps round so opposite edges are adjacent.

Examiner tip. Any three distinct rules earn the marks. The wrapping rule is the one most often forgotten.

SQ4[2 marks]
Explain why simplifying a Boolean expression before building the circuit is worthwhile.
Model answer

A simpler expression needs fewer gates, which makes the circuit cheaper to manufacture, smaller, and lower in power consumption. Fewer gates in a signal path also means less propagation delay, so the circuit runs faster.

Examiner tip. Two distinct benefits are needed — cost or size, and speed.

Exam questions

1 · 6 marks

Multi-part questions with a full mark scheme.

Q1[6 marks]
(a) Simplify A·B + A·B̄ using Boolean algebra, showing each law used.
(b) Simplify A + Ā·B.
(c) Explain what is meant by saying NAND is functionally complete, and show how a NOT gate is made from one.
Mark scheme
  1. (a) A·B + A·B̄ = A·(B + B̄) — factorising, using the distributive law.Taking out the common factor is the first move.[1]
  2. B + B̄ = 1 by the inverse law, so A·1 = A by the identity law.Both laws should be named for full credit.[1]
  3. (b) A + Ā·B = (A + Ā)·(A + B) by distributionThis is the less obvious route; the absorption-style result can also be quoted.[1]
  4. = 1·(A + B) = A + BUsing the inverse and identity laws again.[1]
  5. (c) Functionally complete means any logic circuit can be built using only that one type of gate.The definition must mention building any circuit.[1]
  6. A NOT gate is made by connecting both inputs of a NAND together: NAND(A, A) = (A·A)‾ = Ā.The working using the idempotent law makes it convincing.[1]

(a) A; (b) A + B; (c) any circuit from one gate type; NAND(A,A) = NOT A