Tutor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Hspice Tutorial

指導老師:鄭桂忠 老師

NTHU - NBME 0
Contents
Introduction
Simulation inputs and controls
- build the main part
- input sources
- analysis
Waveform observation

NTHU - NBME 1
What is SPICE
 Simulation Program with Integrated Circuit Emphasis

 PSPICE 、SPECTRE use graphical interface like


 HSPICE use text interface like
Mn vd vg vss vss nch w=1u l=0.35u m=1
device name net1 net2……. type parameter value

NTHU - NBME 2
Basic flow for hspice

NTHU - NBME 3
Contents
Introduction
Simulation inputs and controls
- build the main part
- input sources
- analysis
Waveform observation

NTHU - NBME 4
Prepare File

• Library file
cic018.l (it’s “L”) (CIC virtual 0.18um CMOS technology)

• Simulation file: xxx.sp (write it on your own)


Device into 3 parts
- Setup
- Main circuit description
- Analyses

Can be separated as a single file


(xxx.spi). Then type .include “xxx.spi”
in the simulation file to use it.

NTHU - NBME 5
How to run hspice
• Make sure all files are in the same folder
You can type ls to check

• Enter the folder, type


hspice xxx.sp >! xxx.lis
hsipce –i xxx.sp –o xxx.lis
.lis is the result file including the information of the simulation

• If there is no error, terminal will print out job concluded


otherwise, terminal will print out job aborted

NTHU - NBME 6
Text Editor

• joe xxx.sp(檔名)
• vi
• vim
• gvim
• gedit

NTHU - NBME 7
Syntax Overview
**** inverter example **** 模擬時第一行會被忽略
.protect
.lib "cic018.l" TT 吃進本file的library檔,並設
.unprotect 定corner
.inc "inv.spi"
用*作為 .option post=1 accurate=1 增加/修改 模擬條件
整行註解 + CAPTAB
一行寫不完可用”+”在下一行繼續寫
**** NETLIST ****
大小寫沒 xinv IN OUT VDD VSS inv 呼叫”inv” 這個sub circuit
有區分
**** SOURCES ****
V1 VDD VSS DC=1.8 Net 0 代表global ground (或 gnd)
V2 VSS 0 DC=0
V3 IN VSS DC=0
分析電路偏壓點
**** ANALYSIS ****
.OP 可在waveview觀察節點電壓變化
.DC V3 0 1.8 0.01
.PROBE V(IN) V(OUT) 結束一定要有.end
.end
NTHU - NBME 8
CIC 0.18um Model

• Syntax: .lib “cic0.18.l” <TT/SS/FF/SF/FS>

NTHU - NBME 9
Elements and Device Models
• Passive Devices
- Resistor R Ex: R1 v1 v2 100
- Inductor L Ex: L2 v3 v4 1n
- Capacitor C Ex: C3 v5 v6 2p
• Active Devices
- MOSFET M Mxxx D G S B mname w=val l=val n=val
- BJT Q D: Drain G: Gate S: Source B: Body
Mname: model name, please refer to the library file
- Diode D w: width, l: length, m: 並聯個數(只有整數)
• Other Devices
- Sub-Circuit X
- Behavioral E, G, H, F, B
10
Scale Factor

f: 1e-15 k: 1e3
p: 1e-12 meg/x: 1e6
n: 1e-9 g: 1e9
u: 1e-6 t: 1e12
m: 1e-3 db: 20log10

NTHU - NBME 11
Elements and Device Models -- MOSFET

• Mxxx Drain Gate Source Body mname W=val L=val M=val


• NMOS body is the most negative bias (GND)
• PMOS body is the most positive bias (VDD)

• Ex: Inverter
MP Z A VDD VDD p_18 w=1u l=0.18u m=2
MN Z A GND GND n_18 w=1u l=0.18u m=1

NTHU - NBME 12
Elements and Device Models – Subcircuit

• .subckt subcircuit_name port_name


Your circuit schematic
.ends subcircuit_name (與simulation file結尾.end不一樣)

• Ex: Inverter (“inv.spi”)


**** inverter ****
.subckt inv A Z VDD GND
M1 Z A VDD VDD p_18 w=4.5u l=0.18u m=1
M2 Z A GND GND n_18 w=1.5u l=0.18u m=1
.ends inv
subckt若沒接出VDD GND,在setup時須加上.global VDD GND
NTHU - NBME 13
Contents
Introduction
Simulation inputs and controls
- build the main part
- input sources
- analysis
Waveform observation

