Models¶
Core data models for the topology synthesizer.
All structures are plain dataclasses — they carry no logic and can be freely inspected, serialized, or passed between pipeline stages.
- class circuitgenome.synthesizer.models.Device(ref, type, terminals, params=<factory>)[source]¶
Bases:
objectA single primitive device (MOSFET, resistor, or capacitor).
- Parameters:
ref (str) – Reference designator within the module (e.g.
m1,r2).type (str) – Device type:
nmos,pmos,resistor, orcapacitor.terminals (dict[str, str]) – Maps terminal names to local net names. MOSFETs use
d/g/s/b; resistors uset1/t2; capacitors usep/m.params (dict[str, str]) – Optional device parameters preserved verbatim from a sized SPICE line, keyed as written. MOSFETs carry
W/L/nf/m(and any otherkey=valuetoken, values kept as SI-suffixed SPICE strings like0.5u); resistors/capacitors carry their positional value token undervalue(e.g.{"value": "1k"}). Empty for devices built by the synthesizer or parsed from an unsized netlist. Seeparse().
- class circuitgenome.synthesizer.models.PortDef(name, role, alias_of=None)[source]¶
Bases:
objectA port on a module variant.
- Parameters:
name (str) – Port name (must match the canonical interface for its category).
role (str) – One of
input,output,supply,supply_in, oroptional. Optional ports are skipped when not wired in a topology.alias_of (str | None) – If set, this port is electrically the same node as the named port on the same variant (e.g. a non-cascode load’s
out1aliases itsin1). Used to recover the global net for ports that no device terminal references directly.
- class circuitgenome.synthesizer.models.ModuleVariant(name, category, display_name, ports, devices, polarity=None, output_cardinality=None, unsupported=None, bias_infeasible=None)[source]¶
Bases:
objectOne concrete implementation of a module category.
Every variant in the same category exposes the same canonical port signature; only the internal devices differ.
- Parameters:
name (str) – Unique snake_case identifier (e.g.
differential_pair_pmos).category (str) – Module category (e.g.
input_pair,load).display_name (str) – Human-readable name shown in listings.
polarity (str | None) – Electrical compatibility tag, either
"pmos_input","nmos_input", orNone. Variants that share a current-flow direction with a giveninput_pairpolarity declare the matching tag;Nonemeans the variant is compatible with either polarity. Used byis_combination_valid()to filter out combinations with no DC current path.output_cardinality (str | None) –
load-only tag, either"single","differential", orNone. Declares which topologyoutput_typethe variant is structurally usable with: for the cascode loads, whichoutput_typedefines a net for the variant’s mandatory output port(s) (outfor"single",out1/out2for"differential"); forcurrent_source_load_*,"differential"because theirbias_cmfb-gated branch devices need the CMFB loop that onlyfully_differentialtopologies wire (issue #112).Nonemeans the variant imposes no constraint and is compatible with either output type. Used byis_output_type_compatible().unsupported (str | None) –
Nonefor enumerable variants. A non-Nonereason string parks the variant: it stays loadable (recognizer patterns and hand-built variant maps keep working) butenumerate_circuits()skips it unlessconfig={"include_unsupported": True}.bias_infeasible (str | None) –
Nonefor variants whose bias/headroom is expected to close on typical (low-voltage) specs. A non-Nonereason string marks a variant whose wiring is functionally correct but whose DC bias is infeasible under normal supply/Vcm headroom (e.g. the stacked-diode cascode tails, which need|Vgs|+Vdsatof tail compliance — issue #111). Unlikeunsupportedthe circuit is fully buildable and would size into a complete netlist; it is simply predicted to fail the DC bias gate (the"bias_infeasible"designer outcome) on the default spec class.enumerate_circuits()skips it unlessconfig={"include_infeasible": True}, which design-space exploration sets to keep these correct-but-infeasible circuits as mutation seeds.
- class circuitgenome.synthesizer.models.BiasLegLibrary(reference, pref_branch, legs)[source]¶
Bases:
objectThe typed leg templates that demand-driven bias construction assembles.
Loaded from
config/bias_legs.yamlbyload_bias_legs(); consumed byconstruct_bias_generation(). Device terminals use the template-local net namesibias,pref,out,vdd,gnd(see the YAML header for the contract).- Parameters:
reference (list[Device]) – The master reference devices (always emitted).
pref_branch (list[Device]) – Devices deriving the PMOS-side reference gate (emitted only when an instantiated leg references
pref).legs (dict[str, list[Device]]) – Maps each rail kind (
gate_vdd,gate_gnd,current_source,current_sink,tunable) to its leg’s device templates.
- class circuitgenome.synthesizer.models.Slot(name, category)[source]¶
Bases:
objectA named placeholder for one module category in a topology template.
- Parameters:
- class circuitgenome.synthesizer.models.Connection(slot, port, net)[source]¶
Bases:
objectWires one port of a module slot to a global net in the assembled circuit.
- Parameters:
- class circuitgenome.synthesizer.models.TopologyTemplate(name, config, external_ports, slots, connections)[source]¶
Bases:
objectA wiring blueprint for a complete op-amp topology.
Defines which module slots are required and how their ports connect to global nets and to each other.
- Parameters:
- connections: list[Connection]¶
- class circuitgenome.synthesizer.models.SynthesizedCircuit(name, topology, variant_map, external_ports, devices=<factory>)[source]¶
Bases:
objectA fully instantiated circuit produced by the synthesizer.
- Parameters:
name (str) – Auto-generated name encoding the topology and variant combo.
topology (str) – Name of the
TopologyTemplateused.variant_map (dict[str, ModuleVariant]) – Maps each slot name to the chosen
ModuleVariant.external_ports (list[str]) – Top-level subcircuit ports (inherited from the template).
devices (list[tuple[str, Device]]) – Flat list of
(global_ref, Device)pairs after net substitution. Internal nets are prefixed with the slot name to avoid collisions.
- variant_map: dict[str, ModuleVariant]¶