Escolar Documentos
Profissional Documentos
Cultura Documentos
The heart of your SPICE file is the netlist, which is simply a list of components and
the nets (or nodes) that connect them together. As an example, we'll create a netlist for
a simple low-pass RC filter. Just draw the schematic, then assign names for the resistor,
capacitor, voltage source (R1, C1, VS) and node numbers (1 and 2). Ground is the only
exception whose node is always numbered 0.
As you can see, much of the netlist is intuitively obvious: name a component, designate
the nodes where it's connected, and give it a value. For example,
RS 1 2 1000
describes a 1000 ohm resistor connected between nodes 1 and 2. Just follow a few rules
- all resistors names begin with R, capacitors with C, voltage sources with V, etc.
Voltage Source
SPICE has many voltage sources available: SINE, PULSE, AC, DC, etc. For this
example, the voltage source statement has two functions.
VS 1 0 AC 1 SIN(0V 0.2V 10kHz)
requests a Transient (time) Analysis TRAN for a duration of 0.2 ms and prints out the
results at 0.001 mS intervals.
What analysis results do you want to see? Most SPICE versions today automatically
open a separate plot window after running a simulation. Through pull-down menus
typically named Add Plot or Add Trace, you can enter variables like V(2) or I(R1) to
be plotted.
Some viewers list all of the variables and you just click on the ones you want to see. As
a bonus many plotting windows let you enter calculations like V(2)*I(VS) or V(2)-
V(1). The more sophisticated versions go a step further by providing operations on
variables like AVG( V(2) ) or RMS( V(2)*I(VS) ).
NOTE SPICE Simulator will save the variables for the plot window if you include
the
.PROBE
You can display the magnitude, real part, imaginary, part, phase, etc of the variables for
the AC Analysis. Just add the appropriate suffix as follows:
Most versions of SPICE also print the results to a text file named filename.OUT. The
PRINT command places the numerical results in a table.
.PRINT AC VM(2)
.PRINT TRAN V(1) V(2)
The statements above prints the voltage magnitude at node 2 for the AC Analysis and
the voltages at nodes 1 and 2 for the Time Analysis.
Comments
You can add a comment or ignore any statements by placing a * at the beginning of
the line. This is a great way to label circuit sections, include some simple notes in the
file, or remove a component.
The first line of a netlist is always a comments, regardless of its first character.
Apart from first line Other Lines beginning with * will treats as comments.
$ sign is used for comments that do not begin in the first character position on a line.
For Example
* comment_on_a_line
Subcircuit definition.
.ENDS
The node numbers and component names in the definition will be separate from those
in the main circuit. The only exception is node 0, the global ground reference. To place
your subcircuit into the main circuit use the statements
XCircuitName <node 1> <node 2> ... <definition name>
When the simulation is run, a subcircuit is created with its <node A> connected to
<node 1> of the main circuit and so on.
Subcircuit Example
Heres a quick example to show how a subcircuit called OPAMP1 is used for both
devices XOP1 and XOP2 in a cascaded amplifier circuit. Weve labeled the subcircuit
node numbers in parentheses for clarity.
Heres a SPICE subcircuit schematic for the guts of an op amp.
The subcircuit OPAMP1 gets inserted into two places of the main circuit by the
statements
XOP1 0 2 3 OPAMP1
XOP2 3 4 5 OPAMP1
For XOP1, the subcircuit nodes (1), (2) and (6) connect to main circuit nodes 0,
2 and 3. Likewise, for XOP2 the subcircuit nodes (1), (2) and (6) connect to main
circuit nodes 3, 4 and 5.
SPICE Units
The default units for SPICE are volts, amps, ohms, farads, henries, watts etc. You can
specify values in decimal form, 0.0056, or exponential form, 5.6e-3. SPICE also
recognizes the following abbreviations:
F E-15 femto
P E-12 pico
N E-9 nano
U E-6 micro
M E-3 milli
K E+3 kilo
MEG E+6 mega
G E+9 giga
T E+12 tera
For clarity you can add letters to the abbreviation as in 1U or 1UFARADS and both are
read as the value 1e-6. SPICE processes the first letter after the number and ignores the
rest.
Here's a brief reference of the SPICE devices and statements. Parameters enclosed by
braces { } are required, while, those in brackets [ ] are optional. Parameters followed
by an asterisk { }* should be repeated as necessary. Each SPICE vendor may have other
parameters or commands unique to their version of SPICE.
DEVICES
C device - Capacitor.
C{name} {+node} {-node} [{model}] {value} [IC={initial}]
Examples:
CLOAD 15 0 20pF
CFDBK 3 33 CMOD 10pF IC=1.5v
D device - Diode.
D{name} {+node} {-node} {model} [area]
Examples:
DCLAMP 14 0 DMOD
L device - Inductor.
L{name} {+node} {-node} [model] {value} [IC={initial}]
Examples:
LLOAD 15 0 20mH
L2 1 2 .2e-6
LSENSE 5 12 2uH IC=2mA
M device - MOSFET.
M{name} {d} {g} {s} {sub} {mdl} [L={value}] [W={value}]
+ [AD={value}] [AS={value}]
+ [PD={value}] [PS={value}]
+ [NRD={value}] [NRS={value}]
Examples:
M1 14 2 13 0 PNOM L=25u W=12u
M13 15 3 0 0 PSTRONG
R device - Resistor.
R{name} {+node} {-node} [{model}] {value}
Examples:
RLOAD 15 0 2k
CONTROLLED SOURCES
E device - Voltage Controlled Voltage Source VCVS.
E{name} {+node} {-node} {+cntrl} {-cntrl} {gain}
E{name} {+node} {-node} POLY({value}) {{+cntrl} {-cntrl}}* {{coeff}}*
Examples:
EBUFF 1 2 10 11 1.0
EAMP 13 0 POLY(1) 26 0 500
INPUT SOURCES
EXPONENTIAL
EXP( {v1} {v2} {trise_delay} {tau_rise} {tfall_delay} {tau_fall) )
PULSE
PULSE( {v1} {v2} {tdelay} {trise} {tfall} {width} {period} )
PIECE WISE LINEAR
PWL( {time1} {v1} {time2} {v2} ... {time3} {v3} )
SINGLE FREQUENCY FM
SFFM( {voffset} {vpeak} {fcarrier} {mod_index} {fsignal} )
SINE WAVE
SIN( {voffset} {vpeak} {freq} {tdelay} {damp_factor} {phase} )
TABLE
E|G{name} {+node} {-node} TABLE {expression} = (invalue, outvalue)*
Examples:
ECOMP 3 0 TABLE {V(1,2)} = (-1MV 0V) (1MV, 10V)
LAPLACE
E|G{name} {+node} {-node} LAPLACE {expression} {s expression}
Examples:
ELOPASS 4 0 LAPLACE {V(1)} {10 / (s/6800 + 1)}
FREQ
E|G{name} {+node} {-node} FREQ {expression} (freq, gain, phase)*
Examples:
EAMP 5 0 FREQ {V(1)} (1KZ, 10DB, 0DEG) (10KHZ, 0DB, -90DEG)
POLY
E|G{name} {+node} {-node} POLY(dim) {inputs X} {coeff k0,k1,...} [IC=value]
Examples:
EAMP 3 0 POLY(1) (2,0) 0 500
EMULT2 3 0 POLY(2) (1,0) (2,0) 0 0 0 0 1
ESUM3 6 0 POLY(3) (3,0) (4,0) (5,0) 0 1.2 0.5 1.2
COEFFICIENTS
POLY(1)
y = k0 + k1X1 + k2X1X1 + k3X1X1X1 + ...
POLY(2)
y = k0 + k1X1 + k2X2 +
+ k3X1X1 + k4X2X1 + k5X2X2 +
+ k6X1X1X1 + k7X2X1X1 + k8X2X2X1 +
+ k9X2X2X2 + ...
POLY(3)
y = k0 + k1X1 + k2X2 + k3X3 +
+ k4X1X1 + k5X2X1 + k6X3X1 +
+ k7X2X2 + k8X2X3 + k9X3X3 + ...
STATEMENTS
AC - AC Analysis.
.AC [LIN][OCT][DEC] {points} {start} {end}
Examples:
.AC LIN 101 10Hz 200Hz
.AC DEC 20 1MEG 100MEG
.DC - DC Analysis.
.DC [LIN] {varname} {start} {end} {incr}
.DC [OCT][DEC] {varname} {start} {end} {points}
Examples:
.DC VIN -.25 .25 .05
.DC LIN I2 5mA -2mA 0.1mA VCE 10V 15V 1V
Examples:
.MODEL RMAX RES (R=1.5 TC=.02 TC2=.005)
.MODEL QDRIV NPN (IS=1e-7 BF=30)
GPOLY<n> (VCCS)
EPOLY<n> (VCVS):
N1+, N2+, ... , Nn+, NC+, N1-, N2-, ..., Nn-, NC-
FPOLY<n> (CCCS)
HPOLY<n> (CCVS)
NC+, NC-
Where NC+, NC- are positive and negative terminals of output current or voltage of the controlled source,
while Nk+, Nk- are positive and negative terminals of the k-th control voltage, k = 1, 2, ..., n.
Controls of the current controlled sources FPOLY<n> and HPOLY<n> are defined by an additional
argument - a list of names of the voltage sources, whose currents control the source. All the controlling
sources must be at the same level of hierarchy of the same design.
All the models have an argument "COEFS" which is a list of polynomial coefficients exactly as the models
re defined in SPICE. For example, for 1-controlled sources it defines a list:
All the sources have the list of negative terminals in the end of the lists; this is done to have a possibility
of using device symbols with less numbers of terminals for the models; all absent terminals are grounded.
For example, the VCCS with 1 control voltage is defined by the model GPOLY1 and has the following list
of terminals:
Note:
If we define a 2-terminal part with the model, it will create a part having grounded negative input
and negative output terminals. It defines the grounded current controlled source, not a non-linear
resistor, even if it uses a resistor's symbol (symbols do not affect model functionality beyond
number of nodes). A non-linear resistor may be creates using the GPOLY1 model, when both
positive input and output and negative input and output terminals are connected together.
Parameters:
COEFS - array of coefficients of polynomial formula
V1, V2, ..., Vn - names of voltage sources controlling the srouce. It may be any voltage source,
including signal ground (SGND model).