The objective of this tutorial is to provide an introduction to the HSPICE simulation environment. For further assistance the students are encouraged to contact the lab tutors during the lab sessions or via e-mail.
Lab Tutors: Dr. Edward Gatt ejgatt@eng.um.edu.mt Mr. Owen Casha oecash@eng.um.edu.mt
It is very important that you read this tutorial before going to the laboratory sessions.
2. Running a Simulation
When running HSPICE, the source netlist file has an extension .sp. The output file usually has the extension .lis. Thus in order to run HSPICE on example.sp:
hspice example.sp > example.lis
The output file EXAMPLE.LIS must not exist before the simulation is started, otherwise UNIX will report an error. If the output filename already exists, it must first be deleted using:
rm example.lis
3. Editing the source (netlist) file:
The netlist file is edited using the VIEW (VI) text editor:
vi example.sp
The default mode is the command mode. By pressing a, the append mode will come into operation. Pressing i" from the command mode will enable the insert mode. The command mode may again be called by pressing esc, or any of the cursor keys.
A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 2
The following are basic VI command mode commands:
Command Description / Search :w Write (update) file :q Quit if file has been saved :q! Unconditional quit (forced exit) x Deletes 1 character nx Deletes n character dd Deletes 1 line ndd Deletes n lines 0G Go to last line in file nG Go to line n
4. Basic UNIX commands
Since HSPICE runs on a UNIX environment it is important that you have a good grasp of the UNIX command line interface. These are some basic UNIX commands; next to them are their DOS equivalent commands:
UNIX DOS ls dir cat type cp copy mkdir md rm del man help cp -r xcopy/s cat a1 a2 > a3 copy a1+a2 a3 clear cls mv rename cd cd
5. HSPICE Simulator
The basic analyses that can be carried out using HSPICE are: DC operating point, DC Sweep, AC Sweep (Bode Plotting), Transient, Sensitivity and Fourier Analysis. Note that AC/DC Sweep and Transient analyses must be preceded by the command .option POST in the netlist A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 3 file in order to enable the HSPLOT interface. A note on each of these analyses is given in section 6 together with self-explanatory examples. What follows are some general points that one must keep in mind whilst using HSPICE:
(a) Value Multipliers in HSPICE:
G = 10 9 m = 10 -3
X = 10 6 K = 10 3
u = 10 -6 n = 10 -9
p = 10 -12
Example: 100K = 100000 = 0.1X
(b) Commonly used components in HSPICE
R1 n1 n2 va1 - Resistor C1 n1 n2 va1 - Capacitor L1 n1 n2 va1 - Inductor V1 n1 n2 va1 - Voltage Source I1 n1 n2 va1 - Current Source X1 d g s J2N5459 - jfet transistor from lib. X1 a k D1N4742 - diode from library
(c) The reference (common/chassis) point is always taken as node 0.
(d) Comments start with an asterisk, example:
* This is a comment
(e) Each file must start with the .FILE statement,
.FILE example.sp
(f) Each node must have at least 2 connects. For a single-ended node, connect a 0 value current source to chassis:
0A
A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 4
6. HSPICE Analyses
(a) DC Operating Point
This analysis is output in the .lis file and is controlled as follows:
.OP All Full Operating Point .OP Brief Line summary of each elements voltage, current & power .OP Current Voltage table with element currents and power .OP Debug Invoked by programme in case of non-convergence .OP None Inhibits node and element print backs .OP Voltage Voltage table only
The default mode is All and this mode is the one that is most commonly used.
Var1 is the parameter to be swept. Type could be DEC (decade), OCT (octave), LIN (linear) or POI (list of points). The linear sweep is the one most commonly used. Two variables could be swept resulting in a nested sweep (see example 2):
.DC var1 start1 stop1 inc1 var2 start2 stop2 inc2
2 1 3 4 0 M1 RD 10k Vp RS 10k Vn A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 5 The sweep of var1 is nested within the sweep of var2. The .DC statement causes an output file with extension .swo to be produced. This file can later be read by HSPLOT in order to produce a graphical output. Variables to be plotted could be specified as follows using the .PLOT DC statement.
.PLOT DC V(1) I(Vdd)
Later it would be possible to plot the voltage at node 1 and the current through component Vdd using HSPLOT.
2 0 1 M1 VGS VDS A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 6 (c) AC Sweep
The AC Sweep produces a file with extension .aco which may later be called by HSPLOT. AC Sweep is enabled using:
.AC type np fstart fstop
where np is the number of points and type can be either OCT, DEC or LIN. Usually DEC is used for AC Sweep analysis. An example of outputting variables to HSPLOT:
.PLOT AC AV=PAR(20*LOG10(V(2)/V(1))) PHI=PAR(VP(2)-VP(1))
Using HSPLOT it would be possible to plot AV and PHI versus frequency, i.e., a bode plot of the circuit. Equivalently one could use:
.PLOT AC VDB(2,1) VP(2,1)
Example:
.FILE ampce.sp
.OPTION searchpaths = /usr/meta/h92/lib/bjt .OPTION POST
A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 7 (d) Transient Analysis
The transient analysis produces a file with extension .tro. The analysis is invoked using the statement:
.TRAN tiner tstop START=stval
where tiner is the timestep, tstop is the final time value and stval is the initial time value. Again, variables are passed to the HSPLOT programme using:
.PLOT TRAN V(1)
In this way, using HSPLOT V(1) can be plotted versus time.
Example:
.FILE attenuation.sp
.OPTION POST .OPTION searchpaths = /usr/meta/h92/lib/bjt
Again the output of this analysis is saved in the .lis file. Fourier analysis is invoked using:
.FOUR freq var1 var2
Freq is the fundamental frequency with respect to which the Fourier analysis is to be carried out. Normally freq is specified as the input (driving) frequency, so that harmonic generation can be assessed. Note that Fourier analysis must always be preceded by Transient Analysis.
2 3 0 4 1 M1 VDRAIN RD 10k RG1 10k RG2 10k Vp A Tutorial on HSPICE Owen Casha B. Eng. (Hons.) 2005 9 Example: