You are on page 1of 9

A Tutorial on HSPICE

Owen Casha B. Eng. (Hons.) 2005 1


A Tut or i al on HSPI CE

1. Introduction

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.

Example:

.FILE nmosdc.sp

M1 2 0 3 3 Mod1 L=10u W=10u
Rs 3 4 5K
Vp 1 0 5V
Rd 1 2 10K
Vn 4 0 -5V

.MODEL Mod1 nmos (LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)

.OP ALL

.end

(b) DC Sweep

.DC var1 type start stop step

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.

Example 1:

.FILE mosamp.sp

.OPTION POST

M1 3 3 2 0 Mod1 L=10u W=10u
M2 2 1 0 0 Mod1 L=10u W=10u
Vp 3 0 10V
Vin 1 0 DC 2V

.MODEL Mod1 nmos (LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)

.DC Vin 1.5V 3V 10mV

.PLOT V(2)

.end

Example 2:

.FILE mosdc.sp

.OPTION POST

M1 1 2 0 0 Mod1 L=10u W=10u
Vgs 2 0 DC 0V
Vds 1 0 DC 0V

.MODEL Mod1 nmos (LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)

.DC Vds 0V 10V 100mV Vgs 0 8V 2V

.PLOT I(Vds)

.end
1
0
2
3
M2
VIN
M1
Vp

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

X1 1 2 3 T2N2222A
R1 4 2 88K
R2 2 0 11K
R3 4 1 4.7K
R4 3 0 470
C1 3 0 10u
C2 5 2 1u
C3 1 2 4.7n

Vp 4 0 10V
Vs 5 0 AC 1mV

.AC DEC 100 1Hz 1XHz

.PLOT AC VDB(1,5) VP(1,5)

.end




2
1
3
0
5
4
Q1
2N2222A
R1
83k
R2
11k
R3
4k7
R4
470
C3
4n7
C1
10uF
C2
1uF
Vs
Vp

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

X1 2 1 0 T2N2222A
R1 3 1 10K
R2 2 4 10K
R3 5 6 1K
R4 7 6 22K
R5 6 8 22K
R6 8 0 10K
C1 2 5 100pF

Vp 4 0 10V

* sin(offset amplitude frequency)
Vs 7 0 sin(0 4V 455kHz)

* pulse(VL VH Delay Rise Fall Pulse Period)
Vin 3 0 pulse(0 10V 0.1ms 0.05ms 0.05ms 0.1ms 0.3ms)

.TRAN 0.001ms 0.45ms start=0

.PLOT TRAN V(3) V(8)

.end



1 3
2 5
0
8
6
4
7
X1
2N2222A
R1
10k
Vin
R2
10k
C1
100pF
R3
1k
R4
22k
R5
22k
R6
10k
Vp Vs


A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) 2005 8
(e) Sensitivity Analysis

Sensitivity analysis is invoked using:

.SENS var1 var2

The output is saved in the .lis file and consists of the dependence of
var1, var2, , varn on the component values.


Example:

.FILE nmosbias.sp

.OPTION POST

M1 3 4 0 0 Mod1 L=10u W=10u
Rg1 1 4 1X
Rg2 4 0 1X
Rd 1 2 2K
Vp 1 0 15V
Vdrain 2 3 0V

.MODEL Mod1 nmos (LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)

.OP ALL

.SENS I(Vdrain)

.end

(f) Fourier Analysis

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:

.FILE ota.sp

.OPTION POST

* simple transconductance operational amplifier

M1 2 2 6 6 Mod1 L=9.6u W=40u
M2 3 2 6 6 Mod1 L=9.6u W=40u
M3 4 1 3 6 Mod1 L=2.4u W=400u
M4 5 8 3 6 Mod1 L=2.4u W=400u
M5 4 4 7 7 Mod2 L=9.6u W=35u
M6 5 4 7 7 Mod2 L=9.6u W=35u

* mosfet models

.MODEL Mod1 nmos (LEVEL=2 VTO=1V tox=500 nsub=1e15 kp=1m)
.MODEL Mod2 pmos (LEVEL=2 VTO=-2V tox=500 nsub=1e15 kp=30u)

* reference circuit

Iref 7 2 1m

* RC Load

c1 5 0 4pF
r1 5 0 100k

* Input Bias Resistors

Rb1 1 0 10X
Rb2 8 0 10X

* Supply Voltages

vdd 7 0 5V
vss 6 0 -5V

* Fourier Analysis for 15mV peak

Vd 1 8 sin(0 15mV 1kHz)

.TRAN 0.05ms 10ms start=0

.FOUR 1kHz V(5)

.end

6
2
4
1 8
5
7
6
0
M3 M4
M2 M1
IREF
M5 M6
R1
100k
C1
4pF
Vdd
Vss