Ngspice Features, Extras and Options

Ngspice enhances the original spice3f5 in many ways. Here you will find a list and links to the various options. Typically details are not provided here, but are offered by the various links shown on the left or throughout the text. We also recommend to have a look at the actual ngspice manual.

Programming ngspice

Various programming interface are available to add control flows to ngspice simulation or control ngspice from external programs or scripts.

  • The ngspice scripting language (see manual chapter 17) allows to add control flows to a single simulation. You may run mathematical operations on simulation results, and start new simulations based on these data. Please have a look at scripts provided with the distribution, or at the examples from the manual. A complete optimizer may be written in this language.
  • Ngspice may be controlled via input, output fifos. Please see the manual at chapt. 16.12 for an example.
  • The shared ngspice option is designed to compile ngspice as a shared library or dynamic link library, which may be loaded by any suitable application. This caller has full control over ngspice.
  • The tclspice option is designed to add tcl scripting capability (including a graphics interface) to ngspice.
  • The ASCO optimizer is a nice example how to control ngspice from another program and how to run several ngspice instances in parallel on a multicore computer.

User defined device models

  • The B-, E-, and G-sources (see manual chapt. 5) allow to generate voltages or currents which result from evaluating a mathematical expression, derived from node voltages, branch currents, parameters, and constants. Behavioral R, L, or C devices may depend on exquations as well.
  • The XSPICE option integrates C language device models (code models) into ngspice. Behavioral modeling is strongly supported by various devices like amplifiers, filters, oscillators, integrators and others. Mixed signal analysis is sped up by event driven simulation of the digital sections. Various models already come along with ngspice to facilitating analog-digital co-simulation (see manual chapt. 12). The user may define his/her own analog, mixed, or digital devices and models (see chapt. 25-29, especially 28).
  • The ADMS interface integrates verilog device models into ngspice.

Ngspice as a shared library

Ngspice may be compiled as a shared library (*.so or *.dll). This will offer full control over the simulator from a calling process. See this page or the actual manual at chapter 19 for more information.

Circuit optimization with ngspice

Several methods of using ngspice in circuit optimization have been devised by users.

  • Optimization using a set of ngspice scripts. This is the original web site by F. Schmidt. A slightly modified set of scripts is available.
  • Optimization using tcl as scripting language. An example is provided with the tclspice option. The manual at chapt. 20 has additional infos.
  • Werner Hoch has developed a ngspice optimization procedure based on the ’differential evolution’ algorithm. On his web page he provides a Python script containing the control flow and algorithms.
  • The ASCO optimizer by Joao Ramos, introduced the ’differential evolution’ algorithm for circuit optimization. An enhanced version 0.4.7.1, adding ngspice as a simulation engine, may be downloaded (including a MS Windows ngspice executable based on CVS). Chapt. 23.5 of the actual manual describes the ngspice specific integration issues and examples. You will need ngspice-24 to run the examples.

Statistical circuit analysis with ngspice

ngspice offers random numbers, as well as dedicated functions and scripts to vary device parameters for circuit simulation.

  • Functions like AGAUSS are available for voltage and current sources (manual, chapt 22.2).
  • Random voltage or current values may be generated directly (manual chapt. 4.1.8).
  • Behavioral sources (B, E, G, R, L, C) include optionally generated random number values (manual chapt. 22.3).
  • The ngspice scripting language uses the above mentioned functions and additional post processing functions (manual chapt. 22.4) for Monte Carlo analysis (manual chapt. 22.5). Example scripts are part of the ngspice distribution.
  • Efficient noise voltage generators are part of the independent voltage and current sources (manual chapt. 4.1.7). Thermal noise, 1/f noise as well as random telegraph signal noise (RTS noise) are available. These sources are the basis for (time dependent) transient noise simulation with ngspice.

RF analysis with ngspice

High frequency simulation bridges the gap between high end scaled CMOS circuits and digital and analog applications. ngspice provides transistor models, e.g. BSIM4 for RF simulation as well as further tools. This field, however, ist still under development.

  • Various transmission line models are available in ngspice and are decribed in chapt. 6 of the manual. They range from lossless, over lossy, distributed RC up to recursive convolution modelled single and coupled lines.
  • You may 'measure' two port Scattering parameters of of your circuit and store them in a Touchstone file (see chapt. 17.8).
  • ngspice incorporates a very efficient fast fourier analysis of output vectors (see chapt. 17.4.23).
  • Periodic steady state analysis using a shooting method is under development. Test function are available (see chapt. 15.3.11).

TCAD and ngspice

Technology and device simulation, typically assembled in TCAD tools, may be integrated into ngspice. Thus individual devices may be simulated from scratch, being part of e.g. a transient ngspice simulation.

  • An early adoption of this approach is the cider option, fully integrated into ngspice. Part of the documentation is available in the ngspice manual, chapt 30.
  • ngspice is integrated into a more recent TCAD tool gss.
  • The successor to gss is the Genius Device Simulator which applies ngspice for device and circuit co-simulation.

Please send your comments, suggestions, and corrections on this page to the ngspice developers' list.