Skip to content

analog: sar_comparator.t27 -- the SAR ADC dynamic comparator, multi-node Newton, square law against ngspice LEVEL=1 (Closes #10583) - #10604

Merged
gHashTag merged 1 commit into
masterfrom
claude/analog-m4b-comparator-10583
Oct 18, 2026
Merged

gHashTag merged 1 commit into
masterfrom
claude/analog-m4b-comparator-10583

Conversation

@gHashTag

Copy link
Copy Markdown
Owner

Closes #10583

Part of #10524 (M4b), epic #10486.

Device level: the SQUARE LAW (cpphdl's MOS law, SPICE MOSFET LEVEL=1), not PSP103. IHP tables replace the law in M3b (#10516) and change nothing in the solver. The decision times below are the 0.1 ps backward Euler grid's, not the continuous circuit's.

What it is

specs/analog/sar_comparator.t27: the StrongARM-style dynamic_comparator of the golden SAR deck (uberWAVE wp2-parser/golden/top.spice, GPL-2.0, read at run time and not vendored): eight internal nodes (ap, an, net1, net2, net3, dp, dn, n_clkc), fifteen devices (XM1..XM13 and the inverter), W/L/m of the deck.

  • Devices: square law, KP 300 uA/V^2 (n) / 100 uA/V^2 (p), W/L 1/0.45 (n) and 3/0.45 (p) times m (666.7 uA/V^2 per unit m for both types, so one table serves both), Vth 0.35 V, lambda 0. Node capacitances 4 fF on ap, an, dp, dn; 6 fF on net1; 2 fF on net2, net3, n_clkc. No other capacitance.
  • Each device is read from M3a's table (use analog::mos_table: id_of, gm_cell, gds_cell, unchanged): its 24-cell grid is read as 24 cells of 62.5 mV (unit 2^-24 V, Vdd = 1.5 * 2^24). Price: 0.35 V lands inside cell 5, a soft knee, measured in the spec.
  • Step: backward Euler on all eight nodes, K = 3 fixed Newton iterations, the dense 8 x 9 system solved by Gaussian elimination with partial pivoting in unsigned sign-magnitude u64 words (no signed type, no float from sc_clk_at to sc_sign). The f64 twin of the same iteration and an analytic-law run (Newton to convergence) are in the tests. Residual after the last iteration is computed at every step.
  • Four ngspice MOSFET LEVEL=1 decks in specs/analog/decks/ (sar_cmp_p2, _m2, _p05, _m05), fixed-step backward Euler by the recipe of bench.t27, the same W, L, m, KP, VTO and capacitors. Their numbers are recorded in the spec (the spec does not run ngspice; run ngspice -b specs/analog/decks/sar_cmp_p2.cir).

Result (K = 3, fixed point, against ngspice LEVEL=1 on the same grid)

input decision time (first output through Vdd/2) resolution time (abs(dp-dn) = Vdd/2) sign
+-2 mV 5.489 ps vs ngspice 5.496 ps (-0.14 %) 6.963 ps vs 6.931 ps (+0.47 %) right (+2: dp high, -2: dn high)
+-0.5 mV 5.558 ps vs 5.569 ps (-0.20 %) 7.734 ps vs 7.694 ps (+0.53 %) right

The issue asks for 5 %; the worst is 0.53 %. The decks for -2 mV and -0.5 mV print the same times as +2 mV and +0.5 mV.

Errors, kept apart (each bound asserted from both sides)

  • arithmetic (fixed point vs the f64 twin of the same iteration): under 3 units (0.2 uV) up to step 50, then amplified by the regeneration to 68 units (4.1 uV) at 2 mV (bound 70) and 251 units (15 uV) at 0.5 mV (bound 255); times differ by under 3.4e-4 steps.
  • table (f64 twin vs the analytic law, same grid): 15.2 mV at 2 mV (bound 15.4), 19.0 mV at 0.5 mV (bound 19.2). The largest error here; it is the 62.5 mV cells and the knee.
  • model (analytic law vs ngspice LEVEL=1): 1.44e-9 V at the 8 recorded steps x 8 nodes (bound 1.6e-9), 1.47e-9 V over every node and step (measured with a throwaway float64 raw-file reader, not in the repo). The deck is the spec's circuit.
  • residual after the last iteration: at most 2 units (0.12 uV) at all 840 steps of six runs.

Negative controls (each a test that passes by seeing the failure)

  • K = 1: residual reaches 29361 units against the bound of 2 (K = 2: 55; K = 4: same as K = 3).
  • inputs swapped, and the input pair's m swapped (38/34 vs 34/38): the decision follows the mismatch; the sign check fails for all four stimuli in one orientation and the opposite in the other. (The golden deck's pair is m = 36 / 36, so the swap needs an unequal pair; 35/37, 5.6 %, already outweighs 2 mV.)
  • Vth = 0.30 table: decides the right way but 16.7 % early against ngspice (bound 5 %) and 0.39 V off the recorded states.

Also reported, not hidden

  • Metastability: each quartering of the input adds 7.67 steps to the resolution time (0.554 ps per e-fold). At 0 V the circuit stays exactly symmetric in real arithmetic and unresolved at step 140 in fixed point.
  • The loser's peak: ngspice 0.7473 V (2 mV), the table model 0.7530 V, so whether the loser crosses Vdd/2 is below this model's resolution and is not used.

Gates

  • t27c test-report specs/analog/sar_comparator.t27: 20 tests, 20 pass, 0 vacuous passes; tri test: 20 pass.
  • Seal saved and verified (all MATCH), no home path in it. python3 -I tools/dupe_scan.py: ok. tri types ratchet: CLEAN (no new type). t27c check: 0 warnings.
  • No cli/ change, no hand-written foreign code; the four decks are plain SPICE netlists (data, like the bench decks). docs/reports/t27b_expectations.json untouched.
  • Note: built with a prebuilt t27c a few hours older than master's compiler, so t27c frontier reports toolchain drift; the tests and seal were run on it.

🤖 Generated with Claude Code

…ode Newton, square law against ngspice LEVEL=1 (Closes #10583)

M4b of the SAR ADC milestone (#10524, epic #10486). The StrongARM-style
dynamic_comparator of the golden SAR deck: eight internal nodes, fifteen
square-law devices (the device level is the square law, not PSP103), each
read from M3a's bilinear table (the 24-cell grid read as 62.5 mV cells).

- backward Euler on all eight nodes at once, K = 3 fixed Newton iterations,
  the 8 x 9 system solved by Gaussian elimination with partial pivoting in
  unsigned sign-magnitude u64 words; the f64 twin of the same iteration and
  an analytic-law run (Newton to convergence) live in the tests
- residual after the last iteration at every step: at most 2 units (0.12 uV)
  at K = 3; K = 1 reaches 29361, K = 2 reaches 55 (negative controls)
- +-2 mV and +-0.5 mV decide the right way; decision time (first output
  through Vdd / 2) 5.489 / 5.558 ps against ngspice 5.496 / 5.569 ps
  (-0.14 % / -0.20 %), resolution time 6.963 / 7.734 ps against 6.931 /
  7.694 ps (+0.47 % / +0.53 %)
- errors kept apart: arithmetic 68 / 251 units, table 15.2 / 19.0 mV,
  analytic law against ngspice 1.4e-9 V
- negative controls: K = 1, K = 2, inputs swapped, input-pair m swapped
  (38/34 vs 34/38), Vth = 0.30 table
- four ngspice MOSFET LEVEL=1 decks (fixed-step backward Euler recipe of
  bench.t27) in specs/analog/decks/, their numbers recorded in the spec
- metastability reported: each quartering of the input adds 7.67 steps;
  at 0 V the circuit stays symmetric and never decides

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gHashTag
gHashTag enabled auto-merge (squash) October 18, 2026 18:46
This was referenced Oct 18, 2026
@gHashTag
gHashTag merged commit aa56dde into master Oct 18, 2026
34 of 35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-18 19:56:18 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 43
PRs with All Checks Green 7
READY 1
FAILING 43
PENDING 0
NO CHECKS YET 0

These columns do not partition: 1 + 43 + 0 + 0 = 44, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=fad12492937a != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

gHashTag added a commit that referenced this pull request Oct 18, 2026
…#10547)

The ratchet on a616b7a reported the spec (landed on master in #10604)
as UNLISTED with a t27b pass; master's ledger has no row for it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Oct 18, 2026
…Closes #10649) (#10650)

The spec landed on master in #10604 without a ledger row, so every
PR's t27b-native-ratchet reports UNLISTED 1 with a t27b pass
(measured on #10632's run 0ce6fae vs ledger 90f6248).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
gHashTag added a commit that referenced this pull request Oct 18, 2026
…Closes #10547)

The ratchet on a616b7a reported the spec (landed on master in #10604)
as UNLISTED with a t27b pass; master's ledger has no row for it yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

analog M4b: the SAR ADC dynamic comparator -- multi-node Newton on the M3a solver, square-law first, against ngspice LEVEL=1

2 participants