---
title: Rail-to-rail and low-voltage design
heading: Complementary input pairs, constant transconductance and swing to the rails
eyebrow: S2 · Lesson 23 · Rail-to-rail and low-voltage design
xp: 50
---

::: hook
On a 5 V supply an op amp could waste a volt here and there; on 1.2 V every stacked transistor's 0.15 V of saturation headroom and every $V_{GS}$ of half a volt matters. A single NMOS input pair can't accept inputs near ground, a PMOS pair can't accept them near the supply, and a cascoded output can't swing anywhere near the rails. This lesson builds the standard low-voltage answers: put two complementary pairs in parallel so one always works, keep their combined transconductance constant so the loop's bandwidth doesn't wander, and drive the output with common-source devices that swing to within an overdrive of each rail.
:::

::: play
- The curves show the transconductance of an NMOS input pair, a PMOS pair, and their sum, against the input's common-mode voltage on a supply of $V_{DD}$.
- The NMOS pair turns on above about 0.55 V; the PMOS pair works below $V_{DD} - 0.55$ V. In the middle both conduct and the total doubles.
- Lower the supply: the overlap shrinks, and below about 1.1 V a gap opens in the middle where neither pair works.
:::

```sim plot
view: graph
x: v = 0..3.3 V
y: g = 0..2.5
slider: d = 0.9..3.3 step 0.05 = 1.8 V
plot: 1/(1 + exp(-(v - 0.55)/0.03))*step(d - v) | label: NMOS pair
plot: 1/(1 + exp((v - (d - 0.55))/0.03))*step(d - v) | label: PMOS pair
plot: (1/(1 + exp(-(v - 0.55)/0.03)) + 1/(1 + exp((v - (d - 0.55))/0.03)))*step(d - v) | label: total
```

::: predict
## A complementary input stage has both pairs on in the middle of its range and only one near each rail. With no correction, how does its total transconductance vary across the range?

- [ ] It stays constant
- [x] It doubles in the middle
- [ ] It halves in the middle
- [ ] It goes to zero in the middle

::: reveal
Where both pairs conduct, their transconductances add: twice the value near either rail. A feedback amplifier's unity-gain frequency is proportional to $g_m$, so its bandwidth and phase margin would change with the input level. Constant-$g_m$ circuits steer extra current into whichever pair is working alone.
:::
:::

::: nameit
## Input range of one pair

An NMOS pair needs its gate at least $V_{GS} + V_{DS,\text{tail}}$ above ground. At the top, the pair stays saturated only while its gate is no more than $V_T$ above its drain. On low supplies that leaves a window of a few hundred millivolts.

## Complementary pairs

An NMOS and a PMOS pair in parallel cover the whole range if $V_{DD} \ge V_{GS,n} + V_{GS,p} + 2V_{DS,\text{sat}}$ (each needs its tail transistor too). Below that supply a dead zone opens in the middle.

## Constant transconductance

In strong inversion $g_m \propto \sqrt I$. Where only one pair is on, giving it four times its normal current doubles its $g_m$ to match the middle region, where both pairs share. Current switches driven by the common-mode level do the steering (in weak inversion, where $g_m \propto I$, doubling the current suffices).

## Output swing

Common-source output transistors, a PMOS to the supply and an NMOS to ground, can each pull the output to within their own $V_{DS,\text{sat}}$ of a rail: a rail-to-rail output loses only about $2V_{ov}$ of the supply.
:::

::: example
## An NMOS input pair on 1.2 V has $V_{GS}$ = 0.55 V ($V_T$ = 0.4 V), a tail needing 0.15 V, and diode-connected PMOS loads with $|V_{GS}|$ = 0.55 V. What common-mode range does it accept?

::: solution
1. **Bottom of the range.**
   $$0.55 + 0.15 = 0.70\ \text{V}$$
2. **The drains.** The loads hold them at
   $$1.2 - 0.55 = 0.65\ \text{V}$$
3. **Top of the range.** So the gate may rise to
   $$0.65 + 0.40 = 1.05\ \text{V}$$
4. **The window.** A 0.35 V window on a 1.2 V supply: unusable as a follower, which needs the input to track the output across most of the range.

**Answer:** it accepts 0.70 V to 1.05 V, a 0.35 V window.
:::
:::

::: example
## What supply does a complementary input stage need for both pairs to overlap everywhere, with $V_{GS}$ = 0.55 V for each type and 0.15 V per tail?

::: solution
1. **Add up the stack.** Both gate-source voltages and both tails must fit:
   $$\begin{aligned} V_{DD} &= V_{GS,n} + V_{GS,p} \\ &\quad + 2 \times 0.15\ \text{V} \\ &= 1.4\ \text{V} \end{aligned}$$
