3. Preliminary work: preparing your symbols and SPICE files.

When you create schematic symbols for inclusion into your schematic, you must make sure that certain built-in attributes are correctly configured. The steps outlined below are done by editing the symbol itself using the symbol editor in gschem, or by editing the symbol file itself using a text editor.

3.1. Configuring your symbols.

3.1.1. Identifying the component to the netlister

The SPICE netlister can recognize any particular symbol in two ways:

  1. The symbol's device attribute, and

  2. The symbol's refdes.

Both of these attributes are attached to the symbol when the symbol is created.

Each symbol has a device attribute attached to it. The device attribute is the first thing the netlister examines when processing the symbol. There are a number of devices which are native to the netlister, meaning that the netlister knows exactly how to deal with these types of devices. Native device types include RESISTOR, CAPACITOR, NPN_TRANSISTOR, etc. The entire list of native devices is present in the appendix.

The device attribute is hidden during normal use of gschem. Most often, the symbol's creator has already given the symbol the correct device attribute. However, because the device attribute is hidden from the ordinary user, it can sometimes cause problems with SPICE netlist creation when it is set to an unexpected value. To view the device attribute, go into the symbol editor (select the symbol to edit, and do Hierarchy ->down symbol), and turn on invisible attributes (Edit ->show/hide inv text). If the device attribute is incorrect, you may change it by editing the symbol itself using a text editor.

If a symbol is not native (i.e. the netlister doesn't recognize it as a built-in type), the netlister relies upon the first letter of the refdes to determine how to process the symbol. The refdes prefix is also built into the symbol when it is created. Example refdes prefixes are R for resistors, C for capacitors, Q for transistors, etc. refdes prefixes correct for SPICE are listed in the appendix. Note that relying upon the refdes to identify the component for SPICE is not foolproof -- for example, the netlister cannot distinguish between NPN and PNP transistors based upon the refdes. Therefore, it is always best to use a native device in your symbols.

3.1.2. Setting the pin order

The netlister emits a components pins in the order set by the pinseq attribute. Note that this is not the same as the physical pin location. To set the pinseq attribute, first determine the pin ordering you want. SPICE uses a specific pin order for many components, including diodes and transistors. For example, a bipolar transistor's pins listed in CBE order. Another example: if your symbol is meant to represent an IC modeled with a vendor's .subckt, the order of the connections to the subcircuit is set by the .subckt line in the file.

Once you know the order in which to emit the pins, simply set the pinseq attribute with the correct order for the part. This will ensure that the part's pins are emitted in the correct order.

3.2. Configuring your SPICE files.

Files holding complicated SPICE models or other SPICE code may be incorporated into the final SPICE netlist by including appropriate symbols into the schematic. SPICE model files are usually obtained from component vendors. Dealing with these files is straightforward. However, some issues should be kept in mind when preparing models for use during schematic capture: