A light switch on the wall is worked by a finger. The switches inside a logic chip are worked by a voltage instead: put a voltage on one terminal and the path between the other two opens or closes. That switch is a , and the four gates of a 74HC00 need at least sixteen of them.
The kind inside a 74HC chip is the . It has three terminals, and the one that does the controlling is called the gate, which is an unlucky name in a series about logic gates. Think of it as the transistor’s handle. The gate is insulated from everything else, so it takes almost no current, only a voltage; that is why the input in part 3 could float.
MOSFETs come in two opposite kinds, and a logic chip needs both:
- An N-type switches on when its gate is high, and off when it is low.
- A P-type does the reverse: on when its gate is low, off when it is high. Diagrams mark it with a small bubble on the gate, the same bubble that means “invert” on a gate symbol.
The Transistor as a Switch and Driving Bigger Things show single transistors switching LEDs and motors. In a chip they are microscopic, and they switch other transistors.
Before the transistors, try plain switches. Two switches can be connected to a light in only two useful ways.
In a row, one after the other (in series), the current has to pass through both. The light comes on only if switch A and switch B are closed. That is an AND gate.
Side by side (in parallel), the current has two paths to choose from. Either switch, or both, completes the circuit. That is an OR gate.
Claude Shannon, a student at MIT, made this connection formal in his 1937 master’s thesis: networks of switches and relays follow the algebra of logic, so that algebra can be used to design and simplify them. Part 6 picks it up.
Two switches and a light
Close and open the two switches, first in a row, then side by side. The moving dots show the path the current takes, when there is one.
| A | B | LED |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The current has to pass through both switches, and both are open.
A 5 V supply, a 330 Ω resistor and a red LED. The truth table lights the row that matches the switches.
A single switch can connect an output to 5 volts, or leave it unconnected. But “unconnected” is not a logic level: it is floating, the trap from part 3. A gate’s output must always be firmly high or firmly low.
So every output in a 74HC chip has two sets of switches. One set, made of P-type transistors, can join the output to +5 V. The other, made of N-type transistors, can join it to ground. The two are wired so that whenever one set is closed, the other is open. This arrangement of opposite pairs is called , complementary metal–oxide–semiconductor, and it is what the C in 74HC stands for.
The simplest example is the NOT gate, with just two transistors:
- Input high: the N-type at the bottom switches on, joining the output to ground. The P-type at the top is off. Output low.
- Input low: the P-type switches on, joining the output to +5 V. The N-type is off. Output high.
One of the pair is always on, and the other always off. The output is never left floating, and there is never a direct path from +5 V to ground, so a CMOS chip that is not switching draws almost no current at all. That is why your phone’s billions of transistors do not drain its battery in minutes, and why the floating input of part 3, which turns both on halfway, wastes power.
CMOS was presented by Frank Wanlass and Chih-Tang Sah of Fairchild Semiconductor in 1963. RCA built a whole family of CMOS logic chips, the 4000 series, from 1968, and the 74HC family brought CMOS to the 7400 pinouts in the early 1980s.
Inside the gate
Choose a gate and switch its inputs. Each transistor's switch closes or opens; the top paths join the output to +5 V, the bottom paths join it to 0 V. Watch for the moment both could be closed. It never comes.
At least one input is low, so at least one P-type is closed and joins the output to +5 V. The chain of N-types is broken. Output 1.
Simplified CMOS circuits, drawn as switches. P-type transistors carry a bubble and close when their gate is low; N-type transistors close when their gate is high. The LED stands for whatever the output drives.
Look again at the NAND. Its two N-types are in a row, so they join the output to ground only when A and B are both high: the AND pattern from the switches above. Its two P-types sit side by side, so either one, with its input low, joins the output to +5 V. The bottom half does the AND, and the result comes out upside down, because closing the bottom switches pulls the output low. That is NAND, in four transistors.
This is true of every CMOS gate: closing the N-type switches always pulls the output low, so a single stage always inverts. The natural gates are NOT, NAND and NOR. To get an AND, the chip builds a NAND and then adds a NOT after it to turn the answer round again: six transistors instead of four, and a little slower, because the signal passes through two stages.
So inside a 74HC08, every AND gate is really a NAND followed by a NOT. NOR is NAND’s mirror image, with the P-types in a row and the N-types side by side, and OR is a NOR followed by a NOT. When designers count transistors, NAND and NOR come out cheapest, and that is one reason they are so often the building block of choice. Part 9 builds every other gate from NANDs alone.
You can build AND and OR from the switches alone. The buttons are the switches; the LED is the output.
- In a row. Button A across the channel in columns 5 and 7, with a5 wired to the + rail. Button B in columns 9 and 11. A yellow wire from i7 to i9 carries A’s output to B. The 330 Ω goes from h11 to h15, the LED from i15 (long leg) to i16, and a black wire from j16 to the − rail.
- Side by side. Rebuild with B in columns 11 and 13, and a11 also wired to the + rail. A yellow wire from j7 to j13 joins the two outputs, the 330 Ω goes from h13 to h16, the LED from i16 to i17, and a black wire from j17 to −.
In a row, the LED lights only while both buttons are held. Side by side, it lights while either button is held, or both. No chip, no power pins: just two switches in two arrangements.
You can now read a circuit of switches as AND and OR. The next part writes those circuits down as algebra, so you can work out a design on paper, simplify it, and build it with fewer gates.
Sources for this part
Transistors and CMOS
- MOSFET – Wikipedia
- CMOS – Wikipedia
- Lessons in Electric Circuits, Volume IV, chapter 3: CMOS gate circuitry (Tony R. Kuphaldt, CC BY)
Switches and logic