2. **Below that.** On a lower supply there's a band in the middle where neither pair conducts.
3. **What designers do then.** They switch to a single pair with a charge-pumped tail, or bulk-driven or subthreshold inputs.

**Answer:** a 1.4 V supply.
:::
:::

::: example
## A rail-to-rail output stage's common-source transistors need 0.1 V each to stay saturated. How much of a 1.2 V supply can its output swing over, and how does that compare with a cascoded class-A output?

::: solution
1. **Rail-to-rail output.** From 0.1 V to 1.1 V:
   $$\frac{1.1 - 0.1}{1.2} = 83\%$$
   of the supply.
2. **Cascoded class-A output.** With two saturated devices on each side it needs about 0.3 V at each end:
   $$1.2 - 2 \times 0.3 = 0.6\ \text{V}$$
   half the supply.
3. **What follows.** That's why low-voltage op amps finish with a common-source class-AB stage.

**Answer:** the output swings over 1.0 V, 83% of the supply, against 0.6 V (half the supply) for a cascoded class-A output.
:::
:::

::: check
kind: parts
given: V = 1 | 1.2 | 1.8; g = 0.5 | 0.6; t = 0.1 | 0.2; T = 0.35 | 0.45

## An NMOS input pair on {V} V has $V_{GS}$ = {g} V ($V_T$ = {T} V) and a tail needing {t} V; its diode-connected PMOS loads drop {g} V.

::: part
answer: g + t
unit: V
tolerance: 0.5%

### What is the lowest common-mode input it accepts?

::: misses
- [any] $V_{GS} + V_{DS,\text{tail}}$.
:::
:::

::: part
answer: V - g + T
unit: V
tolerance: 0.5%

### What is the highest?

::: misses
- [V - g] The gate may sit $V_T$ above the drain.
- [any] Drain voltage + $V_T$.
:::
:::
:::

::: check
kind: parts
given: n = 0.5 | 0.6; p = 0.5 | 0.7; t = 0.1 | 0.2

## A complementary input stage has $V_{GS,n}$ = {n} V, $|V_{GS,p}|$ = {p} V, and tails needing {t} V each.

::: part
answer: n + p + 2*t
unit: V
tolerance: 0.5%

### What is the lowest supply on which the pairs overlap everywhere?

::: misses
- [n + p] Each pair's tail needs headroom too.
- [any] $V_{GS,n} + |V_{GS,p}| + 2V_{DS,\text{sat}}$.
:::
:::

::: part
answer: n + p + 2*t - 1
unit: V
tolerance: 1%

### How wide is the dead zone on a 1 V supply (negative means none)?

::: misses
- [any] Minimum supply less 1 V.
:::
:::
:::

::: check
kind: parts
given: k = 2 | 4 | 9; r = 2 | 4

## In strong inversion $g_m \propto \sqrt I$. A pair carries {k} times its nominal current where it works alone.

::: part
answer: sqrt(k)
tolerance: 0.5%

### By what factor does its $g_m$ rise?

::: misses
- [k] $g_m$ goes as the square root of current here.
- [any] $\sqrt k$.
:::
:::

::: part
answer: r^2
tolerance: 0.5%

### What current factor would raise its $g_m$ by {r}?

::: misses
- [any] The square.
:::
:::
:::

::: check
kind: parts
given: V = 0.9 | 1.2 | 1.8; o = 0.05 | 0.1 | 0.15

## A rail-to-rail output on {V} V uses common-source devices needing {o} V each.

::: part
answer: V - 2*o
unit: V
tolerance: 0.5%

### What swing can it reach?

::: misses
- [any] Supply less two saturation voltages.
:::
:::

::: part
answer: (V - 2*o)/V*100
unit: %
tolerance: 0.5%

### What share of the supply is that?

::: misses
- [any] Swing ÷ supply.
:::
:::
:::

::: check
kind: parts
given: g = 1 | 2; f = 10 | 50; C = 1 | 2

## A complementary input stage's single-pair $g_m$ is {g} mS, compensated by {C} pF; without constant-$g_m$ correction both pairs add in the middle.

::: part
answer: g*1e-3/(2*pi*C*1e-12)/1e6
unit: MHz
tolerance: 0.5%

### What unity-gain frequency does it have near a rail?

::: misses
- [any] $g_m/(2\pi C_c)$.
:::
:::

::: part
answer: 2*g*1e-3/(2*pi*C*1e-12)/1e6
unit: MHz
tolerance: 0.5%

### And in the middle of the range?

::: misses
- [any] Twice: both pairs contribute.
:::
:::
:::

::: check
kind: match

## Match each low-voltage problem to its usual fix.

- Inputs near the supply rail can't reach an NMOS pair :: a PMOS pair in parallel
- The total $g_m$ doubles where both pairs conduct :: current steering that quadruples a lone pair's current
- A cascoded output can't swing near the rails :: common-source class-AB output devices
- Too little headroom for a $V_{GS}$ plus a tail :: subthreshold or bulk-driven inputs
- [extra] a larger compensation capacitor

