Madhava Vemuri, Ph.D.
Here are some of the scaling factors used in SPICE modeling to specify different values
T
G
M
K
m
u
n
p
f
Tera
Giga
Mega
Kilo
milli
micro
nano
pico
femto
10^12
10^9
10^6
10^3
10^-3
10^-6
10^-9
10^-12
10^-15
R
C
L
K
I
M
D
Q
W
X
Resistor
Capacitor
Inductor
Mutual Inductor
Independent Current Source
MOSFET
Diode
Bipolar Junction Transistor
Lossy Transmission Line
Subcircuit
Resistance
Capacitance
MOSFET
RXX n1 n2 <Resistance Value in Ohms>
CXX n1 n2 <Capacitance Value in Farad>
MXX n1 n2 n3 n4 < transistor type> <parameters>
The order of nodes are D G S B
R1 n1 n2 1K
C1 n1 n2 20uF
M1 n1 n2 n3 n4 nmos l=50n w=100n
Voltage PWL
Voltage PULSE
Voltage DC
VXX n1 n2 PWL (T1 V1 T2 V2 T3 V3 .........)
VXX n1 n2 PULSE (V1 V2 Tdelay tr tf Twidth Period)
VXX n1 n2 <DC Value in volts >
Use the node names to create simple circuits using SPICE modeling. Here is a simple RC circuit, whose resistance and capacitance are 1K Ohm and 1u Farad. The RC circuit is connected to a DC voltage source of 5V.
In SPICE modeling, each component should be instantiated using a unique identifier. Each identifier cannot be reused to create another component. Here, the identifiers of the components are R1, C1, and V1. This is called a netlist since it contains the information of all electrical components
R1 n1 n2 1K
C1 n2 gnd 1pF
V1 n1 gnd 5V
*----------------------------------------------------------
* Include device model files
* No files are included
*----------------------------------------------------------
* Define Parameters
.param SUPPLY=5.0 * Here SUPPLY is created as a parameter
.option post * The option is necessary to run the simulations
*----------------------------------------------------------
* Creating the netlist
R1 n1 n2 1K
C1 n2 gnd 1uF
*-----------------------------------------------------------
* Adding Voltage sources
V1 n1 gnd PULSE (0 'SUPPLY' 2ms 0ms 0ms 5ms 10ms)
*-----------------------------------------------------------
* Stimulus
.tran 0.1ms 50ms
To conduct a transient analysis, we can vary the voltage with time. In this example, we vary the voltage over time using an independent voltage source. The stimulus can only be applied when .tran command is used. Here, time is varied with an increment of 0.1ps and the end time of simulation is 80ps. To execute the simulation and plot the waveform using WaveView (wv) tool. Use the following script to invoke the tool.
hspice <filename>.sp > <output>.lis
wv <filename.tr0> &
To create a simple transistor circuit, first, we need to include the model libraries. The libraries contain SPICE models, which define the behavior of electrical components, such as transistors and diodes. We utilize the keyword ".include" to add the path to the files into the current SPICE file. The include can also be used to call Subcircuits, which are often used to create instances of other circuits and Parameters. The parameters are made using the keyword ".param" to use it as a variable to change values. The parameter can be accessed using inverted comma '<VARIABLE>'
.include <<Path to the model libraries>
Here are some examples of model libraries from the University of Minnesota based on the device modeling group from the BSIM group at UC Berkeley. Download any file from the previous links and add it to the path in the remote lab.
* Include device model files
.include "model-files.pm" * We are using the 32nm hp file from the UMinn
*----------------------------------------------------------
* Define Parameters
.param SUPPLY=1.0 * Here SUPPLY is created as a parameter
.option post * The option is necessary to run the simulations
*----------------------------------------------------------
* Creating the netlist
M1 D G S S nmos l=32n w=32n
*-----------------------------------------------------------
* Adding Voltage sources
VGS G gnd 'SUPPLY'
VDS D gnd 'SUPPLY'
VSB S gnd 0
To conduct DC analysis, we can sweep the voltages to extrapolate the performance of circuits. A simple DC analysis is conducted on the following circuit. To extract the drain-to-source current (IDS) vs Voltage (VDS) behavior, We gradually increase the VDS and sweep gate-to-source voltage (VGS). In this example, the VDS varies from 0 to 1.0V, and the IDS current is extrapolated by sweeping VGS between {0.4, 0.6, 0.8, 1.0}
*-----------------------------------------------------------
* Stimulus
.dc VDS 0 'SUPPLY' 0.05 SWEEP VGS 0 'SUPPLY' 0.2
.plot '-1*i(vds)' * current is often negative in scale for nmos, so reversing the magnitude
The .dc command varies the voltage source VDS with an increment of 0.05, while sweeping VGS and extracting the IDS vs VDS characteristics. The sweep plots are stored in files with the extension ".sw0". Use the following script to invoke the tool.
hspice <filename>.sp > <output>.lis
wv <filename.sw0> &
Subcircuits and macros are used to create reusable circuit modules within SPICE modeling, which allows the creation of large-scale circuits using smaller blocks. A subcircuit contains a more detailed device-level circuit netlist, whereas macros contain larger circuit implementations.
To create a subcircuit module, we use the keyword .SUBCKT and end the netlist .ENDS . Here is the script for creating a subcircuit file.
* Creating a Subcircuit
* Start the description with SUBCKT
.SUBCKT <name> <Terminals list>
* End the description with ENDS
.ENDS
Consider the following subcircuit of an inverter circuit, where we can scale the widths of nmos and pmos devices using scale (S).
* Creating a Inverter subcircuit
* Include the model libraries
.include "model-files.pm" * We are using the 32nm hp file from the UMinn
* Defining the Parameters used in the SUBCKT
.param S = 1
* Start the description with SUBCKT
.SUBCKT INV IN OUT VDD VSS S
* Creating the PULL-UP
M1 OUT IN VDD VDD pmos l=32n w='32n*S' * Note the parameter 'S' is used inside the inverted commas
* Creating the PULL-DOWN
M2 OUT IN VSS VSS nmos l=32n w='32n*S'
* End the description with ENDS
.ENDS
Instantiating the subcircuit to create the inverter instance
* Include device model files
.include "subcircuit_files.sp" * We are using the 32nm hp file from the UMinn
*----------------------------------------------------------
* Define Parameters
.param SUPPLY=1.0 * Here SUPPLY is created as a parameter
.param SCALE=1.0 * Here SCALE is the scaling parameter for inverter sizing
.option post * The option is necessary to run the simulations
*----------------------------------------------------------
* Creating the netlist
X1 IN OUT DD SS INV S='SCALE' * Here the parameter is created after the subckt name
CLOAD OUT GND 1f
*-----------------------------------------------------------
* Adding Voltage sources
VDS DD gnd 'SUPPLY'
VSB SS gnd 0
VIN IN gnd 0
*-----------------------------------------------------------
* Stimulus
.dc VIN 0 'SUPPLY' 0.05
The .dc command varies the voltage source IN with an increment of 0.05, while sweeping the input and extracting the output voltage OUT . The sweep plots are stored in files with the extension ".sw0". Use the following script to invoke the tool.
hspice <filename>.sp > <output>.lis
wv <filename.sw0> &