Holger Vogt, Marcel Hendrix, Paolo Nenzi

January 1st, 2019

Locations

The project and download pages of ngspice may be found at

Ngspice home page http://ngspice.sourceforge.net/

Project page at sourceforge http://sourceforge.net/projects/ngspice/

Download page at sourceforge http://sourceforge.net/projects/ngspice/files/

Git source download http://sourceforge.net/scm/?type=cvs&group_id=38962

Status

This manual is a work in progress. Some to-dos are listed in Chapt. 24.3. More is surely needed. You are invited to report bugs, missing items, wrongly described items, bad English style etc.

How to use this manual

The manual is a `work in progress'. It may accompany a specific ngspice release, e.g. ngspice-24 as manual version 24. If its name contains `Version xxplus', it describes the actual code status, found at the date of issue in the Git Source Code Management (SCM) tool. The manual is intended to provide a complete description of the ngspice functionality, its features, commands, or procedures. It is not a book about learning SPICE usage, but the novice user may find some hints how to start using ngspice. Chapter 21.1 gives a short introduction how to set up and simulate a small circuit. Chapter 32 is about compiling and installing ngspice from a tarball or the actual Git source code, which you may find on the ngspice web pages. If you are running a specific Linux distribution, you may check if it provides ngspice as part of the package. Some are listed here.

License

This document is covered by the Creative Commons Attribution Share-Alike (CC-BY-SA) v4.0..

Part of chapters 12 and 25-27 are in the public domain.

Chapter 30 is covered by New BSD (chapt. 33.3.2).

Part I Ngspice User Manual

Table of Contents

Locations

Status

How to use this manual

License

Part I Ngspice User Manual

Prefaces

Preface to the first edition

Preface to the actual edition (as May 2018)

Acknowledgments

ngspice contributors

Chapter 1 Introduction

1.1 Simulation Algorithms

1.2 Supported Analyses

1.3 Analysis at Different Temperatures

1.4 Convergence

Chapter 2 Circuit Description

2.1 General Structure and Conventions

2.2 Basic lines

2.3 .MODEL Device Models

2.4 .SUBCKT Subcircuits

2.5 .GLOBAL

2.6 .INCLUDE

2.7 .LIB

2.8 .PARAM Parametric netlists

2.9 .FUNC

2.10 .CSPARAM

2.11 .TEMP

2.12 .IF Condition-Controlled Netlist

2.13 Parameters, functions, expressions, and command scripts

Chapter 3 Circuit Elements and Models

3.1 General options and information

3.2 Elementary Devices

Chapter 4 Voltage and Current Sources

4.1 Independent Sources for Voltage or Current

4.2 Linear Dependent Sources

Chapter 5 Non-linear Dependent Sources (Behavioral Sources)

5.1 Bxxxx: Nonlinear dependent source (ASRC)

5.2 Exxxx: non-linear voltage source

5.3 Gxxxx: non-linear current source

5.4 Debugging a behavioral source

5.5 POLY Sources

Chapter 6 Transmission Lines

6.1 Lossless Transmission Lines

6.2 Lossy Transmission Lines

6.3 Uniform Distributed RC Lines

6.4 KSPICE Lossy Transmission Lines

Chapter 7 Diodes

7.1 Junction Diodes

7.2 Diode Model (D)

7.3 Diode Equations

Chapter 8 BJTs

8.1 Bipolar Junction Transistors (BJTs)

8.2 BJT Models (NPN/PNP)

Chapter 9 JFETs

9.1 Junction Field-Effect Transistors (JFETs)

9.2 JFET Models (NJF/PJF)

Chapter 10 MESFETs

10.1 MESFETs

10.2 MESFET Models (NMF/PMF)

Chapter 11 MOSFETs

11.1 MOSFET devices

11.2 MOSFET models (NMOS/PMOS)

11.3 Power MOSFET model (VDMOS)

Chapter 12 Mixed-Mode and Behavioral Modeling with XSPICE

12.1 Code Model Element & .MODEL Cards

12.2 Analog Models

12.3 Hybrid Models

12.4 Digital Models

12.5 Predefined Node Types for event driven simulation

Chapter 13 Verilog A Device models

13.1 Introduction

13.2 ADMS

13.3 How to integrate a Verilog-A model into ngspice

Chapter 14 Mixed-Level Simulation (ngspice with TCAD)

14.1 Cider

14.2 GSS, Genius

Chapter 15 Analyses and Output Control (batch mode)

15.1 Simulator Variables (.options)

15.2 Initial Conditions

15.3 Analyses

15.4 Measurements after AC, DC and Transient Analysis

15.5 Safe Operating Area (SOA) warning messages

15.6 Batch Output

15.7 Measuring current through device terminals

