A Tutorial on HSPICE

advertisement
A Tutorial on HSPICE
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
1
The following are basic VI command mode commands:
4.
Command
Description
/
:w
:q
:q!
x
nx
dd
ndd
0G
nG
Search
Write (update) file
Quit if file has been saved
Unconditional quit (forced exit)
Deletes 1 character
Deletes n character
Deletes 1 line
Deletes n lines
Go to last line in file
Go to line n
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:
5.
UNIX
DOS
ls
cat
cp
mkdir
rm
man
cp -r
cat a1 a2 > a3
clear
mv
cd
dir
type
copy
md
del
help
xcopy/s
copy a1+a2 a3
cls
rename
cd
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
2
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 = 109
X = 106
u = 10-6
p = 10-12
m = 10-3
K = 103
n = 10-9
Example: 100K = 100000 = 0.1X
(b)
Commonly used components in HSPICE
R1
C1
L1
V1
I1
X1
X1
n1
n1
n1
n1
n1
d
a
(c)
The reference (common/chassis) point is always taken as node “0”.
(d)
Comments start with an asterisk, example:
n2
n2
n2
n2
n2
g
k
va1
va1
va1
va1
va1
s
J2N5459
D1N4742
- Resistor
- Capacitor
- Inductor
- Voltage Source
- Current Source
- jfet transistor from lib.
- diode from library
* 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
3
6.
HSPICE Analyses
(a)
DC Operating Point
This analysis is output in the “.lis” file and is controlled as follows:
.OP All
.OP Brief
.OP Current
.OP Debug
.OP None
.OP Voltage
Full Operating Point
Line summary of each element’s voltage, current & power
Voltage table with element currents and power
Invoked by programme in case of non-convergence
Inhibits node and element print backs
Voltage table only
The default mode is All and this mode is the one that is most commonly
used.
Example:
1
Vp
.FILE nmosdc.sp
2
RD
10k
0
4
0
2
0
3
3
5K
5V
10K
-5V
Mod1
L=10u W=10u
Mod1
nmos
(LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)
.DC
var1
0
M1
3
2
3
1
1
4
RS
10k
4
M1
Rs
Vp
Rd
Vn
Vn
.MODEL
.OP ALL
.end
(b)
DC Sweep
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
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
stop1
inc1
var2
start2
stop2
inc2
4
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:
Vp
.FILE mosamp.sp
3
M1
3
2
3
1
3
1
0
0
2
0
.MODEL
Mod1
nmos
(LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)
.DC
1.5V
3V
10mV
Vin
0
0
DC
Mod1
Mod1
10V
2V
L=10u W=10u
L=10u W=10u
1
M2
VIN
0
M1
M2
Vp
Vin
2
.OPTION POST
.PLOT V(2)
.end
Example 2:
.FILE mosdc.sp
1
2
.OPTION POST
M1
Vgs
Vds
1
2
1
VGS
L=10u W=10u
VDS
2
0
0
0
0
DC
DC
.MODEL
Mod1
nmos
(LEVEL=2 VTO=2V uo=800 tox=500 nsub=1e15)
.DC
0V
10V
100mV
Vds
Mod1
0V
0V
M1
Vgs
0
0
8V
2V
.PLOT I(Vds)
.end
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
5
(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
R1
R2
R3
R4
C1
C2
C3
1
4
2
4
3
3
5
1
2
2
0
1
0
0
2
2
Vp
Vs
4
5
0
0
.AC
DEC
100
.PLOT AC
3
T2N2222A
88K
11K
4.7K
470
10u
1u
4.7n
10V
AC
1Hz
VDB(1,5)
Vp
4
R1
83k
R3
4k7
1
Vs
5
1uF
C2
4n7
C3
2
R2
11k
0
Q1
2N2222A
3
R4
470
C1
10uF
1mV
1XHz
VP(1,5)
.end
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
6
(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”
Vs
7
4
Vp
X1
R1
R2
R3
R4
R5
R6
C1
2
3
2
5
7
6
8
2
1
1
4
6
6
8
0
5
Vp
4
0
10V
*
Vs
7
0
sin(offset
sin(0
amplitude
4V
*
Vin
3
0
pulse(VL VH
pulse(0 10V
Delay
0.1ms
0.001ms
0.45ms
start=0
.TRAN
.PLOT TRAN V(3)
T2N2222A
10K
10K
1K
22K
22K
10K
100pF
R2
10k
2
Vin
3
R1
10k
R4
22k
C1
100pF
1
5 R3
1k
6
X1
2N2222A
R5
22k
8
0
0
R6
10k
frequency)
455kHz)
Rise
Fall
Pulse
0.05ms 0.05ms 0.1ms
Period)
0.3ms)
V(8)
.end
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
7
(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:
Vp
1
.FILE nmosbias.sp
2
RD
10k
.OPTION POST
.MODEL
4
4
0
2
0
3
0
Mod1
nmos
0
1X
1X
2K
15V
0V
Mod1
L=10u W=10u
RG2
10k
VDRAIN
3
3
1
4
1
1
2
4
RG1
10k
M1
0
M1
Rg1
Rg2
Rd
Vp
Vdrain
(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.
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
8
Example:
.FILE ota.sp
.OPTION POST
* simple transconductance operational amplifier
M1
M2
M3
M4
M5
M6
2
3
4
5
4
5
2
2
1
8
4
4
6
6
3
3
7
7
6
6
6
6
7
7
Mod1
Mod1
Mod1
Mod1
Mod2
Mod2
L=9.6u
L=9.6u
L=2.4u
L=2.4u
L=9.6u
L=9.6u
W=40u
W=40u
W=400u
W=400u
W=35u
W=35u
* mosfet models
.MODEL
.MODEL
Mod1 nmos
Mod2 pmos
(LEVEL=2 VTO=1V tox=500 nsub=1e15 kp=1m)
(LEVEL=2 VTO=-2V tox=500 nsub=1e15 kp=30u)
* reference circuit
Iref
7
2
1m
* RC Load
Vdd
c1
r1
5
5
0
0
4pF
100k
7
M5
M6
4
* Input Bias Resistors
Rb1
Rb2
1
8
IREF
6
1
0
0
10X
10X
5
M3
M1
2
8
M4
R1
100k
0
C1
4pF
M2
6
* Supply Voltages
Vss
vdd
vss
7
6
0
0
5V
-5V
* Fourier Analysis for 15mV peak
Vd
1
8
.TRAN
0.05ms
.FOUR 1kHz
V(5)
sin(0
15mV 1kHz)
10ms
start=0
.end
A Tutorial on HSPICE
Owen Casha B. Eng. (Hons.) – 2005
9
Download