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.
- 1 mV in
- 1 µV in
- 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.
- 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.
- 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
| Time | 1 mV in | 1 µV in |
|---|---|---|
| 0 s | -20.87 fV | 37.75 fV |
| 488.3 ps | 900 mV | 1.179 mV |
| 500 ps | 1.036 V | 1.522 mV |
| 600 ps | 1.696 V | 13.64 mV |
| 803.4 ps | 1.8 V | 900 mV |
| 1 ns | 1.8 V | 1.789 V |
| 1.5 ns | 10.23 mV | 10.23 mV |
| 2 ns | 1.966 µV | 1.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.
- 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.
- 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
- 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.
- 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:
- 10 mV
- 100 µV
- 1 µV
- 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.
- 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.
- 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.
- 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
| Time | 10 mV | 100 µV | 1 µV |
|---|---|---|---|
| 0 s | -25.76 fV | -10.66 fV | 37.75 fV |
| 110 ps | -878 nV | -8.797 nV | -79.7 pV |
| 383.3 ps | 900 mV | 11.77 mV | 117.7 µV |
| 500 ps | 1.711 V | 150.8 mV | 1.522 mV |
| 593.4 ps | 1.793 V | 900 mV | 11.79 mV |
| 803.4 ps | 1.8 V | 1.792 V | 900 mV |
| 1 ns | 1.8 V | 1.8 V | 1.789 V |
| 1.5 ns | 10.27 mV | 10.23 mV | 10.23 mV |
| 2 ns | 2.308 µV | 1.932 µV | 1.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.
- 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.
- 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.
- 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 volts | decision time |
|---|---|
| -6 | 693.4 ps |
| -5 | 588.4 ps |
| -4.063 | 490 ps |
| -4 | 483.4 ps |
| -3 | 378.3 ps |
| -2 | 273.3 ps |
| -1 | 141.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.
- v(outp)
- v(outn)
- difference
- 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.
- 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.
- 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
| Time | v(outp) | v(outn) | difference |
|---|---|---|---|
| 0 s | 1.8 V | 1.8 V | 37.75 fV |
| 318.1 ps | 900 mV | 900 mV | 28.6 µV |
| 483 ps | 849.8 mV | 848.7 mV | 1.048 mV |
| 500 ps | 849.9 mV | 848.4 mV | 1.522 mV |
| 803.4 ps | 1.301 V | 401.2 mV | 900 mV |
| 1 ns | 1.794 V | 5.664 mV | 1.789 V |
| 1.5 ns | 1.803 V | 1.793 V | 10.23 mV |
| 2 ns | 1.8 V | 1.8 V | 1.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.
- Latch, from most negative offset 1offset = -19.63 mV
The most negative latch flips at −19.6 mV.
- 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 offset | offset |
|---|---|
| 1 | -19.63 mV |
| 5 | -11.38 mV |
| 10 | -875 µV |
| 15 | 3.625 mV |
| 20 | 10.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.
// 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
endmoduleThe 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
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.
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.
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.
Run the netlist to draw its plots here.
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-10Check yourself
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.