Overview
Readings Brown & Vranesic §2.1–2.10 · weeks 2–4
Logic gates are what every digital circuit is built from, and Boolean algebra is the math that describes them. This chapter goes through each gate, how to read a circuit as a Boolean expression (and the other way around), the rules for simplifying expressions, the two standard forms (SOP and POS), how to build anything out of only NAND or only NOR gates, and the basic design process: specification → truth table → expression → circuit.
Notes
The basic gates
Every gate has one output and, except for NOT, two or more inputs. A gate with inputs has input combinations, so its truth table has rows.
| Gate | Expression | Output is 1 when… |
|---|---|---|
| NOT (inverter) | the input is 0 (it flips the input) | |
| AND | all inputs are 1 | |
| OR | at least one input is 1 | |
| NAND | at least one input is 0 (AND, then NOT) | |
| NOR | all inputs are 0 (OR, then NOT) | |
| XOR | the inputs are different | |
| XNOR | the inputs are the same |
| AND | OR | NAND | NOR | XOR | XNOR | ||
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Try it: pick a gate, then click the inputs (on the diagram or the buttons) to flip them. The matching row of the truth table lights up.
Notes on each gate
- NOT: also called complementation. The small circle (bubble) on its output is the negation indicator, so anywhere a bubble shows up, the signal is inverted.
- AND: called logical multiplication ( or just ). It works as an enable gate: with one input at 1 the other input passes through, and with one input at 0 the output is stuck at 0.
- OR: called logical addition. Unlike binary addition there’s no carry, so .
- NAND / NOR: the universal gates. Either one alone can build NOT, AND and OR, which means it can build any circuit (see NAND and NOR logic).
- XOR: exactly two inputs. Its output is the sum bit from adding two bits (, sum 0), so it’s a 1-bit modulo-2 adder, and it tells you when two signals disagree.
- XNOR: the opposite of XOR, so it’s a 1-bit equality detector.
Example 2.1: Truth table for a multi-input gate
(a) Write the truth table for a 3-input NOR gate. (b) How many input combinations does a 5-input NAND gate have?
Show answerHide answer
(a) A NOR output is 1 only when all inputs are 0, so only the first row is 1:
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
(b) combinations.
Example 2.2: XOR and XNOR as comparators
Two 4-bit values and are compared bit by bit. Find the XOR and XNOR of each bit pair, and say what the results mean.
Show answerHide answer
| Bit position | 3 | 2 | 1 | 0 |
|---|---|---|---|---|
| 1 | 0 | 1 | 1 | |
| 1 | 0 | 0 | 1 | |
| 0 | 0 | 1 | 0 | |
| 1 | 1 | 0 | 1 |
XOR is 1 exactly where the bits disagree, so only bit 1 differs. XNOR is 1 where they agree. If all four XNOR outputs were 1, the two numbers would be equal. That is how a digital comparator tests equality (more in Ch 6).
Active-HIGH and active-LOW
The bubble also tells you which level is active (asserted):
- No bubble: the input/output is active-HIGH, so it “does its thing” when it’s 1.
- Bubble: the input/output is active-LOW, so it “does its thing” when it’s 0.
That gives you a second way to read NAND and NOR gates:
Figure 2.1: The NAND gate is also a negative-OR gate, and the NOR gate is also a negative-AND gate.
- NAND as negative-OR: the output is 1 when is 0 OR is 0. Use this view when you’re looking for “any input LOW”.
- NOR as negative-AND: the output is 1 when is 0 AND is 0. Use this view when you’re looking for “all inputs LOW”.
It’s the same physical gate either way. DeMorgan’s theorems (DeMorgan’s theorems) prove the two symbols are equal.
Example 2.3: Choosing a gate from active-LOW sensors
A press has two safety guards. Each guard’s sensor outputs LOW when the guard is closed and HIGH when it’s open. (a) Pick one gate whose output is HIGH (enabling the press) only when both guards are closed. (b) Pick one gate whose output is HIGH (a warning light) when at least one guard is open.
Show answerHide answer
(a) “Both inputs LOW → output HIGH” is a negative-AND, which is a NOR gate: .
(b) “At least one input HIGH → output HIGH” is a plain OR gate: .
When a question has active-LOW inputs, think negative-OR (NAND) and negative-AND (NOR).
Timing diagrams
In real circuits the inputs are waveforms, not fixed levels. A timing diagram lines up the waveforms on the same time axis. To find a gate’s output waveform:
- Draw a vertical line at every edge of every input.
- Between the lines the inputs are constant, so just use the truth table for each interval.
- Draw the output level for each interval.
Try it: click any time slot of or to flip it and watch the output. Use the buttons to switch gates.
Example 2.4: Output waveform of a circuit
The circuit is an OR gate () feeding a NAND with . The inputs over eight equal time intervals are below. Find and .
| Interval | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | |
| 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | |
| 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | |
| ? | ? | ? | ? | ? | ? | ? | ? |
Show answerHide answer
| Interval | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | |
| 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | |
| 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | |
| 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
I always work out the in-between waveforms first (here ), one gate at a time. Jumping straight to is where mistakes happen.
Boolean algebra basics
- A variable (, , …) is 0 or 1. Its complement (“not A”, “A bar”, or ) is the opposite value. A variable or its complement is called a literal.
- A sum term is literals ORed together (). It’s 0 only when every literal is 0.
- A product term is literals ANDed together (). It’s 1 only when every literal is 1.
Laws
| Law | Addition (OR) | Multiplication (AND) |
|---|---|---|
| Commutative | ||
| Associative | ||
| Distributive |
The 12 rules
| # | Rule | Why |
|---|---|---|
| 1 | OR with 0 passes through | |
| 2 | OR with 1 is always 1 | |
| 3 | AND with 0 is always 0 | |
| 4 | AND with 1 passes through | |
| 5 | , | |
| 6 | one of them is always 1 | |
| 7 | , | |
| 8 | one of them is always 0 | |
| 9 | inverting twice gets you back | |
| 10 | ||
| 11 | proved below | |
| 12 | proved below |
Rules 1–9 come straight from the gate truth tables, and Rules 10–12 are derived from them:
Rule 12 is the distributive law "the other way around". OR distributes over AND too, which ordinary algebra doesn't let you do.
Example 2.5: Which rule applies?
Name the rule and simplify: (a) , (b) , (c) , (d) , (e) .
Show answerHide answer
- (a) Rule 5: .
- (b) Rule 8: .
- (c) Rule 11: .
- (d) Rule 12: .
- (e) Rule 10: .
Spotting the pattern first makes long simplifications much shorter.
DeMorgan’s theorems
In words: break the bar, change the sign. Splitting a bar over a product turns the AND into an OR, and splitting a bar over a sum turns the OR into an AND. They work for any number of variables:
Procedure for a big expression (like ):
- Treat each term under the longest bar as one variable (, ).
- Apply DeMorgan to the longest bar: .
- Cancel any double bars (Rule 9).
- Repeat on the bars that are left until every bar sits over a single variable.
Example 2.6: DeMorgan with several variables
Apply DeMorgan’s theorems to (a) and (b) .
Show answerHide answer
(a) Treat as one variable. The bar is over a product, so it becomes a sum:
(b) The bar is over a sum, so it becomes a product of the two complemented terms, and then each of those gets split:
Example 2.7: Expression with nested bars
Simplify so that bars only sit over single variables.
Show answerHide answer
- Longest bar first. It covers a product of two terms, so it turns into a sum:
- Second term: the double bar cancels, .
- First term: DeMorgan again, .
From circuit to expression to truth table
Circuit → expression: start at the inputs and write the expression at each gate output as you work toward the final output.
Expression → truth table:
- List all input combinations (count in binary).
- Find which combinations make the expression 1 (or work out every column in between).
- Fill in the output column.
For example, is 1 only when and , so when (any ), or (any ).
Example 2.8: From a circuit to a truth table
Find the expression and the truth table for the circuit in Figure 2.2.
Figure 2.2: Circuit for Example 5.
Show answerHide answer
- G1 is an OR: . G2 is a NOT: .
- G3 ANDs them:
- Truth table: needs (so ) and (so or is 1).
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
Simplifying with Boolean algebra
A simpler expression means fewer gates for the same function, so fewer chips, less power, and less material to make them. The usual moves are:
- Factor out a common literal:
- Absorb with Rule 10:
- Remove a complemented literal with Rule 11:
- Duplicate a term you need twice (Rule 5: )
Example:
Five gates become two (one AND, one OR).
Example 2.9: Simplifying with Boolean algebra
Simplify (a) and (b) .
Show answerHide answer
(a)
(b)
Algebra works, but it’s easy to miss a step. Ch 4 has a more systematic method (the Karnaugh map).
Standard forms: SOP and POS
Any expression can be rewritten in one of two standard forms:
| Form | Looks like | Built with |
|---|---|---|
| Sum of products (SOP) | AND gates feeding one OR gate (AND-OR) | |
| Product of sums (POS) | OR gates feeding one AND gate (OR-AND) |
In both forms a bar can only cover one variable. is fine, but is not.
- To get SOP from a general expression, distribute: .
- The domain is the set of all variables in the expression. A standard (canonical) SOP or POS has every variable of the domain in every term.
Converting to standard SOP: multiply each product term by for each missing variable (that’s multiplying by 1) and expand. Every missing variable doubles the number of terms.
Example 2.10: Nonstandard SOP to standard SOP
Convert (domain ) to standard SOP, then write its truth table.
Show answerHide answer
- Each term is missing one variable, so multiply by :
- Binary value of each term (the input that makes it 1): , i.e. rows 5, 4, 6, 2.
- Truth table: 1 on those rows, 0 everywhere else.
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 |
Converting to standard POS: add for each missing variable (that’s adding 0), then use Rule 12 to split.
Example 2.11: Nonstandard POS to standard POS
Convert to standard POS and find the rows where it’s 0.
Show answerHide answer
- Add to the first term and to the second, then split with Rule 12:
- Binary value of each sum term (the input that makes it 0): .
So on rows 0, 2, 3, 4 and on rows 1, 5, 6, 7.
Minterms and maxterms
Each row of a truth table has one standard product term that’s 1 only on that row, and one standard sum term that’s 0 only on that row:
- Minterm : the product term that’s 1 only on row . A 1 in the row becomes the variable and a 0 becomes its complement.
- Maxterm : the sum term that’s 0 only on row . A 0 in the row becomes the variable and a 1 becomes its complement.
| Row | Minterm | Maxterm | |
|---|---|---|---|
| 0 | 0 0 0 | ||
| 1 | 0 0 1 | ||
| 2 | 0 1 0 | ||
| 3 | 0 1 1 | ||
| 4 | 1 0 0 | ||
| 5 | 1 0 1 | ||
| 6 | 1 1 0 | ||
| 7 | 1 1 1 |
So from any truth table:
- Standard SOP = OR of the minterms for the rows where the output is 1. Shorthand: .
- Standard POS = AND of the maxterms for the rows where the output is 0. Shorthand: .
The two lists are complements of each other, so every row number shows up in exactly one of them.
Example 2.12: Truth table to SOP and POS
Write the standard SOP and POS for this truth table.
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |
Show answerHide answer
SOP from the 1s (rows 1, 3, 6, 7). A 0 in the row becomes a complemented variable:
POS from the 0s (rows 0, 2, 4, 5). A 1 in the row becomes a complemented variable:
Both describe the same function. The SOP simplifies to , and Ch 4 shows how to spot that right away.
Floyd calls this the "binary value" of a term. has binary value 1010 because that's the one input that makes it 1, and has binary value 0101 because that's the one input that makes it 0. It's the same idea as and .
NAND and NOR logic
NAND and NOR are universal, meaning each one alone can make every other gate.
| To get | With NAND only | With NOR only |
|---|---|---|
| NOT | tie the inputs together: | tie the inputs together: |
| AND | NAND, then a NAND inverter | invert both inputs, then NOR: |
| OR | invert both inputs, then NAND: | NOR, then a NOR inverter |
| NOR | OR (above), then a NAND inverter | — |
| NAND | — | AND (above), then a NOR inverter |
Two-level NAND = SOP. An AND-OR circuit turns into NAND-NAND when you swap every gate for a NAND, because the bubbles cancel in pairs:
Two-level NOR = POS. Same idea here, an OR-AND circuit becomes NOR-NOR:
Dual symbols. To read a NAND or NOR circuit quickly, redraw it so every connection is bubble-to-bubble or plain-to-plain. Bubbles that meet cancel out (it’s a double inversion), so you can read the gates as plain AND/OR:
- In NAND logic, draw the gates as NAND and negative-OR symbols, alternating by level, with the output gate as a negative-OR.
- In NOR logic, draw the gates as NOR and negative-AND symbols, with the output gate as a negative-AND.
- If a bubble meets a plain input, that variable picks up a bar.
Example 2.13: NAND-only circuit for
Build with as few NAND gates as possible.
Show answerHide answer
Write it as the NAND of two things. By DeMorgan, , so choose (that is, , a NAND of and ) and (so , with no gate needed):
Two gates suffice: and . Using the AND-OR to NAND-NAND swap blindly would also work, but it would spend an extra NAND inverting twice.
Example 2.14: NAND logic with dual symbols
Implement using only NAND gates, drawn with dual symbols.
Show answerHide answer
- Start from AND-OR: two ANDs ( and ) feeding an OR.
- Swap every gate for a NAND. The output gate is drawn as a negative-OR so its input bubbles meet the bubbles of G2 and G3 and cancel.
- needs its own inverter: a NAND with its inputs tied together (G4).
Figure 2.3: NAND-only implementation of .
Check:
Example 2.15: NOR logic
Implement using only NOR gates.
Show answerHide answer
- Start from OR-AND: ORs for and , then an AND.
- Swap every gate for a NOR. G2 = NOR(, ), G3 = NOR(, ), and the output G1 = NOR, drawn as a negative-AND so the bubbles cancel.
- comes from a NOR with its inputs tied together.
Check:
Design process
The textbook’s three steps (§2.8):
- Specify exactly what the circuit should do.
- Synthesize: specification → truth table → Boolean expression → circuit.
- Test: apply every input combination and check the output.
Design example: three-way light control. A room has three doors, and each has a switch (, , ) for the same light . Flipping any one switch has to change the light. Start with the light off when all the switches are open (). Flipping one switch turns it on, flipping a second turns it off, and so on, so the light is on when an odd number of switches are closed.
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
Both are correct (NOT → AND → OR for SOP, NOT → OR → AND for POS). This function is also just .
Example 2.16: Design a majority circuit
Design a circuit for three judges (, , ) that outputs when at least two judges vote yes (1). Simplify it.
Show answerHide answer
- Truth table: on rows with two or three 1s: .
- Standard SOP:
- Simplify. Use Rule 5 to copy twice, so it can pair with each of the others:
- Circuit: three 2-input ANDs feeding a 3-input OR (or five NAND gates, by Example 2.14’s method).
Design example: 2-to-1 multiplexer. A multiplexer (MUX) is a data selector, where a select input picks which data input reaches the output. If then , and if then .
| 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
Multiplexers with more inputs are in Ch 6.
Example 2.17: Evaluating the multiplexer
For the 2-to-1 MUX , find when (a) and (b) .
Show answerHide answer
(a) . With , the output copies .
(b) . With , the output copies .
The inputs are identical in both cases. Only the select line changed, and the output followed whichever input it chose.
Key formulas
Number of input combinations
- : rows in the truth table
- : number of input variables
XOR and XNOR
Useful rules
DeMorgan’s theorems
- , : any variables or sub-expressions
Standard forms from a truth table
- : minterm, the product term that’s 1 only on row
- : maxterm, the sum term that’s 0 only on row
2-to-1 multiplexer
- : select input
- : data input passed through when
- : data input passed through when
Common mistakes
- Treating Boolean like binary. In Boolean algebra (OR), , not .
- Splitting a bar without changing the operation. , it’s .
- Dropping the parentheses when applying DeMorgan. , not .
- Mixing up the two lists. SOP comes from the 1s (0 → complemented) and POS comes from the 0s (1 → complemented).
- Giving an XOR gate more than two inputs. A multi-input “XOR” is really a chain of 2-input XORs (it’s 1 when an odd number of inputs are 1).
- Connecting a bubble output to a plain input in a NAND/NOR diagram and forgetting that variable now has a bar.