A modern computer does not use mechanical switches; it uses electronic switches made of transistors. Groups of transistors form logic gates , small units that take bits in and give a bit out. Gates wired together form a logic circuit . This section connects circuits with Boolean expressions in both directions.
The three basic gates
Definition 3.7 · Logic gate
A logic gate is an electronic circuit that receives one or more input bits (voltage levels 0 or 1) and produces one output bit according to a fixed rule. The three basic gates are AND (x 1 ∧ x 2 x_1 \land x_2 x 1 ∧ x 2 ), OR (x 1 ∨ x 2 x_1 \lor x_2 x 1 ∨ x 2 ) and NOT (x ′ x' x ′ ).
x 1 x_1 x 1 x 2 x_2 x 2 AND x 1 ∧ x 2 x_1 \land x_2 x 1 ∧ x 2 OR x 1 ∨ x 2 x_1 \lor x_2 x 1 ∨ x 2 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1
These are exactly the truth tables of ∧ \land ∧ , ∨ \lor ∨ and ¬ \neg ¬ from Unit 1, with T replaced by 1 and F by 0. That is why they are called logic tables .
Correction · Wrong row in the AND-gate table (Table 3)
Study material says: Table 3 (§3.3) lists the inputs of the AND gate as ( 0 , 0 ) (0,0) ( 0 , 0 ) , ( 1 , 1 ) (1,1) ( 1 , 1 ) , ( 0 , 1 ) (0,1) ( 0 , 1 ) , ( 1 , 1 ) (1,1) ( 1 , 1 ) , with outputs 0, 0, 0, 1. The second row shows inputs 1 , 1 1, 1 1 , 1 with output 0.
Correct version: The second row is x 1 = 1 x_1 = 1 x 1 = 1 , x 2 = 0 x_2 = 0 x 2 = 0 , output 0. The four rows are ( 0 , 0 ) → 0 (0,0) \to 0 ( 0 , 0 ) → 0 , ( 1 , 0 ) → 0 (1,0) \to 0 ( 1 , 0 ) → 0 , ( 0 , 1 ) → 0 (0,1) \to 0 ( 0 , 1 ) → 0 , ( 1 , 1 ) → 1 (1,1) \to 1 ( 1 , 1 ) → 1 .
Why: An AND gate outputs 1 when both inputs are 1, so 1 ∧ 1 1 \land 1 1 ∧ 1 cannot be 0; the same table also lists ( 1 , 1 ) → 1 (1,1) \to 1 ( 1 , 1 ) → 1 in its last row.
Intuition
A logic circuit is like an assembly line. Each gate is a worker who receives parts (bits) from the left, does one simple job, and passes the result to the right. To know the final product, follow the line from left to right, writing down what each worker produces.
From a circuit to its expression
Work from the inputs towards the output, writing the expression at the output of every gate.
Example 3.8 Finding the expression of a circuit
Goal. Find the output expression of this circuit:
Circuit with three inputs Copy x1 ──┐
[AND]── x1∧x2 ──[NOT]── (x1∧x2)′ ──┐
x2 ──┘ [OR]── output
x3 ──[NOT]── x3′ ───────────────────────┘
Step. The first AND gate receives x 1 , x 2 x_1, x_2 x 1 , x 2 and outputs x 1 ∧ x 2 x_1 \land x_2 x 1 ∧ x 2 .
Step. The NOT gate after it outputs ( x 1 ∧ x 2 ) ′ (x_1 \land x_2)' ( x 1 ∧ x 2 ) ′ .
Step. The lower NOT gate outputs x 3 ′ x_3' x 3 ′ .
Step. The OR gate joins the two: ( x 1 ∧ x 2 ) ′ ∨ x 3 ′ (x_1 \land x_2)' \lor x_3' ( x 1 ∧ x 2 ) ′ ∨ x 3 ′ .
Result. Output = ( x 1 ∧ x 2 ) ′ ∨ x 3 ′ = (x_1 \land x_2)' \lor x_3' = ( x 1 ∧ x 2 ) ′ ∨ x 3 ′ , which by De Morgan’s law equals ( x 1 ∧ x 2 ∧ x 3 ) ′ (x_1 \land x_2 \land x_3)' ( x 1 ∧ x 2 ∧ x 3 ) ′ (a single 3-input NAND).
From an expression to its circuit
Work in the opposite direction: find the last operation applied in the expression (the “main connective”); it is the gate nearest to the output. Then build its inputs in the same way.
Example 3.9 Drawing the circuit of an expression
Goal. Draw the circuit for x 1 ∨ ( x 2 ′ ∧ x 3 ) x_1 \lor (x_2' \land x_3) x 1 ∨ ( x 2 ′ ∧ x 3 ) and give its logic table (this is E8).
Step. The main connective is ∨ \lor ∨ , so the last gate is an OR gate with inputs x 1 x_1 x 1 and x 2 ′ ∧ x 3 x_2' \land x_3 x 2 ′ ∧ x 3 .
Step. x 2 ′ ∧ x 3 x_2' \land x_3 x 2 ′ ∧ x 3 needs an AND gate whose inputs are x 2 ′ x_2' x 2 ′ (from a NOT gate on x 2 x_2 x 2 ) and x 3 x_3 x 3 :
Circuit for x1 ∨ (x2′ ∧ x3) Copy x1 ─────────────────────────┐
[OR]── x1 ∨ (x2′∧x3)
x2 ──[NOT]── x2′ ──┐ │
[AND]─────┘
x3 ────────────────┘
Step. Logic table:
x 1 x_1 x 1 x 2 x_2 x 2 x 3 x_3 x 3 x 2 ′ x_2' x 2 ′ x 2 ′ ∧ x 3 x_2' \land x_3 x 2 ′ ∧ x 3 output 0 0 0 1 0 0 0 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 1
Result. The circuit uses one NOT, one AND and one OR gate; its output is 1 exactly when x 1 = 1 x_1 = 1 x 1 = 1 , or when x 2 = 0 x_2 = 0 x 2 = 0 and x 3 = 1 x_3 = 1 x 3 = 1 .
Correction · Evaluation of the Fig. 10 circuit at (0, 1, 0)
Study material says: In §3.3, evaluating ( x 1 ∨ x 2 ) ′ ∧ x 3 (x_1 \lor x_2)' \land x_3 ( x 1 ∨ x 2 ) ′ ∧ x 3 at x 1 = x 3 = 0 x_1 = x_3 = 0 x 1 = x 3 = 0 , x 2 = 1 x_2 = 1 x 2 = 1 , it uses “the second row of Table 3” for 0 ∨ 1 0 \lor 1 0 ∨ 1 , writes the last step as "0 ∧ 1 = 0 0 \land 1 = 0 0 ∧ 1 = 0 ", and concludes “if x 1 x_1 x 1 and x 3 x_3 x 3 are closed, while x 2 x_2 x 2 is open, the circuit remains closed”.
Correct version: x 1 ∨ x 2 = 0 ∨ 1 = 1 x_1 \lor x_2 = 0 \lor 1 = 1 x 1 ∨ x 2 = 0 ∨ 1 = 1 (OR table, Table 4); ( x 1 ∨ x 2 ) ′ = 0 (x_1 \lor x_2)' = 0 ( x 1 ∨ x 2 ) ′ = 0 ; ( x 1 ∨ x 2 ) ′ ∧ x 3 = 0 ∧ 0 = 0 (x_1 \lor x_2)' \land x_3 = 0 \land 0 = 0 ( x 1 ∨ x 2 ) ′ ∧ x 3 = 0 ∧ 0 = 0 , because x 3 = 0 x_3 = 0 x 3 = 0 . In words: with x 1 x_1 x 1 and x 3 x_3 x 3 open (0) and x 2 x_2 x 2 closed (1), the output is 0 — no current reaches the output.
Why: The input given was x 3 = 0 x_3 = 0 x 3 = 0 (not 1), and the value 1 means “closed”, 0 means “open”. The result 0 itself (and row 3 of Table 6) is correct.
Common mistake
Reading a circuit from right to left. Always start at the inputs and follow the wires towards the output; each gate’s output becomes the next gate’s input.
Common mistake
Applying NOT to the wrong part. In ( x 1 ∧ x 2 ) ′ (x_1 \land x_2)' ( x 1 ∧ x 2 ) ′ the NOT gate comes after the AND gate; in x 1 ′ ∧ x 2 x_1' \land x_2 x 1 ′ ∧ x 2 it comes before , on x 1 x_1 x 1 only. The two circuits are different.
Key idea
AND, OR and NOT gates compute ∧ \land ∧ , ∨ \lor ∨ and ′ ' ′ on bits. A circuit’s expression is found by following the wires from inputs to output; a circuit for an expression is built from its main (last) operation backwards to the inputs.
TEE Exam note
Expect: “Draw the logic circuit for …” and “Find the Boolean expression of the given circuit and its logic table”. Label every intermediate wire with its expression; examiners give marks for these labels. Answers: E3/E4 — the AND and OR tables are the truth tables of p ∧ q p \land q p ∧ q and p ∨ q p \lor q p ∨ q with T, F replaced by 1, 0. E6(a) ( x 1 ∨ x 2 ) ′ (x_1 \lor x_2)' ( x 1 ∨ x 2 ) ′ ; E6(b) ( x 1 ∧ x 2 ) ′ ∧ x 3 ′ (x_1 \land x_2)' \land x_3' ( x 1 ∧ x 2 ) ′ ∧ x 3 ′ . E7: NOT on x 1 x_1 x 1 ; NOT on x 3 x_3 x 3 ; OR of x 2 x_2 x 2 and x 3 ′ x_3' x 3 ′ ; AND of x 1 ′ x_1' x 1 ′ with x 2 ∨ x 3 ′ x_2 \lor x_3' x 2 ∨ x 3 ′ . E9: the table of ( x 1 ∧ x 2 ) ′ ∧ x 3 ′ (x_1 \land x_2)' \land x_3' ( x 1 ∧ x 2 ) ′ ∧ x 3 ′ is 1 exactly for inputs ( 0 , 0 , 0 ) (0,0,0) ( 0 , 0 , 0 ) , ( 0 , 1 , 0 ) (0,1,0) ( 0 , 1 , 0 ) , ( 1 , 0 , 0 ) (1,0,0) ( 1 , 0 , 0 ) .
Key takeaways
AND outputs 1 only if all inputs are 1; OR outputs 1 if at least one input is 1; NOT flips the bit.
Gate tables are the truth tables of ∧ \land ∧ , ∨ \lor ∨ , ¬ \neg ¬ with 1 for T and 0 for F.
Circuit → expression: follow the wires from left to right.
Expression → circuit: the main connective is the last gate.
Practice questions Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 1 · multiple choice What is the output of an AND gate with inputs 1 1 1 and 0 0 0 ?
A 1 B 0 C 1, because one input is 1 D It depends on the order of inputs
Check answer
Show answer Answer: B. 0
AND outputs 1 only when all inputs are 1. Option 3 describes an OR gate.
Question 2 · multiple choice A NOT gate receives the output of an OR gate whose inputs are x 1 x_1 x 1 and x 2 x_2 x 2 . What is the output expression?
Check answer
Show answer Answer: A. ( x 1 ∨ x 2 ) ′ (x_1 \lor x_2)' ( x 1 ∨ x 2 ) ′
The NOT acts on the whole OR output. Option 2 would need two NOT gates before the OR gate; by De Morgan it equals ( x 1 ∧ x 2 ) ′ (x_1 \land x_2)' ( x 1 ∧ x 2 ) ′ , not ( x 1 ∨ x 2 ) ′ (x_1 \lor x_2)' ( x 1 ∨ x 2 ) ′ .
Question 3 · multiple choice For the circuit ( x 1 ∨ x 2 ) ′ ∧ x 3 (x_1 \lor x_2)' \land x_3 ( x 1 ∨ x 2 ) ′ ∧ x 3 , what is the output when x 1 = 0 x_1 = 0 x 1 = 0 , x 2 = 0 x_2 = 0 x 2 = 0 , x 3 = 1 x_3 = 1 x 3 = 1 ?
Check answer
Show answer Answer: C. 1
x 1 ∨ x 2 = 0 x_1 \lor x_2 = 0 x 1 ∨ x 2 = 0 , so ( x 1 ∨ x 2 ) ′ = 1 (x_1 \lor x_2)' = 1 ( x 1 ∨ x 2 ) ′ = 1 , and 1 ∧ 1 = 1 1 \land 1 = 1 1 ∧ 1 = 1 . Option 2 forgets the NOT gate, which turns 0 into 1.
Question 4 · multiple choice Which gate is the last (output) gate in the circuit for ( x 1 ′ ∧ x 2 ) ∨ ( x 1 ∨ x 3 ) (x_1' \land x_2) \lor (x_1 \lor x_3) ( x 1 ′ ∧ x 2 ) ∨ ( x 1 ∨ x 3 ) ?
Check answer
Show answer Answer: D. the OR gate joining ( x 1 ′ ∧ x 2 ) (x_1' \land x_2) ( x 1 ′ ∧ x 2 ) and ( x 1 ∨ x 3 ) (x_1 \lor x_3) ( x 1 ∨ x 3 )
The main connective of the whole expression is the middle ∨ \lor ∨ , so its OR gate produces the output. Option 3 is an OR gate too, but it only produces one of the two inputs of the final gate.
Question 5 · multiple choice How many rows does the logic table of a circuit with 4 inputs have?
A 4 B 8 C 16 D 32
Check answer
Show answer Answer: C. 16
Each input is 0 or 1, so there are 2 4 = 16 2^4 = 16 2 4 = 16 combinations. Option 2 is the count for 3 inputs.
Question 6 · short answer
Draw the circuit for x 1 ′ ∧ ( x 2 ∨ x 3 ′ ) x_1' \land (x_2 \lor x_3') x 1 ′ ∧ ( x 2 ∨ x 3 ′ ) (E7) and find its output for the input ( x 1 , x 2 , x 3 ) = ( 0 , 0 , 1 ) (x_1, x_2, x_3) = (0, 0, 1) ( x 1 , x 2 , x 3 ) = ( 0 , 0 , 1 ) .
Show worked answer Circuit: a NOT gate on x 1 x_1 x 1 gives x 1 ′ x_1' x 1 ′ ; a NOT gate on x 3 x_3 x 3 gives x 3 ′ x_3' x 3 ′ ; an OR gate with inputs x 2 x_2 x 2 and x 3 ′ x_3' x 3 ′ gives x 2 ∨ x 3 ′ x_2 \lor x_3' x 2 ∨ x 3 ′ ; a final AND gate with inputs x 1 ′ x_1' x 1 ′ and x 2 ∨ x 3 ′ x_2 \lor x_3' x 2 ∨ x 3 ′ gives the output. For ( 0 , 0 , 1 ) (0, 0, 1) ( 0 , 0 , 1 ) : x 1 ′ = 1 x_1' = 1 x 1 ′ = 1 , x 3 ′ = 0 x_3' = 0 x 3 ′ = 0 , x 2 ∨ x 3 ′ = 0 ∨ 0 = 0 x_2 \lor x_3' = 0 \lor 0 = 0 x 2 ∨ x 3 ′ = 0 ∨ 0 = 0 , output = 1 ∧ 0 = 0 = 1 \land 0 = 0 = 1 ∧ 0 = 0 .