For translation in
Bulgarian click here (courtesy of Cloudlakes.com)
- Indonesian click here (courtesy of Chameleon.John.com)
- French Translation cleck here (courtesy of Avice Robitaille at1001-soldes.com)
- Portugese click (to be added shortly)
- Romanian click here (courtesy of Irina Vasilescu)
- Swedish Translation click here(courtesy of Catherine Desroche)
3. HOW TO GET STARTED WITH SPICE? (for beginners)
This document will explain how to run Spice or HSpice. It does not explain
the Spice commands. This can be found earlier in this document under How
to Specify the Circuit Topology?, in your textbook, or the Spice User's
In order to run Spice, you will have to go through the following steps:
Draw a schematic of the circuit (can be skipped)
Create an input file
Run the program
Look at the output file and print the results
3.1 Creating an Input File for Spice
We will first explain how to use PSpice without a Schematic Editor (see
for how to use the Schematic Editor).
a. Draw a schematic of the circuit, number the nodes and
label all elements. Note that the common node (ground) always has number
A sample circuit is given below.
We are interested in the voltages v12, v2 and the current i4 when the input
voltage vin is equal to 10V. We also want to find the Thevenin equivalent
voltage and resistance seen by the terminals ab.
In addition, we like to step the input voltage between 0 and 20 V in
steps of 2V and print and plot v12, vo, v2 and i4 as a function of vin.
Note that we inserted a DC voltage source, VMEAS, of zero value, in
order to be able to measure the current i4.
b. Create the input file (source file) for PSpice.
The source file needs the extension (usually ".cir") in its name. For a description
of the data, control and output statement, refer to "How to Specify the Circuit
Topology" earlier in this document, the Spice manual or the textbook.
Create the input file with any editor, such as Emacs, Microsoft editor,
Word perfect, NotePad under windows, etc. Save it on the c: drive or on
your disk on the a: drive. In case you store it on the c: drive, put it
in a subdirectory (ex. c:\users\filename.cir; the subdirectory is required
for the PSpice version that runs on the network in the PC labs and sits
on the h: drive). Save the file as a textfile (when using a word processor
such as MS Word).
VIN 1 0 DC 10
F1 0 3 VMEAS 0.5
VMEAS 4 0 DC 0
R1 1 2 1K
R2 2 3 10K
R3 1 3 15K
R4 2 4 40K
R5 3 0 50K
.TF V(3,0) VIN
.DC VIN 0 20 2
.PRINT DC V(1,2) V(2,4) I(VMEAS)
.PLOT DC V(1,2) V(2,4)
.PLOT DC I(VMEAS)
c. Run Spice
1. The first line is a title line and can be anything. It cannot be omitted.
2. The last line must be the .END statement.
3. You can insert comment lines. Anytime a line starts with an "*", PSpice
ignores the whole line. Using an "*" is also handy to block out a command
4. You can use upper or lower case letters.
5. Don't forget to add a carriage return after the .END statement.
Once you are in PSpice, pull down the File menu at the top of
the screen and select "Open ". The system prompts you for the name
of the file. Type in the file name of the circuit you have created before.
As an example: c:\users\example1.cir
A window will appear telling you that Spice program is running, or that the
simulation has been completed successfully, or that errors were detected. Click
on the "OK" button.
5.1 Running HSPICE
You can run HSPICE on Eniac (Sun Sparc), which is basically the same program
as PSpice, except for the Schematic editor and Probe. The advantage of
using HSpice on Eniac is that you can run it from your room through a modem
connection or over ResNet. In addition, it comes with a user-friendly and
powerful graphical interface (gsi) provided you have access to an x-terminal.
First, you have to create the input file that contains the data, control
and output statements in the same way as is done for PSpice. The format
and commands are identical. You can create this input file with any editor.
Once you have the input file, you can run HSpice by typing the following
command at the unix prompt,
in which inputfile is the name of your input file. The output will be displayed
on the screen. You can also store the output of HSPice in an output file,
hspice inputfile > outputfile
To view the output file, use your favorite editor. The file can be printed
as any other document:
Notice that HSpice does not give the DC voltages unless you have specified
a certain analysis type, such as for instance .TRAN, or .AC analysis (Spice
automatically does a DC analysis before doing a transient or AC analysis).
Thus, if you are only interested in the DC voltages in HSpice, you should
specify the .OP option, or the .DC
5.2 Special Features of HSPICE
HSpice has many capabilities. If you intend to use HSpice for Integrated
Circuits simulation you will need to make use of many of these. Please
consult the MetaSoftware manual (available from the DSL, room 100M). Here
are a couple of these features.
a .Mathematical expressions in Hspice
HSPICE supports a few mathematical functions which can be used to condition
any output variable. The following general format should be used for all
This instructs HSPICE to print the square root of the voltage "v3" and
assign it the variable name varname. The results can be found in the output
file as well as gsi under the print'plot field. Apart from square root,
other useful functions such as log(), sin() and tan() are supported. Consult
the HSPICE manual for a complete listing.
b. Node Names.
Instead of using node numbers, you can use node names in the input file.
This makes the files much easier to read. The same names will appear in
the output file and the graphical display.
5.3 Graphical Output: gsi
In case you have access to an x-window terminal the output can also be
viewed graphically using the gsi program. In order to use the graphical
display, you have to include the statement "option post" in the
input file. This will create a *.sw# (for .sweep analysis) or a *.tr# file
(for transient analysis) which contains the simulation results in a format
that can be interpreted by gsi.
To run gsi, type "gsi inputfilename". All node voltages will
be saved for later display. In case you have a large circuit and don't
need to look at all the nodes, you can reduce the size of the file by specifying
which node voltages to save. This is done by the ".option post probe",
followed by the ".print nodenames" command. This last command
is identical to the one you use to specify what node voltages, or currents
you want Spice to save.
Here is an example of the input file, with the .option post command
To see the graphical output, type gsi example1 (if on an x-window
terminal; if you are not familiar with x-windows consult CETS). The gsi
output is shown in the next figure. After typing "gsi", two windows
example hspice with gsi
vin input 0 dc 10
f1 0 output vmeas 0.5
vmeas 4 0 dc 0
r1 input 2 1k
r2 2 output 10k
r3 input 3 15k
r4 2 4 40k
r5 output 0 50k
.tf output vin
.dc vin 0 20 2
*.print dc v(1,2) v(2,4) i(vmeas)
*.plot dc v(1,2) v(2,4) i(vmeas)
The top one allows you to select what variables to display. After making
the selection of the "type" of variables (voltages, current, etc.) and
the "curves" to be displayed, click on the "Draw" button. The curves will
be shown on the second window (Graph window).
You can select the number of panels by going to the "Panels" menu and
selecting the number of panels. There are several option and manipulations
you can incorporate (see Features of gsi below).
Features of gsi
In the Graph window you have a number of interesting options. The measurement
menu allows you to use cursors. To zoom in/out click on the right
mouse button and select one of the zoom commands. Then with the left button
draw a short line to indicate what you would like to zoom.
To clear a panel, click on the right mouse button and select
Printing can be done by going to the "Print" menu. The print
command will write the graphical output to a file (labeled as filename.gr#))
which can then be printed later on (using the lpr command).
Mathematical expressions can be plotted as well. In the top window,
you will see a small box called expression. You can type mathematical
expressions such as additions, multiplications, square, etc. of graphs.
As an example lets calculate the power in a resistor (power = i(vmeas)*v(2)).
To display the expression, select expression in the "Types" window
and "power" in the "Curves" window. Next, click on the "Draw" button.
6. Most common mistakes
Typos in the source file: wrong node numbers, wrong units (ex. the value
of a capacitor of 12 picofarad, incorrectly specified as 12, instead of
Confuse M for mega instead of MEG: a 5 megaohm resistor should be specified
as 5MEG and not 5M. (M or m stands for milli).
Typing the letter O instead for the number 0 (zero as in
Omitting the final carriage return after the .END statement.
7. If Spice does not run.
1. First check that /cad/bin is in your path. If not, you should alter
the path to statement in your shell initialization file to include /cad/bin.).
2. To run hspice on eniac from an X-TERMINAL that runs on a computer
different from eniac (lets say hobo in the EE domain):
logon to hobo.ee (to which the display is connected) and type:
login to eniac and type:
rsh eniac.seas.upenn.edu; once on eniac type:
setenv DISPLAY hobo.ee:0.0
Back to Table of Contents
SPICE, A Guide to Circuit Simulation and Analysis Using PSpice, 3rd Ed.,
P. Tuinenga, Prentice Hall, Upper Saddle River, NJ, 1995. This book comes
with a IBM-PC 3.5 disk with the PSpice Student Version.
Schematic Capture with MicroSim PSpice, 3rd Ed., Marc. E. Herniter, Prentice
Hall, Upper Saddle River, N.J, 1998. This book comes with a CD that contains
an evaluation version of PSpice.
MicroSim PSpice with Circuit Analysis, 2nd Ed., F. Monssen, Prentice Hall,
Upper Saddle River, NJ, 1998.
MicroSim PSpice for Windows, Vol. I and II, R. W. Goody, Prentice Hall,
Upper Saddle River, NJ, 1998.
Spice for Circuits and Electronics Using PSpice, 2nd ed., M. H. Rashid,
Prentice Hall, Englewood Cliffs, NJ, 1995. This book comes with a tear-out
card to order a disk with the PSpice Student Version (available for both
PC and MAC). The cost for the disk is about $7.50-$15.50
Computer-Aided Circuit Analysis Using PSpice, 2nd Ed., W. Banzhaf, Prentice-Hall,
Englewood Cliffs, NJ, 1992
Hands On PSpice,"J.G. Gottling, Houghton Mifflin Co., MA, 1995
The Spice Book, A. Vladimirescu, John Wiley & Sons, New York, NY, 1994
Semiconductor Device Modeling with Spice, 2nd Ed., G. Massobrio and P.
Antognetti, McGraw-Hill, NY, 1993
Mosfet Modeling with Spice, D. Foty, Prentice Hall, Upper Saddle River,
Macromodeling with Spice, J.A. Connelly/P. Choi, Prentice-Hall, Englewood
Cliffs, NJ, 1992
Inside SPICE, Overcoming the Obstacles of Circuit Simulation, R. M. Kielkowski,
MacGraw-Hill, Inc., New York, 1994.
SPICE, Practical Device Modeling, R. W. Kielkowski, McGraw-Hill, Inc.,
New York, 1995.
Introduction to PSpice, A Supplement to Electric Circuits, 4th ed., by
J. W. Nilsson and Susan A. Reidel, Addison-Wesley Publ. Company, Reading,
Spice, by G. Roberts and A. Sedra, Oxford University Press, 1997, 2nd Edition.
HSPice Users' Manual, Meta-Software, Inc., Campbell, CA
PSpice Users' Guide, MicroSim Corporation, Irvine, CA
SPICE User's Guide
Jan Van der Spiegel
Created Sept. 30, 1995; Updated Dec. 3, 2001