The two-stage op-amp

Add a common-source stage after a five-transistor OTA, measure the gain of each stage and of the whole, find which input is now +, and size the second stage so the output sits where it should.

Lesson
E5.5
Time
30 min
Runs on
ngspice
Check
5 questions

An audio DAC needed an output buffer with a gain error under 0.01 %. A buffer built from one five-transistor OTA (E5.3) measured 0.89 %. The designer added a second gain stage and reached 0.006 %, then watched the new buffer ring on a step: two stages bring two poles, and that is E6.

DC sweepBuffer error of one stage and of two stagesBoth buffers share one bias and follow the same input. The error is vout − vin.
  • one stage
  • two stages
-5 mV-4 mV-3 mV-2 mV-1 mV0Error0.80 V0.85 V0.90 V0.95 V1.00 V1.05 V1.10 VInputslope read at 0.9 V-5 mV-4 mV-3 mV-2 mV-1 mV0Error0.8 V0.9 V1.0 V1.1 VInputslope read at 0.9 V
  1. Input 800 mVone stage = -1.279 mV · two stages = -176.9 µV

    At 0.8 V the one-stage buffer is 1.279 mV low; the two-stage buffer is 0.177 mV low.

  2. Input 900 mVone stage = -2.166 mV · two stages = -131.8 µV

    The slope of vout against vin is 0.99106 for one stage, a gain error of 0.89 %, and 1.000058 for two stages.

  3. Input 1.1 Vone stage = -4.277 mV · two stages = -197.8 µV

    At 1.1 V the one-stage error has grown to 4.277 mV. The two-stage error is 0.198 mV: it barely moves.

Read the plot as a table
Inputone stagetwo stages
800 mV-1.279 mV-176.9 µV
850 mV-1.724 mV-141.6 µV
900 mV-2.166 mV-131.8 µV
950 mV-2.624 mV-133.3 µV
1 V-3.114 mV-142.5 µV
1.05 V-3.654 mV-161.2 µV
1.1 V-4.277 mV-197.8 µV

Every point is from a run on ngspice 42 (151 points), SKY130 tt, 27 °C.

A follower's gain error, the shortfall of its slope from 1, is about 1/A, so a hundredfold smaller error needs a hundredfold more gain.

Two stages, two jobs

One stage with a cascode could raise the gain, but on a 1.8 V supply the stacked devices leave little room for the output to swing. The two-stage op-amp splits the jobs between two simpler stages. Stage one is the OTA of E5.3: it takes the differential input and gives gain. Stage two is a common-source stage: more gain, and an output that can swing close to both rails (E5.6).

OPA-B, the two-stage op-ampStage one is OTA-A with its output renamed o1. M6 and M7 form the second stage. Cc and Rz connect o1 to out.
OPA-B, the two-stage op-ampVDD1.8 VIB20 µAMB8/1M38/1M48/1M110/1M210/1M58/1M632/1M716/1Rz​5 kΩCc​1 pFCL​2 pF− inn+ inpoutx0.618 Vo10.603 Vtail0.204 Vout0.900 V
  1. Stage one

    M1-M5 are the OTA of E5.3. M5 sinks 18.67 µA from the tail, and the mirror M3-M4 turns the pair's current difference into a voltage at o1. Its gain is A1 = gm2/(gds2 + gds4).

    ISS = 18.67 µA

  2. Stage two

    M6 is a PMOS common-source stage driven by o1. M7, on the bias line, sinks 40.87 µA. Its gain is A2 = gm6/(gds6 + gds7).

    I7 = 40.87 µA

  3. The inputs swap

    Raise M2's gate: M2 pulls more current, o1 falls, M6 turns on harder and out rises. M2's gate is now the + input. Stage two inverts, so M1's gate becomes −.

  4. Compensation

    Cc in series with Rz links o1 to out. It makes the closed loop stable; E6.4 explains how. This lesson uses it as given.

Read the circuit as text
  • IB current source (20 µA): + → VDD, − → n1
  • MB NMOS transistor (8/1): gate → n1, drain → n1, source → 0
  • M3 PMOS transistor (8/1): gate → x, source → VDD, drain → x
  • M4 PMOS transistor (8/1): gate → x, source → VDD, drain → o1
  • M1 NMOS transistor (10/1): gate → n2, drain → x, source → tail
  • M2 NMOS transistor (10/1): gate → n3, drain → o1, source → tail
  • M5 NMOS transistor (8/1): gate → n1, drain → tail, source → 0
  • M6 PMOS transistor (32/1): gate → o1, source → VDD, drain → out
  • M7 NMOS transistor (16/1): gate → n1, drain → out, source → 0
  • R_z resistor (5 kΩ): pin 1 → o1, pin 2 → n4
  • C_c capacitor (1 pF): pin 1 → n4, pin 2 → out
  • C_L capacitor (2 pF): pin 1 → out, pin 2 → 0
  • − inn port: terminal → n2
  • + inp port: terminal → n3
  • out port: terminal → out
  • x = 0.618 V
  • o1 = 0.603 V
  • tail = 0.204 V
  • out = 0.900 V

