A logic circuit is a Boolean expression drawn as gates joined by wires. To interpret it, read from the inputs towards the output, one gate at a time, and write down what comes out of each gate.
This lesson follows truth tables and belongs to the Boolean logic module. Here the circuit is described in words, so you can practise even without the diagram in front of you.
What do the gates do?
| Gate | Output is 1 when |
|---|---|
| NOT | the input is 0 |
| AND | both inputs are 1 |
| OR | at least one input is 1 |
| NAND | not both inputs are 1 (AND, then NOT) |
| NOR | both inputs are 0 (OR, then NOT) |
| XOR | the two inputs are different |
How to read a circuit
- Find the inputs on the left (A, B, C) and the output Q on the right.
- Label the output of each gate with a new letter, X, Y and so on.
- Write the expression for each label in terms of earlier values.
- Combine the labels to write Q in terms of the inputs.
- Test with a few input rows, or build the full table.
Worked example
A circuit has these parts. Inputs A and B go into an XOR gate whose output is X.
X and C go into an AND gate whose output is Y. Y goes into a NOT gate whose output is Q.
Expression: X = A XOR B, Y = X AND C, Q = NOT Y. So Q = NOT ((A XOR B) AND C).
Test A = 1, B = 0, C = 1: X = 1 XOR 0 = 1. Y = 1 AND 1 = 1. Q = NOT 1 = 0.
Test A = 1, B = 1, C = 1: X = 1 XOR 1 = 0. Y = 0 AND 1 = 0. Q = NOT 0 = 1.
The full table, in the order ABC:
| A | B | C | X | Y | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 |
Q is 0 only when C = 1 and A is different from B. That sentence is a useful plain-language description of what the circuit does.
The mistake to watch for
Students often treat XOR as OR.
Mistaken working for A = 1, B = 1, C = 1: X = 1 OR 1 = 1, Y = 1, Q = 0.
XOR of two equal inputs is 0, so X = 0, Y = 0 and Q = 1. The mistaken version gives the opposite output. Always check what happens when both inputs are 1, because that is the one row where OR and XOR disagree.
Check yourself
1. What is the output of a NAND gate when both inputs are 1?
Show answer
AND gives 1, then NOT flips it to 0.
2. What is the output of a NOR gate when both inputs are 0?
Show answer
OR gives 0, then NOT flips it to 1.
3. A and B go into a NOR gate with output X. X goes into a NOT gate with output Q. Write Q in terms of A and B, and say what it does.
Show answer
X = A NOR B = NOT (A OR B). Then Q = NOT X = NOT (NOT (A OR B)) = A OR B. Check: A = 0, B = 0 gives X = 1 and Q = 0. A = 1, B = 0 gives X = 0 and Q = 1. The two gates together behave as a single OR gate.
Where this leads next
Next, learn how to prove two expressions are the same in comparing equivalent expressions using cases. You can use the restricted pseudocode trace trainer for similar step-by-step tracing of algorithms, and the Boolean and number-representation lab for circuit-style checks.
If you can read circuits taught in class but freeze on a new one, a teacher can build a reading routine with you in online one-to-one Computer Science tuition.