spice < example.cirThe word “spice” invokes the SPICE interpreting program (providing that the SPICE software has been installed on the computer!), the “<” symbol redirects the contents of the source file to the SPICE interpreter, and example.cir is the name of the source file for this circuit example. The file extension “.cir” is not mandatory; I have seen “.inp” (for “input”) and just plain “.txt” work well, too. It will even work when the netlist file has no extension. SPICE doesn’t care what you name it, so long as it has a name compatible with the filesystem of your computer (for old MS-DOS machines, for example, the filename must be no more than 8 characters in length, with a 3 character extension, and no spaces or other non-alphanumerical characters). When this command is typed in, SPICE will read the contents of the example.cir file, analyze the circuit specified by that file, and send a text report to the computer terminal’s standard output (usually the screen, where you can see it scroll by). A typical SPICE output is several screens worth of information, so you might want to look it over with a slight modification of the command:
spice < example.cir | moreThis alternative “pipes” the text output of SPICE to the “more” utility, which allows only one page to be displayed at a time. What this means (in English) is that the text output of SPICE is halted after one screen-full, and waits until the user presses a keyboard key to display the next screen-full of text. If you’re just testing your example circuit file and want to check for any errors, this is a good way to do it.
spice < example.cir > example.txtThis second alternative (above) redirects the text output of SPICE to another file, called example.txt, where it can be viewed or printed. This option corresponds to the last step in the development cycle listed earlier. It is recommended by this author that you use this technique of “redirection” to a text file only after you’ve proven your example circuit netlist to work well, so that you don’t waste time invoking a text editor just to see the output during the stages of “debugging.” Once you have a SPICE output stored in a .txt file, you can use a text editor or (better yet!) a word processor to edit the output, deleting any unnecessary banners and messages, even specifying alternative fonts to highlight the headings and/or data for a more polished appearance. Then, of course, you can print the output to paper if you so desire. Being that the direct SPICE output is plain ASCII text, such a file will be universally interpretable on any computer whether SPICE is installed on it or not. Also, the plain text format ensures that the file will be very small compared to the graphic screen-shot files generated by “point-and-click” simulators. The netlist file format required by SPICE is quite simple. A netlist file is nothing more than a plain ASCII text file containing multiple lines of text, each line describing either a circuit component or special SPICE command. Circuit architecture is specified by assigning numbers to each component’s connection points in each line, connections between components designated by common numbers. Examine the following example circuit diagram and its corresponding SPICE file. Please bear in mind that the circuit diagram exists only to make the simulation easier for human beings to understand. SPICE only understands netlists:
Example netlist v1 1 0 dc 15 r1 1 0 2.2k r2 1 2 3.3k r3 2 0 150 .endEach line of the source file shown above is explained here:
1*******10/10/99 ******** spice 2g.6 3/15/83 ********07:32:42***** 0example netlist 0**** input listing temperature = 27.000 deg c v1 1 0 dc 15 r1 1 0 2.2k r2 1 2 3.3k r3 2 0 150 .end *****10/10/99 ********* spice 2g.6 3/15/83 ******07:32:42****** 0example netlist 0**** small signal bias solution temperature = 27.000 deg c node voltage node voltage ( 1) 15.0000 ( 2) 0.6522 voltage source currents name current v1 -1.117E-02 total power dissipation 1.67E-01 watts job concluded 0 total job time 0.02 1*******10/10/99 ******** spice 2g.6 3/15/83 ******07:32:42***** 0**** input listing temperature = 27.000 deg cSPICE begins by printing the time, date, and version used at the top of the output. It then lists the input parameters (the lines of the source file), followed by a display of DC voltage readings from each node (reference number) to ground (always reference number 0). This is followed by a list of current readings through each voltage source (in this case there’s only one, v1). Finally, the total power dissipation and computation time in seconds is printed. All output values provided by SPICE are displayed in scientific notation. The SPICE output listing shown above is a little verbose for most peoples’ taste. For a final presentation, it might be nice to trim all the unnecessary text and leave only what matters. Here is a sample of that same output, redirected to a text file (spice < example.cir > example.txt), then trimmed down judiciously with a text editor for final presentation and printed:
example netlist v1 1 0 dc 15 r1 1 0 2.2k r2 1 2 3.3k r3 2 0 150 .end
node voltage node voltage ( 1) 15.0000 ( 2) 0.6522
voltage source currents name current v1 -1.117E-02
total power dissipation 1.67E-01 wattsOne of the very nice things about SPICE is that both input and output formats are plain-text, which is the most universal and easy-to-edit electronic format around. Practically any computer will be able to edit and display this format, even if the SPICE program itself is not resident on that computer. If the user desires, he or she is free to use the advanced capabilities of word processing programs to make the output look fancier. Comments can even be inserted between lines of the output for further clarity to the reader.
In Partnership with Anritsu
In Partnership with Arm
by Gary Elinoff
by Aaron Hanson