| Circuit simulation using gEDA and SPICE -- HOWTO | ||
|---|---|---|
| <<< Previous | Next >>> | |
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.
The SPICE netlister can recognize any particular symbol in two ways:
The symbol's device attribute, and
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.
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.
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:
It is usually prudent to place these files into a dedicated directory distinct from the symbol directories.
Make sure that the SPICE files pin assignments correctly correspond to the pins as defined in the component's symbol! This is hard to over-emphasize. The order in which pins are listed in a .subckt file do not necessarily correspond to the physical pin ordering of the part. As described above, pins are emitted from the netlister in the order given by the pinseq attribute.
Make sure that the last character in a SPICE model file is a carriage return. If no carriage return exists, then the next component listed in the netlist may be placed on the same line as the last line of the SPICE model file.
| <<< Previous | Home | Next >>> |
| The big picture: the design flow in gEDA. | Creating your circuit: schematic capture |