Sub topic 17
Logic Gates and Truth Tables
This chapter assumes you know how a transistor works as a switch (cutoff and saturation) and can read binary numbers. It covers the five gates in the JEE Main syllabus: OR, AND, NOT, NAND and NOR. For each one you will learn the symbol, the Boolean expression and the truth table. You will also learn how to trace a signal through a small circuit of gates.
Digital signals
An analog signal can take any value in a range. A digital signal uses only two voltage ranges. Each range stands for a logic level:
- Logic 1 (HIGH) is a voltage near the supply, for example about 5 V.
- Logic 0 (LOW) is a voltage near 0 V.
This is positive logic, the convention used in JEE problems. Negative logic swaps the meaning of the two levels. Real circuits tolerate a band of voltages around each level, so small noise does not flip a bit.
A logic gate is a circuit with one or more inputs and one output. The output is HIGH or LOW depending only on the present inputs. A gate has no memory. Its behaviour is fully described by a truth table, which lists the output for every combination of inputs. A gate with n inputs has 2^n rows.
The transistor as the building block
A transistor in saturation acts like a closed switch. In cutoff it acts like an open switch. The simplest gate, the NOT gate (inverter), uses one transistor in common-emitter connection with a resistor from the supply to the collector:
- Input LOW: the base-emitter junction is not forward biased, so the transistor is in cutoff. No current flows through the collector resistor, so the output sits at the supply voltage (HIGH).
- Input HIGH: base current drives the transistor into saturation. The collector is pulled close to 0 V, so the output is LOW.
The output is the opposite of the input, which is why the common-emitter amplifier has a 180° phase reversal. Other gates are built by combining several such switches in series or in parallel. A series path conducts only if all switches are on, which gives AND-like behaviour. A parallel path conducts if any switch is on, which gives OR-like behaviour.
The five gates
| Gate | Boolean expression | Output is 1 when |
|---|---|---|
| OR | Y = A + B | at least one input is 1 |
| AND | Y = A · B | all inputs are 1 |
| NOT | Y = Ā | the input is 0 |
| NAND | Y = (A · B)‾ | not all inputs are 1 |
| NOR | Y = (A + B)‾ | all inputs are 0 |
In Boolean algebra "+" means OR and "·" means AND. These are not arithmetic operations, so 1 + 1 = 1.
Truth tables
| A | B | OR | AND | NAND | NOR |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 |
NOT has one input: 0 gives 1, and 1 gives 0.
NAND is AND followed by NOT. NOR is OR followed by NOT. The NAND and NOR columns are exactly the complements of the AND and OR columns, row by row. This is the quickest way to write them down without mistakes.
Reading waveforms
JEE questions often give input waveforms and ask for the output. Treat each time slot as one row of the truth table. Take A = 1 1 0 0 and B = 1 0 1 0 over four consecutive slots:
| Slot | A | B | AND | OR | NAND | NOR |
|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 0 | 0 |
| 2 | 1 | 0 | 0 | 1 | 1 | 0 |
| 3 | 0 | 1 | 0 | 1 | 1 | 0 |
| 4 | 0 | 0 | 0 | 0 | 1 | 1 |
The output sequences are AND = 1000, OR = 1110, NAND = 0111 and NOR = 0001.
Tracing a combination of gates
To analyse a circuit, label the output of each gate and write one intermediate column per gate. Consider the circuit Y = (A + B) · C̄. An OR gate combines A and B. A NOT gate inverts C. An AND gate combines the two results.
| A | B | C | A + B | C̄ | Y |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Y is 1 only when C = 0 and at least one of A, B is 1.
Generating truth tables with code
Gates are functions on bits, so a short program can print any truth table. Use it to check your hand-made tables.
from itertools import product
gates = {
"AND": lambda a, b: a & b,
"OR": lambda a, b: a | b,
"NAND": lambda a, b: 1 - (a & b),
"NOR": lambda a, b: 1 - (a | b),
}
print("A B | " + " ".join(gates))
for a, b in product((0, 1), repeat=2):
row = " ".join(str(f(a, b)) for f in gates.values())
print(a, b, "|", row)
# The circuit Y = (A + B) . NOT C
print("\nA B C | Y")
for a, b, c in product((0, 1), repeat=3):
y = (a | b) & (1 - c)
print(a, b, c, "|", y)Two useful identities
De Morgan's theorems link AND, OR and NOT:
- (A · B)‾ = Ā + B̄
- (A + B)‾ = Ā · B̄
The first says that a NAND gate equals an OR gate fed with inverted inputs. The second says that a NOR gate equals an AND gate fed with inverted inputs. You can verify both from the truth table. The next chapter uses these identities to build every other gate from NAND or NOR alone.
Two more identities are worth remembering: A + A = A and A · A = A. A gate with its inputs tied together behaves like a one-input gate. A two-input NAND or NOR with both inputs tied to A gives Ā, which is a NOT gate.
Common errors
- Confusing NAND and NOR outputs. NAND is 0 only for input 11. NOR is 1 only for input 00. Complement the AND and OR columns instead of memorising them.
- Treating "+" as addition. In Boolean algebra 1 + 1 = 1, not 2.
- Forgetting the bubble. In gate symbols, a small circle at the output means inversion. AND with a bubble is NAND, OR with a bubble is NOR, and a triangle with a bubble is NOT.
- Skipping intermediate columns. For a multi-gate circuit, evaluate one gate at a time. Doing the whole expression in your head is where sign and complement slips occur.
- Missing rows. Three inputs need eight rows. List them in binary counting order (000 to 111) so none are skipped or repeated.
- Using negative logic by accident. Unless the question says otherwise, HIGH is 1.
Exercise
The inputs to a two-input NOR gate are A = 1 0 1 0 and B = 0 0 1 1 over four time slots. Give the output sequence. Then say what single gate gives the same output as a NAND gate with both inputs joined to A.
Show answer
Evaluate slot by slot. Slot 1 is (1, 0), so OR = 1 and NOR = 0. Slot 2 is (0, 0), so NOR = 1. Slot 3 is (1, 1), so NOR = 0. Slot 4 is (0, 1), so NOR = 0. The output is 0 1 0 0. A NAND gate with both inputs tied to A gives (A · A)‾ = Ā, so it acts as a NOT gate.
Exercise
For Y = (A · B)‾ + C, find all input combinations (A, B, C) for which Y = 0.
Show answer
Y is an OR of (A · B)‾ and C, so Y = 0 requires both terms to be 0. C must be 0. (A · B)‾ = 0 means A · B = 1, so A = B = 1. The only combination is (A, B, C) = (1, 1, 0).