---
title: The CMOS inverter
heading: Two transistors, one always off
eyebrow: C7 · Lesson 7 · The CMOS inverter
xp: 40
---

::: hook
Every gate in a modern chip is built from pairs of MOSFETs: an NMOS that pulls the output down to ground and a PMOS that pulls it up to the supply. In the CMOS inverter, the simplest such gate, one transistor is always off whichever way the input sits, so in a steady state no current flows from supply to ground. That's why a phone's processor, with billions of transistors, can idle on milliwatts. Power is spent mainly when gates switch, charging and discharging the tiny capacitances they drive.

::: play
- A CMOS inverter: the PMOS on top, the NMOS below, gates tied together as the input. Slide the input from 0 to 5 V.
- Watch the current through the NMOS. When is it large, and when is it almost zero?
- Find the input where the output is halfway. Why isn't it exactly 2.5 V?
:::
:::

```sim circuit
VIN in 0 1                                                  @ 0,2 down 3
MP out in vdd pmos VTO=-1 KP=50u W=4u L=1u LAMBDA=0.02      @ 2,2 flip
MN out in 0 nmos VTO=1 KP=100u W=2u L=1u LAMBDA=0.02        @ 2,4
VDD vdd 0 5                                                 @ 6,1 down 4
slider: VIN.amp 0..5
scope: v(in), v(out)
time: 0..1m s
meter: v(in), v(out), i(MN)
```

::: predict
## A CMOS gate in a chip drives 10 fF of wiring and inputs from a 1 V supply, switching a billion times a second (on average one full charge and discharge per cycle). Roughly how much power does it use?

- [ ] 10 W
- [ ] 1 mW
- [x] 10 µW
- [ ] 10 nW

::: reveal
About 10 µW: $P = CV^2f = 10^{-14} \times 1^2 \times 10^9 = 10^{-5}$ W. Each charge takes $CV^2$ from the supply (half stored, half lost in the PMOS), and the discharge dumps the stored half through the NMOS. Multiply by a billion gates and that's 10 kW, which is why real chips switch only a fraction of their gates each cycle and keep cutting the supply voltage: power goes as $V^2$.
:::
:::

::: nameit
## CMOS logic

**The inverter.** Input high: the NMOS conducts and the PMOS is off, so the output is pulled to ground. Input low: the PMOS conducts and the NMOS is off, so the output is pulled to $V_{DD}$. Only while the input passes through the middle are both partly on, letting a brief **short-circuit current** flow.

**Why the PMOS is wider.** Holes are about 2 to 3 times less mobile than electrons (B9.13), so a PMOS needs a wider channel to pull up as strongly as the NMOS pulls down. With matched strengths the switching point sits at $V_{DD}/2$; here the PMOS is a little weaker, so it's below.

**Other gates.** A NAND has two NMOS in series (both must be on to pull down) and two PMOS in parallel; a NOR is the reverse. A k-input gate uses 2k transistors. NAND and NOR are the natural CMOS gates: AND and OR need an inverter after them.

**Power:**

- **dynamic:** $P = \alpha CV_{DD}^2f$, with α the fraction of cycles in which the node switches;
- **static:** leakage through transistors that are "off", which in modern processes is a large share of the total.

**Delay.** A gate's output is an RC: the transistor's on-resistance charging the load capacitance. More load or weaker transistors mean slower gates (lesson 19).
:::


::: example
## An inverter drives 10 fF on a 1.0 V supply, switching with α = 0.5 at 1 GHz. What dynamic power does it use?

::: solution
1. **Dynamic power.**
   $$\begin{aligned} P &= \alpha CV^2f \\ &= 0.5 \times 10\ \text{fF} \times 1^2 \times 10^9 \\ &= 5\ \mu\text{W} \end{aligned}$$
2. **Scale it up.** A billion such nodes would take 5 kW, which is why activity and supply voltage are kept low.

**Answer:** 5 µW.
:::
:::

::: example
## Electrons are about twice as mobile as holes. How wide should an inverter's PMOS be relative to its NMOS for equal rise and fall?

::: solution
1. **Widen the PMOS.** Make it about twice as wide, so its channel conducts as well as the NMOS's.
2. **Set the widths.** With NMOS width 1, PMOS width 2.

**Answer:** about twice as wide as the NMOS.
:::
:::

::: example
## A chip has $10^8$ transistors, each leaking 10 nA when off, on a 0.8 V supply. What does the leakage cost, even with nothing switching?

::: solution
1. **Leakage power.**
   $$\begin{aligned} P &= 10^8 \times 10\ \text{nA} \times 0.8\ \text{V} \\ &= 0.8\ \text{W} \end{aligned}$$
   burned whether or not the chip does anything.
2. **Compare with older processes.** In older processes leakage was negligible; in modern ones it can rival the switching power.
3. **What designers do about it.** That's why idle blocks are both stopped and disconnected from the supply (power gating), and why thresholds can't simply be lowered to make transistors faster.

**Answer:** 0.8 W, even with nothing switching.
:::
:::

::: check
given: C = 1 | 10 | 50; V = 0.8 | 1.2 | 1.5; f = 0.5 | 1 | 3
answer: C*1e-15*V^2*f*1e9*1e6
unit: µW
tolerance: 0.5%

