Lecture 12Lecture 12
Introduction to SPICEIntroduction to SPICE
Ref: Star-Hspice Manual Avanti
1
1. What is SPICE?1. What is SPICE?
�SPICE (Simulation Program with Integrated Circuit
Emphasis)
� A computer program
�� Used to analyze the operation of an electronic circuit
containing a variety of components, e.g., transistors,
diodes, resistors, capacitors, transmission lines etc.
� Performed under the nonlinear DC, nonlinear
transient and linearized operating conditions.
2
SPICE history and programsSPICE history and programs
� The original SPICE was developed at University of California, Berkeley
and released for public use in 1972.
� SPICE programs today
� Berkeley SPICE: original
� I-SPICE: interactive SPICE, the first commercial version of SPICE � I-SPICE: interactive SPICE, the first commercial version of SPICE
developed in the late 1970’s
� HSPICE: created by Meta-software and owned by Avanti (owned by
Synopsys now); popular within unixed-based users. BSIM2 and BSIM3
are implemented as levels 39, 47, and 49; level 28 model is still popular.
� PSPICE: PC-based version SPICE created by Micro-sim and acquired by
Orcad.
� SPECTRA: created by Cadence.
3
SPICE simulator and
SPICE device models
SPICE simulator and
SPICE device models� The interaction between SPICE simulator and SPICE device models
Iteration steps to simulate a circuit composed of device models.
� 1) Guest all of the node voltages.�
� 2) Pass a subset voltages to device model and evaluate the branch
currents.
� 3) Check whether the kirchoff current law is fulfilled at each node.
� 4) If no, to calculate the new node voltages and repeat 2) and 3)
� 5) If yes (convergent), iteration stops.
4
SPICE models-MOSFETSPICE models-MOSFET
Level 1: Shichman-Hodeges model
long-channel devices ;
C-V portion of the model is Meyer model instead of a
charge-conservative model .charge-conservative model .
Level 2: short-channel effects such as
the velocity saturation;
C-V portion of the model is Meyer model OR Ward-
Dutton model (a charge-conservative model) convergence
problem due to the complicated mathematical implementation
of model .
5
� Level 3: Semi-empirical model (simplified of Level 2); robust
and popular; discontinuity of the first derivative of the drain
current
� BSIM: Berkeley short-channel IGFET model, (as Level 4);
empirical model; convergence problem.
� HSPICE Level 28: by Meta-software; similar to BSIM; suitable
6
� HSPICE Level 28: by Meta-software; similar to BSIM; suitable
for analog design.
� BSIM 2: extension to BSIM; suitable for analog design; several
operation regions, discontinuity problem;
� BSIM3: a single equation to describe device characterizes in
various operation regions (Level 8 model), no discontinuity
problem. accurate in 0.18 um technology. Three version: BSIM
3v1, BSIM 3v2 and BSIM 3v3. eecs.berkeley.edu/~bsim3
� BSIM4: improved model over BSIM3 (Level 14);
I-V modeling of the intrinsic transistor;
incorporation of extrinsic parasitics.
� MODEL 9: non-berkeley model;
similar to BSIM3;
7
similar to BSIM3;
by Philips Lab with IP issues.
� EKV Model: bulk-referencing model instead of the popular
source-referencing model; unpopular
� Level 1,2, and 3 models : the first generation models.
emphasize the device physics.
�BSIM, BSIM 2: the second generation models.
emphasize the mathematical representation;
complicated parameters hard to extract;
weakening the link between the model parameters
and fabrication process.
8
and fabrication process.
�BSIM3, BSIM4: the third generation model;
a semi-physics model
reintroduce a physical basis to the model
SPICE simulator and SPICE models are different. Berkeley
SPICE simulator does not support TI-SPICE model.
HSPICE supports BSIM2, BSIM3V2, and BSIM3V3 and are
implemented as level 39, 47, and 49, respectively.
SPICE GrammarSPICE Grammar
An spice program include three parts:
1) circuit description: its elements, source, and how they are connected.
2) Analysis request: dc, small-signal, transient (large signal), etc.
3) Output request: a table of current, voltage3) Output request: a table of current, voltage
Notes: 1) The first line must be a title with comment asterisk;
2) the last must be .end statement.
3) Comment statements are identified by inserting an asterisk (*).
4) case insensitive
9
Circuit descriptionCircuit descriptionElement statement: name, nodes, and value.
Component Name Nodes Value
Resistor Rxxxxxxx N+ N- Value
R11 2 3 50Example:
10
Resistor Rxxxxxxx N+ N- Value
Capacitor Cxxxxxxx N+ N- Value
Inductor Lxxxxxxx N+ N- Value
Voltage source Vxxxxxxx N+ N- Qual
Current source Ixxxxxxx N+ N- Qual
VCCS Gxxxxxxx N+ N-
VCVS Exxxxxxx N+ N-
CCCS Fxxxxxxx N+ N-
CCVS Hxxxxxxx N+ N-
• The component name begins with a particular letter as indicated,
and is from one to eight alphanumeric characters long.
• N+ and N- indicate the positive node and the negative node.
• Value is in units of ohms, farads, henries, volts, amperes, A/V,
V/V, A/A, V/A, respectively.
• NC+ and NC- are nodes across the controlling voltage.
• VNAM is the voltage source through the controlling current • VNAM is the voltage source through the controlling current
flows.
• QUAL is a set of qualifiers of the source, whether DC or
transient (including pulse, sinusoid, exponential or piecewise-
linear) with amplitudes and other qualifiers, or AC with
magnitude and phase.
11
General FormVxxx n+ n- <<DC=> dcval> <tranfun> <AC=acmag, <acphase>>
orIyyy n+ n- <<DC=> dcval> <tranfun> <AC=acmag, <acphase>>+ <M=val>
Vxxx Independent voltage source element name. Must begin with a “V”.
Iyyy Independent current source element name. Must begin with an “I.
n+ Positive node.
n- Negative node.
12
n- Negative node.
DC=dcval DC source keyword and value in volts.
tranfun Transient source function (one or more of: AM, DC, EXP, PE, PL,
PU, PULSE, PWL, SFFM, SIN). The functions specify the characteristics of
a time-varying source
AC AC source keyword for use in AC small-signal analysis.
acmag Magnitude (RMS) of the AC source in volts.
acphase Phase of the AC source in degrees. Default=0.0.
M Multiplier used for simulating multiple parallel current sources. The
source current value is
multiplied by M. Default=1.0.
1. Voltage source VB has a DC bias specified by the parameter ‘VCC’,
VB 2 0 DC=VCC
2. Voltage source VH has a 2 volt DC bias, a 1 volt RMS AC bias with 90
degree phase offset,
VH 3 6 DC=2 AC=1,90
3. Current source IG has a time-varying response given by the piecewise-
linear relationship with 1 milliamp at time=0 and 5 milliamps at 25
Source examples
13
linear relationship with 1 milliamp at time=0 and 5 milliamps at 25
milliseconds,
IG 8 7 pwl(0 1mA 25m 5mA)
4. Voltage source VIN has a 0.001 volt DC bias, a 1 volt RMS AC bias, and
a sinusoidal time-varying response from 0 to 1 volts with a
frequency of 1 Megahertz.
VIN 3 2 0.001 AC 1 sin (0 1 1meg)
5. Current source ISRC has a 1/3 amp RMS AC response with a 45 degree
phase Offset .The positive terminal is connected to node 23 while
the negative terminal is connected to node 21.
ISRC 23 21 AC 0.333 45.0
DC Sources
For a DC source, you can specify the DC current or voltage in different ways:
V1 1 0 DC=5V
V1 1 0 5V
AC Sources
AC current and voltage sources are impulse functions used for an AC
analysis.
V1 1 0 AC=10V,90
14
V1 1 0 AC=10V,90
VI 1 0 AC 10V 90
Transient Sources
For transient analysis, you can specify the source as a function of time.
• Pulse (PULSE function)
• Sinusoidal (SIN function)
• Exponential (EXP function)
• Piecewise linear (PWL function)
• Single-frequency FM (SFFM function)
• Single-frequency AM (AM function)
General form:
Vxxx n+ n- PU<LSE> <(>v1 v2 <td <tr <tf <pw <per>>>>> <)>
Vxxx, Ixxx Independent voltage source which will exhibit the pulse response.
PULSE Keyword for a pulsed time-varying source. The short form is ‘PU’.
v1 Initial value of the voltage or current, before the pulse onset (units of volts or
amps).
v2 Pulse plateau value (units of volts or amps).
PULSE function
15
v2 Pulse plateau value (units of volts or amps).
Td Delay time in seconds from the beginning of transient interval to the first onset
ramp. Default=0.0 and negative values are considered as zero.
tr Duration of the onset ramp in seconds, from the initial value to the pulse
plateau value (reverse transit time). Default=TSTEP).
tf Duration of the recovery ramp in seconds, from the pulse plateau back to the
initial value (forward transit time). Default=TSTEP.
pw Pulse width (the width of the plateau portion of the pulse) in seconds.
Default=TSTEP.
per Pulse repetition period in seconds.
Default=TSTEP.
16
.option post
.tran .5ns 75ns
vpulse 1 0 pulse( v1 v2 td tr tf pw per )
r1 1 0 1
.param v1=1v v2=2v td=5ns tr=5ns tf=5ns pw=20ns
+per=50ns
.end
Sinusoidal Source Function
General form:
Vxxx n+ n- SIN <(> vo va <freq <td <θ <ϕ>>>> <)>
Vxxx Independent voltage source that will exhibit the sinusoidal response.
SIN Keyword for a sinusoidal time-varying source.
vo Voltage or current offset in volts or amps.
Va Voltage or current RMS amplitude in volts or amps.
Freq Source frequency in Hz. Default=1/TSTOP.
17
td Time delay before beginning the sinusoidal variation in seconds.
Default=0.0, response will be 0 volts or amps until the delay value is reached,
even with a non-zero DC voltage.
θ Damping factor in units of 1/seconds. Default=0.0.
ϕ Phase delay in units of degrees. Default=0.0.
Sinusoidal Source
Function
18
*<decay envelope>
.OPTIONS POST
.PARAM V0=0 VA=1 FREQ=100MEG DELAY=2N
THETA=5E7
+PHASE=0
V 1 0 SIN (V0 VA FREQ DELAY THETA PHASE)
R 1 0 1
.TRAN .05N 50N
.END
General form:
Vxxx n+ n- EXP <(> v1 v2 <td1 <τ1 <td2 <τ2>>>> <)>
or
Ixxx n+ n- EXP <(> v1 v2 <td1 <τ1 <td2 <τ2>>>> <)>
The arguments are defined as:
Vxxx, Ixxx Independent voltage source that will exhibit the exponential response.
EXP Keyword for a exponential time-varying source.
v1 Initial value of voltage or current in volts or amp
Exponential Source Function
19
v1 Initial value of voltage or current in volts or amp
v2 Pulsed value of voltage or current in volts or am
td1 Rise delay time in seconds. Default=0.0.
td2 Fall delay time in seconds. Default=td1+TSTEP
τ1 Rise time constant in seconds. Default=TSTEP.
τ2 Fall time constant in seconds. Default=TSTEP.
20
*FILE: EXP.SP THE EXPONENTIAL WAVEFORM
.OPTIONS POST
.PARAM V1=-4 V2=-1 TD1=5N TAU1=30N TAU2=40N TD2=80N
V 1 0 EXP (V1 V2 TD1 TAU1 TD2 TAU2)
R 1 0 1
.TRAN .05N 200N
.END
General form:
Vxxx n+ n- PWL <(> t1 v1 <t2 v2 t3 v3…> <R <=repeat>> <TD=delay> <)>
Piecewise Linear Source Function
Vxxx, Ixxx Independent voltage source that will exhibit the piecewise
linear response.
PWL Keyword for a piecewise linear time-varying source.
v1 v2 … vn Current or voltage values at corresponding timepoint.
21
v1 v2 … vn Current or voltage values at corresponding timepoint.
t1 t2 … tn Timepoint values where the corresponding current or voltage
value is valid.
R=repeat Keyword and time value to specify a repeating function.
TD=delay Time in units of seconds which specifies the length of time to
delay the piecewise linear function.
22
**file pwl.sp REPEATED PIECEWISE LINEAR SOURCE
.OPTION POST
.TRAN 5N 500N
V1 1 0 PWL 60N 0V, 120N 0V, 130N 5V, 170N 5V, 180N 0V, R 0N
R1 1 0 1
V2 2 0 PL 0V 60N, 0V 120N, 5V 130N, 5V 170N, 0V 180N, R 60N
R2 2 0 1
.END
Single-Frequency FM Source Function
General form:
Vxxx n+ n- SFFM <(> vo va <fc <mdi <fs>>> <)>
Vxxx, Ixxx Independent voltage source which will exhibit the frequency-
modulated response.
SFFM Keyword for a single-frequency frequency-modulated time-varying
source.
vo Output voltage or current offset, in volts or amps.
23
vo Output voltage or current offset, in volts or amps.
va Output voltage or current amplitude, in volts or amps.
fc Carrier frequency in Hz. Default=1/TSTOP.
mdi Modulation index which determines the magnitude of deviation from
the carrier frequency. Values normally lie between 1 and 10. Default=0.0.
fs Signal frequency in Hz. Default=1/TSTOP.
0 sin[2
sin(2 )]
a c
c
sourcevalue v v f Time
mdi f Time
π
π
= + • • • +
• • •
24
**file SFFM.SP THE SINGLE FREQUENCY FM SOURCE
.OPTIONS POST
V 1 0 SFFM (0, 1m, 20K, 10, 5K)
R 1 0 1
.TRAN .0005M .5MS
.END
Amplitude Modulation Source Function
General form:
Vxxx n+ n- AM <(> so sa fm fc <td> <)>
Vxxx, Ixxx Independent voltage source that will exhibit the amplitude-
modulated response.
AM Keyword for an amplitude-modulated time-varying source.
sa Signal amplitude in volts or amps. Default=0.0.
25
sa Signal amplitude in volts or amps. Default=0.0.
fc Carrier frequency in hertz. Default=0.0.
fm Modulation frequency in hertz. Default=1/TSTOP.
oc Offset constant, a unitless constant which determines the absolute
magnitude of the modulation. Default=0.0.
td Delay time before start of signal in seconds. Default=0.0
[ ]{ }sin 2 ( )
sin[2 ( )]
m
c
sourcevalue sa oc f Time td
f Time td
π
π
= • + • • −
• • • −
.OPTIONS POST
.TRAN .01M 20M
V1 1 0 AM (10 1 100 1K 1M)
R1 1 0 1
26
R1 1 0 1
V2 2 0 AM (2.5 4 100 1K 1M)
R2 2 0 1
V3 3 0 AM (10 1 1K 100 1M)
R3 3 0 1
.END
Voltage and Current
Controlled Elements
Voltage and Current
Controlled Elements� The E element is a voltage and/or current controlled voltage source, an ideal
op-amp, an ideal transformer, an ideal delay element, or a piecewise linear
voltage controlled multi-input AND, NAND, OR, and NOR gate.
� The G element is a voltage and/or current controlled current source, a voltage
controlled resistor, a piecewise linear voltage controlled capacitor, an ideal
delay element, or a piecewise linear multi-input AND, NAND, OR, and
NOR gate.
� The H element is a current controlled voltage source, an ideal delay element,
or a piecewise linear current controlled multi-input AND, NAND, OR, and
NOR gate.
� The F element is a current controlled current source, an ideal delay element,
or a piecewise linear current controlled multi-input AND, NAND, OR, and
NOR gate.27
Polynomial Functions
POLY(1) One-dimensional equation
-a polynomial equation as a function of one controlling variable
POLY(2) Two-dimensional equation
-a polynomial equation as a function of two controlling variables
POLY(3) Three-dimensional equation
-a polynomial equation as a function of three controlling variables
One-Dimensional Function
28
Example: E1 5 0 POLY(1) 3 2 1 2.5 (5,0) 1 2.5 (3, 2)V V= + i
Suffix letter Metric Prefix Multiplying
factor
T tera 10+12
G giga 10+9
Meg mega 10+6
TABLE Scaling factor abbreviations
Meg mega 10
K kilo 10+3
M milli 10-3
U micro 10-6
N nano 10-9
P pico 10-12
F femto 10-15
29
Device Name Nodes Models
Diode DXXXXXXX N+ N- MNAME
BJT QXXXXXXX NC NB NE
NS
MNAME
MOSFET MXXXXXXX ND NG NS MNAME
Table element statements for semiconductor devices
MOSFET MXXXXXXX ND NG NS
NB
MNAME
• FOR a diode, N+ is the node connected to the anode, N- is
the node connected to the cathode.
• For a BJT, NC, NB, NE and NS are the nodes connected
to the collector, base, emitter, and substrate.
• For a MOSFET, ND, NG, NS and NB are the nodes
connected to the drain, gate, source and body.
30
Table Syntax of model statements
Device Model statement
Diode .Model MNAME D(IS=… N=.. Etc.)
BJT .Model MNAME NPN( IS=…BF=…,etc.)
MOSFET .Model MNAME NMOS (kp=…,vto=…etc)MOSFET .Model MNAME NMOS (kp=…,vto=…etc)
31
Analysis requestsAnalysis requests
Analysis requests Spice commands
Operating-point .OP
DC sweep .DC source name start_value stop_value step value
32
AC frequency response .AC DEC points_per_decade freq_stat freq_stop
.AD OCT points_per_decade freq_stat freq_stop
.AC LIN points_per_decade freq_stat freq_stop
Transient response .TRAN time_step time_stop
Output requestsOutput requests
Output requests Spice commands
Print data points .PRINT DC output variables
.PRINT AC output variables
.PRINT TRAN output variables
33
.PRINT TRAN output variables
Plot data points .PLOT DC output variables
.PLOT AC output variables
.PLOT TRAN output variables
ExampleExample* RLC circuit
.option post=2
vs 1 0 pwl(0 0 100p 1.5 )
R 1 2 180
34
R 1 2 180
L 2 3 46n
C 3 0 1500f
.tran 1p 1000p
.print v(3)
.end
35