Watch on Instagram

Circuit Bytes · Episode 50 · Electronics · CMOS logic

"How transistors make a gate"

Chips build gates from two kinds of transistor switch. N-type turns on when its input is high, P-type when it is low. Stack a P-type to 5 V over an N-type to ground, drive both from one input, and you get a NOT gate, the CMOS inverter, which uses almost no power while it waits.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

A transistor is a switch flipped by a voltage

Last episode pictured logic gates as switches and a lamp. Inside a chip, the switches are transistors. The voltage on a transistor's control input (its gate) decides whether current can flow between its other two terminals, so it acts like a switch that a voltage flips instead of a finger. (A transistor can also be partly on, which is how amplifiers work, but logic only uses fully on or fully off.)

Two kinds: N-type and P-type

Logic chips use two kinds of transistor, called MOSFETs, that behave as opposites:

  • An N-type (n-channel) transistor turns on when its input is high and off when it is low.
  • A P-type (p-channel) transistor turns on when its input is low and off when it is high.

On a schematic, the P-type often has a small circle (a "bubble") on its gate, the same "flip it" bubble you saw on the NOT gate symbol.

Stacking them: the CMOS inverter

Put the two in a column between the supply and ground:

  • The P-type sits on top and links the output to 5 V.
  • The N-type sits below and links the output to ground (0 V).
  • One input wire drives both gates at once.

Feed in a 1 (high). The N-type turns on, so the bottom switch closes; the P-type turns off, so the top switch opens. The output is now connected only to ground, so it drops to 0. The input was 1 and the output is 0: the circuit flips its input, which is exactly what a NOT gate does.

Because the pair is made of complementary (opposite) transistors, the design is called CMOS, short for complementary metal-oxide-semiconductor. This circuit is the CMOS inverter.

Why it barely uses power

In either steady state, one switch in the column is open. That means there is never a closed path straight from 5 V to ground, so almost no current flows while the gate just sits there holding its answer. Only a tiny leakage current trickles through. The gate does draw real current for a moment each time it switches, because it has to charge or drain the inputs of the next gates. Billions of gates switching billions of times a second is why fast chips still get warm.

Nearly every digital logic chip, including the processor in your phone, is built from complementary pairs like this one.

Try it yourself

Do some chip math on paper. One CMOS inverter uses 2 transistors. How many transistors would 1,000 inverters need? Now look up how many transistors your phone's processor has (search its name plus "transistor count"; recent phone chips list figures in the billions). If the whole chip were made of inverters, roughly how many could it hold? Real chips mix many kinds of gates, most of them only a few transistors each, so the answer gives you a feel for how many gates are switching inside your phone right now.

Good to know

  • The "switch" picture is a simplification: a MOSFET can also partly conduct, which is how transistor amplifiers work (episode 27). In a logic gate it is driven fully on or fully off.
  • An n-channel MOSFET conducts when its gate is high relative to its source; a p-channel MOSFET conducts when its gate is low.
  • "Almost no current": in a steady state only tiny leakage flows. CMOS draws real current while switching, which is why fast chips get warm.
  • Five volts matches the logic levels from episode 48; modern phone chips run near or below 1 V with the same circuit.
  • "Nearly every chip" means digital logic chips; some analog and power parts use other processes.
  • Battery or low-voltage supplies only; leave wall wiring to a licensed electrician.

Answer to the comment question

Feed a 0 into this NOT gate. Which transistor turns on, the top one or the bottom one? The top one. A 0 is a low input. The top transistor is the P-type, which turns on when its input is low, so its switch closes and connects the output to 5 V. The bottom transistor is the N-type, which needs a high input, so it stays off. The output reads 1: a 0 in gives a 1 out, just as a NOT gate should.

Test your knowledge

Quick quiz: "How transistors make a gate"

4 multiple-choice questions. Pick one answer for each, then check how you did.

1When does an N-type transistor turn on?
2In a CMOS inverter, what does the N-type transistor connect the output to?
3A CMOS inverter gets a 1 at its input. What is the output?
4Why does a CMOS gate use almost no power while it waits?

Sources

Video transcript

How do two transistors make a NOT gate?

A transistor is a switch flipped by a voltage. Chips use two kinds. N-type turns on when its input is high. P-type turns on when it's low.

Stack them. The P-type links the output to five volts; the N-type links it to ground. One input drives both.

Feed in a one. The bottom switch closes, the top one opens, and the output drops to zero.

One switch is always open, so almost no current flows while it waits.

That's a CMOS inverter, and nearly every chip in your phone is built from pairs like it.

Feed a zero into this NOT gate. Which transistor turns on, the top one or the bottom one? Comment your answer below!

That's your byte.

More from Circuit Bytes

All Circuit Bytes lessons