---
title: Designing a two-stage op amp
heading: Gain, bandwidth, phase margin, slew rate and the nulling resistor
eyebrow: S2 · Lesson 20 · Designing a two-stage op amp
xp: 50
---

::: hook
The two-stage Miller op amp is the workhorse of CMOS analog design: a differential pair with a mirror load, then a common-source gain stage, with a capacitor across the second stage to split the poles (lesson 13). C6 simulated one at transistor level. This lesson turns it into a design procedure: start from the specifications (gain-bandwidth, phase margin, load capacitance, slew rate), choose the compensation capacitor, size each transistor's transconductance and current by gm/ID, and deal with the right-half-plane zero with a single resistor. Every step is one of the formulas from the last six lessons.
:::

::: play
- The open-loop gain of a two-stage op amp ($g_{m1}$ = 0.2 mS, $g_{m6}$ = 2 mS, $C_L$ = 5 pF, DC gain 5000) on a Bode plot, with compensation capacitor $C_c$ and a nulling resistor $R_z$ in series with it.
- With $R_z$ = 0 the right-half-plane zero at $g_{m6}/C_c$ adds phase lag. At $R_z = 1/g_{m6}$ = 0.5 kΩ the zero goes to infinity. Larger still, it becomes a left-half-plane zero that adds phase lead.
- Raise $C_c$: the unity-gain frequency falls and the phase margin improves. The readout estimates the phase margin from the poles and the zero.
:::
:::

```sim plot
view: bode
x: f = 100..1G Hz log
slider: Cc = 0.3..5 = 1 pF log
slider: Rz = 0..4 step 0.05 = 0 kΩ
H: 5000*(1 - j*2*pi*f*Cc*1e-12*(500 - Rz*1e3))/((1 + j*2*pi*f*5000*Cc*1e-12/0.2e-3)*(1 + j*2*pi*f*5e-12/2e-3))
readout: unity-gain frequency, MHz = 0.2e-3/(2*pi*Cc*1e-12)/1e6
readout: phase margin estimate, degrees = 90 - atan((0.2e-3/(Cc*1e-12))/(2e-3/5e-12))*180/pi - atan((0.2e-3/(Cc*1e-12))*Cc*1e-12*(500 - Rz*1e3))*180/pi
readout: slew rate with a 50 µA tail, V/µs = 50e-6/(Cc*1e-12)/1e6
```

::: predict
## A two-stage op amp's right-half-plane zero costs it phase margin. What value of the resistor in series with $C_c$ removes the zero?

- [ ] Zero ohms
- [x] $1/g_{m6}$, the second stage's inverse transconductance
- [ ] The second stage's output resistance
- [ ] Any large value

::: reveal
$R_z = 1/g_{m6}$. The zero comes from current flowing forward through $C_c$, cancelling the second stage's $g_{m6}v$. With $R_z$ in series the zero moves to $s = \frac{1}{C_c(1/g_{m6} - R_z)}$, which goes to infinity at $R_z = 1/g_{m6}$ and into the left half plane for larger $R_z$. A common choice puts the left-half-plane zero right on top of the second pole, $R_z = \frac{1 + C_L/C_c}{g_{m6}}$, cancelling it, so the third pole sets the margin.
:::
:::

::: nameit
## The small-signal design equations

With the first stage $g_{m1}$ into resistance $R_1 = r_{o2} \parallel r_{o4}$, the second stage $g_{m6}$ into $R_2 = r_{o6} \parallel r_{o7}$ and load $C_L$:

