The comparator and its decision time

Measure how long a latched comparator takes to decide, see why that time grows with the logarithm of 1/input, and turn the numbers into a comparator model a mixed-signal bench can trust.

Lesson
E8.1
Time
30 min
Runs on
ngspice
Check
5 questions

A flash ADC passed every functional test, then in the field printed an occasional code far from its neighbours: a sparkle. One comparator had seen an input within microvolts of its threshold and had not finished deciding when the encoder read it.

TransientTwo latches, at 1 mV and at 1 µV, read 490 ps after the clockThe difference between the two outputs of a latched comparator. The clock crosses 0.9 V at 0.11 ns and the next stage reads at 0.6 ns.
  • 1 mV in
  • 1 µV in
-0.5 V00.5 V1.0 V1.5 V2.0 Vv(outp) − v(outn)00.5 ns1.0 ns1.5 ns2.0 nsTimedecidedencoder reads-0.5 V00.5 V1.0 V1.5 V2.0 Vv(outp) − v(outn)00.5 ns1.0 ns1.5 ns2.0 nsTimedecidedencoder reads
  1. Time 488.3 ps1 mV in = 900 mV · 1 µV in = 1.179 mV

    With 1 mV in, the outputs are 0.9 V apart 378 ps after the clock edge: decided.

  2. Time 600 ps1 mV in = 1.696 V · 1 µV in = 13.64 mV

    The encoder reads now. The 1 µV latch's outputs are only 13.6 mV apart, so the gate after it sees neither a 1 nor a 0.

  3. Time 803.4 ps1 mV in = 1.8 V · 1 µV in = 900 mV

    It decides 693 ps after the clock, 203 ps after the read.

Read the plot as a table
Time1 mV in1 µV in
0 s-20.87 fV37.75 fV
488.3 ps900 mV1.179 mV
500 ps1.036 V1.522 mV
600 ps1.696 V13.64 mV
803.4 ps1.8 V900 mV
1 ns1.8 V1.789 V
1.5 ns10.23 mV10.23 mV
2 ns1.966 µV1.927 µV

Measured on ngspice 42 with SKY130 devices (the lab netlist).

That comparator was metastable, exactly like a flip-flop whose setup time was violated, and for the same reason.

How a StrongARM latch decides

A comparator turns the sign of vin+ − vin− into a digital 1 or 0. A latched comparator decides on a clock edge: the input unbalances two cross-coupled inverters, and their positive feedback does the rest. The StrongARM latch below is the usual choice in ADCs and serial links.

The StrongARM latchM1 and M2 compare the inputs; M3-M6 are two cross-coupled inverters; S1-S4 reset; M0 is the clocked tail.
The StrongARM latchVDD1.8 VS11/0.15M52/0.15M62/0.15S21/0.15M32/0.15M42/0.15S31/0.15VDDS41/0.15VDDM14/0.15M24/0.15M04/0.15inpinnclkclkclkclkclkoutnoutppq
  1. Reset

    With the clock low, M0 is off and S1-S4 pull outn, outp, p and q to 1.8 V. Nothing conducts from VDD to ground, so the latch draws no current while it waits.

  2. Integrate

    The clock rises: S1-S4 open and M0 turns on. M1 and M2 discharge p and q, and the side with the higher input discharges a little faster.

    I1 > I2

  3. Regenerate

    Once p and q are low enough, M3 and M4 conduct and both outputs fall. Each output drives the other inverter, so the one falling faster turns the other side's pull-up on.

  4. Decided

    One output reaches ground and the other returns to 1.8 V. With inp above inn, outp ends high. The current stops: a decided latch draws no static current either.

