Analog Netlist Gen
Translates the sizing table (from analog-sizing) and topology (from analog-topology-select) into a valid, simulatable SPICE netlist with proper PDK model includes, body connections, and measurement statements.
When to use
- Step A3 of the analog track
- After
analog-sizinghas produced a device table with W/L/Id values - When the user wants to convert hand analysis into a SPICE deck
Inputs
analog/<block>/topology.md— fromanalog-topology-selectanalog/<block>/sizing.md— fromanalog-sizing(device table with W, L, gm/Id, Id)analog/<block>/spec.json— fromanalog-spec-extract(specs for .meas statements)- PDK: gf180 or sky130
GF180 device instantiation (CRITICAL)
From analog-sizing/PRACTICAL_NOTES.md — verified working:
* Model include — ORDER MATTERS
.include /foss/pdks/gf180mcuD/libs.tech/ngspice/design.ngspice
.lib /foss/pdks/gf180mcuD/libs.tech/ngspice/sm141064.ngspice typical
* NMOS: drain gate source body
XM1 drain gate source 0 nfet_03v3 W=20u L=2u
* PMOS: drain gate source body — BODY MUST BE VDD
XMP1 drain gate source VDD pfet_03v3 W=20u L=4u
Body connection rules (NMOS body → VSS/0, PMOS body → VDD — the #1 SPICE
simulation failure): enforced deterministically by programs/analog_netlist_pdk_check.py
(PMOS_BODY_TO_VSS / NMOS_BODY_TO_VDD). Model-include presence is also enforced
there (NO_MODEL_INCLUDE).
SKY130 device instantiation
.lib /foss/pdks/sky130A/libs.tech/ngspice/sky130.lib.spice tt
* NMOS: drain gate source body
XM1 drain gate source 0 sky130_fd_pr__nfet_01v8 W=1u L=0.15u
* PMOS: drain gate source body
XMP1 drain gate source VDD sky130_fd_pr__pfet_01v8 W=2u L=0.15u
Workflow
- Read topology schematic → identify all devices and their connections.
KEEP-JUDGMENT: resolving a free-form/ASCII topology description into the
device-to-net connectivity graph is comprehension, not parsing — only an LLM can
do this reliably. (Once the graph exists,
analog_netlist_connectivity_check.pyverifies it has no floating nodes / unused ports.) - Read sizing table → get W, L for each device
- Generate subcircuit definition:
.subckt <block_name> <port_list> * Device instantiations .ends - Generate testbench:
- Check the actual testbench supply against the selected PDK device flavor and its original voltage limits before running SPICE. A nominal process label alone does not establish device compatibility.
- Stimulus: DC sweep, AC source, transient pulse — choosing the stimulus class and load network requires understanding the block's function (KEEP-JUDGMENT).
- Load: resistive/capacitive per spec
- Generate
.measstatements from spec.json — deterministic; do not hand-author. Runprograms/analog_meas_from_spec_gen.py <block>/spec.json --out meas.inc. It classifies each spec key into DC / AC / TRAN and emits the templated.measlines (FAILs honestly if spec.json is missing or has no measurable keys). - Add
.controlblock for ngspice batch mode
Output format
Two files per block:
analog/<block>/<block>.sp — subcircuit
* <block_name> — auto-generated from sizing table
* PDK: GF180MCU Process: typical
.include /foss/pdks/gf180mcuD/libs.tech/ngspice/design.ngspice
.lib /foss/pdks/gf180mcuD/libs.tech/ngspice/sm141064.ngspice typical
.subckt <block_name> <ports>
<device instantiations>
.ends
analog/<block>/tb_<block>.sp — testbench
* Testbench for <block_name>
.include <block>.sp
X1 <connections> <block_name>
Vdd VDD 0 DC 3.3
<stimulus>
<analysis commands>
<.meas statements>
.end
Deterministic gates (run these — do not eyeball)
These rules are enforced by programs, not by prose. Run them after emitting .sp/tb_*.sp:
| Rule | Program | FAIL codes |
|---|---|---|
| Body connections + model-include presence | programs/analog_netlist_pdk_check.py |
PMOS_BODY_TO_VSS, NMOS_BODY_TO_VDD, NO_MODEL_INCLUDE |
| Include order (design.ngspice before .lib, GF180) | programs/analog_netlist_include_order_check.py |
LIB_BEFORE_DESIGN_INCLUDE |
No hardcoded absolute paths (except /foss/pdks/...) |
programs/analog_netlist_path_lint.py |
NON_WHITELISTED_ABSOLUTE_PATH |
| No floating nodes / unused ports | programs/analog_netlist_connectivity_check.py |
FLOATING_NODE, UNUSED_PORT |
| Supply value matches PDK + device flavor | Native tool result | SUPPLY_PDK_MISMATCH, SUPPLY_DEVICE_MISMATCH, DEVICE_FLAVOR_PDK_MISMATCH |
.meas lines from spec.json |
programs/analog_meas_from_spec_gen.py |
(generator) |
Do not
- Do not use
.paramfor device sizes unless doing a sweep — use literal values for clarity (style preference; not gated).
Handoff
analog/<block>/<block>.sp+tb_<block>.sp→/ams-simoreda_spice_corner(Step A4)- If simulation fails → back to
/analog-sizingfor re-sizing
Captured rule
Keep a derived OP deck's include checks in the same directory context as its native ngspice command. A temporary deck outside the block directory must not make a relative include of the delivered DUT appear absent. Use the runtime PDK's startup to register compiled models, while keeping project-staged model directories first in the native search path; otherwise a staged corner library can silently load an installed submodel from another revision. Preserve the input libraries and their parameters. A converged OP still needs its original comparison bounds and operating conditions before it establishes acceptance.
Captured rule
A power-on PWL rail has a time-zero voltage and a steady-state voltage. Build a separate OP view using its explicit DC bias, or its delivered final PWL value when no DC bias is stated. Identify the rail through the topology's ports and actual DUT connections; preserve signal waveforms and the delivered transient deck. Reuse the same supply selection as native hardmacro OP characterization. A solved zero-rail point does not validate the powered circuit. Review the native final point and convergence diagnostics against the original conditions; OP convergence alone does not establish performance.
Captured rule
Bind each documented operating-point target to an explicit native OP
expression in its spec row's measurement field; preserve that field through
A1. Reuse analog_meas_from_spec_gen.measurement_commands to ask ngspice for
the number, then compare it with the unchanged source bounds. Keep the native
node table for convergence and rail review. For a loaded regulator, subtract
the native load current from the supply current when measuring quiescent
current; total input current includes the delivered load. An absent expression,
number or original bound stays NOT_MEASURED. Dynamic accuracy, rejection and
dropout sweeps retain their own analyses and limits.