Chapter 16 Starting ngspice

16.1 Introduction

16.2 Where to obtain ngspice

16.3 Command line options for starting ngspice and ngnutmeg

16.4 Starting options

16.5 Standard configuration file spinit

16.6 User defined configuration file .spiceinit

16.7 Environmental variables

16.8 Memory usage

16.9 Simulation time

16.10 Ngspice on multi-core processors using OpenMP

16.11 Server mode option -s

16.12 Ngspice control via input, output fifos

16.13 Compatibility

16.14 Tests

16.15 Reporting bugs and errors

Chapter 17 Interactive Interpreter

17.1 Introduction

17.2 Expressions, Functions, and Constants

17.3 Plots

17.4 Command Interpretation

17.5 Commands

17.6 Control Structures

17.7 Internally predefined variables

17.8 Scripts

17.9 Scattering parameters (s-parameters)

17.10 MISCELLANEOUS

17.11 Bugs

Chapter 18 Ngspice User Interfaces

18.1 MS Windows Graphical User Interface

18.2 MS Windows Console

18.3 Linux

18.4 CygWin

18.5 Error handling

18.6 Postscript printing options

18.7 Gnuplot

18.8 Integration with CAD software and `third party' GUIs

Chapter 19 ngspice as shared library or dynamic link library

19.1 Compile options

19.2 Linking shared ngspice to a calling application

19.3 Shared ngspice API

19.4 General remarks on using the API

19.5 Example applications

19.6 ngspice parallel

Chapter 20 TCLspice

20.1 tclspice framework

20.2 tclspice documentation

20.3 spicetoblt

20.4 Running TCLspice

20.5 examples

20.6 Compiling

20.7 MS Windows 32 Bit binaries

Chapter 21 Example Circuits

21.1 AC coupled transistor amplifier

21.2 Differential Pair

21.3 MOSFET Characterization

21.4 RTL Inverter

21.5 Four-Bit Binary Adder (Bipolar)

21.6 Four-Bit Binary Adder (MOS)

21.7 Transmission-Line Inverter

Chapter 22 Statistical circuit analysis

22.1 Introduction

22.2 Using random param(eters)

22.3 Behavioral sources (B, E, G, R, L, C) with random control

22.4 ngspice scripting language

22.5 Monte-Carlo Simulation

22.6 Data evaluation with Gnuplot

Chapter 23 Circuit optimization with ngspice

23.1 Optimization of a circuit

23.2 ngspice optimizer using ngspice scripts

23.3 ngspice optimizer using tclspice

23.4 ngspice optimizer using a Python script

23.5 ngspice optimizer using ASCO

Chapter 24 Notes

24.1 Glossary

24.2 Acronyms and Abbreviations

24.3 To Do

Part II XSPICE Software User's Manual

Chapter 25 XSPICE Basics

25.1 ngspice with the XSPICE option

25.2 The XSPICE Code Model Subsystem

25.3 XSPICE Top-Level Diagram

Chapter 26 Execution Procedures

26.1 Simulation and Modeling Overview

26.2 Circuit Description Syntax

26.3 How to create code models

Chapter 27 Example circuits

27.1 Amplifier with XSPICE model `gain'

27.2 XSPICE advanced usage

Chapter 28 Code Models and User-Defined Nodes

28.1 Code Model Data Type Definitions

28.2 Creating Code Models

28.3 Creating User-Defined Nodes

28.4 Adding a new code model library

28.5 Compiling and loading the new code model (library)

28.6 Interface Specification File

28.7 Model Definition File

28.8 User-Defined Node Definition File

Chapter 29 Error Messages

29.1 Preprocessor Error Messages

29.2 Simulator Error Messages

29.3 Code Model Error Messages

Part III CIDER

Chapter 30 CIDER User’s Manual

30.1 SPECIFICATION

30.2 BOUNDARY, INTERFACE

30.3 COMMENT

30.4 CONTACT

30.5 DOMAIN, REGION

30.6 DOPING

30.7 ELECTRODE

30.8 END

30.9 MATERIAL

30.10 METHOD

30.11 Mobility

30.12 MODELS

30.13 OPTIONS

30.14 OUTPUT

30.15 TITLE

30.16 X.MESH, Y.MESH

30.17 NUMD

30.18 NBJT

30.19 NUMOS

30.20 Cider examples

Part IV Appendices

Chapter 31 Model and Device Parameters

31.1 Accessing internal device parameters

31.2 Elementary Devices

31.3 Voltage and current sources

31.4 Transmission Lines

31.5 BJTs

31.6 MOSFETs

Chapter 32 Compilation notes

32.1 Ngspice Installation under Linux (and other 'UNIXes')

