Mastering SPICE Netlist Syntax: Component Naming, Passive & Active Elements, and Source Definitions
While this guide focuses on the essentials, SPICE offers a comprehensive set of features for accurate circuit simulation. The following overview condenses key syntax rules and examples to help you write clean, error‑free netlists.
Every SPICE element is introduced by a single-letter keyword: R for resistors, C for capacitors, L for inductors, V for voltage sources, I for current sources, D for diodes, Q for bipolar transistors, M for MOSFETs, J for JFETs, and K for transformer couplings. The following characters uniquely identify each instance of a given type. Names may be any sequence of up to eight alphanumeric characters; case is ignored, so r1 and R1 refer to the same resistor. Excessive length beyond eight characters is truncated, which can cause naming collisions. For example, rpulldown is interpreted as rpulldow, potentially duplicating rpulldow if it appears elsewhere.
SPICE supports metric prefixes to simplify value specification, though the convention differs slightly from the standard due to ASCII limitations and case insensitivity. Common prefixes include:
t– tera (1012)g– giga (109)meg– mega (106)k– kilo (103)m– milli (10-3)u– micro (10-6)n– nano (10-9)p– pico (10-12)f– femto (10-15)
Scientific notation is also supported. Typical resistor definitions:
R1 1 0 2t ; 2 TΩ R2 1 0 4g ; 4 GΩ R3 1 0 47meg ; 47 MΩ R4 1 0 3.3k ; 3.3 kΩ R5 1 0 55m ; 55 mΩ R6 1 0 10u ; 10 µΩ R7 1 0 30n ; 30 nΩ R8 1 0 5p ; 5 pΩ R9 1 0 250f ; 250 fΩ R10 1 0 4.7e3 ; 4.7 kΩ R11 1 0 1e-12 ; 1 pΩ
Passive Components
Capacitors
C1 12 33 10u ; 10 µF C1 12 33 10u IC=3.5 ; 10 µF with 3.5 V initial voltage
Initial condition (IC) sets the capacitor voltage at the start of DC analysis; if omitted, the default is zero. For transient analyses, include the .tran card with the UIC option to honor IC values.
Inductors
L1 12 33 133m ; 133 mH L1 12 33 133m IC=12.7m ; 133 mH with 12.7 mA initial current
IC specifies the inductor current in amperes at DC start. Transient analyses require the .tran card with UIC to activate IC values.
Transformer Coupling (k‑devices)
K1 L1 L2 0.999 ; 99.9 % coupling between L1 and L2
Coupling factors must lie strictly between 0 and 1. The order of inductors is irrelevant.
Resistors
RLOAD 23 15 3.3k ; 3.3 kΩ between nodes 23 and 15
Resistor power ratings are not represented; all components are treated as ideal unless modeled otherwise.
Active Components
Every semiconductor device must be defined by a .MODEL card that specifies its electrical characteristics. Omitted parameters default to SPICE’s internal values.
Diodes
D1 1 2 MOD1 ; diode using model MOD1
Model definition example:
.MODEL MOD1 D ; simple diode model .MODEL MOD2 D VJ=0.65 RS=1.3 ; diode with junction voltage and series resistance
Key parameters include IS (saturation current), RS (junction resistance), N (emission coefficient), VJ (junction potential), and BV (breakdown voltage).
Bipolar Junction Transistors (BJT)
Q1 2 3 0 MOD1 ; BJT using model MOD1
Example BJT model (2N2222, NPN):
.MODEL M2N2222 NPN IS=19f BF=150 VAF=100 IKR=.18 + ISE=50p NE=2.5 BR=7.5 VAR=6.4 IKR=12m + ISC=8.7p NC=1.2 RB=50 RE=0.4 RC=0.4 CJE=26p + TF=0.5n CJC=11p TR=7n XTB=1.5 KF=0.032f AF=1
For a PNP transistor (2N2907):
.MODEL M2N2907 PNP IS=1.1p BF=200 NF=1.2 VAF=50 + IKF=0.1 ISE=13p NE=1.9 BR=6 RC=0.6 CJE=23p + VJE=0.85 MJE=1.25 TF=0.5n CJC=19p VJC=0.5 + MJC=0.2 TR=34n XTB=1.5
Model names must begin with a letter. Extensive parameter lists are available in The Spice Book by Andrei Vladimirescu (ISBN 0‑471‑60926‑9).
Junction Field‑Effect Transistors (JFET)
J1 2 3 0 MOD1 ; JFET using model MOD1
JFET model example:
.MODEL MOD2 NJF LAMBDA=1e-5 PB=0.75
Parameters include VTO (threshold voltage), BETA (transconductance), LAMBDA (channel‑length modulation), and capacitances CGS, CGD.
MOSFETs
M1 2 3 0 0 MOD1 ; MOSFET using model MOD1
Model syntax:
.MODEL MOD1 PMOS .MODEL MOD2 NMOS LEVEL=2 PHI=0.65 RD=1.5 .MODEL MOD3 NMOS VTO=-1 ; depletion‑mode N‑channel .MODEL MOD4 NMOS VTO=1 ; enhancement‑mode N‑channel .MODEL MOD5 PMOS VTO=1 ; depletion‑mode P‑channel .MODEL MOD6 PMOS VTO=-1 ; enhancement‑mode P‑channel
The VTO parameter distinguishes enhancement from depletion mode. A positive VTO on a P‑channel (or negative on an N‑channel) indicates depletion mode; a negative (or positive) value indicates enhancement mode.
Voltage & Current Sources
AC Sine‑Wave Voltage Sources (using .AC)
V1 1 0 AC 12 SIN V1 1 0 AC 12 240 SIN ; 12 V at 240° phase
Use this form when all sources share the same frequency but may differ in phase. For multiple frequencies, use the alternate syntax.
AC Sine‑Wave Voltage Sources (without .AC)
V1 1 0 SIN(0 12 60 0 0)
Parameters: offset (DC bias), voltage (peak), freq (Hz), delay (phase in seconds), damping (decay).
DC Voltage Sources
V1 1 0 DC ; DC source defined by .DC card V1 1 0 DC 12 ; explicit 12 V DC
When using the .dc analysis card, sources must be declared with the DC keyword. Otherwise, specify the voltage value directly.
Pulse Voltage Sources
V1 1 0 PULSE(-3 3 0 0 0 10m 20m)
This generates a square wave oscillating between –3 V and +3 V, with zero rise/fall times, a 20 ms period, and 50 % duty cycle.
AC Sine‑Wave Current Sources (using .AC)
I1 1 0 AC 3 SIN I1 1 0 AC 1m 240 SIN ; 1 mA at 240° phase
AC Sine‑Wave Current Sources (without .AC)
I1 1 0 SIN(0 1.5 60 0 0)
DC Current Sources
I1 1 0 DC ; defined by .DC card I1 1 0 DC 12 ; explicit 12 A DC
Note: In SPICE, the first node specified is the negative node; current flows from the negative to the positive node.
Pulse Current Sources
I1 1 0 PULSE(-3m 3m 0 0 0 17m 34m)
Produces a square wave between –3 mA and +3 mA, with a 34 ms period and 50 % duty cycle.
Dependent Voltage Sources
E1 2 0 1 2 999k
Creates a voltage follower with a high gain of 999 k. Dependent sources do not load the input node; they should be used with care in feedback networks.
Industrial Technology
- Circuit With a Switch: A Practical Guide to Basic Electrical Circuits
- Mastering AC Circuit Equations: Impedance, Reactance & Resonance
- Getting Started with SPICE: A Text‑Based Circuit Simulation Tool
- SPICE Diode Modeling: A Practical Guide to Accurate Simulation
- Mastering Electric Circuit Simulation with SPICE: A Practical Guide for Designers and Students
- Mastering Scientific Notation in SPICE: A Practical Guide
- Integrated Circuits (ICs): Compact, Powerful Chips Powering Modern Electronics
- The 10 Essential Electronic Circuit Components Every Engineer Should Know
- 15 Essential Electronic Circuit Board Components You Must Know
- Essential PCB Components & Their Applications: How They Drive Modern Electronics