Digital electronics and logic gates
Zero, one and three basic gates
This is an extra topic. Logic gates are not in the current NCERT syllabus, but they are asked in competitive exams, and they sit inside every phone and computer you use.
First, two kinds of signal. An analogue signal, like the voltage from a microphone, changes smoothly and can take any value. Watch it rise and fall like a sine wave.
A digital signal has only two levels. Low, say 0 volts, is called 0. High, say 5 volts, is called 1. The signal jumps between them in steps.
A logic gate is a digital circuit that follows a fixed logical rule between its inputs and its output. A truth table lists the output for every possible combination of inputs.
The simplest is the NOT gate. It has one input, A, and one output, Y. It flips the input: 0 becomes 1 and 1 becomes 0. We write Y equals A bar. Its symbol is a triangle with a small circle at the tip.
Next, the OR gate, with two inputs. Y equals A plus B. The output is 1 if A is 1, or B is 1, or both. It is like two switches in parallel lighting one bulb: close either switch and the bulb glows.
Its truth table: 0 and 0 give 0; 0 and 1 give 1; 1 and 0 give 1; and 1 and 1 give 1. Careful: in Boolean algebra, 1 plus 1 is 1, not 2.
Now the AND gate. Y equals A dot B. The output is 1 only when A and B are both 1. Think of two switches in series: the bulb glows only if both are closed.
Its truth table has a single 1, in the last row: 1 and 1 give 1. Every other row gives 0.
With two inputs there are four rows, because each input can be 0 or 1. With n inputs, the truth table has 2 to the power n rows.
NAND, NOR and reading waveforms
Put a NOT gate after an AND gate and you get a NAND gate, short for NOT AND. Y equals A dot B, with a bar over the whole of it. Its symbol is the AND shape with a small circle at the output.
So its truth table is the AND table flipped: 1, 1, 1, and 0. The output is 0 only when both inputs are 1.
In the same way, OR followed by NOT is the NOR gate. Y equals A plus B, with a bar over it. Its output is 1 only when both inputs are 0: the table reads 1, 0, 0, 0.
NAND and NOR are called universal gates. Using only NAND gates, or only NOR gates, you can build NOT, OR and AND, and so any digital circuit at all.
Watch. Join both inputs of a NAND gate together and feed in A. Then Y equals A dot A, bar. Since A dot A is just A, Y equals A bar. It has become a NOT gate.
Now follow a NAND gate with this NAND-made NOT gate. The second bar cancels the first, and the output is A dot B. Two NAND gates make an AND gate.
For OR, first invert A and B with two NAND-made NOT gates, then NAND them together. Check the row A equals 0, B equals 1: the inverted inputs are 1 and 0, and NAND of 1 and 0 is 1. Exactly what OR gives.
Exam questions often give the inputs as waveforms. Here A goes 0, 1, 1, 0, 1, 0 and B goes 0, 0, 1, 1, 1, 0, over six equal time intervals, into a NAND gate.
Read the inputs one interval at a time. 0, 0 gives 1. 1, 0 gives 1. 1, 1 gives 0. 0, 1 gives 1. 1, 1 gives 0. And 0, 0 gives 1.
So Y goes 1, 1, 0, 1, 0, 1. It drops to 0 only in the intervals where A and B are both high. In real circuits, gates like these are built from diodes and transistors on tiny chips called ICs.
Try it: logic gate lab
- Tap A and B (or press the A and B keys) and watch the lamp and the highlighted row of the truth table.
- Compare AND with NAND, and OR with NOR: in every row, the outputs are opposite.
- Open “NOT from NAND” and the other built-up circuits. The small numbers show the output of each gate; check that the final truth table matches the gate in the name.
- Switch to the timing diagram and tap slots of A and B to draw your own waveforms. Predict Y before you look.
- Try the mystery gate: test all four input pairs, then guess which gate is hidden.
Waveforms into a NAND gate
Over four equal intervals, input A of a NAND gate is 0, 1, 1, 0 and input B is 1, 1, 0, 0. What is the output Y in the four intervals?
- 0, 1, 0, 0
- 1, 0, 1, 1
- 1, 1, 1, 0
- 0, 0, 0, 1
Answer
B. Take one interval at a time. NAND gives 0 only when both inputs are 1. The pairs are (0, 1), (1, 1), (1, 0), (0, 0), so Y = 1, 0, 1, 1. 0, 1, 0, 0 is the AND output (the bar forgotten); 1, 1, 1, 0 is OR and 0, 0, 0, 1 is NOR.
Two NOTs and a NOR
Inputs A and B each pass through a NOT gate, and the two outputs go into a NOR gate. The whole circuit behaves as which gate?
- OR
- NAND
- AND
- NOR
Answer
C. The NOR gate gives 1 only when both its inputs are 0, that is, when Ā = 0 and B̄ = 0, which means A = 1 and B = 1. Check the table: (0,0) → 0, (0,1) → 0, (1,0) → 0, (1,1) → 1. That is the AND gate: Y = NOT(Ā + B̄) = A·B. (With NAND instead of NOR, the same trick gives OR.)
Summary
- Y for NOT, OR, AND:
Ā, A + B, A·B - Y for NAND:
NOT(A·B) - Y for NOR:
NOT(A + B)
- A digital signal has only two levels, 0 (low) and 1 (high); an analogue signal varies continuously.
- A truth table lists the output for every input combination: 2ⁿ rows for n inputs.
- OR gives 1 if any input is 1 (switches in parallel); AND gives 1 only if all inputs are 1 (switches in series).
- NAND = AND + NOT (0 only when both inputs are 1); NOR = OR + NOT (1 only when both inputs are 0).
- NAND and NOR are universal gates: tie the inputs of either one together and it becomes a NOT gate; from that, AND and OR can be built.