Академический Документы
Профессиональный Документы
Культура Документы
SPICE
Introduction
SPICE: Simulation Program with Integrated
Circuit Emphasis
p
SPICE is program that simulates electronic
circuits on your PC
You can view any voltage or current waveform
in your circuit. SPICE calculates these voltages
and currents versus time (Transient Analysis)
or versus frequency (AC Analysis).
SPICE
C
was deve
developed
oped at U
University
ve s ty oof
S
California Berkeley.
SPICE3 is the latest version that UCB offers.
Analog Electronics Laboratory
SPICE Versions
Various SPICE based circuit simulators are available:
Commercial:
- HSpice
- Spectre Widely used in Industry
- Eldo
- PSpice
Free:
- WinSpice
- LTSPICE
- ngSpice
S i
Output
MOSFET
10
Scale Factors
A number field may be an
integer field (e
(e.g.
g 12,
12 -44)
44),
a floating point field
(3.14159), either an
i t
integer
or floating
fl ti point
i t
number followed by an
integer exponent (1e-14,
2.65e3), or an integer or a
floating point number
followed by one of the
scale factors.
11
12
Capacitors
Generall form
G
f
:
Cxxx N+ N- VALUE <IC=INCOND>
Cxxx is the name of the resistor in circuit.
N+ and N- are the two element nodes.
VALUE is the capacitance in Farads.
The
he (optional) initial condition is the initial (time
(time-zero)
e o) value of
capacitor voltage.
Example:
C1 32 33 1U
CSHUNT 50 51 10U IC=3 V
Analog Electronics Laboratory
13
Example:
p
L1 32 33 1U
LSHUNT 50 51 10U IC=13.1MA
Analog Electronics Laboratory
14
Independent DC Sources
Voltage source: Vname N+ N- <DC=> DCValue
Current source: Iname N+ N- <DC=> DCValue
N+ is the positive terminal & N is the negative
terminal.
DCValue gives the value of the source.
g and current source must
The name of a voltage
start with V and I, respectively.
15
Independent Sources
VXXXXXXX N+ N- <<DC> DCVALUE> <AC
<ACMAG <ACPHASE>>>
IYYYYYYY N+ N- <<DC> DCVALUE> <AC
<ACMAG <ACPHASE>>>
The name of a
voltage and
current source
must start with
ihV
and I,
respectively.
p
y
Analog Electronics Laboratory
16
17
Examples
VCC 10 0 DC 12
ISRC 23 21 AC 0.333 45.0
V2 28 41 DC 5 AC 00.333
333 45
45.0
0
18
19
Example
p
VIN 3 0 PULSE(-1 1 2NS 2NS 2NS 50NS 100NS)
PULSE(V1
( V2 TD TR TF PW PER))
20
21
EXAMPLE
V1 is the amplitude
VO
VO iis th
the offset
ff t voltage
lt
To is the time delay
fo is the frequency
a is damping factor in perseconds
Analog Electronics Laboratory
22
Device Models
For Semiconductor devices we use device models
Each model specify different parameters of a device
This line appears any where in your netlist
D/Q/Mxxx N1 N2 N3.. MODName
Then any where you write
For diode
.MODEL MODName D (IS= N= Rs= CJO= ..)
For NPN/PNP BJT
.MODEL MODName NPN/PNP (BETA= VA= CJBE=)
For NMOS/PMOS MOSFET
.MODEL
MODEL MODName NMOS/PMOS (VTO
(VTO= ))
N1, N2, N3 are the terminals of the device:
N1, N2 are Anode and Cathode nodes of Diode respectively
N1,, N2,, N3,, <N4> are the Collector,, Base,, Emitter nodes of BJT respectively.
p
y
N4 is the (optional) Substrate node
N1, N2, N3, N4 are the Drain, Gate, Source and Body nodes of MOSFET
respectively.
Analog Electronics Laboratory
23
24
.DC
DC Statement
Another form is
.DC
DC SRCNAM VSTART VSTOP VINCR <SRC2
SRC2
START2 STOP2 INCR2>
Example
.DC VDS 0 10 .5 VGS 0 5 1
This causes the value of the voltage source VDS
to be swept from 0 Volts to 10.0 Volts in
increments of 0.5 Volts. For each increment in the
secondd source, first
fi source is
i swept over its
i range.
25
Example
NMOS VDS-ID CURVES
VDD 4 0 5
VDUM 4 3 0
VGS 2 0 1
M1 3 2 0 0 MN L
L=0.25U
0.25U W
W=1U
1U
.MODEL MN NMOS (LEVEL=1 TOX=2.6N VT0=0.3 GAMMA=0.2
+PHI=0.6 U0=250 LD=0.025U CJ=8E-4 CJSW=8E-12
+CGSO = 3.365E-10 CGDO=3.365E-10 LAMBDA=0.2)
.DC VDD 0 5 0.01 VGS 0 0.7 0.1
.PLOT DC I(VDUM)
.END
26
Output
27
Transient Analysis
.TRAN
.TRAN TSTEP TSTOP<TSTART><UIC>
TSTEP is the increment or step size.
size TSTOP is the final
time, and TSTART is the initial time. If TSTART is
omitted, it is assumed to be zero. UIC (use initial
conditions)) indicates that the user does not want SPICE to
solve for the quiescent operating point before beginning
the transient analysis. SPICE then uses the values specified
using IC=... on the various elements as the initial transient
condition.
di i
Example :
.TRAN 1NS 100NS
.TRAN 1NS 1000NS 500NS
Analog Electronics Laboratory
28
AC Statement: .AC
This statement is used to specify the frequency (AC) analysis. The format is as
follows:
.AC
AC LIN NP FSTART FSTOP
.AC DEC ND FSTART FSTOP
.AC OCT NO FSTART FSTOP
LIN stands for a linear frequency
q
y variation.
DEC and OCT for a decade and octave variation respectively.
NP stands for the number of points and ND and
NO for the number of frequency points per decade and per octave respectively.
FSTART and FSTOP are the start and stopping frequencies in Hertz.
Examples:
.AC
AC DEC 10 1 10K
.AC DEC 10 1K 100MEG
.AC LIN 100 1 100HZ
29
30
OUTPUT STATEMENTS
.PRINT and .PLOT
.PRINT TYPE OV1 OV2 OV3 ...
.PLOT TYPE OV1 OV2 OV3 ...
.PLOT DC V(1,2) V(3)
.PLOT TRAN I(V1)
In the original SPICE version (and the one that we will use
in the lab) we must place a DC dummy voltage source i.e.
Vdum = 0 V,
V source to measure current.
current
We then use I(Vdum) to print or plot current through the
dummy voltage source.The current entering the positive
terminal is taken as positive.
In one .PLOT statement OV1 OV2can be current or
voltage variables but not both.
Analog Electronics Laboratory
31
Example
+15V
R1
33k
CB
10uF
RC
1.2k
CC
10uF
10
F
Q1
NPN
+
-
R2
18k
RE
1.2k
VIN
RL
1k
CE
100uF
32
Example (contd)
VDB AMP
.MODEL QMOD NPN (Is=6.734f Xti=3 Eg=1.11 Vaf=74.03 Bf=100
+Ne=1.259 Ise=0 Ikf=66.78m Xtb=1.5 Br=.7371 Nc=2 Isc=0 Ikr=0
+Rc=1 Cjc=3.638p Mjc=.3085 Vjc=.75 Fc=.5 Cje=4.493p Mje=.2593
+Vje=.75 Tr=239.5n Tf=301.2p Itf=.4 Vtf=4 Xtf=2 Rb=10)
VCC 12 0 15
VDUM 12 10 0
RC 10 9 1.2k
Q1 9 8 7 QMOD
RE 7 0 1.2K
R1 12 8 33K
R2 8 0 18K
CE 7 0 100U
CB 6 8 10U
CC 9 11 10U
RL 11 0 1K
Analog Electronics Laboratory
33
Example (contd)
VIN 6 0 AC SIN(0 10M 10000 0 0)
* Note the AC keyword in the above line which specifies that the
* VSIN has magnitude 1 for the AC analysis. Omitting the AC
* keyword will set the magnitude of VSIN to 0 for AC analysis and
*hence will result in incorrect output for the AC analysis
.OP
.TRAN 100N 1M
.PLOT TRAN V(6) V(11)
.AC DEC 100 1 1000MEG
.PLOT AC V(11)
.END
END
34
Output:
p TRAN analysis
y
35
Output:
p AC analysis
y
36
Output:
p OP analysis
y
37
Circuit Restrictions
1
+
100mA
1uF
u
0
1uF
+
1uF
+
10V
1
+
1uF
0
38
Circuit Restrictions
SPICE does not permit any loop to consist
exclusively of inductance(s) and/or voltage
sources.
1
+
10V
1k
1uH
39
Subcircuits
A complex
l electronic
l
i circuit
i i often
f contain
i severall components, or
subsections of circuitry that are identical to each others
Examples
- opamps
- logic gates
SPICE allows a user to create subcircuits that are created once and
then can be inserted into a larger system at as many places as desired.
A subcircuit definition starts with .SUBCKT
.SUBCKT
SUBCKT SUBNAM N1 <N2,N3.>
N2 N3
SUBNAM is the subcircuit name N1,N2,N3are the node numbers in
the subcircuit that will be joined to other nodes in the main circuit and
cannot contain datum(0) node.
Examples:
.SUBCKT OPAMP 1 2 3
.SUBCKT INV IN OUT VCC
Analog Electronics Laboratory
40
Subcircuits contd
A subcircuit can contain other subcircuits, device models
and subcircuit calls.
Analysis
A l i andd output lines
li
suchh as .AC,
AC .DC,
DC .PLOT,
PLOT
cannot appear within a subcircuit definition
Any device models or subcircuit definitions included as
partt off a subcircuit
b i it definition
d fi iti are strictly
t i tl local
l l i.e.
i suchh
models and definitions are not known outside the
subcircuit definition.
Nodes not included on the .SUBCKT
SUBCKT line are strictly local,
local
with the exception of 0 (ground) which is always global.
Local nodes can be made global by using the .GLOBAL
directive (see User Manual) .
41
Calling Subcircuits
The last statement in a subcircuit must be
.ENDS <SUBNAM>
if a subcircuit itself contains subcircuits,
subcircuits the SUBNAM
must be given in the .ENDS to specify which subcircuit
definition has been ended.
To insert a subcircuit into the main circuit,
circuit we must write a
subcircuit call
X**** N1, <N2,N3.> SUBNAM
N1 N2 are the node numbers in the main circuit that are
N1,N2
joined to subcircuit nodes specified in the .SUBCKT line
in exactly the order. SUBNAM is the name of the
subcircuit to be inserted.
Examples:
X1 6 7 8 OPAMP
X13 11 12 VCC INV
Analog Electronics Laboratory
42
Example
+5V
RC1
1k
RC2
1k
RB2
100 ohms
RB1
100 ohms
Q1
NPN
RC3
1k
RB3
100 ohms
Q2
NPN
Q3
NPN
+
PULSE
0-5V
43
Example (contd)
3 CASCADED INVERTERS
VSUPPLY VCC 0 5
VIN 1 0 PULSE (0 5 0 0 0 10N 20N)
X1 1 2 VCC INVERTER
X2 2 3 VCC INVERTER
X3 3 4 VCC INVERTER
.SUBCKT INVERTER IN OUT VCC
Q1 OUT BASE 0 NPNMOD
RB IN BASE 100
RC VCC OUT 1K
.MODEL NPNMOD NPN(BF 100)
.ENDS
ENDS
.TRAN 1N 100N
.PLOT TRAN V(1)
( ) V(4)
( )
.END
Analog Electronics Laboratory
44
OUTPUT
45
Download
Download and install WinSpice. Its Free
www.winspice.com
To check, double click on WinSpice icon, a
command window will open
p then ggo to
File>Open>C:\Program Files\ Ouse
Tech\WinSpice\Examples and then double click
on any .cir file.
WinSpice also has a very well written User
M
Manual.
l Go
G to start menu>All
All
Programs>WinSpice>User Manual
Analog Electronics Laboratory
46
References
11. WinSpice User Manual
Man al
2. Spice and PSpice an appendix chapter
in El
Electronic
t i Devices
D i
andd Circuits
Ci it by
Theodore F. Bogart.
In these slides we have presented only a
small subset of all SPICE capabilities. For
a complete discussion on SPICE see
WinSpice User Manual.
Analog Electronics Laboratory
47