::: misses
- [any] Each fix targets the headroom or the $g_m$ problem it names.
:::
:::

::: check
kind: derivation
vars: n = 0.3..0.8, p = 0.3..0.8, t = 0.05..0.3, V = 0.8..3.3

## A complementary pair stage has $V_{GS,n}$ = n, $|V_{GS,p}|$ = p, tails needing t each, on supply V.

::: step
answer: n + t

### Above what common-mode voltage does the NMOS pair work?
:::

::: step
answer: V - p - t

### Below what voltage does the PMOS pair work?
:::

::: step
answer: V - p - t - (n + t)

### How wide is the region where both work (negative is a dead zone)?
:::

::: right
Right. The overlap is the supply less both gate-source voltages and both tails.
:::
:::

::: check
kind: python

## Write `gm_total(vcm, vdd, vgs_n=0.55, vgs_p=0.55, w=0.03, const_gm=False)`: the input stage's total $g_m$ (normalized so one pair alone gives 1) at common-mode vcm, with each pair turning on smoothly as $1/(1 + e^{-x/w})$ past its threshold. With `const_gm`, a pair working alone gets four times the current (so $\sqrt4 = 2$ times the $g_m$): scale each pair's $g_m$ by $\sqrt{1 + 3(1 - s_\text{other})}$ where $s_\text{other}$ is the other pair's on-fraction. Then `gm_ratio(vdd, const_gm)`: max over min of the total across 0.1 V to vdd − 0.1 V in 1 mV steps.

```python starter
import math

def gm_total(vcm, vdd, vgs_n=0.55, vgs_p=0.55, w=0.03, const_gm=False):
    return 1.0

def gm_ratio(vdd, const_gm):
    return 1.0
```

```python solution
import math

def gm_total(vcm, vdd, vgs_n=0.55, vgs_p=0.55, w=0.03, const_gm=False):
    sn = 1 / (1 + math.exp(-(vcm - vgs_n) / w))
    sp = 1 / (1 + math.exp((vcm - (vdd - vgs_p)) / w))
    if not const_gm:
        return sn + sp
    return sn * math.sqrt(1 + 3 * (1 - sp)) + sp * math.sqrt(1 + 3 * (1 - sn))

def gm_ratio(vdd, const_gm):
    vals = []
    v = 0.1
    while v <= vdd - 0.1 + 1e-12:
        vals.append(gm_total(v, vdd, const_gm=const_gm))
        v += 0.001
    return max(vals) / min(vals)
```

```python tests
r0 = gm_ratio(1.8, False)
assert 1.9 < r0 < 2.01, "Uncorrected: the total nearly doubles in the middle."
r1 = gm_ratio(1.8, True)
assert r1 < 1.3, "With current steering the variation falls to under 30%."
assert abs(gm_total(0.9, 1.8) - 2) < 0.01, "In the middle both pairs give 1 each."
```

::: right
Right. The steering law keeps the sum nearly flat; the residual bumps come from the transition regions, where neither the square law nor the weak-inversion law holds exactly.
:::
:::

::: explain
## Why does an op amp's unity-gain frequency vary with input common-mode voltage in a simple complementary input stage, and why does that matter?

::: model
The unity-gain frequency of a compensated op amp is the input stage's transconductance divided by the compensation capacitance. In a complementary stage, only one pair conducts near each rail, but both conduct in the middle, so the total transconductance there is about twice as large. The bandwidth therefore doubles in the middle of the range, and since the compensation was designed for one value, the phase margin shrinks where $g_m$ is high and the response becomes slower than necessary where it's low. Keeping $g_m$ constant, by steering more current into a pair when it works alone, keeps the loop's dynamics the same whatever the input level.
:::
:::

::: practice
::: check
given: V = 1.2 | 3.3; g = 0.6 | 0.8; t = 0.15
answer: g + t
unit: V
tolerance: 0.5%

## Lowest input for an NMOS pair with $V_{GS}$ = {g} V and a {t} V tail?

::: misses
- [any] $V_{GS} + V_{DS,\text{tail}}$.
:::
:::

::: check
given: n = 0.45 | 0.6; p = 0.5 | 0.65
answer: n + p + 0.3
unit: V
tolerance: 0.5%

## Minimum supply for full overlap, tails 0.15 V each, $V_{GS}$ {n} and {p} V?

::: misses
- [any] Sum plus both tails.
:::
:::

::: check
given: V = 1 | 1.5; o = 0.08 | 0.12
answer: V - 2*o
unit: V
tolerance: 0.5%

## Rail-to-rail output swing on {V} V with {o} V per device?

::: misses
- [any] $V_{DD} - 2V_{ov}$.
:::
:::
:::
