Written and maintained by CASRAI Editorial Board
Published
On this page
Short answer
ngspice is an open-source mixed-signal, mixed-level circuit simulator that executes electronic circuit analysis across DC, AC, transient, and noise domains. Originating from Berkeley SPICE3f5, Georgia Tech XSPICE, and UC Berkeley CIDER, ngspice enables researchers and engineers to simulate passive networks, integrated semiconductor devices, and event-driven digital subcircuits within electronic design automation workflows.
Definition and scope
ngspice is an open-source circuit simulator for verifying and characterizing analog, digital, and mixed-signal electrical systems. Distributed under BSD and LGPL licenses, it is the community-maintained successor to UC Berkeley’s SPICE3f5 engine. While classic SPICE focused strictly on analog circuits, ngspice integrates analog equation solvers, event-driven digital engines, and physical numerical device solvers into a unified runtime environment.
The scope of ngspice spans several key engineering domains:
- Board-Level Electronics: Simulating printed circuit board (PCB) schematics, operational amplifiers, passive filters, and power converter switching.
- Integrated Circuit (IC) Design: Simulating analog, RF, and mixed-signal ICs using foundry compact models, including CMOS, BiCMOS, and FinFET nodes.
- Open-Source Silicon Flows: Serving as the core analog simulator in open silicon toolchains like OpenLane and open PDKs (e.g., SkyWater 130nm).
- Embedded Simulation Infrastructure: Functioning as a headless shared library (
libngspice) embedded within graphical schematic editors and automated testing scripts.
How it works or how it is used in practice
According to the Ngspice User’s Manual (Vogt et al., 2023) and Berkeley technical reports (Quarles, 1989), ngspice translates netlists into mathematical equation systems and iteratively solves them across time or frequency intervals.
Core Formulation and Solvers
ngspice applies Modified Nodal Analysis (MNA) to construct non-linear differential-algebraic equations from circuit topology. For non-linear components (diodes, transistors), it linearizes equations around an operating point using multi-dimensional Newton-Raphson iterations. For dynamic storage elements (capacitors, inductors), it applies numerical integration via Trapezoidal or Gear algorithms.
To solve linear equation matrices, ngspice provides two solvers:
- Sparse 1.3 Solver: Inherited from Berkeley SPICE3f5, offering robust numerical stability for general analog circuits and arbitrary non-linear behavioral sources (B-sources).
- KLU Sparse Matrix Solver: Optimized for circuit-derived sparse matrices in large-scale designs containing thousands of MOS transistors, significantly reducing LU factorization time.
Tripartite Architecture
ngspice unifies three historically distinct simulation engines:
- Berkeley SPICE3f5 Core: Implements continuous-time analog simulation, standard device models, and core analyses (
.op,.dc,.ac,.tran,.noise,.disto,.pz,.sens,.tf). - Georgia Tech XSPICE: Embeds an event-driven engine alongside the analog solver, supporting digital nodes and C-based code models (
.cm) for mixed-signal subsystems. - UC Berkeley CIDER1b1: Couples 1D and 2D numerical device simulation, solving Poisson and carrier continuity equations directly across a spatial discretization mesh.
Compact Models and OpenVAF/OSDI
ngspice supports standard compact models including BSIM3v3, BSIM4v4.8, BSIM-SOI, PSP, and HiCUM. For modern foundry models written in Verilog-A, ngspice integrates the Open Simulation Device Interface (OSDI). Models are compiled via OpenVAF into dynamic libraries and loaded at runtime with compiled C execution speeds.
Execution Modes
In laboratory practice, ngspice operates in three modes:
- Interactive CLI: Command prompt with Nutmeg plotting and vector manipulation.
- Batch Mode: Headless execution (
ngspice -b circuit.cir -r output.raw) for automated regression testing. - Shared Library (
libngspice): C API allowing host software to pass netlists in memory, control steps, and retrieve simulation vectors without disk I/O bottlenecks.
Types or related concepts
Selecting the proper simulation tier balances computational speed against physical modeling accuracy. The table below compares the simulation paradigms supported in ngspice, as documented in the Ngspice User’s Manual (Vogt et al., 2023).
| Simulation Tier | Primary Engine | Mathematical Basis | Typical Lab Application | Key Trade-Off |
|---|---|---|---|---|
| Compact Device Modeling | SPICE3f5 Core | Analytical closed-form I-V and Q-V equations (BSIM3/4, PSP) | Analog and mixed-signal IC verification; foundry PDK design | Fast evaluation; constrained to pre-parameterized physics. |
| Behavioral Code Modeling | Georgia Tech XSPICE | C-language algorithmic states, transfer functions, event queues | PLLs, ADC/DAC conversion, control loops, digital filters | Rapid execution; abstracts internal device structures. |
| Numerical Device Simulation | UC Berkeley CIDER1b1 | Coupled spatial Poisson and drift-diffusion equations (1D/2D mesh) | Semiconductor physics research, radiation effects, power devices | Extreme physical accuracy; high computational cost per device. |
| Compiled Verilog-A Models | OSDI / OpenVAF | Verilog-A compact equations compiled to machine code via LLVM | Emerging process nodes (FinFET, GAA, GaN) and nanoelectronics | Native C execution speed; requires pre-compilation step. |
| Scripted In-Memory Simulation | libngspice C API |
Direct memory pointer passing between host runtime and MNA matrix | Monte Carlo yield analysis, automated hardware-in-the-loop tests | Zero disk overhead; requires host wrapper programming. |
Where it matters for labs, clinics or supply decisions
Circuit simulation is essential for electronics laboratories, research facilities, and instrument development:
1. Electronic Design Automation and PCB Development
Open-source schematic capture and PCB tools, including KiCad and gEDA, use ngspice as their native simulation back-end. Through libngspice, engineers verify analog filtering, signal integrity, and power regulation directly within schematic canvases prior to physical PCB fabrication.
2. Open-Source Semiconductor Research
Commercial EDA licenses impose high recurring fees that restrict academic research. ngspice provides the analog simulation engine for open silicon toolchains (such as OpenLane and Tiny Tapeout) targeting open foundry technologies like SkyWater 130nm, democratizing microelectronic tape-outs.
3. Automated Testing and Bench Instrumentation
In measurement benches, pairing libngspice with Python (e.g., PySpice) enables automated closed-loop parameter extraction. Simulated circuits can be matched against physical oscilloscope acquisitions in real time to optimize component tolerance budgets.
4. Open Science, Licensing, and Computational Reproducibility
Publishing hardware designs alongside verifiable netlists ensures compliance with FAIR Data Principles. Releasing simulation models under an open-source license supports peer review in venues such as JOSS (Journal of Open Source Software). In addition, adherence to IEEE 754 floating-point standards ensures deterministic results across operating systems.
Common misunderstandings
- Misunderstanding: ngspice is merely a graphical schematic tool. ngspice is fundamentally a command-line engine, numerical solver, and shared C library. Graphical schematic capture is handled by external tools like KiCad, Xschem, or Qucs-S.
- Misunderstanding: Multi-core CPUs automatically speed up all SPICE simulations. The MNA matrix solution in SPICE is inherently sequential. While ngspice uses OpenMP multi-threading to parallelize device equation evaluations, transient time-stepping on smaller circuits remains single-thread bound.
- Misunderstanding: XSPICE replaces digital HDL simulators. XSPICE provides mixed-signal behavioral modeling and event-driven digital node support for analog co-simulation. It does not replace full RTL digital synthesis or simulators like Verilator.
- Misunderstanding: Compact models and numerical simulations provide identical data. Compact models (like BSIM4) use empirical parameter fitting for rapid circuit simulation. Numerical simulators (like CIDER) solve spatial field equations for detailed physical device analysis.
FAQ
What is the difference between ngspice and Berkeley SPICE3f5?
ngspice is the actively maintained successor to Berkeley SPICE3f5. While SPICE3f5 development ended in 1993, ngspice adds 64-bit support, the KLU sparse matrix solver, XSPICE mixed-signal extensions, CIDER numerical device modeling, modern compact models (BSIM4, PSP), Verilog-A support via OpenVAF/OSDI, and an embeddable shared library (libngspice).
How does ngspice integrate with schematic capture tools like KiCad?
ngspice integrates with KiCad through its dynamic shared library (libngspice). KiCad links directly to the library in memory, passing netlists and receiving simulation vector arrays without requiring external file conversions or process launches.
When should researchers select the KLU solver instead of Sparse 1.3?
The KLU solver is recommended when simulating large-scale integrated circuits with thousands of MOS transistors. For large, highly sparse matrices, KLU significantly reduces LU factorization time compared to Sparse 1.3, which remains best suited for smaller circuits and non-linear behavioral sources.
Does ngspice support modern Verilog-A compact device models?
Yes. ngspice supports Verilog-A models via the Open Simulation Device Interface (OSDI). Engineers compile Verilog-A code using OpenVAF into shared libraries, which ngspice loads at runtime with native C execution performance.
Sources
- Vogt, H., Hendrix, M., Nenzi, P., and Warning, D. (2023). Ngspice User’s Manual Version 42. Official ngspice documentation distribution. URL: https://packages.ubuntu.com/noble/ngspice-doc (and https://ngspice.sourceforge.io/docs.html). Checked November 11, 2026.
- Quarles, T. L. (1989). The SPICE3 Implementation Guide. Memorandum No. UCB/ERL M89/44, Electronics Research Laboratory, College of Engineering, University of California, Berkeley. URL: https://www2.eecs.berkeley.edu/Pubs/TechRpts/1989/1218.html. Checked November 11, 2026.
- Canonical Ubuntu Packaging Team. (2024). Package ngspice: Spice Circuit Simulator (Version 42+ds-3build1). Ubuntu Noble 24.04 LTS Package Repository. URL: https://packages.ubuntu.com/noble/ngspice. Checked November 11, 2026.
- Cox, F., Cohen, P., and Hu, M. (1992). XSPICE Software User’s Manual. Georgia Tech Research Institute, Atlanta, GA. Checked November 11, 2026.







