SPICE circuit simulation
How SPICE-type simulators solve the equations of an electronic circuit to predict voltages and currents in DC, AC and time-domain analyses before any hardware is built.
What it is
SPICE (Simulation Program with Integrated Circuit Emphasis) is the standard family of circuit simulators for analog and mixed-signal electronics. Developed at the University of California, Berkeley in the early 1970s (SPICE1 in 1973, SPICE2 in 1975, SPICE3 in 1989), it computes node voltages and branch currents of a circuit described by a netlist of components (resistors, capacitors, inductors, diodes, transistors, sources and subcircuits). Modern descendants include LTspice, ngspice, Xyce, PSpice, HSPICE and Cadence Spectre. Engineers use it to design amplifiers, power converters, filters, oscillators, sensors interfaces and integrated circuits, checking behavior before fabrication.
It answers questions such as: What is the DC bias of each transistor? What is the gain and bandwidth of this amplifier? How does the circuit respond to a step or a pulse? How much noise does it add? Does it still work across temperature, supply voltage and component tolerance? SPICE predicts only what the models describe, so model quality sets the reliability of the result.
Fundamentals
Circuit equations and nodal analysis
A circuit is solved using Kirchhoff’s current law (currents into each node sum to zero) and Kirchhoff’s voltage law, with device equations such as Ohm’s law, v = R i; capacitor current, i = C dv/dt; and inductor voltage, v = L di/dt. SPICE uses modified nodal analysis (MNA): unknowns are node voltages (plus currents through voltage sources and inductors), assembled into the matrix equation G x = b by “stamping” each component into a sparse matrix, and solved by sparse LU decomposition. Circuits with only linear elements need one solve, but diodes and transistors are nonlinear, for example the Shockley diode, I = IS(exp(V/(nVT)) − 1), with thermal voltage VT = kT/q ≈ 25.85 mV at 300 K. Nonlinear equations are solved iteratively by Newton–Raphson: at each iteration every nonlinear device is replaced by a linear companion model (conductance and current source) at the present voltage, and iteration repeats until voltage and current changes fall below tolerances (RELTOL 10−3, VNTOL 1 µV and ABSTOL 1 pA by default).
Analysis types
- DC operating point (.op): capacitors open, inductors shorted; gives bias voltages and currents. DC sweep (.dc) varies a source, giving transfer curves.
- AC small-signal analysis (.ac): linearizes devices at the operating point and solves at each frequency with complex phasors, giving gain, phase, bandwidth, impedance and stability margins (Bode plots). A first-order RC low-pass has cutoff fc = 1/(2πRC), so 1 kΩ and 1 µF give about 159 Hz.
- Transient analysis (.tran): integrates the circuit equations over time using backward Euler, trapezoidal or Gear methods with automatic time-step control based on local truncation error; the time constant of an RC circuit is τ = RC.
- Noise (.noise), transfer function (.tf), sensitivity, Fourier/FFT of transient results, and .step, .temp, Monte Carlo and worst-case runs for parameter sweeps and tolerances.
Device models and parameters
Accuracy depends on models. Passive components are ideal unless parasitics (ESR, ESL, lead inductance) are added. Diodes and bipolar transistors use Shockley and Gummel–Poon models. MOSFETs use Level 1–3 (educational) or BSIM models (BSIM3, BSIM4, BSIM-CMG for FinFETs), with parameters supplied by the foundry or manufacturer as process design kits or SPICE model files (.model, .lib, .subckt). Op-amps and ICs are often behavioral or macromodel subcircuits, and manufacturers supply them for their parts. Models are valid only within stated limits (frequency, temperature, bias), and different vendors’ models vary in quality, so critical circuits should be compared with bench measurements. Parasitics from layout, such as wiring capacitance, are added after extraction for post-layout simulation. Mixed-signal simulation combines SPICE with digital event-driven simulators (see Verilog and VHDL).
Convergence and numerical issues
Failures such as “timestep too small” or “singular matrix” are common. Causes include floating nodes (no DC path to ground), ideal voltage sources in loops, discontinuities (ideal switches, abrupt steps), very large and very small component values in the same circuit, and bistable circuits (oscillators, latches) with multiple operating points. Remedies: add a small resistance to ground (gmin, default 10−12 S), use .nodeset or .ic to supply starting guesses, source or gmin stepping, add rise and fall times to pulse sources, relax tolerances carefully, or switch the integration method (Gear for ringing-prone circuits; trapezoidal can show numerical ringing). Setting the maximum time step well below the fastest signal period avoids missing events. Always check the result against a hand calculation of the operating point and expected gain.
Typical applications and limits
Used for analog and RF design, power electronics (switching converters), sensor interfaces, filters and integrated circuit verification, including corner and statistical analysis. Limits are model accuracy, no layout or electromagnetic coupling unless extracted, slow simulation for large circuits (fast-SPICE tools trade accuracy for speed), and unrealistic results if non-ideal effects are ignored.
Basic operation
- Draw or write the circuit. Create a schematic or netlist with a ground node and all supplies and sources.
- Assign models. Use manufacturer or foundry models for active devices, and add important parasitics.
- Choose the analysis. Pick DC, AC, transient or noise, with sweep ranges and time step limits.
- Run the simulation. Watch for convergence warnings and fix them.
- Check the operating point. Confirm devices are biased as intended.
- Probe the results. Plot voltages, currents, gain and phase, and measure with .meas commands.
- Test variation. Run temperature, tolerance and Monte Carlo analyses.
- Collect the output. You obtain waveforms and measured quantities; convergence fixes and Monte Carlo setup are covered in the video.
Good practice
- Check results by hand. Compare with simple estimates.
- Use trusted models. Confirm validity range and version.
- Include real-world effects. Add parasitics, tolerances and temperature.
- Give every node a DC path. This avoids singular matrices.
- Save netlists and settings. Keep simulations reproducible.
- Do not treat simulation as proof of safety. Mains-connected, medical or high-energy circuits need bench testing, safety certification and proper isolation design.
Key terms
- Netlist — a text description of components and their connections.
- Modified nodal analysis — the matrix method SPICE uses to formulate circuit equations.
- Newton–Raphson — an iterative method for solving nonlinear circuit equations.
- Operating point — the DC bias state of a circuit with no signal.
- Transient analysis — a time-domain simulation of circuit response.
- Subcircuit — a reusable block defined with its own internal components.
- Convergence — the solver reaching a solution within tolerances.
Video coming soon
About five minutes on SPICE circuit simulation: how it works in detail, how the data is acquired, and how it is analyzed.
More in 4.2 Computational Modeling and Simulation
- Density functional theory (DFT)
- Ab initio methods (Hartree-Fock, post-HF)
- Semi-empirical/DFTB
- Molecular dynamics
- Coarse-grained modeling
- QM/MM
- Monte Carlo
- Kinetic Monte Carlo
- Finite element analysis
- Finite difference method
- Finite volume method
- Computational fluid dynamics
- Discrete element method
- Lattice Boltzmann
- Phase-field modeling
- FDTD
- Multiscale modeling
- CALPHAD
- Topology optimization
- Reduced-order modeling
- Digital twins
- Agent-based modeling
- System dynamics
- Climate modeling (GCM/RCM)
- Hydrological modeling
- Species distribution modeling
- SPICE circuit simulation
- TCAD device simulation
- EM simulation
- MIMO/OFDM simulation
- Power system load-flow and stability analysis
- Quantum circuit design and simulation
