File format

A circuit has two files:

File Contents Required
<name>.cir A SPICE netlist. This file is the source of truth. Yes
<name>.layout.toml Schematic positions for the parts in the netlist. A circuit in circuits/library/ or circuits/blocks/ can have one. The gallery and the editor then draw the circuit from it. No

Directives

ssp reads directives from comment lines in the netlist. Other SPICE tools ignore these lines.

Directive Meaning
* ssp:title <text> The title of the circuit.
* ssp:input <node> The node that receives the input signal.
* ssp:output <node> The node that gives the output signal.
* ssp:knob <part> <taper> <pos> A potentiometer, its taper, and its position. The netlist holds two resistors, <part>_1 (top to wiper) and <part>_2 (wiper to bottom). Pot.Apply keeps their sum and sets <part>_2 to the share of the total that the taper gives. A missing resistor, an unknown taper, or a position outside 0 to 1 gives an error diagnostic.
* ssp:switch <part> <pos> A switch and its position. The netlist holds one resistor for each throw: <part>_1 to <part>_n, at most 3. The resistor of the chosen throw is 1 mohm (closed). The others are 1 Gohm (open). Position 0 opens all throws. A switch with one throw is on at 1 and off at 0. A missing <part>_1 resistor or a position outside 0 to n gives an error diagnostic.
* ssp:part <ref> <part-id> The part in the parts table (models/parts.toml) that a reference uses. This mapping wins over the default mapping by kind and model name. An unknown part id gives an error diagnostic. A reference with no part gives a warning.

Rules:

Example

* ssp:title RC low-pass
* ssp:input in
* ssp:output out
V1 in 0 AC 1
R1 in out 10k
C1 out 0 10n
.end

Compatibility

The file format follows Semantic Versioning from version 1.0.0. A breaking change raises the major version of the tool. A corrected simulation value is a fix, not a break, and the release notes name it.

File A breaking change An additive change
Netlist (.cir) A valid netlist now gives an error. ssp drops an element or reads a value differently. A new directive, a new part or a new model.
Layout (.layout.toml) A valid layout now gives an error. A position moves without a reason. A new key with a default.

Layout file

It is TOML. It holds the schematic position of each reference and the points of each wire.

[[part]]
ref = "R1"
x = 40.0
y = -20.0
rotation = 90
flip = false

[[wire]]
net = "out"
points = [[40.0, 0.0], [80.0, 0.0]]
Table Key Meaning
part ref A reference in the netlist. Required.
part x, y The position. Numbers. Required.
part rotation Degrees. A multiple of 90. Default 0.
part flip true or false. Default false.
wire net The net that the wire belongs to. Required.
wire points A list of [x, y] points. At least two. Required.

Rules:

LTspice import

AscImporter.ToNetlist makes a netlist from the text of an LTspice .asc file. AscImporter.Import gives the same netlist and the diagnostics.

.asc line Result
WIRE x1 y1 x2 y2 Connects the two points.
FLAG x y <name> Gives the name to the net at the point. 0 is ground.
SYMBOL <name> x y <orientation> One element. The pins come from PinTable.Builtin.
SYMATTR InstName <ref> The reference of the element.
SYMATTR Value <value> The value or model name of the element.
TEXT x y <align> <size> !<directive> A SPICE line, for example .model.

Rules:

Layout import

AscImporter.ToLayout makes a layout from the text of an LTspice .asc file. Write it with Layout.Write to get the layout file.

Orientation res, cap, ind, diode npn, pnp, njf, opamp
R0 270 0
R90 180 270
R180 90 180
R270 0 90
M0 270, flip 180, flip
M90 180, flip 90, flip
M180 90, flip 0, flip
M270 0, flip 270, flip