8.4. pyopus.netlister.kicadsocfg — KiCad netlister configuration for Spice Opus netlists
Basic configuration of the KiCAD XML -> Spice Opus netlister.
config is a dictionary with the following entries:
EnumerateNets- when set toTrueall nets that are not explicitly named (nets that match theRenameNetPatternregular expression) are renamed to<prefix><number>. IfFalsenets keep the names assigned by the CAD tool. All illegal characters are converted to underscores.+and-are converted topandm, respectively.RenameNetPattern- nets that match this regular expression are renamed to<prefix><number>. A new name is generated based onNetPrefixandNetNumbeers.NetPrefixin the<prefix>used in renaming.NetNumbers- number of decimal places used for constructing<number>. Numbers that don’t fill all the reserved places are prefixed with zeros. If set toNonethe number takes as many places as it requires and no prefixing with zeros takes place.GroundNets- list of net names that represent the ground. These nets are renamed to0.SymbolLib- name of the KiCAD library that holds the symbols representing SPICE devices and netlist directives.Components- list holding the names of the Kicad components that represent netlist directives. These components are not handled by theMappingrules.SuppressEnd- when set toTruethe.endcard is not added. This is useful for dumping include files..endis never added to files that define a subcircuit.Mapping- a dictionary that specifies how individual components are mapped to a netlist. An entry in this dictionary has a tuple of the form(library, component)for key. The value specifies how a component is dumped. If the library member of the key tuple isNonethe entry matches components with the specified name from all libraries. When looking for a mapping the netlister searches for an exact match. If it is not found it tries to find an entry with(None, component)as key. Finally, if that one is also not found theMappingentry with(None, None)for key is (the default) is used.Because KiCad stores copies of component definitions in cache files it is recommended that the mapping entries have the form
(None, component). Such entries will match a component regardless of the library where the component is stored.
The following entries are availablefor describing the mapping of one component:
NamePrefix- SPICE device name prefix (one letter) used for this component. Case is ignored. If a refdes does not start with this letter the name is prefixed with this letter. If set toNonethe original KiCad refdes is used.SpiceDevice- SPICE device name used for this component. Currently not used.ValueField- specified the name of the field whose value is overridden by theValuefield. If set toNonetheValuefield does not correspond to any of the instance parameters. If a field with the same name as given byValueFieldalready exists the value of theValuefield will override it. If the parameter is not listed inParametersit will not be dumped via##PNV(). You will have to explicitly list it in thePatternas#PNV(<parameter name>.Parameters- the list of field names that correspond to SPICE instance parameters with the same name.PinMap- the list of pin numbers that specifies how pins are mapped to SPICE instance nodes.OutPattern- string with macros that specifies how SPICE instance(s) correspondint to a component should be generated. The following macros can be used:#REF()- refdes of a component with an optionally added prefix letter (seeNamePrefix). This refdes is all-lowercase.#REFORIG()- original KiCad refdes of a component (lowercase).#PINS()- nets corresponding to pins ordered as specified byPinMap.#PINS(pin1 pin2 ...)- nets corresponding to listed pins#MODEL()- SPICE model name (specified by Value or Model field)PARAM()- expands toparam:if at least one parameter is specified. Otherwise expands to an empty string. Only parameters that are listed underParametersin theMappingdictionary orParametersfield of the component are considered when counting passed parameters. Parameters passed viaSpecificationfield do not count.#PV(field)- the value of the specified field. Expands to an empty string if the field is not specified. A field set totrueis treated as a boolean parameter and only the field name is dumped. If it is set tofalseit won’t appear in the netlist.#PNV(field)- same as#PV, except that the field is formated as<field name>=<field value>. Expands to an empty string if the field is not specified. A field set totrueis treated as a boolean parameter and only the field name is dumped. If it is set tofalseit won’t appear in the netlist.#PNV()- equivalent to#PNV(f1) #PNV(f2) ...where fieldsf1,f2, … are specified byParametersin the component’sMappingentry.
All the settings specified for a components mapping can be overridden by
component’s fields with corresponding names. The Parameters field must
be given as a space-separated list of parameter names. The PinMap field
must be given as a space-separated list of pin numbers.
The default for NamePrefix is None (i.e. all device names are OK).
The default for ValueField is None.
If Parameters is not defined it is assumed to be an empty list.
If PinMap is not defined the pins are dumped in the increasing pin
number order.
Not specifying an OutPattern (either in config or as a field) results
in an error.
Every element is netlisted in such manner that the value of the
Specification field is added at the end of the netlist line specifying
the element. This makes it possible to quickly and easily add arbitrary
parameters to the elements in the netlist. It is also used by the two
independent sources for describing the type and the value of the source
(i.e. AC, DC, PULSE, …).