SPICE Reference
Free reference guide: SPICE Reference
About SPICE Reference
The SPICE Reference is a comprehensive, searchable guide to SPICE circuit simulation syntax and methodology. It covers netlist structure and rules, element name prefixes (R, C, L, V, I, D, Q, M, J, X), unit suffixes (T/G/MEG/K/M/U/N/P/F), voltage and current source declarations (DC, AC, SIN, PULSE, PWL), and passive element definitions with initial conditions and temperature coefficients.
Organized into five categories -- Netlist Basics, Analysis Commands, Device Models, Control Directives, and Practical Examples -- this reference provides the exact syntax for transient (.tran), AC (.ac), DC sweep (.dc), and operating point (.op) analyses, along with parameter sweeps (.step), automated measurements (.meas), and convergence control (.options). Each entry includes ready-to-use code that works in LTspice, PSpice, ngspice, and other SPICE-compatible simulators.
From diode and BJT model parameters (Is, Bf, Vaf) to MOSFET Level 1 models (VTO, KP, LAMBDA) and op-amp subcircuit definitions, every device model entry lists default values and connection syntax. The practical examples section includes complete netlists for an RC low-pass filter with Bode plot, an inverting amplifier, a CMOS inverter, and Monte Carlo tolerance analysis -- all ready to copy and simulate.
Key Features
- Complete netlist syntax reference: title lines, comments, continuation (+), case insensitivity rules, and node naming conventions
- All 15 element name prefixes (R/C/L/V/I/D/Q/M/J/X/E/F/G/H/K) with connection syntax and example declarations
- Six analysis commands (.tran, .ac, .dc, .op, .param/.step, .meas) with full parameter lists, sweep types, and output formats
- Device model definitions for diodes (1N4148), BJTs (2N2222 NPN), and MOSFETs (Level 1 NMOS/PMOS) with all key parameters and defaults
- Subcircuit (.subckt) creation and instantiation including a simplified LM741 op-amp model with output limiting
- Control directives for external files (.include/.lib), initial conditions (.ic/.nodeset), simulator options (.options), and temperature analysis (.temp)
- Four complete simulation examples: RC LPF with .meas bandwidth, inverting amplifier, CMOS inverter DC sweep, and Monte Carlo/worst-case analysis
- SPICE unit suffix table (T through F) with the critical M vs MEG distinction and suffix-after-character ignore rule
Frequently Asked Questions
What SPICE simulators is this reference compatible with?
The syntax covered is based on standard SPICE3/Berkeley SPICE and is compatible with LTspice, PSpice, ngspice, HSPICE, and most SPICE-derivative simulators. Some features like the mc() and gauss() functions in Monte Carlo examples are LTspice-specific.
What is the difference between M and MEG in SPICE?
In SPICE, M means milli (10^-3) and MEG means mega (10^6). This is a common source of confusion -- writing 1M gives 0.001, not 1,000,000. Characters after a suffix are ignored, so 10kohm is the same as 10k.
How do I set up a transient analysis in SPICE?
Use .tran Tstep Tstop [Tstart [Tmaxstep]] [UIC]. For example, .tran 1u 10m simulates from 0 to 10ms with 1us output steps. Set Tmaxstep to Tstop/1000 or smaller for better accuracy. Add UIC to use initial conditions and skip DC operating point.
How do I create an AC analysis for a Bode plot?
Use .ac DEC Npoints Fstart Fstop. For example, .ac DEC 100 1 100MEG sweeps from 1Hz to 100MHz with 100 points per decade on a logarithmic scale. Plot VDB(out) for magnitude in dB and VP(out) for phase in degrees.
What are the key parameters in a SPICE diode model?
Key parameters include Is (saturation current, default 1e-14A), N (ideality factor, default 1), Rs (series resistance), BV (breakdown voltage), CJO (zero-bias junction capacitance), and TT (transit time). The reference includes a complete 1N4148 model with typical values.
How do I define a MOSFET in SPICE?
Use .model name NMOS(Level=1 VTO=0.7 KP=110u ...) for the model, then M1 drain gate source body name W=10u L=1u for the element. Key Level 1 parameters are VTO (threshold), KP (transconductance), and LAMBDA (channel-length modulation).
What should I do when SPICE has convergence problems?
Try reducing Tmaxstep in .tran analysis, using .options RSHUNT=1e8 to add shunt resistors to each node, increasing ITL1/ITL4 iteration limits, adjusting ABSTOL/RELTOL/VNTOL tolerances, or switching the integration METHOD to GEAR. The .nodeset directive can also help provide DC convergence hints.
How do I run a Monte Carlo simulation in LTspice?
Define tolerance parameters using .param R1tol=mc(R1val, 0.05) for 5% uniform distribution or gauss(nominal, sigma, limit) for Gaussian. Use .step param run 1 100 1 to run 100 iterations. The reference includes a complete worst-case analysis example combining temperature and component tolerances.