Read the circuit as text
  • S1 PMOS transistor (1/0.15): gate → n1, source → VDD, drain → outn
  • M5 PMOS transistor (2/0.15): gate → outp, source → VDD, drain → outn
  • M6 PMOS transistor (2/0.15): gate → outn, source → VDD, drain → outp
  • S2 PMOS transistor (1/0.15): gate → n2, source → VDD, drain → outp
  • M3 NMOS transistor (2/0.15): gate → outp, drain → outn, source → p
  • M4 NMOS transistor (2/0.15): gate → outn, drain → outp, source → q
  • S3 PMOS transistor (1/0.15): gate → n3, source → VDD, drain → p
  • S4 PMOS transistor (1/0.15): gate → n4, source → VDD, drain → q
  • M1 NMOS transistor (4/0.15): gate → n5, drain → p, source → n6
  • M2 NMOS transistor (4/0.15): gate → n7, drain → q, source → n6
  • M0 NMOS transistor (4/0.15): gate → n8, drain → n6, source → 0
  • inp port: terminal → n5
  • inn port: terminal → n7
  • clk port: terminal → n8
  • clk port: terminal → n1
  • clk port: terminal → n2
  • clk port: terminal → n3
  • clk port: terminal → n4

W/L in µm. NMOS bodies at ground, PMOS bodies at VDD. The lab adds 10 fF from each output to ground.

Three latches of the lab run, at 10 mV, 100 µV and 1 µV of input:

TransientSmaller inputs take longer to decideThe difference v(outp) − v(outn) for three inputs, all around a 0.9 V common level.
  • 10 mV
  • 100 µV
  • 1 µV
-0.5 V00.5 V1.0 V1.5 V2.0 Vv(outp) − v(outn)00.5 ns1.0 ns1.5 ns2.0 nsTime0.9 V apart-0.5 V00.5 V1.0 V1.5 V2.0 Vv(outp) − v(outn)00.5 ns1.0 ns1.5 ns2.0 nsTime0.9 V apart
  1. Time 110 ps10 mV = -878 nV · 100 µV = -8.797 nV · 1 µV = -79.7 pV

    The clock crosses 0.9 V. All three differences are still near zero.

  2. Time 383.3 ps10 mV = 900 mV · 100 µV = 11.77 mV · 1 µV = 117.7 µV

    The 10 mV latch decides 273 ps after the clock.

  3. Time 593.4 ps10 mV = 1.793 V · 100 µV = 900 mV · 1 µV = 11.79 mV

    The 100 µV latch decides 483 ps after the clock: a hundred times less input, 210 ps more.

  4. Time 803.4 ps10 mV = 1.8 V · 100 µV = 1.792 V · 1 µV = 900 mV

    The 1 µV latch decides 693 ps after the clock: another hundredfold, another 210 ps.

Read the plot as a table
Time10 mV100 µV1 µV
0 s-25.76 fV-10.66 fV37.75 fV
110 ps-878 nV-8.797 nV-79.7 pV
383.3 ps900 mV11.77 mV117.7 µV
500 ps1.711 V150.8 mV1.522 mV
593.4 ps1.793 V900 mV11.79 mV
803.4 ps1.8 V1.792 V900 mV
1 ns1.8 V1.8 V1.789 V
1.5 ns10.27 mV10.23 mV10.23 mV
2 ns2.308 µV1.932 µV1.927 µV

Measured on ngspice 42 (the lab netlist). Reset starts at 1.13 ns.

Each tenfold smaller input adds the same delay, about 105 ps. A fixed delay per factor of ten is the mark of an exponential.

Why the decision time grows with log(1/ΔV)

While the inverters are balanced, each one amplifies the other's output. Any difference grows as vdiff(t) = v0·et/τ. Here v0 is the imbalance the input pair left, and τ is the regeneration time constant, about C/gm of the inverters.

Solve for the time to reach a swing Vs: td = τ·ln(Vs/v0). The input sets v0 = A·ΔVin through the pair's gain A. So td = τ·ln(Vs/(A·ΔVin)): a straight line against log ΔVin, with no limit as ΔVin goes to zero.

DC sweepDecision time against the input, one decade per stepEach point is one latch of the lab run. −6 on the x axis is 1 µV, −1 is 100 mV.
100 ps200 ps300 ps400 ps500 ps600 ps700 ps800 psDecision time-6-5-4-3-2-1log10 of the input difference in volts1 µV: 693 ps1 mV: 378 ps100 mV: 141 ps100 ps200 ps300 ps400 ps500 ps600 ps700 ps800 psDecision time-6-4-2log10 of the input difference in volts1 µV: 693 ps1 mV: 378 ps100 mV: 141 ps
  1. log10 of the input difference in volts -6decision time = 693.4 ps

    From 1 µV to 1 mV the line is straight: 105.0 ps per decade. Then τ = 105.0 ps / ln 10 = 45.6 ps.

  2. log10 of the input difference in volts -4.063decision time = 490 ps

    A latch given 490 ps decides any input above 86 µV (10−4.06 V). Smaller inputs are still undecided.

  3. log10 of the input difference in volts -1decision time = 141.1 ps

    Above 10 mV the line bends down: a large input does much of the swing before regeneration takes over.

