by
Wenton L. Davis
Probably the most fundamental part of createing a SPICE simulation is the components used to define each circuit. This page is a reference to use for defining components in SPICE. Note that not all components are included in all versions of SPICE, so I'll include information on which are implemented in GNUcap and NGSPICE, and some are XSPICE extention to NGSPICE.  In all cases, refer to the documantation for your particular version of SPICE; these are just references showing most common uses.
| First Letter | Element | GNUcap | NGSPICE | XSPICE |
| A | XSPICE Code Model | ✓ | ||
| B | Behavioral Source | ✓ | ||
| C | Capacitor | ✓ | ✓ | |
| D | Diode | ✓ | ✓ | |
| E | Voltage Controlled Voltage Source (VCVS) | ✓ | ✓ | |
| F | Current Controlled Current Source (CCCS) | ✓ | ✓ | |
| G | Voltage Controlled Current Source (VCCS) | ✓ | ✓ | |
| H | Current Controlled Voltage Source (CCVS) | ✓ | ✓ | |
| I | Current Source | ✓ | ✓ | |
| J | Junction Field Effect Transistor (JFET) | ✓ | ✓ | |
| K | Coupled (Mutual) Inductors | ✓ | ✓ | |
| L | Inductor | ✓ | ✓ | |
| M | Metal Oxide Field Effect Transistor (MOSFET) | ✓ | ✓ | |
| N | Verilog-A Compact Device Models | ✓ | ||
| O | Lossy Transmission Line | ? | ✓ | |
| P | Coupled Multiconductor Line (CPL) | ✓ | ||
| Q | Bipolar Junction Transistor (BJT) | ✓ | ✓ | |
| R | Resistor | ✓ | ✓ | |
| S | Switch (voltage-controlled) | ? | ✓ | |
| T | Lossless Transmission Line | ✓ | ✓ | |
| U | Uniformly Distributed RC Line | ✓ | ||
| U | Basic Digital Building Blocks | ✓ | ✓ | |
| V | Voltage Source | ✓ | ✓ | |
| W | Switch (current-controlled) | ? | ✓ | |
| X | Subcircuit | ✓ | ✓ | |
| Y | Single Lossy Transmission Line | ? | ✓ | |
| Z | Metal Semiconductor Field Effect Transistor (MESFET) | ✓ |
See XSPICE documentation
Not available in GNUcap
BXXXXXXX n+ n- <I=expr> | <V=expr> | <tc1=value> | <tc2=value> | <temp=value> | <dtemp=value>
Examples:
B1 0 1 I=cos(v(1))+sin(v(2))
B2 0 1 V=ln(cos(log(v(1,2)^2)))-v(3)^4+v(2)^v(1)
B3 3 4 I=17
B4 3 4 V=exp(pi^i(vdd))
B5 2 0 V = V(1) < {Vlow} ? {Vlow} : V(1) > {Vhigh} ? {Vhigh} : V(1)
n+ is the positive node, n- is the negative node. See the NGSPICE documentation for more.
CXXXXXXX n+ n- <value> <mname> <scale=val> <temp=val> <dtemp=val> <tc1=val> <tc2=val> <ic-initial_condition>
Examples:
CBYP 13 0 1UF
COSC 17 23 10U IC=3V
C1 15 5 cstd
C2 2 7 cstd
.model cstd C cap=3n
n+ is the positive node, n- is the negative node. value is listed in Farads.
DXXXXXXX n+ n- mname <area=val> <m=val> <pj=val> <off> <ic=vd> <temp=val> <dtemp=val> <lm=val> <wm=val> <lp=val> <wp=val>
Examples:
DBRIDGE 2 10 DIODE1
DCLMP aa cc DMOD AREA=3.0 IC=0.2
n+ is the positive (anode) and n- is the negative (cathode). mname is a required model name.
EXXXXXXX n+ n- nc+ nc- value
FXXXXXXX n+ n- vnam value <m=val>
GXXXXXXX n+ n- nc+ nc- value <m=val>
HXXXXXXX n+ n- vnam value
Examples:
E1 2 3 14 1 2.0
F1 13 5 VSENSE 5 m=2
G1 2 0 5 0 0.1
HX 5 17 VZ 0.5K
n+ and n- are the positive and negative nodes, respectively, with current flowing from the positive node, through the source, to the negative node. nc+ and nc- are the positive and negative controlling nodes, respectively.
For VCVS, value is the voltage gain.
For CCCS, vnam is the name of a voltage source through which the controlling current flows. value is the current gain. m is an optional multiplier to the output current.
For VCCS, value is transcontuctance in mhos. m is an optional multiplier to the output current.
For CCVS, vnam is the name of a voltage source through which the controlling current flows. value is the current gain.
Dependent sources can also use polynomial structures (XSPICE extension):
EXXXXXXX n+ n- POLY(ND) nc+ nc- P0 (P1...)
FXXXXXXX n+ n- POLY(ND) nc+ nc- P0 (P1...)
GXXXXXXX n+ n- POLY(ND) vnam1 !vnam2...? P0 (P1...)
HXXXXXXX n+ n- POLY(ND) vnam1 !vnam2...? P0 (P1...)
See the SPICE documentation for your particular version of SPICE for information on using polynomials.
IXXXXXXX n+ n- <<DC> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>> <DISTOF1 <F1MAG <F1PHASE> > > <DISTOF2 <F2MAG <F2PHASE> > >
Examples:
ISRC 10 0 DC 0.6
ISRC 23 21 AC 0.333 45.0 SFFM(0 1 10K 5 1K)
IIN1 1 5 AC 1 DISTOF1 DISTOF2 0.001
n+ is the positive node; n- is the negative node.
JXXXXXXX nd ng ns mname <area> <off> <ic=vds,vgs> <temp=t>
Examples:
J1 7 2 3 JM1 OFF
nd, ng, and ns are the drain, gate, and source, respectively. mname is a required model name.
When two (or more) inductors are wound over the same core, they are "coupled."
KXXXXXXX LYYYYYYY LYYYYYYY value
Example: (Three coupled inductors)
L1 1 0 10u
L2 2 0 11u
L3 0 3 10u
K12 L1 L2 0.99
K23 L2 L3 0.99
K13 L1 L3 0.98
or
K123 L1 L2 L3 0.99
LXXXXXXX n+ n- L='expression' <tc1=value> <tc2=value>
LXXXXXXX n+ n- 'expression' <tc1=value> <tc2=value>
MXXXXXXX nd ng ns nb mname <m=val> <l=val> <w=val> <ad=val> <as=val> <pd=val> <ps=val> <nrd=val> <nrs=val> <off> <ic=vds,vgs,vbs> <temp=t>
Examples:
M1 24 2 0 20 TYPE1
M31 2 17 6 10 MOSN L=5U W=2U
M1 2 9 3 0 MOSP L=10U W=5U AD=100P AS=100P PD=40U PS=40U
nd, ng, ns, and nb are the drain, gate, source, and bulk (substrate) nodes, respectively. mname is a required model name.
See XSPICE documentation
OXXXXXXX n1 n2 n3 n4 mname
Examples:
O23 1 0 2 0 LOSSYMOD
.model LOSSYMOD ltra rel=1 r=12.45 g=0 l=8.972e-9 c=0.468e-12
+len=16 steplimit compactrel=1.0e-3compactabs-1.0e-14
OCONNECT 10 5 20 5 INTERCONNECT
n1 and n2 are the nodes at port 1; n3 and n4 are the nodes at port 2. Z0 is the characteristic impedance. mname is a required model name.
PXXXXXXX ni1 ni2...niX GND1 no1 no2...noX GND2 mname <LEN=length>
Example:
P1 in1 in2 0 b1 b2 0 PLINE
.model PLINE CPL length={Len}
+R=1 0 1
+L={L11} {L12} {L22}
+G=0 0 0
+C={C11} {C12}{C22}
.param Len=1 Rs=0
+C11=9.143579E-11 C12=-9.78265E-12 C22=9.143578E-11
+L11=3.83572E-7 L12=8.26253E-8 L22=3.83572E-7
QXXXXXXX nc nb ne <ns> mname <area=val> <areac=val> <areab=val> <m=val> <off> <ic=vbevce> <temp=val> <dtemp=val>
Examples:
Q23 10 24 13 QMOD IC=0.6, 5.0
Q50A 11 26 4 20 MOD1
nc, nb, and ne are the collector, base, and emitter note, respectively. ns is an optional substrate node; gounrd is assumed if not used. mname is a required model name.
RXXXXXXX n+ n- R='expression' <tc1=value> <tc2=value> <noisy=0>
RXXXXXXX n+ n- 'expression' <tc1=value> <tc2=value> <noisy=0>
Examples:
R1 rr 0 r = 'V(vv)<{Vt}?{R0}:{2*R0}' tcl=2e-03 tc2=3.3e-06
R2 r2 rr r = {5k+50*TEMPER}
.param rp1 = 20
R3 no1 no2 r = '5k * rp1' noisy=1
By default, a resistor is assumed to be noiseless, but noise calculation can be enabled with the flag noisy=1.
SXXXXXXX n+ n- nc+ nc- model <ON><OFF>
WXXXXXXX n+ n- vnam model <ON><OFF>
Examples
s1 1 2 3 4 switch1 ON
s2 5 6 3 0 sm2 off
Switch1 1 2 10 0 smodel1
w1 1 2 vclock switchmod1
W2 3 0 vramp sm1 ON
wreset 5 6 vclck lossyswitch OFF
n+ and n- are the two nodes connected by the switch. nc+ and nc- are the positive and negative coltrol voltage nodes. model is a required, but the initial condition (ON/OFF) optionally provides an initial condition in the hysteresis loop. vname is the name of the voltage source through which the current passing through is the controlling current.
TXXXXXXX n1 n2 n3 n4 Z0=value <TD=value> <f=freq <nl=NRMLEN>> <IC=v1, i1, v2, i2>
Example:
T1 1 0 2 0 Z=50 TD=10ns
n1 and n2 are the nodes at port 1; n3 and n4 are the nodes at port 2. Z0 is the characteristic impedance. There are two ways to specify the length. The first is to use the transmission delay, TD, and the second is to specify frequency, f, and the optional nl spefies the normalized electrical length with respect to the wavelength of f. If nl is omitted, 0.25 is assumed.
UXXXXXXX n1 n2 n3 mname l=len <n=lumps>
Examples:
U1 1 2 0 URCMOD L=50U
.model URCMOD URC CPERL=100p RPERL=100K FMAX=10G
URC2 1 12 2 UMODL l=1MIL N=6
n1 and n2 are the two elements the RC line connects. n3 is the node the capacitances are conected to (think the shield of a coax cable). mname is a required model name. len is the length of the RC line, measured in meters. Optional lumps is the number of lumped segments.
UXXXXXXX <basic type> [(<parameter value>>*)] <digital power node> <digital ground node> <node>* <timing model name> <I/O model name> [MNTYMXDLY=<delay select value>] [IO_LEVEL=<interface subcircuit select value>]
Example:
U2 AND(2) $G_DPWR $G_DGND 4 5 6 M2 IOM2 IO_LEVEL=0 MNTYMXDLY=2
.MODEL M2 UGATE ()
.MODEL IOM2 UIO (INLD=0 OUTLD=0 DRVH=50 DRVL=50
+ ATOD1="ATOD1" DTOA1="DTOD1" ATOD2="ATOD2" DTOA2="DTOD2"
+ ATOD3="ATOD3" DTOA3="DTOD3" ATOD4="ATOD4" DTOA4="DTOD4"
+ TSWLH1=0 TSWLH2=0 TSWLH3=0 TSWLH4=0
+ TSWHL1=0 TSWHL2=0 TSWHL3=0 TSWHL4=0 DIGPOWER="DIGPOWER")
VXXXXXXX n+ n- <<DC> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>> <DISTOF1 <F1MAG <F1PHASE> > > <DISTOF2 <F2MAG <F2PHASE> > >
Examples:
VSRC 10 0 DC 6
VIN 13 2 0.001 AC 1 SIN(0 1 1MEG)
VMEAS 12 9
VCARRIER 1 0 DISTOF1 0.1 -90.0
n+ is the positive node; n- is the negative node. NOTE that zero-voltage sources may be inserted into a circuit for the purposes of current measurement, without otherwise effecting the circuit.
See S: above.
See XSPICE documentation
YXXXXXXX n1 0 n2 0 mname <LEN=length>
Example:
Y1 1 0 2 0 ymod LEN=2
.model ymod txl R=12.45 L=8.972e-9 G=0 C=0.468e-12 length=16
n1 and n2 ate the nodes of the two ports. mname is the required model name. LEN is an optional length measured in [units], typically given in meters, and will (for this instance only) override any length parameter in the given model.
ZXXXXXXX nd ng ns mname <area> <off> <ic=vds,vgs>
Examples:
Z1 7 2 3 ZM1 OFF
See J: JFET above
Independent voltage and current sources can have multiple attributes:
DC value
Example
VCC 10 0 DC 6
VIN 13 2 TRAN 0.05
VSUP 18 0 5
Vmeasure 12 9
DC/TRAN is the DC and transient analysis value of the source. If the source is time invarient such as for a power supply, the value may be optionally preceded by DC.
AC acmag <acphase>
Example
ISRC 23 21 AC 0.333 45.0
VLINE 9 10 AC 120
AC indicates a signal to be used for an AC simulation.
DISTOF1 <mag1 <phase1>>
DISTOF2 <mag2 <phase2>>
Examples:
VCARRIER 1 0 DISTOF 0.1 -90.0
VMODULATORR 2 0 DISTOF2 0.01
IIN2 1 5 AC 1 DISTOF1 DISTOF2 0.001
DISTOF1 and DISTOF2 allow simulations with distortions at frequencies F1 and F2, with optional phase angles. If no values are given, the default magnitude is 1.0, and the default phase is 0.0 degrees.
Independent voltage and current sources can also have time-dependent valuse to use for transient analysis. These include:
if any parameters are left out or set to 0, the default values are assumed.
PULSE(V1 V2 TD TR TF PW PER NP)
Examples:
VIN 3 0 PULSE(-1 1 2ns 2ns 2ns 50ns 100ns 5)
The PULSE command specifies pulse streams from the Voltage source:
| Name | Parameter | Default Value | Units |
| V1 | Initial value | - | V, A |
| V2 | Pulsed value | - | V, A |
| TD | Delay Time | 0.0 | sec |
| TR | Rise Time | TSTEP | sec |
| TF | Fall Time | TSTEP | sec |
| PW | Pulse width | TSTOP | sec |
| PER | Period | TSTOP | sec |
| NP | Number of pulses | unlimited | - |
SIN(VO VA FREQ TD THETA PHASE)
Example:
VIN 3 0 SIN(0 1 100MEG 1ns 1E10)
| Name | Parameter | Default Value | Units |
| VO | Offset | - | V, A |
| VA | Amplitude | - | V, A |
| FREQ | Frequency | 1/TSTOP | Hz |
| TD | Delay | 0.0 | sec |
| THETA | Damping Factor | 0.0 | 1/sec |
| PHASE | Phase | 0.0 | degrees |
V(t)=VO if 0≤t<TD
V(t)=VO+VAe-(t-TD)THETAsin(2π*FREQ*(t-td)+PHASE) if TD ≤t<TSTOP
EXP(V1 V2 TD1 TAU1 TD2 TAU2)
Example:
VIN 3 0 EXP(-4 -1 2ns 30ns 60ns 40ns)
| Name | Parameter | Default Value | Units |
| V1 | Initial Value | - | V, A |
| V2 | Pulsed Value | - | V, A |
| TD1 | Rise Delay Time | 0.0 | sec |
| TAU1 | Rise Time Constant | TSTEP | sec |
| TD2 | Fall Time Delay | TD1+TSTEP | sec |
| TAU2 | Fall Time Constant | TSTEP | sec |
Let V21=V2-V1, V12 = V1-V2:
V(t)=V1 if 0≤t<TD1
V(t)=V1+V12(1-e(1-TD1)/TAU1) if TD1≤t<TD2
V(t)=V1+V12(1-e(1-TD1)/TAU1)+V12(1-e(1-TD2)/TAU2) if TD2≤t<TSTOP
PWL(T1 V1 <T2 V2 T3 V3 T4 V4 ... >) <r=value> <td=value>
Example:
VCLOCK 7 5 PWL(0 -7 10ns -7 11ns -3 17ns -3 18ns -7 50ns -7) r=0 td=15ns
Each Tn, Vn pair defies that the value of the sourse is Vn in Volts or Amps at time = Tn. Linear interpolation is used to determint the values at any intermediate times. rdetermines the reapeat time point; if -1 or not given, the sequence of values is issued only once and the output stays at its final value; if 0, the whole sequence is repeated from 0 to time Tn and repeated forever. If r=10ns, the sequence from 10ns to 50ns is repeated forever. td will delay the entire sequence.
SFFM(VO VA FM MDI FC TD PHASEM PHASEC)
Example:
V1 12 0 SFFM(0 2 20 45 1k 1m 0 0)
| Name | Parameter | Default Value | Units |
| VO | Offset | - | V, A |
| VA | Amplitude | - | V, A |
| FM | Modulating Frequency | 5/TSTOP | Hz |
| MDI | Modulation Index | 90 | |
| FC | Carrier Frequency | 500/TSTOP | Hz |
| TD | Signal Delay | 0.0 | sec |
| PHASEM | Modulation Signal Phase | 0.0 | degrees |
| PHASEC | Carrier Signal Phase | 0.0 | degrees |
V(t)=VO+VA*sin(2π*FC*(t-TD)+MDI*sin(2π*FM*(t-TD)+PHASEM)+PHASEC)
AM(V0 VM0 VMA FM FC TD PHASEM PHASEC)
Example:
V1 12 0 AM( 0.5 2 1.8 20K 5MEG 1m)
| Name | Parameter | Default Value | Units |
| VO | Overall Offset | - | V, A |
| VMO | Modulation Signal Offset | - | V, A |
| VMA | Modulating Signal Amplitude | 1 | V,A |
| FM | Modulation Signal Frequency | 5/TSTOP | Hz |
| FC | Carrier Frequency | 500/TSTOP | Hz |
| TD | Signal Delay | 0.0 | sec |
| PHASEM | Modulation Signal Phase | 0.0 | degrees |
| PHASEC | Carrier Signal Phase | 0.0 | degrees |
V(t)=VO+(VMO+VMA*sin(2π*FM*(t-TD)+PHASEM))*sin(2π*FC*(t-TD)+PHASEC)
(experimental)
TRNOISE(NA NT NALPHA NAMP RTSAM RTSCAPT RTSEMT)
Examples:
VNoiw 1 0 DC 0 TRNOISE(20n 0.5n 0 0) $white VNoi1of 1 0 DC 0 TRNOISE(0 10p 1.1 12p) $1/f VNoiw1of 1 0 DC 0 TRNOISE(20 10p 1.1 12p) $white and 1/f IALL 10 0 DC 0 trnoise(1m 1.0 0.1m 15m 22u 50u) $white, 1/f, RTS
| Name | Parameter | Default Value | Units |
| VA | RMS Noise Amplitude (Gaussian) | - | V, A |
| NT | Time Step | - | sec |
| NALPHA | 1/f exponent | 0<α<2 | - |
| NAMP | Amplitude (1/f) | - | V, A |
| RTSAMP | Amplitude | - | V, A |
| RTSCAPT | Trap Capture Time | - | sec |
| RTSEMT | Trap Emission Time | - | sec |
TRRANDOM(TYPE TS <TD <PARAM1 <PARAM2>>>)
Examples:
VR1 r1 0 dc 0 trrandom(2 10m 0 1) ;Gaussian with mean 0 V1 1 0 dc 0 trrando(1 1u 0.5u 0.5 0.5) ;Uniform between 0 and 1
TYPE determines the noise type according to the table below.  TS is the duration of an individual voltage swing. TD is the time delay with the output voltage being held at the offset or mean value. PARAM1 and PARAM2 depend on noise type:
| TYPE | Description | PARAM1 | Default | PARAM2 | Default |
| 1 | Uniform | Range | 1 | Offset | 0 |
| 2 | Gaussian | Standard Dev. | 1 | Mean | 0 |
| 3 | Exponential | Mean | 1 | Offset | 0 |
| 4 | Poisson | Lambda | 1 | Offset | 0 |
EXTERNAL
Examples:
Vex 1 0 dc 0 external Iex I1 I2 dc 0 external
Voltages or currents may be set from a calling process if ng spice is compiled as a shared library and loaded by the process. See ngspice documentation for explanation.
ngspise supports arbitrary phase shifts for independent sources. Other versions of SPICE rely on time delay (TD) parameters, but ngspice can specify phase shift as its final parameter:
Examples:
v1 1 0 0.0 sin(0 1 1k 0 0 45.0) v2 2 0 0.0 pulse(-1 1 0 1e-5 1e-5 5e-4 1e-3 45.0)
See ngspice documentation