Monte Carlo in ngspice on three open PDKs: sky130, GF180MCU and IHP SG13G2
What is real, what is broken, and how to get usable statistics out of each
- Date
- 2026-10-30
- Simulators
- ngspice 45.2 (distribution build), and an ngspice-46+ development build carrying a resistor temperature-coefficient fix
- Method
- 200-seed loops of small test decks per PDK, with every draw read back and compared against the PDK's own constants and, where they exist, its published measurements
- Verdict
- IHP SG13G2 is the most complete; sky130 is real for mismatch but not for process; GF180MCU is real for transistors but has no resistor mismatch
A common belief in the open-source analog community is that "sky130 Monte Carlo doesn't work in ngspice". We needed a definite answer, because we are building Monte Carlo support into an open-source schematic and simulation environment, and its first real use is trim-and-sim on a bandgap: one test finds a trim code for each Monte Carlo sample, and a second test runs that sample with its trim code under stress. A bandgap's spread is dominated by resistor-ratio and bipolar mismatch, as well as transistor offsets, so a PDK that leaves any of those out gives a falsely tight answer.
So we measured all three open PDKs the same way, rather than relying on folklore.
How we measured
Each PDK got the same kinds of test circuit: diode-connected transistor pairs at several sizes, resistor pairs, MIM capacitor pairs and bipolar devices. Each deck ran 200 samples inside a single ngspice process, using a loop that we had already validated for repeatability:
.control
foreach k 1 2 3 ... 200
setseed $k
reset
op
echo "ROW $k $&v(a) $&v(b) ..." >> rows.txt
destroy all
end
.endc
Two details matter here:
destroy all in every sample is essential. Without it, reset slows down with every stored plot, and a 5000-sample run takes more than three times as long.
- Each test directory had its own explicit
.spiceinit. Otherwise one in $HOME can leak into the run and silently change the draws: ngbehavior=hsa changes the random sequence on sky130.
From each run we computed the per-device and pair-difference standard deviation, checked the Pelgrom scaling (σ·√(W·L) should be roughly constant across sizes), checked that two "identical" devices draw independently, and checked that sample k gives the same answer in a loop and in a fresh process. For every PDK the stock 45.2 binary and the development build gave bit-identical draws.
The summary
| sky130 | GF180MCU | IHP SG13G2 |
| MOS mismatch | real, plausible | real, matches PDK docs | real, plausible |
| Process (die-to-die) | broken as shipped; workaround gives VT only | real, combines with mismatch | real, but section order matters |
| Resistor mismatch | real | none (zero in the model) | real; centred upstream since 2026-03-02 (58d1f3d, on main too); the copy measured before 2026-10-30's update predates it and was about one local σ high |
| Resistor temperature coefficient | correct only with a patched ngspice | correct | correct |
| Bipolar mismatch | pnp real | pnp real, npn none | real, scaled by size since PR #1234 (not scaled in the copy measured before 2026-10-30's update) |
| Capacitor mismatch | real | none | real |
| Speed, 200 samples | slowest (2.5 s just to parse the library) | about 1 s for 20 FETs | about 2 s for 12 PSP FETs |
sky130
Mismatch: real
With the tt library and MC_MM_SWITCH=1, local mismatch is per device, Pelgrom-scaled and repeatable. tt with the switch on is bit-identical to the tt_mm section.
| Pair (W/L, µm) | σ(ΔVth) | σ·√(WL) |
| nfet_01v8 1/0.15 | 30.4 mV | 11.8 mV·µm |
| nfet_01v8 2/0.5 | 6.3 mV | 6.3 mV·µm |
| nfet_01v8 10/1 | 1.5 mV | 4.8 mV·µm |
| pfet_01v8 2/0.5 | 7.9 mV | 7.9 mV·µm |
| pfet_01v8 10/1 | 2.7 mV | 8.5 mV·µm |
The PDK's own constants give a pair AVT of 4.75 mV·µm (n) and 8.28 mV·µm (p), which is plausible for a 130 nm process. Only VT varies: the mobility and oxide mismatch lines in the model are commented out. Minimum-size nfets come out about 2.4× wider than the constant suggests, because in nfet_01v8 the mismatch term sits inside a geometry multiplier. That looks unintended, and it makes small nfets pessimistic. We found no published SkyWater mismatch measurement to compare with.
Resistors (res_xhigh_po, res_high_po), MIM capacitors and the pnp_05v5 all vary, by amounts consistent with the PDK constants. For example, a res_xhigh_po 1×20 µm pair shows 1.4% σ in its ratio, and a 10×10 µm MIM pair shows 0.07%.
Process variation: broken as shipped
The .lib mc section cannot be used under ngspice. We found four separate defects:
- 69
GAUSS(0, rel, 1) sites apply relative variation to a nominal of 0, so they never vary.
sw_nw_rs_mult uses 1+EXP(AGAUSS), which adds where it should multiply.
- Every reference to a global
agauss parameter draws it again, so devices on the same die are not correlated.
- VT and oxide process variation are hard-coded to 0.
What remains spread is uncorrelated between identical devices, so it behaves like extra mismatch, not like die-to-die variation.
Workaround: draw the die-level VT yourself. The sw_vth0_*_mc parameters are plain constants, so alterparam can set them per sample. The standard deviations below come from the PDK's own (commented-out) Spectre vary block:
setseed $k
let zn = sgauss(0)
let zp = sgauss(0)
let vn = 0.006*zn
let vp = 0.009*zp
alterparam sw_vth0_sky130_fd_pr__nfet_01v8_mc = $&vn
alterparam sw_vth0_sky130_fd_pr__pfet_01v8_mc = $&vp
reset
This gives genuine die-to-die VT variation, fully correlated across all devices of a type, with n and p independent. It combines correctly with mismatch. It is VT only: there is no oxide, critical-dimension, mobility, resistor or capacitor process variation, and it needs one line per device family. For resistors and capacitors only the discrete corners work.
Resistor temperature coefficient
ngspice converts res_xhigh_po's voltage-dependent body into a B-source, and in doing so drops the model and with it the temperature coefficient. In stock ngspice the body is flat with temperature; it should be +17% at −40 °C and −22% at 125 °C. That alone flips the sign of a bandgap's output slope over temperature. Our patched ngspice build gets it right. Do not also apply the "three-line PDK edit" fix to a patched build, or the coefficient is applied twice.
GF180MCU
Mismatch and process: both real, but off by default
design.ngspice ships with sw_stat_global=0 and sw_stat_mismatch=0; mismatch was switched off by default after an upstream issue in 2022. To get real statistics, use the statistical sections instead of the typical ones, and turn the switches on afterwards:
.include design.ngspice
.lib sm141064.ngspice statistical
.lib sm141064.ngspice res_statistical
.lib sm141064.ngspice bjt_statistical
.lib sm141064.ngspice cap_mim
.lib sm141064_mim.ngspice mimcap_statistical
.param sw_stat_global=1
.param sw_stat_mismatch=1
Replace typical and res_typical with these; do not add them alongside. Including res_typical and res_statistical together fails with subcircuit redefinition and formula errors.
| Pair (W/L, µm) | σ(ΔVth) measured | PDK formula |
| nfet_03v3 1/0.28 | 17.4 mV | 18.9 mV |
| pfet_03v3 1/0.28 | 18.1 mV | 17.6 mV |
| nfet_03v3 10/1 | 2.5 mV | 2.4 mV |
| nfet_03v3 20/5 | 0.73 mV | 0.72 mV |
These match both the model's formula and the measured mismatch plot in the GF180MCU documentation (about 9 mV·µm for n and 8.6 mV·µm for p). Global variation is a genuine die-wide draw: with mismatch off, a pair's difference is exactly zero. With both switches on, single-device σ is the root-sum-square of the two. The ff and ss corners sit about 5σ from typical, wider than a "3σ corner" would be.
What is missing or wrong
- No resistor, MIM or npn mismatch. They vary only globally. The resistor mismatch term exists in the model only as a comment, although the PDK documentation shows measured resistor mismatch of up to about 0.85%. For a bandgap this is serious: the resistor-ratio spread is simply absent.
- The resistor body has no thermal noise. The same B-source conversion that costs sky130 its temperature coefficient costs GF180 its noise: a 10.5 kΩ
ppolyf_u_1k produced 1.7 nV/√Hz instead of 13.2. Only the two head resistors are noisy. The temperature coefficient survives, because it is written into the expression itself.
m= overstates mismatch by √m. The per-instance draw ignores m: an m=4 pair gave 19.5 mV instead of about 8.7. Use par= for matched arrays, which the formula does scale by. (xschem's GF180 symbols emit m=.)
The pnp mismatch (0.035 mV ΔVeb for 10×10 µm) matches the documentation. GF180 is also by far the fastest PDK to parse.
IHP SG13G2
Update, 2026-10-30. We re-measured against IHP-Open-PDK
dev at
dcb03b1 (2026-10-30), which includes the resistor-statistics restructure of 2026-10-17 (
1d12af5). Our previous copy dated from February 2026, so the update brings in several upstream fixes made since then. Most of them are already on the
main branch (last updated 2026-09-01): the resistor centring (
58d1f3d, 2026-03-02), the pmos
muew fix (
bc94a21, 2026-05-18) and the
mm_ok changes. Only the HBT size scaling and the 2026-10-17 restructure (with
res_stat_mismatch) are on
dev alone. We used the same decks and 200 seeds, on both ngspice builds. What the update fixes:
- Resistor mismatch is centred. In
res_typ_mismatch with mm_ok=1, the mean of a 1×10 µm resistor equals its typical value within sampling error: rsil −0.01%, rppd −0.01%, rhigh +0.02%, against +0.15%, +0.26% and +1.39% before. With mm_ok=0, a resistor now sits exactly at nominal. The pair scatter is about what it was (0.75%, 0.93%, 2.17%).
- The pmos
muew process parameter varies (σ 0.024 on 1.052). It was frozen before.
- HBT mismatch scales with size (
dev only). ΔVbe σ is 1.52 mV for one emitter and 0.66 mV for four, against about 4 mV for both before.
- A combined resistor section exists (
dev only): res_stat_mismatch gives resistor process and mismatch together. MOS still has no combined section, and the stat-then-mismatch order trap below is still there.
What to watch for in the new release:
- Mismatch is mostly off by default. The MOS, HBT, resistor, varactor and MIM capacitor (
cap_cmim, cap_rfcmim) subcircuits now default to mm_ok=0 (for the MIM caps this is new: the old copy defaulted them to 1 in the mismatch section, and a hand-written 10×10 µm cap_cmim went from a 0.09% capacitance sigma to 0), so a hand-written instance of those gets zero mismatch. The MOS capacitors (sg13_moscap_n/_p) are the exception: they default to mm_ok=1 and still vary in moscap_tt_mismatch without it. IHP's own symbols put mm_ok=1 on each instance, so a schematic drawn from them is fine. A hand-written netlist needs mm_ok=1 on every device line that should vary.
- The plain sections are no longer mismatch-free. The HBT model now carries its mismatch itself, so
hbt_typ and hbt_typ_stat also draw HBT mismatch for an mm_ok=1 device, and every schematic HBT is one. An ordinary typical simulation of an HBT schematic is therefore random: with no seed set, three runs of the same hbt_typ deck gave Vbe 0.72713, 0.72710 and 0.72660 V, while an instance without mm_ok stayed at 0.72656 V. A nominal or process-only run must set mm_ok=0 on the HBTs to stay one.
res_typ_stat is renamed res_stat. Three of IHP's own example benches still use the old name and stop with "section definition res_typ_stat not found". num_sigmas no longer scales the resistors' process spread.
- Typical resistance moved: at 1×10 µm, rsil +0.9%, rppd +0.6% and rhigh −4.1%. The global spreads are now rsil 4.4%, rppd 3.5% and rhigh 5.4%, where they were 4.2%, 3.1% and 8.3%.
The rest of this section describes the copy measured before 2026-10-30's update, unless it says otherwise.
Running PSP
The SG13G2 MOS model is PSP 103, which ngspice runs through OSDI. The PDK ships only the Verilog-A sources, so the modules have to be compiled. The workarea carries them prebuilt: psp103.osdi (PSP 103.8.2), psp103_nqs.osdi, r3_cmc.osdi, mosvar.osdi, cap_cmomi.osdi and cap_cmomf.osdi, the set upstream's own build script makes, compiled with OpenVAF-Reloaded v24.0.2mob for generic x86-64. They load with pre_osdi on both ngspice 45.2 and the development build. You need OpenVAF only to rebuild them. Moving from PSP 103.6 to 103.8.2 left the MOS numbers here unchanged: the Id check point and the 5.52 mV mismatch pair agree to the printed digit.
Mismatch: real, for every device type
The corner libraries have a _mismatch twin of each section (mos_tt_mismatch, res_typ_mismatch, and so on). Local variation is written on the instance line inside each subcircuit, so every instance draws independently, controlled by the mm_ok instance parameter.
| Pair (W/L, µm) | nmos σ(ΔVgs) | pmos σ(ΔVgs) |
| 0.5/0.13 | 21.5 mV (5.5 mV·µm) | 12.8 mV (3.3 mV·µm) |
| 1/1 | 5.7 mV (5.7 mV·µm) | 3.6 mV (3.6 mV·µm) |
| 4/4 | 1.4 mV (5.7 mV·µm) | 0.8 mV (3.3 mV·µm) |
Pelgrom scaling holds very well, m=2 is applied correctly, and the values were reworked upstream in late 2025 to match measurement. IHP's process specification does not publish an AVT figure, so the cross-check is the upstream rework rather than a datasheet.
| Resistor, 1×10 µm | pair ΔR/R σ (local) | R σ (global) |
| rsil | 0.66% | 4.2% |
| rppd | 0.82% | 3.1% |
| rhigh | 2.23% | 8.3% |
MIM capacitors show 1%/√(area in µm²) local mismatch and 3.3% global. The npn13G2 HBT varies both locally and globally. Resistor temperature behaviour is correct (rsil +3100 ppm/K, rhigh −2300 ppm/K), because the resistor model is an OSDI device and is not converted to a B-source.
Process variation, and the order trap
mos_tt_stat gives genuine die-to-die variation (nmos 1×1 Vgs σ 34 mV). But the PDK has no section combining process and mismatch, and combining the two existing ones depends on their order:
Trap: .lib … mos_tt_stat followed by .lib … mos_tt_mismatch gives no variation of any kind. The only sign is a redefinition of .subckt … ignored warning. The first, non-mismatch subcircuit wins, and the second section's fixed parameters overwrite the global draws. The opposite order works.
A cleaner fix is a small wrapper section of your own that leaves the PDK files untouched: the _norm parameter values from mos_tt_stat, followed by the stat and mismatch model files.
.LIB mos_tt_stat_mm
.param sg13g2_lv_nmos_vfbo_norm = 1.0
.param sg13g2_lv_nmos_ctl_norm = 1.2080
* ... the rest of the *_norm parameters, copied from mos_tt_stat ...
.include <pdk>/models/sg13g2_moslv_stat.lib
.include <pdk>/models/sg13g2_moslv_mismatch.lib
.include <pdk>/models/sg13g2_moslv_mod_mismatch.lib
.ENDL mos_tt_stat_mm
With it, a sample gets the same global draw as the stat-only section plus independent per-device mismatch (34 mV global, 5.3 mV pair difference at 1×1 µm).
Defects in the copy measured before 2026-10-30's update
- One pmos process parameter never varies. In
sg13g2_moslv_stat.lib the pmos muew line reads gauss(…_muew_norm, 0.0235 num_sigmas), with a missing comma. It is fixed upstream, and the update varies it (MEASURED 2026-10-30).
- Resistor mismatch is biased. See the next section. It is fixed in the update.
- HBT mismatch does not scale with size. ΔVbe σ is about 4 mV for both one and four emitters, so large devices are too pessimistic. It is fixed upstream (PR #1234, October 2026): 1.52 mV for one emitter and 0.66 mV for four in the update.
- Global spreads are only indicative. The nmos spread is about twice what the process specification's min/max implies, the pmos spread about 0.7×, and the corners sit at 1–1.6σ (n) and 4–5σ (p) from typical.
Resistor mismatch: right spread, wrong centre (before 2026-10-30's update)
Resistor mismatch should be "nominal plus z × σ", where z is a random number with mean 0 and standard deviation 1, and σ is the local mismatch for that resistor's size. In the copy we measured, the draws are written gauss(1, 1, …): z has mean 1 instead of 0. Every resistor therefore gets "nominal plus (1 + random) × σ". The scatter is the right size, but it is centred about one local σ too high. That is σ of the small random scatter between neighbouring resistors, not the much larger die-to-die variation.
| Resistor, 1×10 µm | local σ (one resistor) | mean shift |
| rsil | 0.47% | +0.15% |
| rppd | 0.58% | +0.26% |
| rhigh | 1.63% | +1.39% (14,943 Ω → about 15,150 Ω) |
The shift is not exactly one σ for every type, because each resistor model applies the draw through its own parameters (sheet resistance, width and length). Turning mismatch off with mm_ok=0 removes the scatter but not the offset: every resistor then sits at its shifted value instead of nominal.
Why it mostly does not matter for matching: two resistors of the same size and type get the same upward shift, so their ratio is unaffected. Only the random part differs between them, and that part is correct; the rhigh pair's 2.23% ratio scatter above is right.
Where it does matter:
- Absolute resistance comes out slightly high, so for example a bandgap's bias current is slightly off. Trim usually absorbs this.
- Ratios between resistors of different sizes or types are biased slightly, because the shift differs between them. For a 1×10 µm rhigh against a 1×10 µm rsil that is about 1.2%.
Fix: load a copy of the resistor mismatch file with mean 0 instead of 1 from a wrapper section, as for the MOS wrapper above, leaving the PDK files untouched. Alternatively, update the PDK: upstream corrected the mean on 2026-03-02 (58d1f3d, on both main and dev), and we measured it centred on 2026-10-30 (see the update above). The wrapper is only needed for a copy older than that.
When updating the PDK: since May 2026 upstream sets the MOS subcircuit default to mm_ok=0. A newer copy therefore gives zero transistor mismatch in mos_tt_mismatch unless each instance sets mm_ok=1. Measured on the 2026-10-30 copy: a plain 1/1 µm nmos pair gives a ΔVgs σ of 0, and with mm_ok=1 it gives 5.52 mV, the same as before. The update applies the same default to resistors, HBTs, varactors and the MIM capacitors (which defaulted to 1 before), but not to the MOS capacitors. Check for this before trusting a run after a PDK update.
Which PDK for bandgap trim-and-sim?
- IHP SG13G2 varies everything that matters for a bandgap: transistors, resistors, bipolars and capacitors, locally and globally, with correct temperature behaviour in stock ngspice. Its defects are known and can be worked around, and upstream has fixed the resistor centre and the pmos
muew (both on main) and the HBT area scaling (dev only). In return, mismatch now has to be switched on per instance (mm_ok=1). This is the one we are building on.
- sky130 is fine for mismatch, including resistors and the pnp, but its process variation is VT-only by workaround, and temperature sweeps need a patched ngspice.
- GF180MCU is excellent for transistors but has no resistor mismatch, so it would understate a bandgap's spread.
Whichever you use, read back a few draws before trusting a run. In every one of these PDKs a plausible-looking simulation can quietly have zero variation in one device class, and the only way to know is to look.