Read the plot as a table
log10 of the input difference in voltsdecision time
-6693.4 ps
-5588.4 ps
-4.063490 ps
-4483.4 ps
-3378.3 ps
-2273.3 ps
-1141.1 ps

Measured on ngspice 42 (the lab netlist; the table is a dc sweep of a dummy source).

This is the law of a metastable flip-flop, which holds its state in a latch too. Its MTBF (mean time between failures) in R6.1 Metastability and MTBF has the same et/τ. Picture a ball balanced on a hill: the closer to the top it starts, the longer it takes to roll off.

The read time sets a window of inputs that fail. Give the latch 490 ps and inputs below 86 µV are undecided. Every extra 105 ps shrinks that window, and the error rate with it, tenfold.

Measure the difference between the outputs

Both outputs start at VDD and fall together while the pair integrates. Only after regeneration does the winner turn back up. A bench that times one output falling through 0.9 V measures that common fall.

TransientAt 1 µV both outputs fall before either winsAbove: each output of the 1 µV latch. Below: their difference.
  • v(outp)
  • v(outn)
  • difference
-0.5 V00.5 V1.0 V1.5 V2.0 VOutputs-0.5 V00.5 V1.0 V1.5 V2.0 VDifference00.5 ns1.0 ns1.5 ns2.0 nsTime0.9 V-1 V01 V2 VOutputs-0.5 V00.5 V1.0 V1.5 V2.0 VDifference00.5 ns1.0 ns1.5 ns2.0 nsTime0.9 V
  1. Time 318.1 psv(outp) = 900 mV · v(outn) = 900 mV · difference = 28.6 µV

    Both outputs cross 0.9 V together, 208 ps after the clock. The difference is still almost zero.

  2. Time 483 psv(outp) = 849.8 mV · v(outn) = 848.7 mV · difference = 1.048 mV

    outp bottoms out at 0.850 V, then turns back up: the latch is deciding.

  3. Time 803.4 psv(outp) = 1.301 V · v(outn) = 401.2 mV · difference = 900 mV

    The difference reaches 0.9 V at 693 ps. That is the decision time.

Read the plot as a table
Timev(outp)v(outn)difference
0 s1.8 V1.8 V37.75 fV
318.1 ps900 mV900 mV28.6 µV
483 ps849.8 mV848.7 mV1.048 mV
500 ps849.9 mV848.4 mV1.522 mV
803.4 ps1.301 V401.2 mV900 mV
1 ns1.794 V5.664 mV1.789 V
1.5 ns1.803 V1.793 V10.23 mV
2 ns1.8 V1.8 V1.927 µV

Measured on ngspice 42 (the lab netlist).

One output falling

meas tran fall3 TRIG v(clk) VAL=0.9 RISE=1 TARG v(on3) VAL=0.9 FALL=1
meas tran fall6 TRIG v(clk) VAL=0.9 RISE=1 TARG v(on6) VAL=0.9 FALL=1

fall3 = 200.7 ps at 1 mV and fall6 = 208.1 ps at 1 µV: nearly the same, whatever the input.

The difference reaching 0.9 V

let d3=v(op3)-v(on3)
meas tran t3 TRIG v(clk) VAL=0.9 RISE=1 TARG d3 VAL=0.9 RISE=1

t3 = 378.3 ps at 1 mV and t6 = 693.4 ps at 1 µV: the regeneration law.

Both from the lab run on ngspice 42.

Offset, kickback and energy

