Showing posts with label qspice. Show all posts
Showing posts with label qspice. Show all posts

Wednesday, November 18, 2026

Saving Arbitrary Terminal Currents in NGSpice - Yes, in Ver-53 (Ours:)

In Spectre you have always been able to write save x1.x2.m3:d and get the current into the drain of a transistor buried two levels down. ngspice had no such thing. Our ngspice branch now does: .probe I(x1.x2.m3,d) saves the current into any terminal of any instance, at any depth, in every analysis.

The gap

ngspice had three ways to get at a terminal current, and none of them was the real thing:

  • .probe I(m1,d) worked for instances at the top level only. Name anything inside a subcircuit and the probe was dropped with a warning.
  • Device parameters such as @m.x1.x2.m3[id]. Their names change from model to model, and they are operating-point quantities, so an AC analysis gives you the bias current, not the small-signal current. They are also read from the Newton iterate before the last, so they agree with the solution only within the solver's tolerance.
  • A hand-placed 0 V source inside the subcircuit. It works, but it edits the subcircuit, so every instance of it gets a source. Every probe you move means another edit.

Here is what the previous build said about a deck that asks for four currents inside a hierarchy:

Warning: Node o is not available for device x1,
   .probe i(x1,o) will be ignored
Warning: Could not find the instance line for x1.r1,
   .probe i(x1.r1) will be ignored
Warning: Could not find the instance line for x1.x2,
   .probe i(x1.x2,s) will be ignored
Warning: Could not find the instance line for x1.x2.m3,
   .probe i(x1.x2.m3) will be ignored

What it looks like now

The same deck: an amplifier x1 holding a resistor, a second-level instance x2 with one NMOS, and a resistor to ground.

* terminal currents two levels down
vdd vdd 0 dc 2
vg  g   0 dc 1.5
x1  vdd g out amp
rl  out 0 10k

.subckt amp p in o
r1 p o 1k
x2 in o mid stage
r2 mid 0 2k
.ends

.subckt stage i d s
m3 d i s 0 nmod w=2u l=1u
.ends

.model nmod nmos level=1 vto=0.5 kp=100u

.probe I(x1.x2.m3)  I(x1.x2,s)  I(x1.r1)  I(x1,o)

.control
op
print i(x1.x2.m3:d) i(x1.x2.m3:g) i(x1.x2.m3:s) i(x1.x2.m3:b_tj)
print i(x1.x2:s) i(x1.r1) i(x1:o)
.endc
.end
i(x1.x2.m3:d)    =  7.294902e-05
i(x1.x2.m3:g)    =  0.000000e+00
i(x1.x2.m3:s)    = -7.29490e-05
i(x1.x2.m3:b_tj) = -1.91776e-12
i(x1.x2:s)       = -7.29490e-05
i(x1.r1)         =  2.481355e-04
i(x1:o)          = -1.75186e-04

I(x1.x2.m3) with no terminal gives all four. The four sum to −1.2e-19 A, so KCL closes to rounding. The port x1.x2:s carries exactly the source current, because nothing else is on it. Inside x1, the 248 µA through r1 splits into the 73 µA the drain takes and the 175 µA that leaves through port o into the load.

Writing a probe

.probe I(instance,terminal)     * or I(instance:terminal)
.probe I(instance)              * every terminal of it
  • The instance is its hierarchical path, x1.x2.m3, or its name in the flattened circuit, m.x1.x2.m3.
  • The terminal is a position counted from 1, a device letter (MOS d g s b, BJT c b e s, JFET d g s, diode a and c or k), the name of a subcircuit port, or the terminal name a Verilog-A model gives it.
  • Two spellings of one terminal are one probe and one vector: I(x1.x2.m3,1) and I(x1.x2.m3:d) are the same thing.

The vector is <path>:<terminal>#branch, which you read as i(x1.x2.m3:d). The terminal part is the name .probe has always used at the top level, so moving a block into a subcircuit only puts the path in front. Nothing in your scripts gets renamed.

