---
title: Comparators and sample-and-hold circuits
heading: Regenerative latches, metastability, aperture jitter and the track-and-hold
eyebrow: S2 · Lesson 40 · Comparators and sample-and-hold circuits
xp: 50
---

::: hook
Every analog-to-digital converter ends in a decision: is the input above or below a threshold? A comparator makes it with a latch, two cross-coupled inverters released from balance with a tiny difference between them. Positive feedback grows that difference exponentially until it's a full logic level. Bigger inputs resolve faster; a small enough input takes arbitrarily long, and that's metastability, the reason a fast converter occasionally outputs nonsense. In front of the comparator, a sample-and-hold freezes the input at an exact instant, and any uncertainty in that instant, the clock's jitter, turns directly into noise on fast signals.
:::

::: play
- A regenerative latch's differential output against time, on a log scale, starting from three initial imbalances: 1 mV, 10 µV and 0.1 µV. Each grows as $e^{t/\tau}$ until it reaches the 1 V supply.
- Every decade of smaller input costs the same extra time, $\tau\ln10$. The marker is the time available before the result must be valid.
- The readout gives the smallest input that still resolves in that time; anything smaller is a metastable decision.
:::
:::

```sim plot
view: graph
x: t = 0..600 ps
y: v = 1e-7..2 log
slider: tau = 5..50 = 20 ps log
slider: T = 100..600 = 300 ps
plot: (1e-3*exp(t/tau) + 1 - abs(1e-3*exp(t/tau) - 1))/2 | samples: 600 | label: from 1 mV
plot: (1e-5*exp(t/tau) + 1 - abs(1e-5*exp(t/tau) - 1))/2 | samples: 600 | color: ch2 | label: from 10 µV
plot: (1e-7*exp(t/tau) + 1 - abs(1e-7*exp(t/tau) - 1))/2 | samples: 600 | color: ch3 | label: from 0.1 µV
marker: x = T | label: decision time
readout: smallest input resolved by then = exp(-T/tau) V | format: sci
```

::: predict
## A latch with a 20 ps time constant resolves a 1 mV input to 1 V in about 140 ps. How long does a 1 µV input take?

- [ ] About 140 ps
- [x] About 280 ps
- [ ] About 140 ns
- [ ] Forever

::: reveal
About 280 ps. Regeneration is exponential, so the time is $\tau\ln\frac{V_\text{final}}{V_0}$: 1 mV needs $20\ln1000$ = 138 ps, 1 µV needs $20\ln10^6$ = 276 ps. A thousand times smaller input costs only twice the time. That's why latches are so good at amplifying tiny differences, and why metastable failures are rare but never impossible.
:::
:::

::: nameit
## The regenerative latch

Two cross-coupled inverters, each with transconductance $g_m$ and load capacitance C, released from a small difference $V_0$, obey $C\frac{dv}{dt} = g_mv$, so

$$v(t) = V_0e^{t/\tau}, \qquad \tau = \frac{C}{g_m}$$

and reaching a logic level $V_L$ takes $t = \tau\ln\frac{V_L}{V_0}$. A preamplifier in front adds gain (so the latch starts from a larger $V_0$), reduces the latch's offset referred to the input, and isolates the input from the latch's **kickback**, the charge spike when it fires.

## Metastability

In a decision time T, inputs smaller than $V_\text{min} = V_Le^{-T/\tau}$ don't resolve. If inputs fall uniformly over a range $V_r$, the chance of a metastable decision is about $2V_\text{min}/V_r$ per comparison; at a high sampling rate that becomes a mean time between failures. Each extra τ of decision time cuts the rate by e.

## The track-and-hold

A switch and a capacitor track the input, then hold it when the switch opens.

- **Tracking bandwidth:** $\frac{1}{2\pi R_\text{on}C}$, and the input must settle to the required accuracy in the tracking time.
- **Aperture jitter:** sampling a sine $A\sin2\pi ft$ at a time uncertain by $\sigma_t$ adds an error of slope × time, limiting SNR to
$$\text{SNR} = -20\log(2\pi f\sigma_t)$$
independent of amplitude. 100 fs of jitter limits a 1 GHz signal to 64 dB, about 10 bits.
- **Pedestal:** charge injection when the switch opens (lesson 39).
- **Droop:** leakage current I discharges the hold capacitor at I/C.
- **Hold-mode feedthrough:** the input couples through the open switch's capacitance.
:::

::: example
## A latch has τ = 20 ps and 500 ps to decide, with inputs spread uniformly over ±0.5 V, at 1 GS/s. How often is it metastable?

::: solution
1. **Smallest input that resolves.**
   $$\begin{aligned} V_\text{min} &= 1\ \text{V} \times e^{-500/20} \\ &= 1.4 \times 10^{-11}\ \text{V} \end{aligned}$$
2. **Chance per decision.** Inputs that land within $\pm V_\text{min}$ of the threshold, out of a 1 V spread, go metastable:
   $$\frac{2 \times 1.4 \times 10^{-11}}{1} = 2.8 \times 10^{-11}$$
3. **How often.** At $10^9$ decisions a second that's one metastable event every 36 seconds on average.
4. **More decision time.** A further 100 ps (5τ) would stretch it by $e^5$ = 148 times, to about 90 minutes.
5. **What follows.** That's why fast converters pipeline their decisions or add latch stages.

**Answer:** about once every 36 seconds.
:::
:::

::: example
## An ADC samples a 1 GHz signal with a clock of 100 fs rms jitter, through a 100 Ω switch onto 1 pF. What SNR does the jitter allow, and is the tracking bandwidth enough?

::: solution
1. **Jitter-limited SNR.**
   $$\begin{aligned} \text{SNR} &= -20\log(2\pi \times 10^9 \times 10^{-13}) \\ &= 64.0\ \text{dB} \end{aligned}$$
   an effective 10.3 bits whatever the converter's own resolution.
2. **Tracking bandwidth.**
   $$\begin{aligned} f_{-3\text{dB}} &= \frac{1}{2\pi \times 100 \times 10^{-12}} \\ &= 1.6\ \text{GHz} \end{aligned}$$
   only 1.6 times the signal.
3. **Is it enough?** No: the input would be attenuated and, worse, the nonlinear switch resistance would distort it.
4. **What samplers do.** High-speed samplers use bootstrapped switches and wider bandwidth.

**Answer:** the jitter allows 64.0 dB (10.3 bits), and the 1.6 GHz tracking bandwidth isn't enough.
:::
:::

::: example
## A latch with τ = 20 ps must amplify a 1 mV input to a 1 V logic level. How long does that take?

::: solution
1. **Regeneration time.** The difference grows as $e^{t/\tau}$, so
   $$\begin{aligned} t &= \tau\ln\frac{1\ \text{V}}{1\ \text{mV}} \\ &= 20 \times 6.9\ \text{ps} \\ &= 138\ \text{ps} \end{aligned}$$
2. **Smaller inputs.** Each tenfold smaller input adds only 46 ps, which is why latches resolve tiny differences quickly, but an input of exactly zero never resolves.

**Answer:** 138 ps.
:::
:::

::: check
given: t = 10 | 20 | 40; V = 0.01 | 1 | 100
answer: t*ln(1/(V*1e-3))
unit: ps
tolerance: 1%

## A latch with τ = {t} ps starts from a {V} mV imbalance. How long until it reaches 1 V?

::: right
Right. $\tau\ln\frac{V_L}{V_0}$ = {answer} ps.
:::

::: misses
- [t*log(1/(V*1e-3))] Use the natural log.
- [any] Not yet. The imbalance grows as $e^{t/\tau}$.
:::
:::

::: check
given: g = 0.5 | 2 | 5; C = 10 | 50
answer: C*1e-15/(g*1e-3)*1e12
unit: ps
tolerance: 1%

## A latch's inverters have $g_m$ = {g} mS and {C} fF of load each. What's its regeneration time constant?

::: right
Right. $\tau = C/g_m$ = {answer} ps.
:::

::: misses
- [any] Not yet. $C\,dv/dt = g_mv$.
:::
:::

::: check
given: t = 10 | 25; T = 200 | 400
answer: exp(-T/t)*1e6
unit: µV
tolerance: 1%

## A latch with τ = {t} ps has {T} ps to reach 1 V. What's the smallest input it resolves in time?

::: right
Right. $V_Le^{-T/\tau}$ = {answer} µV.
:::

::: misses
- [any] Not yet. Run the exponential backward from 1 V.
:::
:::

::: check
given: f = 0.1 | 1 | 5; s = 50 | 200 | 1000
answer: -20*log(2*pi*f*1e9*s*1e-15)
unit: dB
tolerance: 0.5%

## A {f} GHz sine is sampled with {s} fs rms clock jitter. What SNR does the jitter allow?

::: right
Right. $-20\log(2\pi f\sigma_t)$ = {answer} dB.
:::

