Bandgap Layout
How the bandgap reference layout is drawn, wired and checked.
How it's built
How the devices are drawn. Every device comes from the sky130 PDK's own KLayout generators, the same code behind
KLayout's SKY130 PCell menu, driven from layout/bandgap/devices.py. The PNP is the PDK's fixed GDS cell.
How it's wired. layout/bandgap/route.py is a small grid router written for this block. It routes on metal 2, 3 and 4
with a 1 µm pitch and 0.4 µm wires, which leaves 0.6 µm between tracks, more than any spacing rule on those layers.
Connectivity comes from the same LVS netlist the check compares against, so the layout is wired from the schematic, not by hand.
Each terminal needs a way up to the routing layers:
- Metal-1 terminals (gates, sources, drains, resistor ends, PNP emitters) get a via where a landing pad clears neighbouring metal.
- li-only terminals (bulk taps, PNP base and collector rings) get a contact up to metal 1. The PMOS taps sit too close to their drains for that, so they get a short li stub out to free space first.
- The MIM cap plates are reached on metal 4. The bottom plate only comes up as a 0.48 µm strip, so a metal-4 bridge runs across to it.
terminals.py finds where each terminal's metal is by running the LVS deck on each device alone and reading which
shapes belong to which terminal, so the router never guesses at the generators' geometry.
make_layout.py places, wires, labels VDD, VSS and VREF, and writes gds/bandgap.gds:
~/.venvs/sky130-pcells/bin/python layout/bandgap/make_layout.py # writes gds/bandgap.gds
~/.venvs/sky130-pcells/bin/python layout/bandgap/check_devices.py out/ # DRC + LVS each device type alone
The generators need gdsfactory 8.1 (layout/requirements.txt). Newer versions changed the API they use, so they get their own virtual environment.
What's been checked:
| Check | Result |
|---|---|
| Each of the 12 device types alone, DRC | clean |
| Each of the 12 device types alone, LVS against a one-device netlist | all match |
| Wired layout, full DRC | clean |
Wired layout, LVS against xschem/bandgap_core.sch | match: all 21 schematic devices, 14 nets and the VDD, VSS and VREF pins |
| Same LVS with R2 changed to 18.5 µm in the schematic | fails, as it should |
| Same LVS with M6's gate moved from AH to BH | fails, as it should |
| Same LVS with Q2 as 7 units instead of 8 | fails, as it should |
| Placed devices only 0.2 µm apart (to prove DRC is really checking) | 12 violations, as it should |
The deliberately broken checks matter as much as the passing ones. A check that can't fail proves nothing, and the LVS script had been silently passing nothing at all before its three netlist fixes (below).
The first routed layout had 13 DRC violations. Each pointed at something the router didn't yet know:
- Wire segments, not just grid nodes. A wire running between two grid nodes can pass a via pad that neither node is near. The router now reserves both nodes and segments near each pad.
- MIM cap rules. Other metal 3 has to stay 1.2 µm from the cap's bottom plate, not the usual 0.3 µm. New via3s also need room from the cap's own via3 array.
- Notches. Where a pin's off-grid via pad met its on-grid wire, small steps left gaps narrower than metal-2 spacing inside one net's own metal. Pad, stub and wire are now drawn as aligned rectangles of one width.
- Minimum area. A metal 3 square that only joins a via2 to a via3 was below the 0.24 µm² minimum, so those squares are now 0.5 µm.
Two LVS settings were also needed for the wired layout:
- Device combining. The eight Q2 units have to merge into one device to compare with the schematic's
m=8. - Emitter count. xschem's
m=8on a bipolar becomesNE=8, the emitter count LVS compares.
Two generator quirks turned up while checking devices one at a time:
- Resistors: the PDK's resistor generator draws the body 0.12 µm longer than asked. For R1 (2 µm) that's a 6 % error
in the resistor that sets the bias current, so
devices.pyasks for 0.12 µm less. - The PDK code: it doesn't run on current gdsfactory, which is why it has its own environment.
Post-layout simulation
The layout's parasitic resistance and capacitance were extracted with KLayout-PEX and run through the same tests. VREF moves by half a millivolt, and drift, supply range, start-up and noise barely change. The one real loss is PSRR at 1 MHz, −39.8 dB in the schematic against −34.0 dB in the layout. It traces to about 14 fF of capacitance from PB to ground. Full results are on the Post-layout simulation page.
DRC and LVS with KLayout
The scripts wrap the decks that ship
with the PDK in $PDK_ROOT/sky130A/libs.tech/klayout/: drc/sky130A_mr.drc (manufacturing rules) and
lvs/sky130.lvs. Each deck runs through KLayout in batch mode as klayout -b -r <deck> -rd name=value ….
# DRC: front-end, back-end and off-grid rules; prints violations per rule
scripts/run_drc.sh gds/bandgap.gds BANDGAP
# LVS: netlists the schematic for LVS, extracts the layout, compares; exit status 0 = match
scripts/run_lvs.sh gds/bandgap.gds BANDGAP xschem/bandgap_core.sch
# Only the LVS netlist (top level as a .subckt, simulation-only parameters removed, 0 V probes shorted)
scripts/lvs_netlist.sh xschem/bandgap_core.sch
Each script writes a database you can open in KLayout to see every error on the layout:
- DRC writes
drc/<cell>_drc.lyrdb. Open it in Tools → Marker Browser. - LVS writes
lvs/<cell>.lvsdb. Open it in Tools → Netlist Browser. It also writes the netlist extracted from the layout,lvs/<cell>_extracted.cir.
LVS now passes, and fails when it should. A PDK-generated NMOS matches its netlist, and the same netlist with the width deliberately changed to 2 µm fails. Getting there took three fixes to how the schematic netlist is fed to the deck:
convert_subckts=true. xschem writes sky130 devices as subcircuit calls (XM1 … sky130_fd_pr__nfet_01v8). Without this option the deck silently drops them, so every schematic device vanished and its nets merged into one.- Units. xschem writes
L=0.15meaning microns, and KLayout reads a bare number as metres, a factor of 10⁶.scripts/lvs_fix.pyadds theusuffix. - MIM caps. The deck extracts them as
sky130_fd_pr__model__cap_mimand compares area and perimeter, not capacitance.lvs_fix.pyrewrites xschem'scap_mim_m3_1 W= L=into that form.
Two more problems only appeared with the full layout:
- Flat mode. In the deck's hierarchical (
deep) mode, all seven PMOS transistors and the MIM cap disappeared once they were placed as sub-cells, even though each was recognised as a top cell on its own. I bisected it by removing device groups: even a layout with only the PMOS cells extracted nothing, while a flattened copy extracted everything.run_lvs.shnow usesflatmode. - Cell names. The schematic subcircuit is named after its file (
bandgap_core), but the layout's top cell isBANDGAP. When given a.sch,run_lvs.shrenames the subcircuit to match.
That also changes the earlier inverter result. DRC still finds 9 real violations in that illustrative layout. Its LVS mismatch, though, was partly the script dropping the schematic devices.
References
- KLayout, DRC and LVS reference, https://www.klayout.de/doc/manual/lvs.html