DeviceTerminal names, in order
MOSFET (M)d g s b_tj (and tc n6 n7 on models with more nodes)
BJT (Q)c b e s t
JFET, MESFET (J, Z)d g s
Diode (D)a c
Subcircuit instance (X)the port names of the subcircuit
Verilog-A / OSDI (N)the terminal names of the model
everything elsen1 n2 …

b_tj looks odd, but it is the name ngspice's .probe has always given the fourth node of an M line, and keeping it means old decks and new ones agree. You can still type b or 4; only the saved name follows the table.

Which way is positive

A probe gives the current into the terminal, flowing from the net into the instance. The four terminals of a MOSFET sum to zero, and a negative port current means current is leaving the instance there.

The one exception is an instance with two terminals and no terminal named, such as I(x1.r1). That gives one vector named after the instance, the current through it from its first terminal to its second, the same convention .probe has always used at the top level. For a subcircuit with two ports and a path to ground inside, the two ports carry different currents. In that case, name the port you mean.

AC and transient too

The probe is an ideal 0 V source in the circuit, so its current is the solution itself, in op, dc, ac and tran. In AC it is the complex small-signal current. Here is a capacitor inside an RC subcircuit, compared with ωC·|v|:

vin in 0 dc 0 ac 1
x1  in out filt
.subckt filt a b
r1 a b 1k
c1 b 0 1u
.ends
.probe I(x1.c1)
.control
ac dec 1 10 100k
print mag(i(x1.c1)) mag(2*pi*frequency*1u*v(out)) vp(i(x1.c1))
.endc
frequency      mag(i(x1.c1))   w*C*|v(out)|    phase (rad)
1.000000e+01   6.270819e-05    6.270819e-05    1.508047e+00
1.000000e+02   5.320180e-04    5.320180e-04    1.009814e+00
1.000000e+03   9.875705e-04    9.875705e-04    1.578312e-01
1.000000e+04   9.998734e-04    9.998734e-04    1.591415e-02
1.000000e+05   9.999987e-04    9.999987e-04    1.591548e-03

Verilog-A devices loaded through OSDI work the same way, and they use their model's own terminal names. With PSP 103 compiled by OpenVAF, .probe I(n1) gives n1:d, n1:g, n1:s and n1:b, and I(xa.n2,d) reaches one inside a subcircuit.

How it works

A 0 V source is inserted between the drain terminal d of x1.x2.m3 and its net; the probe current i(x1.x2.m3:d) flows from the net into the terminal.
The probe as the simulator sees it. The source changes nothing in the circuit; its branch current is the terminal current.

When the reader expands the subcircuits, it puts the probed terminal on a new node and inserts a 0 V source between that node and the net, with the net as the positive side. Ports of subcircuit instances are handled during the expansion itself, and device terminals afterwards, in the flattened netlist. After the circuit is built, the source is renamed after the terminal and its branch current is added to the save list. The new node is kept out of .save all, so your vector list shows the currents and not the nodes they needed.

Because no device code is involved, every built-in or Verilog-A device gets this for free. The probes are written into the stored copy of the deck, so they come back after reset. The machinery is shared with the stb loop-gain analysis, which uses the same kind of terminal probe. When both are on one terminal, they get two sources in series, and the loop gain is unchanged.

How exact

  • The current is the solution, so KCL holds to rounding: a resistor's probe agrees with (v(a)−v(b))/R to 1e-15 A, and a MOSFET's terminals sum to about 1e-19 A.
  • Device parameters such as @m.x1.x2.m3[id] are read from the iterate before the last, so they match the probe only within the Newton tolerance. In our tests a BJT's @ic was 0.055 % off the probe current.
  • A terminal current includes everything the model stamps there. The MOSFET bulk above shows −1.9 pA: that is the gmin of its junctions, not a bug.
