S2 · Lesson 49 · Converter lab
ENOB, DNL and INL, and a delta-sigma modulator, in Python
Data converters are specified by a handful of numbers (SINAD and ENOB, DNL and INL, a figure of merit) and each comes from a precise measurement procedure. This lab writes those procedures in Python: quantize a coherently sampled sine and compute its SINAD, turn a converter's measured transition levels into DNL and INL, and simulate a first-order delta-sigma modulator to see a one-bit stream average out to an arbitrary input.
- The curve is the ideal SQNR of a one-bit delta-sigma modulator against oversampling ratio, for loop orders 1 to 4: .
- Each doubling of M adds dB: 9 dB at first order, 15 at second.
- High-order loops reach 16 bits or more at modest oversampling, at the cost of stability problems the formula doesn't show.
Predict
A 6-level converter's transition levels are ideally 1 LSB apart, but the fourth transition sits half an LSB late. What are the largest DNL and INL?
The code below the late transition is half an LSB wide too wide (DNL +0.5) and the code above it half an LSB too narrow (−0.5). INL, the transition's distance from the straight line through the endpoints, is +0.5 LSB there and zero elsewhere. A single misplaced transition always shows up as a +/− pair in DNL.
Name it
The procedures
- SINAD and ENOB: sample a sine for a whole number of cycles that is coprime with the record length (coherent sampling), quantize, reconstruct, and compare the error's power with the signal's: .
- DNL and INL: from the transition levels , take ; then and (endpoint fit).
- First-order delta-sigma: each step, output by the sign of an integrator v, then add to v. The average of y equals x.
- Walden figure of merit: .
Check
Write sinad_enob(bits, n=4096, cycles=127): quantize to bits bits with a mid-rise quantizer (code = ⌊(v + 1)/2 · 2^bits⌋, clamped to the top code; reconstruct at code centers) and return (SINAD in dB, ENOB).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write dnl_inl(edges): from a list of transition levels, return (DNL list, INL list) in LSB, with the endpoint-fit LSB.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write sd1(x, n): run a first-order delta-sigma modulator for n steps with input x (|x| < 1) and return the average of its ±1 output.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write sd_sqnr(L, M): the ideal one-bit SQNR of an L-th order modulator at oversampling ratio M, and walden(P, fs, enob).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a one-bit delta-sigma modulator's output average converge to its input, even though each output is only +1 or −1?
The integrator accumulates the difference between the input and the output, and the comparator always chooses the output that pushes that accumulated difference back toward zero. So the integrator's value can never grow without bound: it stays within a fixed range. Since the integrator holds the sum of all past errors, the total error after n steps is bounded, and the error in the average is that bounded amount divided by n, which shrinks as more samples are averaged. The quantization error hasn't disappeared; it has been pushed to high frequencies, where the decimation filter removes it.