W/L in µm. Bodies: NMOS to ground, PMOS to VDD. Node voltages are the lab's operating point.

Each stage is a transconductance driving a resistance: stage one is gm2 into ro2 ∥ ro4, and stage two is gm6 into ro6 ∥ ro7. With g = 1/ro (the output conductance gds), the DC gain is the product A0 = A1·A2. The lab reads every gm and gds from the operating point.

StageFormulaFrom the operating pointIn dB
One (M2, M4)gm2/(gds2 + gds4)114.141.14 dB
Two (M6, M7)gm6/(gds6 + gds7)96.7339.71 dB
ProductA1·A211 03380.85 dB
AC run at 1 Hz80.84 dB

The lab netlist; the product of the formulas lands within 0.02 dB of the simulated gain.

A Bode plot draws gain in dB and phase against frequency on a log axis, and the open-loop one shows both numbers at work. Step through it and read each stop.

AC analysisOPA-B open loop, gain and phaseThe lab netlist: 1 V of AC on the + input, the loop open for AC through the 1 TH inductor.
  • gain
  • phase
-100 dB-50 dB050 dB100 dBGain-360°-270°-180°-90°0Phase1 Hz100 Hz10 kHz1 MHz100 MHzFrequency0 dBgain −3 dBunity gain-100 dB-50 dB050 dB100 dBGain-360°-270°-180°-90°0Phase1 Hz1 kHz1 MHz1 GHzFrequency0 dBgain −3 dBunity gain
  1. Frequency 1 Hzgain = 80.84 dB · phase = -0.02495°

    At 1 Hz the gain is 80.84 dB, eleven thousand times, and the phase is 0°: + in, same sign out.

  2. Frequency 2.291 kHzgain = 77.84 dB · phase = -44.94°

    The gain is 3 dB down at 2.291 kHz. Here the phase has fallen by about 45°: one pole, set by Cc at o1.

  3. Frequency 21.45 MHzgain = -0.01695 dB · phase = -120°

    The gain crosses 0 dB at 21.45 MHz, the unity-gain frequency fu. The phase there is −119.9°, which leaves 60.1° before −180°. E6.2 calls that the phase margin.

Read the plot as a table
Frequencygainphase
1 Hz80.84 dB-0.02495°
10 Hz80.84 dB-0.2495°
100 Hz80.83 dB-2.493°
1 kHz80.09 dB-23.53°
2.291 kHz77.84 dB-44.94°
10 kHz67.84 dB-77.08°
100 kHz48.06 dB-88.85°
1 MHz28.06 dB-91.5°
10 MHz7.681 dB-105.7°
21.45 MHz-0.01695 dB-120°
100 MHz-18.89 dB-161.6°
1 GHz-48.96 dB-278.3°

Every point is from a run of the lab netlist on ngspice 42 (181 points).

Cc is what keeps that phase above −180° near fu. Shrink it to 1 aF and the gain crosses 0 dB at 66.27 MHz with the phase at −194.9°: a buffer made of that op-amp would oscillate. E6.4 explains why.

Where stage one's output must sit

Stage two decides the voltage at o1. M7 sinks a fixed current, so o1 must settle at the VSG that makes M6 carry exactly that current. Stage one works without error only when o1 sits where node x sits. Then M1 and M2, and M3 and M4, see the same drain voltages and carry the same currents.

M6 sits on the same supply as M4 and is driven from M4's drain. Give M6 the same current per unit W/L as M4 and its VSG equals M4's, which equals M3's, so Vo1 = Vx. M4 carries half of M5's current and M7 copies M5 by width, so the sizing rule is (W/L)6/(W/L)4 = 2(W/L)7/(W/L)5. OPA-B keeps it: 32/8 = 2 × 16/8.

Any gap between o1 and x shows up at the input divided by stage one's gain: Vos ≈ (Vo1 − Vx)/A1. The input offset Vos is vout − vin of the buffer. The lab measures Vo1 = 0.6030 V and Vx = 0.6182 V, so −15.2 mV/114.1 = −0.133 mV, against −0.132 mV measured.