## A node of {C} fF switches every cycle at {f} GHz from a {V} V supply. What dynamic power does it draw?

::: right
Right. $CV^2f$ = {answer}.
:::

::: misses
- [C*1e-15*V*f*1e9*1e6] Power goes as $V^2$.
- [0.5*C*1e-15*V^2*f*1e9*1e6] The supply delivers $CV^2$ per cycle (half is stored, half lost on the way); the stored half is lost on discharge.
- [any] Not yet. $P = CV^2f$.
:::
:::

::: check
given: V1 = 1.2 | 1.8 | 3.3; V2 = 0.8 | 1
answer: (V2/V1)^2
tolerance: 0.5%

## A chip's supply is lowered from {V1} V to {V2} V at the same clock. By what factor does its dynamic power change?

::: right
Right. $(V_2/V_1)^2$ = {answer}.
:::

::: misses
- [V2/V1] Dynamic power goes as $V^2$.
- [any] Not yet. $P \propto V^2$.
:::
:::

::: check
given: k = 2 | 3 | 4
answer: 2*k
tolerance: 0.5%

## How many transistors does a {k}-input CMOS NAND gate use?

::: right
Right. k in series to pull down, k in parallel to pull up: {answer}.
:::

::: misses
- [k] Each input drives one NMOS and one PMOS.
- [2*k + 2] That's a {k}-input AND: a NAND plus an inverter.
- [any] Not yet. Two per input.
:::
:::

::: check
kind: choice

## In a CMOS NAND gate, how are the two NMOS transistors connected?

- [x] In series between the output and ground
- [ ] In parallel between the output and ground
- [ ] In series between the supply and the output
- [ ] One in each direction

::: right
Right. Both must conduct to pull the output low, which happens only when both inputs are 1.
:::

::: misses
- [2] Parallel NMOS would pull low if either input were 1: that's NOR.
- [3] The NMOS pull down; the PMOS sit between the supply and the output.
- [4] They're stacked in series.
:::
:::

::: check
given: I = 1 | 10 | 100; V = 0.8 | 1.2
answer: I*V
unit: mW
tolerance: 0.5%

## A chip leaks {I} mA from its {V} V supply even when idle. How much static power is that?

::: right
Right. $IV$ = {answer}.
:::

::: misses
- [any] Not yet. $P = IV$.
:::
:::

::: check
kind: parts
given: N = 1e7 | 1e8 | 1e9; I = 1 | 10 | 50; V = 0.7 | 1 | 1.2

## A chip has {N} transistors, each leaking {I} nA, on {V} V.

::: part
answer: N*I*1e-9*V
unit: W
tolerance: 0.5%

### What's its leakage power?

::: misses
- [any] $NI_\text{leak}V_{DD}$.
:::
:::

::: part
answer: N*I*1e-9*V/10
unit: W
tolerance: 0.5%

### What if a higher threshold cuts the leakage tenfold?

::: misses
- [any] Leakage scales directly.
:::
:::
:::

::: check
kind: derivation
vars: a = 0.01..1, C = 0.0000000000001..0.000000001, V = 0.5..5, f = 1000..5000000000, I = 0.000001..0.1

## A node with activity a and capacitance C switches at f on a supply V; the chip also leaks a total current I.

::: step
answer: a*C*V^2*f

### What's the node's dynamic power?
:::

::: step
answer: I*V

### What's the leakage power?
:::

::: step
answer: a*C*V^2*f/(a*C*V^2*f + I*V)

### What fraction of the total is dynamic, for one such node?
:::

::: right
Right. Dynamic power falls as $V^2$; leakage falls only as V.
:::
:::

::: explain
## Why does a CMOS inverter draw almost no current when its input is steady?

::: model
The NMOS and PMOS are driven by the same input but turn on at opposite levels. With the input high, the NMOS conducts and the PMOS is off; with it low, the PMOS conducts and the NMOS is off. Either way, one transistor in the path from supply to ground is off, so no steady current can flow, apart from tiny leakage. Current flows mainly while the output is switching, to charge or discharge the capacitance it drives.
:::
:::

::: practice

::: check
given: C = 2 | 20; V = 1 | 2
answer: C*V^2
unit: fJ
tolerance: 0.5%

## Energy drawn from the supply to charge {C} fF to {V} V (one cycle)?

::: misses
- [0.5*C*V^2] That's what's stored; the supply delivers twice it.
- [any] $CV^2$.
:::
:::

::: check
given: k = 1.5 | 2 | 2.5 | 3 | 4
answer: k^2
tolerance: 0.5%

## Supply voltage raised {k}×. Dynamic power factor?

::: misses
- [k] $V^2$.
- [any] $k^2$.
:::
:::

::: check
kind: choice

## Which gate is the most natural (fewest transistors) in CMOS?

- [ ] AND
- [x] NAND
- [ ] XOR
- [ ] OR

::: right
Right. AND and OR need an extra inverter; XOR needs more still.
:::

::: misses
- [1] AND is a NAND plus an inverter.
- [3] XOR takes the most.
- [4] OR is a NOR plus an inverter.
:::
:::
:::
