target_spice: raw spice simulation

symbol attributes

attribute descriptioon
spice/params string; append string at the end of the spice instance line for this symbol; for example spice/params=dc 0 ac 1 on a 2 terminal voltage source will result in: V1 netname1 netname2 dc 0 ac 1
spice/prefix single character string; prefix the name of the spice instance (component in the abstract model) if it does not already begin with this prefix; for example a mosfet called Q41 on the schematics with spice/prefix=M will become M_Q41; for the same symbol if spice/prefix=Q, the component name will be Q41. When present, it is exported after the value attribute.

If the model is known and is a subckt, an X prefix is used automatically. If model is subckt and spice/prefix is also specified, attribute priorities decide on the final prefix; the subckt X prefix has the normal plugin priority of target_spice. The user can override this decision with a spice/prefix of higher priority (e.g. 250). A symbol would have a spice/prefix attribute at lowest user priority (31050) so that target_spice can override it with an X if it detects subckt model.

spice/portmap An array that is appended to the portmap attribute of the symbol by the plugin target_spice. Should contain lines that set spice/pinnum attributes on terminals. See also: pinout options.
spice/model name a spice model to use. If spice/model_include is not specified, the model must have a mod (or prm) file in the spice library. This mod file must be a stand-alone file with a single .model or .subckt and will be copied in the output netlist. If the file uses .subckt, a target_spice engine priority spice/prefix=X is added. If spice/model_include is specified, the model is used without any model copied to the output for this component (and no spice/prefix=X set is attempted). The model is searched in the lib first with exact file name, then with .mod then with .prm appended, all case sensitive.

See also: model options.

spice/model_card specify the whole model card, in-place; sch-rnd will generate a model in the output using an unique name; when specified, spice/model is ignored. First word should be either .model or .subckt, with a leading dot. (Also called inline model card for a symbol.)

See also: model options.

spice/model_card_uname optional: per-symbol-unique-name used when saving spice/model_card in the file. Normally generated by target_spice. When this attribute is set, the value is used for model name for both normal components and for model/subcircuit compontnets.

See also: model options.

spice/model_include specify the spice lib or mod file that should be included using .include; sch-rnd does not edit the path, but makes sure there's only one .include per unique attribute value

See also: model options.

spice/file_header print this string on top of the output circuit file, as-is
spice/command print this string on bottom of the output circuit file, after the netlist; useful for printing commands

terminal attributes

attribute descriptioon
spice/pinnum integer or [integer], counting from 1; determines the parameter index within the generated spice instance line, affecting the order of terminal connections listed for the instance. The list formed from all terminals that have spice/pinnum must not be sparse. Plugint target_spice takes all terminals and sort them by their pin numbers (preferring spice/pinnum then falling back to pinnum then to port name) to generate the final port name (display/name). The export code takes port names, requireing integers, sort ports by their names and writes the connections section of the instance line by the sorted list. As many connections as many named ports present in the component.

When [integer], the addressed pin is taken as a vector and the current port is appended to the vector. On the output a [] vector of all the appended port with this integer is exported.

See also: pinout options.

spice/shared When set for a terminal in a symbol that has a slot or -slot attribute set, the terminal is shared among all slots: any connection of the terminal with the same spice/pinnum in any slot is copied to all other slots for the same terminal. A typical example is the positive and negative supply of a dual or quad opamp: spice will get 2 or 4 discrete opamps, but the power supply will be specified only on one slot. The value of this attribute does not matter. See also: pinout options.
spice/bridge/model Insert a bridge between the pin and the network it is connecting to; the bridge instance uses model name specified as the value of this argument. The model is loaded from the spice library (see symbol's spice/model). Useful for mixed digital/analog simulation when ADC and DAC bridges have to be placed between the analog and the digital sections. This can be done explicitly or when a port is to be connected to an opposite type net, it can be hidden in the port description using the spice/bridge/model attribute.

net attributes

attribute descriptioon
spice/gnd if set, the given network would be the true ground, "node 0" in the spice netlist. Must not be set on multiple nets. If not set, target_spice elects a "node 0" looking at net names. (The spice netlist format requires one of the nets dedicated as "node 0" for gnd.) The value of this attribute does not matter.

The final spice instance lineis built by appending the following sections in order, in a single line:

For example the following is a spice diode instance line, split up and annotated with source fields in the table below:

D15 gnd sck 1n4148 T=35

output D15 gnd sck   1n4148 T=35
section name netnames (value) model name attribute: spice/params
Model name is spice/model_card_uname when presents, or spice/model when not; spice/model_card_uname is set automatically when model card is copied from the lib or symbol into the output.