DC sweepBuffer offset for four widths of M6OPA-B as a unity-gain buffer, M7 fixed at 16/1. Only 32/1 follows the sizing rule.
  • M6 16/1
  • M6 24/1
  • M6 32/1
  • M6 48/1
-14 mV-12 mV-10 mV-8 mV-6 mV-4 mV-2 mV02 mVOffset0.85 V0.90 V0.95 V1.00 V1.05 V1.10 V1.15 V1.20 VInputzero offset-15 mV-10 mV-5 mV05 mVOffset0.9 V1.0 V1.1 V1.2 VInputzero offset
  1. Input 900 mVM6 16/1 = -909.5 µV · M6 24/1 = -412.7 µV · M6 32/1 = -131.8 µV · M6 48/1 = 198.5 µV

    At 0.9 V: −0.910 mV for 16/1, −0.413 mV for 24/1, −0.132 mV for 32/1 and +0.198 mV for 48/1. Narrow M6 needs more VSG, so o1 sits low and the offset is negative.

  2. Input 1.2 VM6 16/1 = -12.65 mV · M6 24/1 = -2.529 mV · M6 32/1 = -523.1 µV · M6 48/1 = 704 µV

    At 1.2 V the 16/1 buffer is 12.65 mV off. Its o1 already sat 98 mV below x at 0.9 V. Since o1 is M2's drain, M2 runs out of VDS sooner as the input rises: a broken rule also shortens the input range.

Read the plot as a table
InputM6 16/1M6 24/1M6 32/1M6 48/1
850 mV-860.8 µV-404.9 µV-141.6 µV171.6 µV
900 mV-909.5 µV-412.7 µV-131.8 µV198.5 µV
950 mV-998.3 µV-439.2 µV-133.3 µV220 µV
1 V-1.152 mV-486.5 µV-142.5 µV243.9 µV
1.05 V-1.448 mV-570 µV-161.2 µV276.7 µV
1.1 V-2.159 mV-735.8 µV-197.8 µV330.2 µV
1.15 V-4.474 mV-1.146 mV-280.2 µV435.5 µV
1.2 V-12.65 mV-2.529 mV-523.1 µV704 µV

Every point is from a run on ngspice 42 (71 points).

M6Vo1 − Vx(Vo1 − Vx)/114.1Measured offset
16/1−97.7 mV−0.857 mV−0.910 mV
24/1−46.5 mV−0.408 mV−0.413 mV
32/1 (rule)−15.2 mV−0.133 mV−0.132 mV
48/1+23.4 mV+0.205 mV+0.198 mV

The same four buffers at 0.9 V. A1 changes a little with Vo1, so the far rows drift from the estimate.

The rule is a first-order estimate, and the simulator says how far it is off. The zero sits between 32/1 and 48/1 because M7 carries 40.87 µA, 2.19 times M5's 18.67 µA, not 2 times. M7 sits at 0.9 V and M5 at 0.204 V, and channel-length modulation (E2.4) gives the device with more VDS more current. The PMOS side adds to it: M4 has 1.20 V across it and M6 only 0.90 V, so M6 carries less current per W/L than M4 at the same VSG. Both effects call for a wider M6.

M6 too narrow

XM6 out o1 vdd vdd sky130_fd_pr__pfet_01v8 W=24 L=1
XM7 out nb 0 0 sky130_fd_pr__nfet_01v8 W=16 L=1

os24 = -4.127405e-04: o1 sits at 0.572 V, 46.5 mV below x.

M6 sized by the rule

XM6 out o1 vdd vdd sky130_fd_pr__pfet_01v8 W=32 L=1
XM7 out nb 0 0 sky130_fd_pr__nfet_01v8 W=16 L=1

os32 = -1.317833e-04: o1 sits 15.2 mV below x.

Both from the offset figure's run, buffers at 0.9 V. The OTA-A buffer of the hook, whose output is the mirror's output, has −2.17 mV.

Two stages cost current: OPA-B draws 79.54 µA from 1.8 V, or 143 µW, made of 20 µA of bias, 18.67 µA in stage one and 40.87 µA in stage two.

