| Circuit simulation using gEDA and SPICE -- HOWTO | ||
|---|---|---|
| <<< Previous | Next >>> | |
Once the schematic is captured, a SPICE netlist can be generated running gEDA's command-line program gnetlist on the schematic files. Gnetlist is architected in two sections: a front-end processor written in C which reads in the .sch file and creates from it an internal, generic representation of your design, and a back-end netlister written in SCHEME. Using this architecture, gnetlist is highly customizable; different SCHEME backends are used to write out different netlist formats. The beauty of this scheme (pun intended) is that gEDA users can easily write their own netlisters to suit their own applications. The back-end Scheme file which implements advanced SPICE netlisting is called gnet-spice-sdb.scm, and it lives in the ${PREFIX}/geda/share/gEDA/scheme directory.
Gnetlist with spice-sdb is invoked from the command line in the following way: “gnetlist [OPTIONS] -g spice-sdb filename1 ... filenameN” . The following command-line options are available with spice-sdb:
-i Interactive scheme mode
-I Put .INCLUDE <filename> in output file instead of model file's contents
-q Quiet mode
-l filename Load scheme file before loading backend
-m filename Load scheme file after loading backend, but still before executing procedure
-g proc Scheme procedure to execute (i.e. spice-sdb)
-o filename Output netlist filename
-c string Execute string as a scheme script
-v Verbose mode on
-s Sort output netlist (for Gnucap)
Creating a netlist from a schematic is easy. To generate a SPICE netlist, just do the following:
Save your schematic to <filename.sch>
Create the SPICE netlist by doing "gnetlist -g spice-sdb <filename.sch>". The output is a netlist held in the file output.net. Alternatively, if you wish to give your output file a different name, set the output name using the -o switch. For example: gnetlist -g spice-sdb -o amplifier.cir amplifier.sch takes the design schematic called "amplifier.sch" and outputs a SPICE netlist named "amplifier.cir".
Inspect your SPICE netlist using a text editor. Verify that there are no missing attributes or other netlist problems.
The following list attempts to catalog common problems with the netlist and the associated fixes.
ERROR_INVALID_PIN: This can happen if the symbol's pinseq attributes don't start at 1, or have gaps in the numbering. This must be fixed by editing the symbol itself in a text editor.
ERROR: In procedure caddr: ERROR: Wrong type argument in position 1: #f This error is quite common. It usually occurs when you forget to add a mandatory attribute. To rectify the problem, try running gnetlist in verbose mode (“gnetlist -v -g spice-sdb <filename.sch>”). The netlister will stop processing and bomb out at the part with the missing attribute. Having therefore identified the offending part, you can re-open the schematic in gnetlist and fix the attributes.
Finally, remember that it is important to manually inspect your SPICE netlist prior to using it in simulation. Please keep in mind that the netlister is still “beta” quality, and some problems may still exist in netlist generation.
| <<< Previous | Home | Next >>> |
| Creating your circuit: schematic capture | SPICE simulation |