::: misses
- [-20*log(f*1e9*s*1e-15)] Include 2π: the sine's slope is $2\pi fA$.
- [any] Not yet. Error = slope × timing error.
:::
:::

::: check
given: N = 8 | 12 | 14; f = 10 | 100 | 1000
answer: 10^(-(6.02*N + 1.76)/20)/(2*pi*f*1e6)*1e15
unit: fs
tolerance: 1%

## How much clock jitter can an ideal {N}-bit ADC tolerate at {f} MHz before jitter limits its SNR?

::: right
Right. Setting $-20\log(2\pi f\sigma_t)$ = 6.02N + 1.76 dB gives {answer} fs.
:::

::: misses
- [any] Not yet. Equate the jitter SNR with the ideal quantization SNR.
:::
:::

::: check
given: R = 20 | 100 | 500; C = 0.5 | 2
answer: 1/(2*pi*R*C*1e-12)/1e9
unit: GHz
tolerance: 1%

## A track-and-hold switch of {R} Ω drives {C} pF. What's its tracking bandwidth?

::: right
Right. $\frac{1}{2\pi R_\text{on}C}$ = {answer} GHz.
:::

::: misses
- [1/(R*C*1e-12)/1e9] Divide by 2π.
- [any] Not yet. An RC low-pass.
:::
:::

::: check
given: I = 1 | 10 | 100; C = 1 | 10; t = 1 | 100
answer: I*1e-12*t*1e-6/(C*1e-12)*1e3
unit: mV
tolerance: 1%

## A hold capacitor of {C} pF leaks {I} pA. How far does it droop in {t} µs?

::: right
Right. $\frac{It}{C}$ = {answer} mV.
:::

::: misses
- [any] Not yet. Charge lost over capacitance.
:::
:::

::: check
kind: parts
given: t = 10 | 20 | 40; v = 0.1 | 1; V = 0.8 | 1.2

## A latch with τ = {t} ps must grow a {v} mV input to {V} V.

::: part
answer: t*ln(V*1000/v)
unit: ps
tolerance: 0.5%

### How long does that take?

::: misses
- [any] $\tau\ln(V_\text{out}/V_\text{in})$.
:::
:::

::: part
answer: t*ln(10)
unit: ps
tolerance: 0.5%

### How much longer does an input ten times smaller take?

::: misses
- [any] $\tau\ln 10$.
:::
:::
:::

::: check
kind: derivation
vars: f = 1e6..5e9, s = 1e-14..1e-11, A = 0.1..2

## A sine of frequency f and amplitude A is sampled with rms clock jitter s.

::: step
answer: -20*log(2*pi*f*s)

### What SNR does jitter allow, in dB?
:::

::: step
answer: (-20*log(2*pi*f*s) - 1.76)/6.02

### How many effective bits is that?
:::

::: right
Right. Jitter's limit depends only on the signal frequency and the jitter, not on the converter's resolution.
:::
:::

::: explain
## Why does a comparator's decision time grow only logarithmically as its input shrinks?

::: model
Once released, a latch's two cross-coupled inverters push their outputs apart, and the rate at which the difference grows is proportional to the difference itself: each inverter's transconductance acting on the other's input. That makes the growth exponential, multiplying by e every time constant. To reach a fixed logic level from a smaller start, the latch only needs enough extra time constants to make up the ratio, so a thousand times smaller input needs ln 1000, about 7 more time constants. The flip side is that there's no input small enough to be guaranteed impossible, only increasingly improbable, which is why metastability can be made rare but never eliminated.
:::
:::

::: practice

::: check
given: t = 15 | 30; V = 0.1 | 10
answer: t*ln(1/(V*1e-3))
unit: ps
tolerance: 1%

## Resolution time: τ = {t} ps, from {V} mV to 1 V?

::: misses
- [any] $\tau\ln(V_L/V_0)$.
:::
:::

::: check
given: f = 0.5 | 2; s = 100 | 500
answer: -20*log(2*pi*f*1e9*s*1e-15)
unit: dB
tolerance: 0.5%

## Jitter-limited SNR: {f} GHz, {s} fs?

::: misses
- [any] $-20\log(2\pi f\sigma_t)$.
:::
:::

::: check
given: R = 50 | 250; C = 1 | 4
answer: 1/(2*pi*R*C*1e-12)/1e9
unit: GHz
tolerance: 1%

## Tracking bandwidth: {R} Ω, {C} pF?

::: misses
- [any] $1/2\pi R_\text{on}C$.
:::
:::
:::