Offset is the input at which a latch is equally likely to say 1 or 0. Mismatch between devices drawn the same gives every latch its own (E7.5 Monte Carlo on an amplifier's offset). The run below draws 20 latches with SKY130's mismatch models and searches each one's flipping point to 0.125 mV.

DC sweepThe offsets of 20 latches, sortedEach point is one latch's input-referred offset. Mismatch on, seed fixed.
-25 mV-20 mV-15 mV-10 mV-5 mV05 mV10 mV15 mVOffset5101520Latch, from most negative offsetno offset-30 mV-20 mV-10 mV010 mV20 mVOffset5101520Latch, from most negative offsetno offset
  1. Latch, from most negative offset 1offset = -19.63 mV

    The most negative latch flips at −19.6 mV.

  2. Latch, from most negative offset 20offset = 10.13 mV

    The most positive flips at +10.1 mV. Mean −2.75 mV, standard deviation σ = 9.0 mV.

Read the plot as a table
Latch, from most negative offsetoffset
1-19.63 mV
5-11.38 mV
10-875 µV
153.625 mV
2010.13 mV

Measured on ngspice 42: 20 latches, 8 halving steps of a search per latch.

Kickback is the latch disturbing its own input. Its big internal swings couple back to the gates through the input devices' capacitances. Latch 7 is driven through 1 kΩ: its gates dip 109 mV when the clock rises, and their difference moves by up to 4.4 mV, more than four times its 1 mV input. In a flash ADC, neighbouring comparators share that input.

Energy: latch 3 has its own supply. One decision and its reset draw 115 fJ from it, and nothing while it waits.

What the digital side sees

A SystemVerilog bench usually models a comparator as out = (vinp > vinn) at the clock edge. The runs above add an offset (σ = 9.0 mV here) and a delay that grows as τ·ln(1/|ΔVin|). They also add an undecided result when that delay passes the next read.

τ, the 1 mV delay and the offset σ come from this lesson's runs. Above 1 mV the model is slower than the latch (141 ps at 100 mV).
// A clocked-comparator model for a mixed-signal bench, with the numbers of this lesson's runs.
`timescale 1ps / 1fs
module latch_cmp #(
  parameter real VOS     = 0.0,    // this instance's offset in volts (20 latches: sigma 9.0 mV)
  parameter real TAU     = 45.6,   // regeneration time constant, ps
  parameter real T_1MV   = 378.3,  // decision time at 1 mV, ps
  parameter real T_AVAIL = 490.0   // time until the next stage reads, ps
) (
  input  logic clk,
  input  real  vinp,
  input  real  vinn,
  output logic out
);
  always @(posedge clk) begin : decide
    automatic real dv  = (vinp - vinn) - VOS;
    automatic real adv = (dv < 0.0) ? -dv : dv;
    automatic real td  = (adv >= 1e-3) ? T_1MV                      // large inputs: no faster than at 1 mV
                       : (adv > 0.0)   ? T_1MV + TAU * $ln(1e-3 / adv)
                       :                 T_AVAIL + 1.0;              // exactly balanced: never decides
    out <= 1'bx;                                                      // deciding
    if (td <= T_AVAIL) out <= #(td) (dv > 0.0);                      // decided in time
    // otherwise out is still x when the next stage reads it
  end
endmodule

The number such models get wrong is the delay near zero input: a fixed delay never produces the x a sparkle starts from.

Asked in interviews
  1. How does a StrongARM latch work?

    Clock low: four PMOS switches reset the outputs and the pair's drains to VDD. Clock high: the tail turns on, the input pair discharges its drains at slightly different rates, and the cross-coupled inverters amplify that difference until one output reaches ground. It draws no static current.

  2. What is the regeneration time constant?

    The τ in vdiff = v0·et/τ while the cross-coupled pair is balanced, about C/gm. It sets the slope of decision time against ln(1/ΔVin): 45.6 ps here. Less load capacitance or more gm per capacitance makes it shorter.

  3. What is comparator metastability and its error rate?

    An input near the threshold leaves the latch near balance, so it may not decide before the result is read. The undecided input window shrinks as e−t/τ with the time allowed, so the error rate falls exponentially, as in a synchronizer's MTBF.

Try it

Run the netlist. t1 to t6 are the decision times from 100 mV down to 1 µV, fall3 and fall6 the one-output trap, kick_cm and kick_dm the kickback at latch 7's gates, and e3 the energy of one decision of latch 3. tau is the slope from 1 µV to 1 mV divided by ln 10.

Predict, then run. Halve C1 and C2 inside .subckt sa: tau should fall, but by less than half, because the transistors' own capacitance stays. Swap VP3 and VN3: the other output wins, so measure with TARG d3 VAL=-0.9 FALL=1, and the time should not change. Then widen M3 and M4 and see whether more gm wins over more capacitance.

SPICEngspice 42 · simulator service
Edit the netlist, then run it
Expected measurements: t1 = 1.410576e-10 targ= 2.510576e-10 trig= 1.100000e-10 t3 = 3.783439e-10 targ= 4.883439e-10 trig= 1.100000e-10 t6 = 6.933734e-10 targ= 8.033734e-10 trig= 1.100000e-10

Check yourself

Predict the outputThis is the lab latch with an input difference of 10 nV. The run adds up the time the clock is high and the outputs are less than 0.9 V apart, rounds it to the nearest 100 ps and prints it in picoseconds. Type the line meas prints (format: td_ps = 6.000000e+02).
* the lab latch with a 10 nV input difference
.lib sky130 tt
.subckt sa inp inn outp outn clk vdd
XM0 tail clk 0 0 sky130_fd_pr__nfet_01v8 W=4 L=0.15
XM1 p inp tail 0 sky130_fd_pr__nfet_01v8 W=4 L=0.15
XM2 q inn tail 0 sky130_fd_pr__nfet_01v8 W=4 L=0.15
XM3 outn outp p 0 sky130_fd_pr__nfet_01v8 W=2 L=0.15
XM4 outp outn q 0 sky130_fd_pr__nfet_01v8 W=2 L=0.15
XM5 outn outp vdd vdd sky130_fd_pr__pfet_01v8 W=2 L=0.15
XM6 outp outn vdd vdd sky130_fd_pr__pfet_01v8 W=2 L=0.15
XS1 outn clk vdd vdd sky130_fd_pr__pfet_01v8 W=1 L=0.15
XS2 outp clk vdd vdd sky130_fd_pr__pfet_01v8 W=1 L=0.15
XS3 p clk vdd vdd sky130_fd_pr__pfet_01v8 W=1 L=0.15
XS4 q clk vdd vdd sky130_fd_pr__pfet_01v8 W=1 L=0.15
C1 outp 0 10f
C2 outn 0 10f
.ends
VDD vdd 0 1.8
VCLK clk 0 PULSE(0 1.8 100p 20p 20p 1n 2n)
VP inp 0 0.900000005
VN inn 0 0.899999995
X1 inp inn outp outn clk vdd sa
.control
tran 2p 1.1n
* undecided: the clock is high and the outputs are less than 0.9 V apart
let d=v(outp)-v(outn)
let und=(v(clk) gt 0.9)*(abs(d) lt 0.9)
* total undecided time, rounded to the nearest 100 ps and printed in ps
let tdps=floor(integ(und)/100p+0.5)*100
meas tran td_ps FIND tdps AT=1.1n
.endc
.end
ConceptFour benches time the lab latch at 1 mV. Which one reports nearly the same time at 1 µV as at 1 mV?
ConceptWhy does a latch's decision time grow with log(1/ΔVin) rather than with 1/ΔVin?
ConceptWhat links a latched comparator to a synchronizer flip-flop?
ConceptHalve the lab latch's load capacitors C1 and C2 to 5 fF. The decision time now grows by 75.1 ps per decade of input. What is the regeneration time constant τ?

Remember

  • A latched comparator amplifies the input's imbalance by positive feedback: vdiff = v0·et/τ, with τ about C/gm of its inverters.
  • Decision time is τ·ln(Vs/(A·ΔVin)): each tenfold smaller input adds ln 10 · τ (105 ps here, τ = 45.6 ps), with no limit at zero.
  • Time a decision on the difference of the outputs; one output falls through mid-rail at nearly the same time for any input.
  • This is flip-flop metastability: the undecided window shrinks as e−t/τ, which is why MTBF grows exponentially with settling time.
  • A useful model adds offset, the log-law delay and an x when the delay passes the read.