Wednesday, November 18, 2026
Dear Tim Edwards - Please Ensure Level-Shifters in SKY130 Don't Keep Causing Grief
Friday, November 13, 2026
GF180MCU Device Cheat Sheet (But Which Flavor?:)
GlobalFoundries 180 nm MCU, variant D (open_pdks gf180mcuD, BSIM4). Corner typical / res_typical; mismatch via sw_stat_mismatch=1 (per-instance ΔVT and Δβ in the fets_mm wrappers). Every number below is simulated from the vendored models with plain ngspice decks, typical corner, 27 °C; the Monte-Carlo columns use the PDK's own per-device mismatch model with 30 samples. Click a column header to sort (first click ascending, second descending); click the # header to restore the original order. Devices marked † could not be simulated at the standard 10/0.5 and 0.5/2 geometries; the geometry used is listed under the table.
FETs
| # | Device | Type | Lmin (µm) | Wmin (µm) | VDS max (V) | VGS max (V) | Vth (V)7 | gm,in (µS)1 | gm,mir (µS)2 | AVT (mV·µm)3 | fT (GHz)4 | σ ΔI/I mirror (%)5 | σ Vos pair (mV)6 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | nfet_03v33.3 V NMOS | NMOS | 0.28 | 0.22 | 3.60 | 3.60 | 0.71 | 161 | 7.0 | 7.4 | 2.03 | 5.1 | 3.3 |
| 2 | pfet_03v33.3 V PMOS | PMOS | 0.28 | 0.22 | 3.60 | 3.60 | -0.79 | 110 | 3.5 | 6.9 | 0.99 | 2.4 | 3.2 |
| 3 | nfet_05v0†5 V NMOS (same model as 06v0) | NMOS | 0.60 | 0.30 | 5.50 | 5.50 | 0.71 | 155 | 6.5 | 19.0 | 2.46 | 6.3 | 7.5 |
| 4 | pfet_05v05 V PMOS | PMOS | 0.50 | 0.30 | 5.50 | 5.50 | -0.82 | 110 | 2.9 | 14.1 | 1.53 | 2.7 | 6.5 |
| 5 | nfet_06v0†6 V NMOS | NMOS | 0.70 | 0.30 | 6.50 | 6.50 | 0.72 | 144 | 6.5 | 16.8 | 1.97 | 6.3 | 6.3 |
| 6 | pfet_06v06 V PMOS | PMOS | 0.50 | 0.30 | 6.50 | 6.50 | -0.82 | 110 | 2.9 | 14.1 | 1.55 | 2.7 | 6.5 |
| 7 | nfet_06v0_nvt†6 V native NMOS | NMOS | 1.80 | 0.80 | 6.50 | 6.50 | -0.09 | 175 | n/a | n/a | 2.02 | n/a | n/a |
| 8 | nfet_03v3_dss3.3 V NMOS, drain salicide block | NMOS | 0.28 | 0.22 | 3.60 | 3.60 | 0.71 | 160 | 7.0 | 7.4 | 2.02 | 5.1 | 3.3 |
| 9 | pfet_03v3_dss3.3 V PMOS, drain salicide block | PMOS | 0.28 | 0.22 | 3.60 | 3.60 | -0.79 | 110 | 3.5 | 6.9 | 0.99 | 2.4 | 3.2 |
| 10 | nfet_06v0_dss†6 V NMOS, drain salicide block | NMOS | 0.60 | 0.30 | 6.50 | 6.50 | 0.71 | 158 | 6.5 | 19.0 | 2.56 | 6.3 | 7.5 |
| 11 | pfet_06v0_dss6 V PMOS, drain salicide block | PMOS | 0.50 | 0.30 | 6.50 | 6.50 | -0.82 | 110 | 2.9 | 14.1 | 1.55 | 2.7 | 6.5 |
† Geometry actually simulated (W/L in µm) where the standard 10/0.5 and 0.5/2 devices are not allowed: nfet_05v0: input-pair device 10/0.6 (Lmin / Wmin); nfet_06v0: input-pair device 10/0.7 (Lmin / Wmin); nfet_06v0_nvt: input-pair device 10/1.8, mirror device 0.8/2 (Lmin / Wmin); nfet_06v0_dss: input-pair device 10/0.6 (Lmin / Wmin).
Notes
- gm of one input-pair device, W = 10 µm, L = 0.5 µm (the geometry listed under † where the model does not allow that), ID = 10 µA, VDS = half the nominal supply of the device's gate class (1.65 V, 2.5 V, 3 V), VSB = 0, 27 °C; dID/dVGS from a 1 mV dc sweep.
- gm of one current-mirror device, W = 0.5 µm, L = 2 µm (or the † geometry), diode-connected, ID = 1 µA. Blank when the device cannot work as a diode-connected mirror (zero-VT or depletion device: VDS = VGS leaves it in triode).
- Pelgrom coefficient for the threshold: σ(ΔVT) of two input-pair devices (geometry of note 1) times √(W·L), from 30 Monte-Carlo mismatch samples (ΔVT read from the model's operating-point
vth). With 30 samples a σ carries about ±13 % (1σ) statistical error; the last section compares the samples with the model's own mismatch parameters. - Transit frequency of the input-pair device at the bias of note 1: frequency where |id/ig| = 1 in a small-signal sweep (drain at fixed VDS, source and bulk on the rail).
- Current-mirror error: two 0.5/2 devices at 1 µA (the "gm·ΔVGS" of a mirror), master diode-connected, slave at the same VDS; σ of (Islave − Imaster) / Imaster over 30 mismatch samples.
- Input offset: σ(ΔVGS) of two input-pair devices at 10 µA each (geometry of note 1), the number a differential pair of this size would show as random offset.
- Threshold voltage as the model reports it at the operating point of note 1 (BSIM4 / PSP
vthof the 10/0.5 device, VSB = 0, so it includes the model's drain-induced shift at that VDS); PMOS values are given with their negative sign, a negative NMOS value marks a depletion-mode device.
Resistors
| # | Resistor | Rsh (Ω/sq)a | TC (ppm/K)f | Wmin (µm) | Density (kΩ/µm²)b | σ ΔR/R, 1×10 µm (%)c | AR (%·µm)d | Rend (Ω)e |
|---|---|---|---|---|---|---|---|---|
| 1 | nplus_uN+ diffusion, unsalicided | 59.6 | 1379 | 0.80 | 0.0931 | n/a | n/a | 3.67 |
| 2 | pplus_uP+ diffusion, unsalicided | 187 | 1406 | 0.80 | 0.291 | n/a | n/a | 10.0 |
| 3 | npolyf_uN+ poly, unsalicided | 311 | -1327 | 0.80 | 0.486 | n/a | n/a | 8.03 |
| 4 | ppolyf_uP+ poly, unsalicided | 352 | -65 | 0.80 | 0.550 | n/a | n/a | 12.0 |
| 5 | ppolyf_u_1khigh-res poly 1k | 1001 | -853 | 1.00 | 1.00 | n/a | n/a | 16.8 |
| 6 | ppolyf_u_2khigh-res poly 2k | 2002 | -1544 | 1.00 | 2.00 | n/a | n/a | 43.9 |
| 7 | ppolyf_u_3khigh-res poly 3k | 3004 | -1544 | 1.00 | 3.00 | n/a | n/a | 62.6 |
| 8 | nwelln-well | 1051 | 2615 | 1.20 | 0.730 | n/a | n/a | 50.3 |
| 9 | ppolyf_sP+ poly, salicided | 7.36 | 3237 | 0.80 | 0.0115 | n/a | n/a | 1.00 |
| 10 | rm1metal 1 | 0.0906 | 3308 | 0.23 | 0.0017 | n/a | n/a | 0 |
Notes
- Sheet resistance from the model: R at W = 10 µm for L = 20 and 40 µm, Rsh = ΔR·W/ΔL, 27 °C, typical corner. A device at Wmin reads higher by the model's width bias (ΔW), up to +30 % for the n-well resistor.
- Resistance per unit body area at the minimum width: Rsh / Wmin² (ends, contacts and spacing not included). Highest = densest.
- Mismatch of two identical resistors, W = 1 µm (or Wmin), L = 10 µm, σ of ΔR/R over 30 Monte-Carlo mismatch samples.
- Area-normalised matching: the σ of note c times √(W·L), so σ(ΔR/R) ≈ AR/√(W·L) for another size. Lowest = best matching.
- End resistance per device from the same two lengths: R(L) ≈ Rsh·L/W + Rend (heads, contacts, salicide transitions).
- Span temperature coefficient of the sheet resistance, (Rsh(125 °C) − Rsh(−40 °C)) / (Rsh(27 °C) · 165 K), from the same wide devices; the models carry a quadratic term, so the local slope is lower at the cold end and higher at the hot end.
Ratings, sizes and what is not here
- Voltages: nominal 3.3 V and 5 V / 6 V supplies with a 10 % overshoot allowance; the design manual caps the DC gate-to-any-node voltage at 3.63 V for thin oxide and 6.5 V for the thick-gate devices. The table lists nominal + 10 % (3.6 / 5.5 V) and 6.5 V for the 6 V devices.
- Lmin/Wmin are the model binning limits (
lmin/wminin the vendored BSIM4 bins): 0.28 / 0.22 µm (3.3 V), 0.6 / 0.3 µm (5 V NMOS), 0.7 / 0.3 µm (6 V NMOS), 0.5 / 0.3 µm (5 V and 6 V PMOS), 1.8 / 0.8 µm (native).nfet_05v0/pfet_05v0share the 6 V models (Appendix A of the design manual); they differ by the V5_XTOR mark and the shorter allowed L. _dss= the same FET with a salicide-block (SAB) drain extension (3.78 µm NMOS / 2.78 µm PMOS on the drain, 0.28 µm on the source) for drain-voltage robustness; electrically identical here except the series drain resistance. The 10 V LDMOS (nfet_10v0_asym) has a symbol but no model in the vendored set and is not characterised. The native has no mismatch model, and its mirror cells are blank because a diode-connected depletion device (VT ≈ −0.1 V) sits in triode.- Mismatch parameters: the
fets_mmwrappers put σ(VT) = par_vth/√(Leff·Weff) with Leff = L − 0.15 µm (0.4 µm for the 5 V / 6 V FETs) and Weff = W + 0.1 µm (0.5 µm), par_vth 7.1 / 6.7 mV·µm (3.3 V n / p), 11.6 / 10.5 (5 V and 6 V n / p). Normalised to drawn W·L that predicts AVT 8.5 / 7.9 (3.3 V) and 19.5 / 17.2 / 16.3 (5 V n, 6 V n, p); the 30-sample values sit 3–13 % below. The 0.4 µm length offset is why the same 6 V model reads 19.0 at L 0.6 and 16.8 at L 0.7. - Resistor Wmin: PRES.1 / LRES.1 = 0.8 µm (unsalicided P+/N+ poly), HRES.2 = 1.0 µm (1k/2k/3k high-res poly); for the diffusion, n-well, salicided poly and metal resistors no device rule was found and the PDK symbol default (0.8 / 1.2 / 0.8 / 0.23 µm) is used. GF180's vendored models carry no resistor mismatch model (the
mis_rhook is never set), only global process σ: that column is empty.
Wednesday, November 11, 2026
In Case it Helps - Randomized Results in TT with SKY130nm and ngspice
Why my sky130 bandgap gave a different answer every run
One test in our xschem fork failed two of our last four full regression runs. On its own it always passed, so for weeks it was filed as "the known flaky one". This week we found the cause, and it is not a test problem at all. Every ordinary run of a tt_mm sky130 bench is a fresh Monte Carlo trial.
What we saw
The test simulates the bandgap testbench that ships with the open_pdks sky130 examples. Sometimes ngspice ran for about 13 seconds, exited with code 1, and wrote no results file. The failing check moved from run to run.
It looked like a load problem, because it only failed inside a full test run. It wasn't.
We copied the exact deck the test used and ran it with ngspice directly, 24 times. One run failed:
doAnalyses: TRAN: Timestep too small; time = 1.63211e-07, timestep = 5e-20: trouble with node "v4#branch" tran simulation(s) aborted
The surprise was earlier in the output. ngspice prints its starting solution before the transient begins, and no two runs printed the same one. Most started near 0 V, with noise from 1e-12 down to 1e-53. The failing run started at a non-physical point, with one node at −1.96×108 V.
Same deck, same binary, a different answer every time. Forcing ngspice onto one thread changed nothing, so it wasn't multithreading.
The cause
The bench's corner symbol says corner=tt_mm. In the sky130 model library, that section sets MC_MM_SWITCH=1, so every transistor draws a random mismatch offset when the netlist is loaded. Plain tt sets it to 0.
ngspice has no separate Monte Carlo analysis. Monte Carlo in ngspice means "run again with a different seed". These runs set no seed, so ngspice used a different one every time. Every run was a new random sample of the circuit.
Seven of the bundled sky130 example benches use tt_mm, including the two bandgaps, the comparator, lvnand and srlatch.
Adding one line before the .control block:
.option seed=1
Six concurrent runs then found the same starting solution, and their results files matched byte for byte once ngspice's date line was removed.
Is ngspice broken?
No. ngspice and the sky130 models are doing what they were designed to do. The bundled sky130_mismatch example even calls setseed 12 when it wants a repeatable run.
The bug is the gap between that design and what a Cadence user expects. In Spectre, mismatch only applies inside a Monte Carlo analysis, so an ordinary run gives the same numbers every time. Our ADE-style front end, ASE-L, handed ngspice the deck without pinning a seed. So pressing Run on a tt_mm bench quietly ran one Monte Carlo trial instead of a repeatable simulation. On this bandgap, about one trial in 24 also failed to converge.
What we're changing
ASE-L will pin the random seed for every run that isn't a Monte Carlo run, so a tt_mm bench gives the same answer each time you press Run.
Keep one subtlety in mind. A fixed seed gives you one particular mismatch sample, repeatably. It is not the mismatch-free typical device you get from tt. If you want typical numbers, use tt. If you want to see mismatch, run Monte Carlo.
If you use ngspice with sky130 today
If your corner ends in _mm and you aren't running Monte Carlo, either switch to the plain corner or put .option seed=1 in your deck. Otherwise two runs of the same schematic can disagree, and you'll chase a change you never made.
A flaky test hides its cause until someone keeps the evidence. These are the requests that got us from "known flaky" to a root cause:
- "Don't re-run it again. Find out why the simulator exits with error 1."
- "Copy the exact deck the test simulates, and run ngspice on it directly, many times, keeping the output of any run that fails."
- "Compare a failing run's output with a passing one, and tell me where they first differ."
- "Before fixing anything, give me the background: where did this come from, and is the tool itself broken?"
The third one cracked it. The difference was before the transient even started, and that pointed straight at the models instead of at the test.
Does ngspice STB Work? Is ASE-L Geared to Use it?
What native stb doesn't do yet:
Tuesday, September 1, 2026
What You Need In Your WSL to Hack Xschem
┌────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ group │ why │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ build-essential pkg-config bison flex gawk │ required by INSTALL; bison/flex regenerate expandlabel.c, eval_expr.c, parselabel.c │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ tcl-dev tk-dev │ pulls 8.6.16 — inside the project's 8.4–8.6 window. Also gives you tclsh (runs the regression suites) and wish (the GUI gate panel) │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ libx11-dev libxpm-dev │ required Xlib/Xpm │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ libcairo2-dev libxcb1-dev libx11-xcb-dev │ the optional-but-standard rendering path (anti-aliased text) │
│ libxrender-dev libxft-dev libfreetype-dev │ │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ xvfb openbox x11-utils │ the persistent dev display. openbox is the one from issue 0645 whose absence silently made every WM measurement a bare-Xvfb measurement. │
│ │ x11-utils gives xdpyinfo/xprop/xwininfo/xlsclients, which devdisplay.sh and the window-mapping suites call directly │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ x11vnc │ only for devdisplay.sh view — optional, but devdisplay.sh:341 dies with an install hint without it │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ gdb valgrind │ you asked; xschemtest.tcl -d 3 -l log also does allocation logging natively │
├────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ngspice verilator │ ~678 test references. Every use is auto_execok-guarded, so the ASE/cosim suites skip rather than fail without them — but skipping is │
│ │ what silently hides a regression │
└────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
sudo apt install -y \
build-essential pkg-config bison flex gawk \
tcl-dev tk-dev libx11-dev libxpm-dev \
libcairo2-dev libxcb1-dev libx11-xcb-dev libxrender-dev libxft-dev libfreetype-dev \
xvfb openbox x11-utils x11vnc \
gdb valgrind \
ngspice verilator
Wednesday, July 8, 2026
Beware - Fable 5 the token Hog. And, You Definitely Want the Caveman Mindset
When I did have Fable 5, for a week or so, till Trump killed it, I didn't notice anything special.
What I *have* noticed is that you burn through tokens *fast* if you ultracode with Fable 5. So, don't - unless someone else is paying :)
Sadly, it's taken two months and sheer luck to realize that Claude was hacking a C project using workarounds (bespoke address sanitizers created as needed) because it didn't find gdb or valgrind - when those two would have taken barely a minute to install.
Lesson - think about what you would need if you were hand coding and also ask Claude proactively. I lucked out seeing a message "no gdb/valgrind here".
The other thing that disappointed me - it's using the existing functionality of the tool to try and recreate fails. Once I asked it why it didn't just add hooks to print out trace information, it started flying. If only I'd known :)
So, there you have it - caveman + gdb + valgrind + trace hooks.
Enjoy!
Tuesday, March 24, 2026
Who Needs Cadence Anymore (for Schematic Tree Reporting that is :)? Make Your Own Reporter with chatGPT!
.subckt A in out vdd vss XB1 n1 n2 B XB2 n3 n4 B XC1 n5 n6 C XC2 n7 n8 C .ends .subckt B a b XD1 x y D XD2 x y D XD3 x y D XD4 x y D XC1 p q C XE1 p q E .ends .subckt C p q R1 p q 1k .ends .subckt D p q R2 p q 1k .ends .subckt E p q R3 p q 1k .ends XTOP in out vdd vss A
A |----- B (2) | |----- C | |----- D (4) | \----- E \----- C (2)
Saturday, July 26, 2025
Test Driven Development in Xschem
What tests are currently implemented?
● Current Testing Infrastructure Analysis
Test Structure:
- 3 main test suites: create_save, open_close, netlisting
- Test runner: run_regression.tcl orchestrates all tests
- Test framework: Tcl-based with standardized test_utility.tcl
- Not integrated: Tests are NOT part of the main Makefile build process
Test Coverage:
1. create_save.tcl: Tests script execution and schematic creation
2. open_close.tcl: Tests file opening/closing for all .sch/.sym files in xschem_library
3. netlisting.tcl: Tests netlisting in 4 formats (VHDL, Verilog, TDX, SPICE)
Test Execution:
- Tests run XSCHEM in headless mode (-q -x -r)
- Captures debug output and validates against expected results
- Tests are comprehensive but do NOT test keyboard/UI interactions
Critical Gap for Refactoring:
The existing tests validate file operations and netlisting but cannot test the handle_key_press() function since it requires
interactive keyboard input. For safe refactoring, we'll need to:
1. Extract testable helper functions from handle_key_press()
2. Rely on manual testing for UI validation
3. Use existing regression tests to ensure no core functionality breaks
The current test infrastructure is sufficient for validating that our refactoring doesn't break file operations, but manual UI
testing will be required for keyboard interaction validation.
handle_key_press - the "Monster Function"
> How do you recommend going after the monster function handle_key_press?
● Excellent question! The handle_key_press() function with 1,524 lines is a prime example of what needs systematic refactoring.
Let me analyze it and provide a concrete attack strategy.
● Update Todos
⎿ ☐ Analyze handle_key_press function structure
☐ Identify key functional groups and responsibilities
☐ Design refactoring strategy with safe incremental steps
☐ Test and validate refactored implementation
☐ Create helper function extraction plan
☐ Implement command dispatch table approach
Stefan++ : How? Reduce Cyclomatic Complexity
What does "high cyclomatic complexity" mean?
It means your code has turned into a labyrinth, and anyone trying to maintain it will likely curse your name.
Cyclomatic complexity is a metric that counts the number of independent paths through your code. Think of it as a "how many ways can I break my brain" counter. The higher the number, the more branches, loops, and conditionals are cluttering up your code.
- Low cyclomatic complexity (1–10): Code is simple, readable, and probably written by someone who still has hope.
- High cyclomatic complexity (20+): Code is a minefield of
ifstatements,whileloops, and spaghetti logic.
In short, “high cyclomatic complexity” means your code is doing too much in one place and needs to be refactored into smaller, cleaner chunks.
Checklist: How to Reduce Cyclomatic Complexity
✅ 1. Split Large Functions
Break big functions into smaller, focused ones.
def process_order(order):
if order.type == 'online':
...
elif order.type == 'in-store':
...
# Better:
def process_order(order):
if order.type == 'online':
handle_online(order)
elif order.type == 'in-store':
handle_instore(order)
✅ 2. Replace Complex Conditionals with Polymorphism
# Bad:
if shape == 'circle':
...
elif shape == 'square':
...
# Better:
class Shape:
def area(self): pass
class Circle(Shape):
def area(self): return pi * r * r
✅ 3. Use Guard Clauses
# Instead of:
def process(user):
if user.is_active:
if user.has_permission:
...
# Do:
def process(user):
if not user.is_active or not user.has_permission:
return
...
✅ 4. Use Lookups Instead of Conditionals
# Instead of:
if key == 'a': do_a()
elif key == 'b': do_b()
# Do:
actions = {'a': do_a, 'b': do_b}
actions.get(key, do_default)()
✅ 5. Extract Logic from Loops
# Instead of:
for item in items:
if item.is_valid() and not item.is_expired():
if item.value > threshold:
...
# Do:
for item in items:
handle_item(item)
✅ 6. Minimize Boolean Logic
# Instead of:
if not (x or (y and not z)):
# Do:
should_skip = x or (y and not z)
if not should_skip:


