Lecture07 SPICE Introduction Up
Lecture07 SPICE Introduction Up
ntsonvldt@gmail.com
SPICE Introduction
1 Introduction to SPICE
4 Basic Components
5 Measurement
6 Example
SPICE Elements
Letter Element
R Resistor
C Capacitor
L Inductor
K Mutual Inductor
V Independent voltage source
I Independent current source
M MOSFET
D Diode
Q Bipolar transistor
W Lossy transmission line
X Subcircuit
E Voltage-controlled voltage source
G Voltage-controlled current source
H Current-controlled voltage source
F Current-controlled current source
Nguyen Tran Son (∞) SPICE Introduction Feb 13, 2023 8 / 38
SPICE Units
Device Models
Types of Analysis:
DC Analysis
AC Small-Signal Analysis
Transient Analysis
Pole-Zero Analysis
Small-Signal Distortion Analysis
Sensitivity Analysis
Noise Analysis
DC Analysis
The DC analysis portion of SPICE determines the
DC operating point of the circuit with inductors
shorted and capacitors opened.
The DC analysis options are specified on the .DC,
.TF, and .OP control lines.
A DC analysis is automatically performed prior to a
transient analysis to determine the transient initial
conditions, and prior to an AC small-signal analysis
to determine the linearized, small-signal models for
nonlinear devices.
General form:
.DC SRCNAM VSTART VSTOP VINCR [SRC2 START2 STOP2
INCR2]
Example:
. DC VIN 0.25 5.0 0.25
. DC VDS 0 10 .5 VGS 0 5 1
. DC VCE 0 10 .25 IB 0 10 U 1 U
Nguyen Tran Son (∞) SPICE Introduction Feb 13, 2023 14 / 38
DC Analysis: Example
NGSpice code:
* Sim INVERTER CIRCUIT
* 23/09/2022
. lib ’E :\ Software \ Spice \
Lecture_Spice \ model \ CE222 . lib ’
TT
. option TEMP =25 C
. param pvdd11 = 1.1
* CMOS inverter
vvdd vdd 0 dc ’ pvdd11 ’
mp vdd in out vdd pmos l =70 n w =2.4 u
mn out in 0 0 nmos l =70 n w =1 u
cload out 0 200 f
vin in 0 dc 1 pwl (0 0 10 ns 0 10.1 ns
’ pvdd11 ’ , 15 ns ’ pvdd11 ’ 15.1 n
0)
. control
set color0 = white ; background , a
nice color of off - white
set color1 = black ; text and grid
almost black
set color2 = blue ; vector0
set color3 = red ; vector1
set color4 = rgb :0/0/ f ; vector2
set xgridwidth =1
set xbrushwidth =2
run
dc vin 0 1 0.005
plot v ( in ) v ( out )
. endc
. end
Nguyen Tran Son (∞) SPICE Introduction Feb 13, 2023 15 / 38
AC Small-Signal Analysis
General form:
.AC DEC ND FSTART FSTOP
.AC OCT NO FSTART FSTOP
.AC LIN NP FSTART FSTOP
Example:
. AC DEC 10 1 10 K
. AC DEC 10 1 K 100 MEG
. AC LIN 100 1 100 HZ
General form:
.TRAN TSTEP TSTOP <TSTART <TMAX» <UIC>
Example:
. TRAN 1 NS 100 NS
. TRAN 1 NS 1000 NS 500 NS
. TRAN 10 NS 1 US UIC
Independent AC Sources:
Voltage source: Vname N+ N- AC ACValue, Phase
Current source: Iname N+ N- AC ACValue, Phase
ACValue gives the value of the source
ACPhase gives the phase in degrees
Nguyen Tran Son (∞) SPICE Introduction Feb 13, 2023 20 / 38
Transient Sources
Sinusoidal
Vname N+ N- SIN(VO VA fo <TD> <a>
<PHASE>)
Vname = VO + VA exp[-a.(t - TD)] sin[2pi.f (t -
TD) + (PHASE/360)]
VO - offset voltage in volts.
VA - amplitude in volts.
fo -the frequency in hertz.
TD - delay in seconds
a - damping factor per second
Phase - phase in degrees (If TD, a and PHASE are
not specified, it is assumed to be zero.)
A cosine can be generated by shifting a sin by 90
degrees
Nguyen Tran Son (∞) SPICE Introduction Feb 13, 2023 21 / 38
Transient Sources
Sinusoidal
Vname N+ N- SIN(VO VA fo <TD> <a>
<PHASE>)
Vname = VO + VA exp[-a.(t - TD)] sin[2pi.f (t -
TD) + (PHASE/360)]
Transient Sources
Pulse
Vname N+ N- PULSE(Vo V1 Td Tr Tf Tw To)
Vo - initial voltage
V1 - peak voltage
Td - initial delay time
Tr - rise time
Tf - fall time
Tw - pulse-width
To - period of wave
Semiconductor Devices
Diode: Dname N+ N- MODName
Model statement: (Appears in your deck to describe
circuit element)
.MODEL MODName D (IS= N= Rs= CJO= Tt= BV=
IBV=)
.model D1N4148 D (IS=0.1PA, RS=16 CJO=2PF
TT=12N BV=100 IBV=0.1PA)
The element name starts with D to indicate that the element is
a diode,
N+ is the positive end and N- is the negative end (where the
arrow points)
MODName is the name of the model of the diode specified in
the model line.
IS - saturation current, (default=1E-14A),
N - the emission coefficient, (=1),
RS - the series resistance, (=0 ohm),
CJO - junction capacitance, (=0F),
TT - transit time, (=0sec),
BV - reverse
Nguyen bias
Tran Son (∞)breakdown voltage, (=infinite) and
SPICE Introduction Feb 13, 2023 26 / 38
Semiconductor Devices
Semiconductor Devices
MOSFET: Mname ND NG NS <NB> ModName <L=VAL>
<W=VAL>
Model:
.MODEL ModName NMOS (<LEVEL=val>
<keyname=val> ... )
.MODEL ModName PMOS (<LEVEL=val>
<keyname=val> ... )
*** 0.5 um CMOS technology
***
* SPICE LEVEL3 PARAMETERS
. MODEL NMOS NMOS LEVEL =3 PHI =0.7 TOX =9.5 E -09 XJ =0.2 U TPG =1
+ VTO =0.7 DELTA =8.8 E -01 LD =5 E -08 KP =1.56 E -04
+ UO =420 THETA =2.3 E -01 RSH =2.0 E +00 GAMMA =0.62
+ NSUB =1.40 E +17 NFS =7.20 E +11 VMAX =1.8 E +05 ETA =2.125 E -02
+ KAPPA =1 E -01 CGDO =3.0 E -10 CGSO =3.0 E -10
+ CGBO =4.5 E -10 CJ =5.50 E -04 MJ =0.6 CJSW =3 E -10
+ MJSW =0.35 PB =1.1
Example:
. subckt invd1 a y gnd vdd
xnm0 y a gnd gnd n_svt m =1 mf =1 w =240 e -9 l =80 e -9
xpm0 y a vdd vdd p_svt m =1 mf =1 w =360 e -9 l =80 e -9
. ends invd1
Subcircuits
Example:
vvdd vdd 0 5
va a 0 5
vb b 0 5
xnand2 a b vout gnd vdd nand2
. dc va 0 5 0.2
. plot dc v ( vout )
vvdd vdd 0 1 v
vin1 in1 0 pwl (0 0 , 10 ns 0 , 10.1 ns 1
v , 15 ns 1v , 15.1 ns 0)
vin2 in2 0 pwl (0 0 , 13 ns 0 , 13.1 ns 1
v , 17 ns 1 v )
Measurement: .MEASURE
Time Delay
.MEAS TRAN tdelay TRIG V(1) VAL=2.5 TD=10n
RISE=1 + TARG V(2) VAL=2.5 FALL=1
Measurement: .MEASURE
NGSpice code:
* MOS Characteristic Curves
* NMOS ID - VGS 11/1/2021
. include ./45 nm_LP . pm
. option TEMP =27 C
vd drain gnd dc 1
vg gate gnd dc 1
mn0 drain gate gnd gnd
nmos W =1 u L =45 n
. control
set color0 = white ; background , a
nice color of off - white
set color1 = black ; text and grid
almost black
set color2 = blue ; vector0
set color3 = red ; vector1
set color4 = rgb :0/0/ f ; vector2
set xbrushwidth =2
dc vg 0 1 0.01
plot -i ( vd )
print -i ( vd ) > m o s _ c h a r a c t e r is t i c s .
dc
. endc
. end
Questions?
Thank you !