Asked in interviews
  1. Draw a two-stage Miller op-amp and give its DC gain.

    An NMOS pair with a PMOS mirror load, then a PMOS common-source stage with an NMOS current sink, and Cc from the first-stage output to the output. A0 = gm2(ro2 ∥ ro4)·gm6(ro6 ∥ ro7), 80.84 dB here, about 40 dB per stage.

  2. How do you size the second stage for zero systematic offset?

    Make M6 carry the same current per W/L as the mirror device it shares a VSG with: (W/L)6/(W/L)4 = 2(W/L)7/(W/L)5. Then the first-stage output sits at the mirror's diode voltage and both halves see equal drain voltages. Check in simulation: channel-length modulation moves the zero.

  3. Why does a two-stage op-amp need compensation?

    Each high-resistance node makes a pole, and two poles at similar frequencies turn the phase by up to 180° before the gain reaches 1. In a feedback loop that rings or oscillates. Cc splits the poles; Rz moves the zero it creates.

Try it

Run it. op prints nothing; it stores each gm and gds, and meas reads them back through the AC plot as stage gains. offset is vout − vinp at DC, where the inductor ties out to the − input: the buffer's offset. The last two lines repeat the AC run with Cc shrunk to 1 aF.

Now break the rule: set w6=24 and predict the sign of offset before you run. Then set L = 2 for M6 and M7 (keep W/L by doubling W) and watch stage2 rise. E5.6 shows what the longer devices cost in output swing.

SPICEngspice 42 · simulator service
Edit the netlist, then run it
Expected measurements: a0_db = 8.084282e+01 f3db = 2.291347e+03 fu = 2.144906e+07 phase_fu = -1.199171e+02 stage1 = 1.140664e+02 stage1_db = 4.114316e+01 stage2 = 9.673231e+01 stage2_db = 3.971143e+01 product_db = 8.085459e+01 i_supply = 7.954101e-05 id5 = 1.867242e-05 id7 = 4.086858e-05 gm6 = 3.933882e-04 v_x = 6.182035e-01 v_o1 = 6.030093e-01 v_tail = 2.039513e-01 offset = -1.317833e-04 fu_nocc = 6.627249e+07 phase_nocc = -1.948878e+02

Check yourself

Predict the outputOPA-B runs open loop with M2's gate at 0.9 V and M1's gate at the level that balances the output at 0.900 V. The run adds 1 mV to M1's gate and prints the output rounded to a whole volt. Type the line meas prints (format: vout = 1.000000e+00).
* OPA-B open loop: M2's gate at 0.9 V, M1's gate at the balance level plus VSTEP
.lib sky130 tt
VDD vdd 0 1.8
IB vdd nb 20u
XMB nb nb 0 0 sky130_fd_pr__nfet_01v8 W=8 L=1
XM5 tail nb 0 0 sky130_fd_pr__nfet_01v8 W=8 L=1
XM1 x g1 tail 0 sky130_fd_pr__nfet_01v8 W=10 L=1
XM2 o1 g2 tail 0 sky130_fd_pr__nfet_01v8 W=10 L=1
XM3 x x vdd vdd sky130_fd_pr__pfet_01v8 W=8 L=1
XM4 o1 x vdd vdd sky130_fd_pr__pfet_01v8 W=8 L=1
XM6 out o1 vdd vdd sky130_fd_pr__pfet_01v8 W=32 L=1
XM7 out nb 0 0 sky130_fd_pr__nfet_01v8 W=16 L=1
RZ o1 z 5k
CC z out 1p
CL out 0 2p
VG2 g2 0 0.9
VBAL gb 0 0.8998682
VSTEP g1 gb 0
.control
dc VSTEP 0 1m 1m
* the output in volts, rounded to a whole volt
let vr = floor(v(out)+0.5)
meas dc vout FIND vr AT=1m
.endc
.end
ConceptM4 is 8/1 and M5 is 8/1. Which second stage breaks the sizing rule for zero systematic offset?
ConceptIn the five-transistor OTA, M2's gate is the − input. Why is it the + input in OPA-B?
ConceptRead the Bode plot and the stage table: the whole op-amp gives 80.84 dB and stage one gives 41.14 dB. What does stage two give?
ConceptWhy use two stages instead of one stage with cascodes to reach 80 dB on a 1.8 V supply?

Remember

  • A two-stage op-amp puts a common-source stage after an OTA: A0 = gm2(ro2 ∥ ro4)·gm6(ro6 ∥ ro7), 80.84 dB for OPA-B.
  • The second stage inverts, so the + input moves to M2's gate; check the sign with a 1 mV step before trusting any number.
  • Stage two sets the first-stage output: size (W/L)6/(W/L)4 = 2(W/L)7/(W/L)5 so Vo1 = Vx; the offset is about (Vo1 − Vx)/A1.
  • The compensation capacitor Cc keeps the loop stable; E6.4 explains how.