- DC gain $A_0 = g_{m1}R_1 \cdot g_{m6}R_2 = \frac{(g_m/I_D)_1}{2\lambda}\cdot\frac{(g_m/I_D)_6}{2\lambda}$ with equal λ.
- Unity-gain frequency $\omega_u = \frac{g_{m1}}{C_c}$.
- Second pole $p_2 \approx \frac{g_{m6}}{C_L}$ (for $C_c$ larger than the internal node's capacitance).
- Zero $z = \frac{1}{C_c(1/g_{m6} - R_z)}$: right half plane for $R_z < 1/g_{m6}$.
- Phase margin $\approx 90° - \arctan\frac{\omega_u}{p_2} - \arctan\frac{\omega_u}{z}$ (the zero's term changes sign when it moves to the left half plane).

## Slew rate

On a large step the input pair switches fully and its whole tail current charges $C_c$: $SR = \frac{I_\text{tail}}{C_c}$. The output stage must also supply $C_L$: $SR \leq \frac{I_6}{C_L + C_c}$.

## A procedure

1. From $C_L$ and the phase margin, pick $p_2 = k\omega_u$ (k ≈ 2 to 3 for 60° to 70°), which sets $g_{m6} = k g_{m1}\frac{C_L}{C_c}$.
2. Pick $C_c$ (often 0.2 to 0.5 times $C_L$), then $g_{m1} = 2\pi\,\text{GBW}\,C_c$.
3. Choose $g_m/I_D$ for each transistor (high for the input pair, for gain and low noise; moderate for the output) and get the currents.
4. Check slew rate, swing, gain and noise; iterate.
5. Choose $R_z$: at least $1/g_{m6}$, or $(1 + C_L/C_c)/g_{m6}$ to cancel $p_2$.
6. Size the mirror and output transistors so their current densities match, avoiding systematic offset.
:::

::: example
## Design for GBW = 30 MHz into $C_L$ = 5 pF with $p_2$ = 2.2 GBW. Take $C_c$ = 2 pF, $g_m/I_D$ = 15 /V for the input pair and 10 /V for the output, and λ = 0.1 V⁻¹.

::: solution
1. **Input transconductance.**
   $$\begin{aligned} g_{m1} &= 2\pi \times 30\ \text{MHz} \times 2\ \text{pF} \\ &= 0.377\ \text{mS} \end{aligned}$$
2. **Input current.** Each input transistor carries
   $$\frac{0.377\ \text{mS}}{15\ \text{/V}} = 25\ \text{µA}$$
   (tail 50 µA).
3. **Output transconductance.**
   $$\begin{aligned} g_{m6} &= 2.2 \times 2\pi \times 30\ \text{MHz} \\ &\quad \times 5\ \text{pF} \\ &= 2.07\ \text{mS} \end{aligned}$$
4. **Output current.**
   $$\frac{2.07\ \text{mS}}{10\ \text{/V}} = 207\ \text{µA}$$
5. **Gain.**
   $$\begin{aligned} A_0 &= \frac{15}{0.2} \times \frac{10}{0.2} \\ &= 75 \times 50 \\ &= 3750 \end{aligned}$$
   or 71.5 dB.
6. **Slew rate.** The input stage gives
   $$\frac{50\ \text{µA}}{2\ \text{pF}} = 25\ \text{V/µs}$$
7. **The output stage's limit.** It can supply
   $$\frac{207\ \text{µA}}{7\ \text{pF}} = 30\ \text{V/µs}$$
   so the input stage limits the slew rate.

**Answer:** 25 µA in each input transistor (50 µA tail) and 207 µA in the output stage, a gain of 3750 (71.5 dB), and a slew rate of 25 V/µs set by the input stage.
:::
:::

::: example
## For the op amp in the sim with $C_c$ = 1 pF, find the phase margin with $R_z$ = 0, with $R_z = 1/g_{m6}$, and the $R_z$ that cancels the second pole.

::: solution
1. **Unity-gain frequency and second pole.** $\omega_u/2\pi$ = 31.8 MHz and $p_2/2\pi$ = 63.7 MHz.
2. **With $R_z$ = 0.** The zero is at $g_{m6}/C_c$ (318 MHz), so
   $$\begin{aligned} \text{PM} &\approx 90 - 26.6 - 5.7 \\ &= 58° \end{aligned}$$
3. **With $R_z$ = 500 Ω.** The zero is gone and PM ≈ 63°.
4. **Cancelling $p_2$.** That needs
   $$\begin{aligned} R_z &= \frac{1 + 5}{2\ \text{mS}} \\ &= 3\ \text{k}\Omega \end{aligned}$$
   then the margin is set by the next, higher pole and approaches 90° in this two-pole model.

**Answer:** about 58° of phase margin with $R_z$ = 0 and 63° with $R_z = 1/g_{m6}$ = 500 Ω; $R_z$ = 3 kΩ cancels the second pole.
:::
:::

::: example
## The two-stage op amp's input stage tail current is 50 µA, and $C_c$ = 1 pF. What is its slew rate, and how long does a 1 V step take to slew?

::: solution
1. **Slew rate.** The tail current is all that can charge $C_c$:
   $$\begin{aligned} SR &= \frac{I_\text{tail}}{C_c} \\ &= 50\ \text{V/µs} \end{aligned}$$
2. **Slewing a 1 V step.** This comes before the linear settling even starts:
   $$\frac{1\ \text{V}}{50\ \text{V/µs}} = 20\ \text{ns}$$
3. **What helps.** Raising GBW by raising $g_m/I_D$ doesn't help slewing; only more current per $C_c$ does.

**Answer:** the slew rate is 50 V/µs, so a 1 V step takes 20 ns to slew.
:::
:::

::: check
given: g = 0.1 | 0.5 | 2; C = 0.5 | 2 | 5
answer: g*1e-3/(2*pi*C*1e-12)/1e6
unit: MHz
tolerance: 1%

## A two-stage op amp has $g_{m1}$ = {g} mS and $C_c$ = {C} pF. What's its gain-bandwidth?

::: right
Right. $\frac{g_{m1}}{2\pi C_c}$ = {answer} MHz.
:::

::: misses
- [g*1e-3/(C*1e-12)/1e6] Divide by 2π.
- [any] Not yet. The input pair's current into $C_c$.
:::
:::

::: check
given: g = 1 | 3 | 10; L = 2 | 10
answer: g*1e-3/(2*pi*L*1e-12)/1e6
unit: MHz
tolerance: 1%

## The output stage has $g_{m6}$ = {g} mS and drives {L} pF. Where's the second pole?

::: right
Right. $\frac{g_{m6}}{2\pi C_L}$ = {answer} MHz.
:::

::: misses
- [any] Not yet. With $C_c$ shorting at high frequency, the output sees $1/g_{m6}$.
:::
:::

::: check
given: g = 1 | 4; C = 0.5 | 2; R = 0.05 | 0.1 | 0.2
answer: 1/(2*pi*C*1e-12*(1/(g*1e-3) - R*1e3))/1e6
unit: MHz
tolerance: 1%

## A Miller op amp has $g_{m6}$ = {g} mS, $C_c$ = {C} pF and $R_z$ = {R} kΩ. Where's the right-half-plane zero?

::: right
Right. $\frac{1}{2\pi C_c(1/g_{m6} - R_z)}$ = {answer} MHz.
:::

::: misses
- [g*1e-3/(2*pi*C*1e-12)/1e6] That's without $R_z$; the resistor moves the zero up.
- [any] Not yet. Include $R_z$ in series with $C_c$.
:::
:::

::: check
given: g = 1 | 3; L = 3 | 10; C = 1 | 2
answer: (1 + L/C)/(g*1e-3)/1000
unit: kΩ
tolerance: 1%

## What nulling resistor puts the zero on the second pole, for $g_{m6}$ = {g} mS, $C_L$ = {L} pF and $C_c$ = {C} pF?

::: right
Right. $\frac{1 + C_L/C_c}{g_{m6}}$ = {answer} kΩ.
:::

::: misses
- [1/(g*1e-3)/1000] That only removes the zero; cancelling $p_2$ needs more.
- [any] Not yet. Set $\frac{1}{C_c(R_z - 1/g_{m6})} = \frac{g_{m6}}{C_L}$.
:::
:::

::: check
given: I = 20 | 100 | 400; C = 0.5 | 2 | 5
answer: I*1e-6/(C*1e-12)/1e6
unit: V/µs
tolerance: 1%

## A two-stage op amp's input pair has a {I} µA tail and $C_c$ = {C} pF. What's its slew rate?

::: right
Right. $\frac{I_\text{tail}}{C_c}$ = {answer} V/µs.
:::

::: misses
- [I/2*1e-6/(C*1e-12)/1e6] The whole tail switches to one side on a large step.
- [any] Not yet. The tail current charges $C_c$.
:::
:::

::: check
given: a = 10 | 20; b = 6 | 12; l = 0.05 | 0.2
answer: a/(2*l)*b/(2*l)
tolerance: 1%

## The input pair runs at $g_m/I_D$ = {a} /V and the output at {b} /V, every transistor with λ = {l} V⁻¹. What's the DC gain?

::: right
Right. $\frac{(g_m/I_D)_1}{2\lambda}\cdot\frac{(g_m/I_D)_6}{2\lambda}$ = {answer}.
:::

::: misses
- [a/l*b/l] Each stage's load is two equal $r_o$ in parallel: halve each.
- [any] Not yet. Each stage's gain is $g_mr_o/2$.
:::
:::

::: check
given: k = 1.5 | 2.2 | 3; g = 0.2 | 0.5; L = 2 | 8; C = 1 | 3
answer: k*g*L/C
unit: mS
tolerance: 1%

## For $p_2$ = {k} times the unity-gain frequency, with $g_{m1}$ = {g} mS, $C_L$ = {L} pF and $C_c$ = {C} pF, what $g_{m6}$ is needed?

::: right
Right. $g_{m6} = kg_{m1}\frac{C_L}{C_c}$ = {answer} mS.
:::

::: misses
- [k*g*C/L] Upside down: a bigger load needs more $g_{m6}$.
- [any] Not yet. Set $g_{m6}/C_L = k g_{m1}/C_c$.
:::
:::

::: check
given: u = 20 | 50; p = 60 | 120; z = 200 | 600
answer: 90 - atan(u/p)*180/pi - atan(u/z)*180/pi
unit: °
tolerance: 1%

## An op amp's unity-gain frequency is {u} MHz, its second pole {p} MHz and its right-half-plane zero {z} MHz. Estimate its phase margin.

::: right
Right. $90° - \arctan\frac{\omega_u}{p_2} - \arctan\frac{\omega_u}{z}$ = {answer}°.
:::

::: misses
- [90 - atan(u/p)*180/pi + atan(u/z)*180/pi] A right-half-plane zero subtracts phase, like a pole.
- [any] Not yet. Add the lags of the second pole and the zero.
:::
:::

::: check
kind: parts
given: I = 20 | 50 | 200; C = 0.5 | 1 | 3; e = 10 | 15 | 20

## A two-stage op amp's tail current is {I} µA, its compensation capacitor {C} pF, and its input pair runs at $g_m/I_D$ = {e} /V.

::: part
answer: I*1e-6/(C*1e-12)/1e6
unit: V/µs
tolerance: 0.5%

### What is its slew rate?

::: misses
- [any] $I_\text{tail}/C_c$.
:::
:::

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

### What is its gain-bandwidth product?

::: misses
- [e*I*1e-6/(2*pi*C*1e-12)/1e6] Each input device carries half the tail.
- [any] $g_{m1}/(2\pi C_c)$.
:::
:::
:::

::: check
kind: derivation
vars: I = 1e-6..1e-3, C = 1e-13..1e-11, e = 5..25

## A two-stage op amp has tail current I, compensation capacitor C, and input pair $g_m/I_D$ = e.

::: step
answer: I/C

### What is its slew rate?
:::

::: step
answer: e*I/(2*C)

### What is its unity-gain frequency (rad/s)?
:::

::: step
answer: 2/e

### What ratio of slew rate to unity-gain frequency results (in volts)?
:::

::: right
Right. The ratio $SR/\omega_u = 2/(g_m/I_D) = V_{ov}$: a high $g_m/I_D$ input pair is quiet and efficient but slews poorly for its bandwidth.
:::
:::

::: explain
## Why does a resistor in series with the compensation capacitor remove the right-half-plane zero?

::: model
The zero appears at the frequency where current flowing forward through the compensation capacitor, from the second stage's input straight to its output, exactly cancels the current the transistor pulls. Without a resistor, the capacitor's current grows with frequency and catches up with $g_{m6}v$ at $g_{m6}/C_c$. A series resistor limits that forward current: the capacitor's branch now has impedance $R_z + 1/sC_c$, so at high frequency its current levels off at $v/R_z$ instead of growing. If $R_z$ equals $1/g_{m6}$, the forward current can never quite equal the transistor's, and the zero moves to infinity; a larger $R_z$ flips the zero into the left half plane, where it adds phase lead instead of lag.
:::
:::

::: practice

::: check
given: g = 0.3 | 1; C = 1 | 4
answer: g*1e-3/(2*pi*C*1e-12)/1e6
unit: MHz
tolerance: 1%

## GBW: $g_{m1}$ = {g} mS, $C_c$ = {C} pF?

::: misses
- [any] $g_{m1}/2\pi C_c$.
:::
:::

::: check
given: I = 30 | 200; C = 1 | 3
answer: I*1e-6/(C*1e-12)/1e6
unit: V/µs
tolerance: 1%

## Slew rate: {I} µA tail, {C} pF?

::: misses
- [any] $I_\text{tail}/C_c$.
:::
:::

::: check
given: g = 1.5 | 5; L = 4 | 12; C = 1.5 | 3
answer: (1 + L/C)/(g*1e-3)/1000
unit: kΩ
tolerance: 1%

## $R_z$ to cancel $p_2$: {g} mS, $C_L$ = {L}, $C_c$ = {C} pF?

::: misses
- [any] $(1 + C_L/C_c)/g_{m6}$.
:::
:::
:::