Where to get it. This is on our ngspice branch, not in upstream ngspice. The behaviour at the top level is unchanged: existing .probe decks give the same vectors under the same names. Scripts and schematic tools can check for the feature with $?probe_version, which is 1 in a build that has it.

Limits

  • vd() and p() in .probe (voltage differences and power) still work at the top level only.
  • .probe alli still covers the top level only; a terminal inside a subcircuit needs its own I(…).
  • Probes are made when the deck is read. You cannot add one from the command prompt afterwards.
  • XSPICE code-model instances, couplings (K), and E/G sources with an expression are refused with a one-line reason. For those, place a 0 V source yourself.
  • Tested in the ngspice executable. The shared-library build (libngspice) has not been exercised yet.

How it was tested

Every behaviour started as a failing test. A new regression suite of 14 decks checks currents against hand-solved circuits: the hierarchy, every spelling of a terminal, the same block at two depths, two-port subcircuits, refusals, reset, what gets saved, sharing a terminal with stb, alli, and the unchanged top level, in op, AC and transient, plus the version variable. Two more decks check the case-sensitive netlist modes. The full ngspice regression and model-QA suite still passes, with one known failure in an unrelated rusage test that predates this work.

Sunday, November 1, 2026

Which FOSSi PDK Can Truly Hack It? (Hint : Not GF or SKY :)

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

sky130GF180MCUIHP SG13G2
MOS mismatchreal, plausiblereal, matches PDK docsreal, plausible
Process (die-to-die)broken as shipped; workaround gives VT onlyreal, combines with mismatchreal, but section order matters
Resistor mismatchrealnone (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 coefficientcorrect only with a patched ngspicecorrectcorrect
Bipolar mismatchpnp realpnp real, npn nonereal, scaled by size since PR #1234 (not scaled in the copy measured before 2026-10-30's update)
Capacitor mismatchrealnonereal
Speed, 200 samplesslowest (2.5 s just to parse the library)about 1 s for 20 FETsabout 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.1530.4 mV11.8 mV·µm
nfet_01v8 2/0.56.3 mV6.3 mV·µm
nfet_01v8 10/11.5 mV4.8 mV·µm
pfet_01v8 2/0.57.9 mV7.9 mV·µm
pfet_01v8 10/12.7 mV8.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) measuredPDK formula
nfet_03v3 1/0.2817.4 mV18.9 mV
pfet_03v3 1/0.2818.1 mV17.6 mV
nfet_03v3 10/12.5 mV2.4 mV
nfet_03v3 20/50.73 mV0.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.1321.5 mV (5.5 mV·µm)12.8 mV (3.3 mV·µm)
1/15.7 mV (5.7 mV·µm)3.6 mV (3.6 mV·µm)
4/41.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 µmpair ΔR/R σ (local)R σ (global)
rsil0.66%4.2%
rppd0.82%3.1%
rhigh2.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 µmlocal σ (one resistor)mean shift
rsil0.47%+0.15%
rppd0.58%+0.26%
rhigh1.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.

Sunday, June 18, 2023

Can You Figure Out Why a Simple Circuit Bogs LTspice Down at 700 us

Build : LTspice XVII(X64) (1.7.0.360) Dec 13 2022, 02:47:55 US Pacific

Test case : (Google Drive 8 kB zipped) https://drive.google.com/file/d/1vWl0ZMB6GwsQwaJHG4GdO22Atp_7z30M/view?usp=sharing

This is Robert Erickson's assignment in the Intro to Power Electronics Course on Coursera, from CU Boulder


Won't finish in 20 minutes.. Had to kill it. Why? What did they break?

BTW, Mike Engelhardt's new simulator will be out eventually, hosted by Qorvo.

Getting a Useful VcXsrv Crash Dump

Winner of the first Nobel Prize in Physics ❯ tell me how to do the VcXsrv shortcut that I currently have in my Startup folder so that we get...