NTHU - NBME 14
Independent Source Elements – DC/AC

• Voltage sources
Vxxx net1 net2 <DC=val> <AC=val>
Ex: V4 4 0 DC=5V AC=1 180

• Current sources
Ixxx net1 net2 <DC=val> <AC=val>
Ex: I1 1 0 DC=100u

NTHU - NBME 15
Independent Source Elements – Transient

• The most commonly used transient forms:


- PULSE (periodic pulse waveform)
- SIN (sinusoidal waveform)
- PWL (piece-wise linear waveform)

NTHU - NBME 16
Independent Source Elements – PULSE

• Vxxx net1 net2 PULSE( V1 V2 Tdelay Trise Tfall Pwidth Period )

Ex: Vin 1 0 PULSE(0V 5V 10ns 10ns 10ns 40n 100ns)

NTHU - NBME 17
Independent Source Elements – SIN

• Vxxx net1 net2 SIN( Voffset Vacmeg <Freq Tdelay Dfactor> )


Damping
factor
Ex: Vin 3 0 SIN(0V 1V 100Meg 2ns 5e7)

NTHU - NBME 18
Independent Source Elements – PWL

• Vxxx net1 net2 PWL( t1 V1 t2 V2… <R=repeat time> )

Ex: Vin 4 0 PWL( 0n 0V 1n 0V 1.3n 1V 2n 1V 2.3n 0V R 0)

NTHU - NBME 19
Contents
Introduction
Simulation inputs and controls
- build the main part
- input sources
- analysis
Waveform observation

NTHU - NBME 20
Analysis (1)
• .OP : Analyze operation point of nodes in circuit.

• .DC : DC analysis to sweep parameter, source and


temperature values.
syntax: .DC <var1> <start> <stop> <step>
Ex: .DC Vgs 0 5 0.1

• .AC : AC analysis to sweep frequency.


syntax: .AC <DEC/OCT/LIN> <np> <fstart> <fstop>
Ex: .AC DEC 10 1K 100Meg Freq sweep 10 points per decade for
1KHz to 100MHz

NTHU - NBME 21
Analysis (2)
• .TRAN : Transient analysis to sweep time.
syntax: .TRAN <Tstep> <Tstop>
Ex: .TRAN 1ns 100us

NTHU - NBME 22
Optional Analysis (1)
• SWEEP : Sweep parameter, source or temperature
values but not model parameters.
syntax: <Analysis> SWEEP <var> <start> <stop> <step>
<Analysis> SWEEP <DEC/OCT/LIN> <np> <fstart> <fstop>
Ex: .DC Vds 0 5 0.1 SWEEP Vgs 2 5 1
.AC DEC 10 1k 10Meg SWEEP RL 10k 30k 1k
• .ALTER : Alter condition and repeat analysis (usually with
.param)
Ex: .ALTER
.param w=5.5u
.ALTER
.param w=6.5u
.end
NTHU - NBME 23
Optional Analysis (2)

• .IC : Set the initial value.


Ex: .IC V(out) = 0

NTHU - NBME 24
Simulation Outputs -- .MEAS (1)

NTHU - NBME 25
Simulation Outputs -- .MEAS (2)

NTHU - NBME 26
Simulation Outputs -- .MEAS (3)

NTHU - NBME 27
Simulation Outputs -- .MEAS example

NTHU - NBME 28
Simulation Outputs – waveform observation

• .Probe:Probe the observation will not show in the


result file but can be seen at Custom WaveView
Ex: .probe V(net) I(device)

• .Print:Print the observation in the result file


Ex: .print V(net) I(device)

• .Plot:Plot the observation in the result file


(Funny Plot)
Ex: .plot V(net) I(device)

NTHU - NBME 29
Temperature & Control Options

NTHU - NBME 30
Analysis result file table

NTHU - NBME 31
Contents
Introduction
Simulation inputs and controls
- build the main part
- input sources
- analysis
Waveform observation

NTHU - NBME 32
Viewing Result Waveform

• Type wv & at terminal

NTHU - NBME 33
Viewing Result Waveform

Step1: Open folder

Step4: Choose Files

Step2: choose folder

Step3: Waveform Files

NTHU - NBME 34
Viewing Result Waveform

Waveview control toolbox

Step1: Select hierarchy

Step2: Double click on


desired signals

NTHU - NBME 35
Practice

NTHU - NBME 14

You might also like