32.2 Ngspice Compilation under Windows OS

32.3 Reporting errors

Chapter 33 Copyrights and licenses

33.1 Documentation license

33.2 ngspice license

33.3 Some license details

33.4 Some notes on the historical evolvement of the ngspice licenses

Prefaces

Preface to the first edition

This manual has been assembled from different sources:

  1. The spice3f5 manual,
  2. the XSPICE user's manual,
  3. the CIDER user's manual

and some original material needed to describe the new features and the newly implemented models. This cut and paste approach, while not being orthodox, allowed ngspice to have a full manual in a fraction of the time that writing a completely new text would have required. The use of and LyX instead of info, which was the original encoding for the manual, further helped to reduce the writing effort and improved the quality of the result, at the expense of an on-line version of the manual but, due to the complexity of the software I hardly think that users will ever want to read an on-line text version.

In writing this text I followed the spice3f5 manual, both in the chapter sequence and presentation of material, mostly because that was already the user manual of SPICE.

Ngspice is an open source software, users can download the source code, compile, and run it. This manual has an entire chapter describing program compilation and available options to help users in building ngspice (see Chapt. 32). The source package already comes with all `safe' options enabled by default, and activating the others can produce unpredictable results and thus is recommended to expert users only. This is the first ngspice manual and I have removed all the historical material that described the differences between ngspice and spice3, since it was of no use for the user and not so useful for the developer who can look for it in the Changelogs of in the revision control system.

I want to acknowledge the work done by Emmanuel Rouat and Arno W. Peters for converting the original spice3f documentation to TeXinfo. Their effort gave ngspice users the only available documentation that described the changes for many years. A good source of ideas for this manual came from the on-line spice3f manual written by Charles D.H. Williams (Spice3f5 User Guide), constantly updated and useful for its many insights.

As always, errors, omissions and unreadable phrases are only my fault.

Paolo Nenzi

Roma, March 24th 2001

Indeed. At the end of the day, this is engineering, and one learns to live

within the limitations of the tools.

Kevin Aylward, Warden of the King's Ale

Preface to the actual edition (as May 2018)

Due to the wealth of new material and options in ngspice the actual order of chapters has been revised. Several new chapters have been added. The LyX text processor has allowed adding internal cross references. The PDF format has become the standard format for distribution of the manual. Within each new ngspice distribution (starting with ngspice-21) a manual edition is provided reflecting the ngspice status at the time of distribution. At the same time, located at ngspice manuals, the manual is constantly updated. Every new ngspice feature should enter this manual as soon as it has been made available in the Git source code master branch.

Holger Vogt

Mülheim, 2018

Acknowledgments

ngspice contributors

Spice3 and CIDER were originally written at The University of California at Berkeley (USA).

XSPICE has been provided by Georgia Institute of Technology, Atlanta (USA).

Since then, there have been many people working on the software, most of them releasing patches to the original code through the Internet.

The following people have contributed in some way:

Vera Albrecht,

Cecil Aswell,

Giles C. Billingsley,

Phil Barker,

Steven Borley,

Stuart Brorson,

Mansun Chan,

Wayne A. Christopher,

Al Davis,

Glao S. Dezai,

Jon Engelbert,

Daniele Foci,

Noah Friedman,

David A. Gates,

Alan Gillespie,

John Heidemann,

Marcel Hendrix,

Jeffrey M. Hsu,

JianHui Huang,

S. Hwang,

Chris Inbody,

Gordon M. Jacobs,

Min-Chie Jeng,

Beorn Johnson,

Stefan Jones,

Kenneth H. Keller,

Francesco Lannutti,

Robert Larice,

Mathew Lew,

Robert Lindsell,

Weidong Liu,

Kartikeya Mayaram,

Richard D. McRoberts,

Manfred Metzger,

Wolfgang Muees,

Paolo Nenzi,

Gary W. Ng,

Hong June Park,

Stefano Perticaroli,

Arno Peters,

Serban-Mihai Popescu,

Georg Post,

Thomas L. Quarles,

Emmanuel Rouat,

Jean-Marc Routure,

Jaijeet S. Roychowdhury,

Lionel Sainte Cluque,

Takayasu Sakurai,

Amakawa Shuhei,

Kanwar Jit Singh,

Bill Swartz,

Hitoshi Tanaka,

Steve Tell,

Andrew Tuckey,

Andreas Unger,

Holger Vogt,

Dietmar Warning,

Michael Widlok,

Charles D.H. Williams,

Antony Wilson,

and many others...

If someone helped in the development and has not been inserted in this list then this omission was unintentional. If you feel you should be on this list then please write to <ngspice-devel@lists.sourceforge.net>. Do not be shy, we would like to make a list as complete as possible.