Electronics II
LTSpice Tutorial
TA: Yu-Chi Hung
Instructor: Sheng-Shian Li
Institute of NanoEngineering and MicroSystems
National Tsing Hua University, Taiwan
Sep. 2024
1
Objective
NATIONAL TSING HUA UNIVERSITY
• Understand basic elements for circuit simulation
• Learn the basic usage of circuit simulators
• Know the concepts of device models
2
Circuit simulation background
NATIONAL TSING HUA UNIVERSITY
Circuit Topology
Physics
+
+
Device modeling Circuit simulator (EDA)
(Process dependent)
Device
characterizations
3
Spice topology
NATIONAL TSING HUA UNIVERSITY
• HSpice as an example
Ref: National Chip Implementation Center(CIC), Hsinchu, Taiwan 4
Start your program
NATIONAL TSING HUA UNIVERSITY
• Install LTSpice IV
• File → Open → Browse your netlist
– Name your netlist as XXX.sp
– Ex: CAD1.sp
• What is “netlist”?
– “Netlist" describes the connectivity of an electronic
design
5
Netlist Commends (simplified)
NATIONAL TSING HUA UNIVERSITY
TITLE First line is input file title
* Asterisk is a command to describe circuit
.LIB / .INCLUDE Cell library of general input files
.OPTIONS Set conditions for simulation
.PARAM Specify parameters
.IC / .NODESET Set initial states
.SUBCKT/.ENDS Define subcircuits
.AC / .DC / .TRAN / .TEMP Statement to set sweep variables
.OP Show DC operating points
.MEAS Provide measurement capability
.STEP Sweep variables
.END Required statement to terminate simulation
6
Element and Node naming
NATIONAL TSING HUA UNIVERSITY
• Either names or numbers (ex: n1, 12, vout1, ….)
• Ground can be 0, gnd, or !gnd
• 0 is always ground
• All nodes are assumed to be local
• “Node Names” can be made across all subcircuits by a
“.GLOBAL” Statement (ex: .GLOBAL VDD VSS )
7
Library input statement
NATIONAL TSING HUA UNIVERSITY
• Syntax
– .lib “filename” entryname
• Entryname is used to define the process corner
(TT, FF, SS…) in foundry CMOS
• No process corners is used in our simple homework.
• To use our “Free035.l” library, use the following:
– .lib “Free035.l”
8
Instance and element names
NATIONAL TSING HUA UNIVERSITY
• Keyword + names
EX:
• VDD
• Cfeedback
• R01
Element names
Keyword, “R” denotes Resistor
9
Element names and units
NATIONAL TSING HUA UNIVERSITY
All length and widths are in
meters
10
Source Element
NATIONAL TSING HUA UNIVERSITY
• Syntax
– Vxxx n+ n- <voltage> ◆Insert Value in < >.
– Ixxx n+ n- <current>
• Examples
– VDD n1 n2 dc 3.3
– Ibias_01 nb1 nb2 dc 30uA
– Vin Vinn 0 dc 1.3 ac 1
11
MOSFET
NATIONAL TSING HUA UNIVERSITY
• Syntax
– Mxx D G S B <model> [L=<len>] [W=<width>]
+ [M=<fingers>]
• Examples
– M26 n1 n3 n2 0 NM L=0.35u W=10u m=4
– Mb3 nbx nbx VDD VDD PM L=3u W=10u m=1
• In this course, model NM for NMOS, PM for
PMOS
12
Passive elements
NATIONAL TSING HUA UNIVERSITY
• Syntax
– Rxx n1 n2 <value>
– Lxx n+ n- <inductance>
– Cxx n+ n- <capacitance>
• Examples
– Rbias VDD nbias 20k
– Ltune n1 n2 19u
– Cdec Vinx vss 20n
13
Analysis type
NATIONAL TSING HUA UNIVERSITY
• .OP
– DC operation point
• .DC
– Sweep DC parameter
• .AC
– Sweep AC parameter, frequency domain
• .TRAN
– Time domain response
14
.DC Analysis
NATIONAL TSING HUA UNIVERSITY
• Syntax
– .dc <srcnam> <Vstart> <Vstop> <Vincr>
+ [<srcnam2> <Vstart2> <Vstop2> <Vincr2>]
• Example
– .DC VDD 0 3.3 0.1 VG1 0 3.3 0.1
Major variable (x-axis)
15
.AC analysis
NATIONAL TSING HUA UNIVERSITY
• Syntax
– .ac <oct, dec, lin> <Nsteps> <StartFreq> <EndFreq>
– Oct = no. of steps per octave
– Dec= no. of steps per decade
– Lin = Total number of linearly spaced steps between
StartFreq and EndFreq
• Example
– .ac dec 10 100k 10G
16
.Tran Analysis
NATIONAL TSING HUA UNIVERSITY
• Syntax
– .TRAN <Tstep> <Tstop> [Tstart [dTmax]] [modifiers]
• Example
– .tran 0.1n 20u
17
Example
NATIONAL TSING HUA UNIVERSITY
• Common-source Amplifier, AC and DC simulation
• Nodes: VDD, Vin, Vout, VSS
• Assume W=5u, L=0.5u, m=4 for M1
• Assume RD=1.0k, and CL=1.0pF
18
Example for .AC simulation
NATIONAL TSING HUA UNIVERSITY
Title
Obtain model library
Define global variables
Define subcircuits,
pin= Vin and Vout
Instant subckt
Load capacitance of the circuit
Power supplies and
input small-signal
.OP, save dc operation points
.AC, frequency response simulation
Termination command
19
Output control
NATIONAL TSING HUA UNIVERSITY
• After simulation (left click “Run” at the toolbar)
you can see a black window
• Right click the black window, you can see:
列出所有能
觀察的資料
加入新的曲線
刪除曲線
在視窗中分隔出
子視窗
在圖中加入網格
在曲線上標出格點
20
Output control
NATIONAL TSING HUA UNIVERSITY
• Select “Add trace”, you can see:
You can type formula here,
Ex: sqrt(V(vout)) to show the square
root of the output voltage gain
• Select “V(Vout)” and OK, you can get frequency
response.
21
V(Vout)
NATIONAL TSING HUA UNIVERSITY
• Voltage gain: 9.126 dB (2.86 V/V)
• Phase: 180-degree at DC
22
Example for .DC simulation
NATIONAL TSING HUA UNIVERSITY
Click here to show the cursor window
[email protected] = voltage gain= -2.83V/V
23
NATIONAL TSING HUA UNIVERSITY
空一行
叫Library
可視為一個有
兩個腳位的黑盒子
子電路
能夠在電路外使用的接點只有
Vin Vout 和.global中定義的點
叫子電路 X1 腳位1 腳位2 子電路名
名字可不同
其他電路上的
東西
你要跑什麼模擬
24