Ngspice User Manual - SourceForge

Transcription

Ngspice User’s ManualVersion 37 plus(ngspice development version)Holger Vogt, Marcel Hendrix, Paolo Nenzi, Dietmar WarningJune 22, 2022

2LocationsThe project and download pages of ngspice may be found atNgspice home page http://ngspice.sourceforge.net/Project page at SourceForge http://sourceforge.net/projects/ngspice/Download page at SourceForge -spicerework/Git source download r/tree/StatusThis manual is a work in progress. Some to-dos are listed in Chapt. 24.3. More is surelyneeded. You are invited to report bugs, missing items, wrongly described items, badEnglish style, etc.How to use this ManualThe manual is a “work in progress.” It may accompany a specific ngspice release, e.g.ngspice-35 as manual version 35. If its name contains ‘Version xxplus’, it describes theactual code status, found at the date of issue in the Git Source Code Management (SCM)tool. This manual is intended to provide a complete description of ngspice’s functionality,features, commands, and procedures. This manual is not a book about learning SPICEusage, however the novice user may find some hints how to start using ngspice. Chapter21.1 gives a short introduction how to set up and simulate a small circuit. Chapter 32 isabout compiling and installing ngspice from a tarball or the actual Git source code, whichyou 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.LicenseThis 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 INgspice User’s Manual3

ContentsINgspice User’s Manual31 Introduction1.11.21.31.435Simulation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361.1.1Analog Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 361.1.2Device Models for Analog Simulation . . . . . . . . . . . . . . . . . 361.1.3Digital Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 371.1.4Mixed-Signal Simulation . . . . . . . . . . . . . . . . . . . . . . . . 371.1.5Mixed-Level Simulation . . . . . . . . . . . . . . . . . . . . . . . . 38Supported Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391.2.1DC Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391.2.2AC Small-Signal Analysis . . . . . . . . . . . . . . . . . . . . . . . 401.2.3Transient Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 401.2.4Pole-Zero Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 411.2.5Small-Signal Distortion Analysis . . . . . . . . . . . . . . . . . . . . 411.2.6Sensitivity Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 411.2.7Noise Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421.2.8Periodic Steady State Analysis . . . . . . . . . . . . . . . . . . . . . 42Analysis at Different Temperatures . . . . . . . . . . . . . . . . . . . . . . 421.3.1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421.3.2Controlling the temperature . . . . . . . . . . . . . . . . . . . . . . 44Convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451.4.1Voltage convergence criterion . . . . . . . . . . . . . . . . . . . . . 451.4.2Current convergence criterion . . . . . . . . . . . . . . . . . . . . . 461.4.3Convergence failure . . . . . . . . . . . . . . . . . . . . . . . . . . . 465

6CONTENTS2 Circuit Description2.147General Structure and Conventions . . . . . . . . . . . . . . . . . . . . . . 472.1.1Input file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.1.2Syntax check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.1.3Circuit elements (device instances) . . . . . . . . . . . . . . . . . . 482.1.4Some naming conventions . . . . . . . . . . . . . . . . . . . . . . . 492.2Dot commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502.3Basic lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522.3.1.TITLE line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522.3.2.END Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532.3.3Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532.3.4End-of-line comments . . . . . . . . . . . . . . . . . . . . . . . . . . 532.3.5Continuation lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 542.4.MODEL Device Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542.5.SUBCKT Subcircuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552.5.1.SUBCKT Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562.5.2.ENDS Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572.5.3Subcircuit Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572.6.GLOBAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572.7.INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582.8.LIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582.9.PARAM Parametric netlists . . . . . . . . . . . . . . . . . . . . . . . . . . 582.9.1.param line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592.9.2Brace expressions in circuit elements: . . . . . . . . . . . . . . . . . 592.9.3Subcircuit parameters . . . . . . . . . . . . . . . . . . . . . . . . . 602.9.4Symbol scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612.9.5Syntax of expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 612.9.6Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642.9.7A word of caution on the three ngspice expression parsers . . . . . . 642.10 .FUNC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642.11 .CSPARAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652.12 .TEMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652.13 .IF Condition-Controlled Netlist . . . . . . . . . . . . . . . . . . . . . . . . 662.14 Parameters, functions, expressions, and command scripts . . . . . . . . . . 682.14.1 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682.14.2 Nonlinear sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682.14.3 Control commands, Command scripts . . . . . . . . . . . . . . . . . 68

CONTENTS73 Circuit Elements and Models713.1About netlists, device instances, models and model parameters . . . . . . . 713.2General options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723.33.2.1Paralleling devices with multiplier m . . . . . . . . . . . . . . . . . 723.2.2Instance and model parameters . . . . . . . . . . . . . . . . . . . . 743.2.3Model binning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.2.4Initial conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Elementary Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763.3.1Resistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763.3.2Semiconductor Resistors . . . . . . . . . . . . . . . . . . . . . . . . 783.3.3Semiconductor Resistor Model (R) . . . . . . . . . . . . . . . . . . 783.3.4Resistors, dependent on expressions (behavioral resistor) . . . . . . 803.3.5Resistor with nonlinear r2 cmc model . . . . . . . . . . . . . . . . 803.3.6Capacitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.3.7Semiconductor Capacitors . . . . . . . . . . . . . . . . . . . . . . . 823.3.8Semiconductor Capacitor Model (C) . . . . . . . . . . . . . . . . . 823.3.9Capacitors, dependent on expressions (behavioral capacitor) . . . . 843.3.10 Inductors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853.3.11 Inductor model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863.3.12 Coupled (Mutual) Inductors . . . . . . . . . . . . . . . . . . . . . . 873.3.13 Inductors, dependent on expressions (behavioral inductor) . . . . . 883.3.14 Capacitor or inductor with initial conditions . . . . . . . . . . . . . 893.3.15 Switches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903.3.16 Switch Model (SW/CSW) . . . . . . . . . . . . . . . . . . . . . . . 914 Voltage and Current Sources4.193Independent Sources for Voltage or Current . . . . . . . . . . . . . . . . . 934.1.1Pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 944.1.2Sinusoidal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954.1.3Exponential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964.1.4Piece-Wise Linear . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964.1.5Single-Frequency FM . . . . . . . . . . . . . . . . . . . . . . . . . . 974.1.6Amplitude modulated source (AM) . . . . . . . . . . . . . . . . . . 974.1.7Transient noise source . . . . . . . . . . . . . . . . . . . . . . . . . 984.1.8Random voltage source . . . . . . . . . . . . . . . . . . . . . . . . . 99

8CONTENTS4.1.9External voltage or current input . . . . . . . . . . . . . . . . . . . 994.1.10 Arbitrary Phase Sources . . . . . . . . . . . . . . . . . . . . . . . . 1004.1.11 RF Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1004.2Linear Dependent Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014.2.1Gxxxx: Linear Voltage-Controlled Current Sources (VCCS) . . . . 1014.2.2Exxxx: Linear Voltage-Controlled Voltage Sources (VCVS) . . . . . 1014.2.3Fxxxx: Linear Current-Controlled Current Sources (CCCS) . . . . 1024.2.4Hxxxx: Linear Current-Controlled Voltage Sources (CCVS)4.2.5Polynomial Source Compatibility . . . . . . . . . . . . . . . . . . . 1025 Non-linear Dependent Sources (Behavioral Sources)5.15.25.3. . . . 102105Bxxxx: Nonlinear dependent source (ASRC) . . . . . . . . . . . . . . . . . 1055.1.1Syntax and usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055.1.2Special B-Source Variables time, temper, hertz . . . . . . . . . . . . 1095.1.3par(’expression’) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1095.1.4Piecewise Linear Function: pwl . . . . . . . . . . . . . . . . . . . . 109Exxxx: non-linear voltage source . . . . . . . . . . . . . . . . . . . . . . . 1125.2.1VOL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125.2.2VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125.2.3TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125.2.4POLY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1135.2.5LAPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Gxxxx: non-linear current source . . . . . . . . . . . . . . . . . . . . . . . 1145.3.1CUR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145.3.2VALUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145.3.3TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.3.4POLY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.3.5LAPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.3.6Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.4Debugging a behavioral source . . . . . . . . . . . . . . . . . . . . . . . . . 1165.5POLY Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1175.5.1E voltage source, G current source . . . . . . . . . . . . . . . . . . 1185.5.2F voltage source, H current source . . . . . . . . . . . . . . . . . . . 118

CONTENTS96 Transmission Lines1216.1Lossless Transmission Lines . . . . . . . . . . . . . . . . . . . . . . . . . . 1216.2Lossy Transmission Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1226.2.16.3Uniform Distributed RC Lines . . . . . . . . . . . . . . . . . . . . . . . . . 1246.3.16.4Lossy Transmission Line Model (LTRA) . . . . . . . . . . . . . . . 122Uniform Distributed RC Model (URC) . . . . . . . . . . . . . . . . 124KSPICE Lossy Transmission Lines . . . . . . . . . . . . . . . . . . . . . . 1256.4.1Single Lossy Transmission Line (TXL) . . . . . . . . . . . . . . . . 1266.4.2Coupled Multiconductor Line (CPL) . . . . . . . . . . . . . . . . . 1267 Diodes1297.1Junction Diodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1297.2Diode Model (D) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1307.3Diode Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1328 BJT1378.1Bipolar Junction Transistors (BJTs) . . . . . . . . . . . . . . . . . . . . . . 1378.2BJT Models (NPN/PNP) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1378.2.1Gummel-Poon Models . . . . . . . . . . . . . . . . . . . . . . . . . 1388.2.2VBIC Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448.2.3MEXTRAM Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 1458.2.4HICUM level 2 Model . . . . . . . . . . . . . . . . . . . . . . . . . 1458.2.5HICUM level 0 Model . . . . . . . . . . . . . . . . . . . . . . . . . 1479 JFETs1499.1Junction Field-Effect Transistors (JFETs) . . . . . . . . . . . . . . . . . . 1499.2JFET Models (NJF/PJF) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1499.2.1Basic model statement . . . . . . . . . . . . . . . . . . . . . . . . . 1499.2.2JFET level 1 model with Parker Skellern modification . . . . . . . . 1499.2.3JFET level 2 Parker Skellern model . . . . . . . . . . . . . . . . . . 15210 MESFETs15510.1 MESFETs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15510.2 MESFET Models (NMF/PMF) . . . . . . . . . . . . . . . . . . . . . . . . 15510.2.1 Basic model statements . . . . . . . . . . . . . . . . . . . . . . . . . 15510.2.2 Model by Statz e.a. . . . . . . . . . . . . . . . . . . . . . . . . . . . 15510.2.3 Model by Ytterdal e.a. . . . . . . . . . . . . . . . . . . . . . . . . . 15610.2.4 hfet1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15610.2.5 hfet2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

10CONTENTS11 MOSFETs15911.1 MOSFET devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15911.2 MOSFET models (NMOS/PMOS) . . . . . . . . . . . . . . . . . . . . . . 16011.2.1 MOS Level 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16211.2.2 MOS Level 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16211.2.3 MOS Level 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16211.2.4 MOS Level 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16211.2.5 Notes on Level 1-6 models . . . . . . . . . . . . . . . . . . . . . . . 16211.2.6 MOS Level 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16511.2.7 BSIM Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16511.2.8 BSIM1 model (level 4) . . . . . . . . . . . . . . . . . . . . . . . . . 16611.2.9 BSIM2 model (level 5) . . . . . . . . . . . . . . . . . . . . . . . . . 16811.2.10 BSIM3 model (levels 8, 49) . . . . . . . . . . . . . . . . . . . . . . . 16811.2.11 BSIM4 model (levels 14, 54) . . . . . . . . . . . . . . . . . . . . . . 16811.2.12 EKV2.6 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16911.2.13 PSP Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17011.2.14 BSIMSOI models (levels 10, 58, 55, 56, 57) . . . . . . . . . . . . . . 17011.2.15 SOI3 model (level 60) . . . . . . . . . . . . . . . . . . . . . . . . . . 17011.2.16 HiSIM models of the University of Hiroshima . . . . . . . . . . . . 17011.3 Power MOSFET model (VDMOS). . . . . . . . . . . . . . . . . . . . . . 17112 Mixed-Mode and Behavioral Modeling with XSPICE17712.1 Code Model Element & .MODEL Cards . . . . . . . . . . . . . . . . . . . 17712.1.1 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17712.1.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18112.1.3 Search path for file input . . . . . . . . . . . . . . . . . . . . . . . . 18212.1.4 Code model location and assessment . . . . . . . . . . . . . . . . . 18212.2 Analog Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18312.2.1 Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18312.2.2 Summer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18412.2.3 Multiplier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18512.2.4 Divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18612.2.5 Limiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18812.2.6 Controlled Limiter . . . . . . . . . . . . . . . . . . . . . . . . . . . 18912.2.7 PWL Controlled Source . . . . . . . . . . . . . . . . . . . . . . . . 191

CONTENTS1112.2.8 Filesource (PWL sourced from file) . . . . . . . . . . . . . . . . . . 19312.2.9 multi input pwl block . . . . . . . . . . . . . . . . . . . . . . . . . 19412.2.10 Analog Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19612.2.11 Alternative Analog Switch . . . . . . . . . . . . . . . . . . . . . . . 19712.2.12 Zener Diode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19812.2.13 Current Limiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20012.2.14 Hysteresis Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20212.2.15 Differentiator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20412.2.16 Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20512.2.17 S-Domain Transfer Function . . . . . . . . . . . . . . . . . . . . . . 20712.2.18 Slew Rate Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20912.2.19 Inductive Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . 21112.2.20 Magnetic Core. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21212.2.21 Controlled Sine Wave Oscillator . . . . . . . . . . . . . . . . . . . . 21512.2.22 Controlled Triangle Wave Oscillator . . . . . . . . . . . . . . . . . . 21612.2.23 Controlled Square Wave Oscillator . . . . . . . . . . . . . . . . . . 21812.2.24 Controlled One-Shot . . . . . . . . . . . . . . . . . . . . . . . . . . 21912.2.25 Capacitance Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . 22112.2.26 Inductance Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22212.2.27 Memristor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22312.2.28 2D table model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22412.2.29 3D table model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22612.2.30 Simple Diode Model . . . . . . . . . . . . . . . . . . . . . . . . . . 22812.2.31 Analog delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22912.3 Hybrid Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23112.3.1 Digital-to-Analog Node Bridge . . . . . . . . . . . . . . . . . . . . . 23112.3.2 Analog-to-Digital Node Bridge . . . . . . . . . . . . . . . . . . . . . 23312.3.3 Controlled Digital Oscillator . . . . . . . . . . . . . . . . . . . . . . 23412.3.4 Node bridge from digital to real with enable . . . . . . . . . . . . . 23512.3.5 A Z**-1 block working on real data . . . . . . . . . . . . . . . . . . 23612.3.6 A gain block for event-driven real data . . . . . . . . . . . . . . . . 23612.3.7 Node bridge from real to analog voltage . . . . . . . . . . . . . . . 23712.3.8 Controlled PWM Oscillator . . . . . . . . . . . . . . . . . . . . . . 23712.4 Digital Models. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23912.4.1 Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

12CONTENTS12.4.2 Inverter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24012.4.3 And . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24112.4.4 Nand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24212.4.5 Or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24312.4.6 Nor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24412.4.7 Xor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24512.4.8 Xnor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24612.4.9 Tristate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24712.4.10 Pullup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24912.4.11 Pulldown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24912.4.12 D Flip Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25012.4.13 JK Flip Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25212.4.14 Toggle Flip Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25412.4.15 Set-Reset Flip Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . 25612.4.16 D Latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25912.4.17 Set-Reset Latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26112.4.18 State Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26412.4.19 Frequency Divider . . . . . . . . . . . . . . . . . . . . . . . . . . . 26712.4.20 RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26812.4.21 Digital Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27012.4.22 LUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27212.4.23 General LUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27312.5 Predefined Node Types for event driven simulation . . . . . . . . . . . . . 27512.5.1 Digital Node Type . . . . . . . . . . . . . . . . . . . . . . . . . . . 27512.5.2 Real Node Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27512.5.3 Int Node Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27612.5.4 (Digital) Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . 27613 Verilog A Device models27713.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27713.2 ADMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27713.3 How to integrate a Verilog-A model into ngspice . . . . . . . . . . . . . . . 27713.3.1 How to setup a *.va model for ngspice . . . . . . . . . . . . . . . . 27713.3.2 Adding admsXml to your build environment . . . . . . . . . . . . . 27813.3.3 Compile ngspice with ADMS. . . . . . . . . . . . . . . . . . . . . 278

CONTENTS1314 Mixed-Level Simulation (ngspice with TCAD)27914.1 Cider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27914.2 GSS, Genius . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28015 Analyses and Output Control (batch mode)28115.1 Simulator Variables (.options) . . . . . . . . . . . . . . . . . . . . . . . . . 28115.1.1 General Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28215.1.2 OP and DC Solution Options . . . . . . . . . . . . . . . . . . . . . 28315.1.3 AC Solution Options . . . . . . . . . . . . . . . . . . . . . . . . . . 28415.1.4 Transient Analysis Options . . . . . . . . . . . . . . . . . . . . . . . 28515.1.5 ELEMENT Specific options . . . . . . . . . . . . . . . . . . . . . . 28615.1.6 Transmission Lines Specific Options . . . . . . . . . . . . . . . . . . 28615.1.7 Precedence of option and .options commands . . . . . . . . . . . . . 28615.2 Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28715.2.1 .NODESET: Specify Initial Node Voltage Guesses . . . . . . . . . . 28715.2.2 .IC: Set Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . 28715.3 Analyses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28815.3.1 .AC: Small-Signal AC Analysis . . . . . . . . . . . . . . . . . . . . 28815.3.2 .DC: DC Transfer Function . . . . . . . . . . . . . . . . . . . . . . 28915.3.3 .DISTO: Distortion Analysis . . . . . . . . . . . . . . . . . . . . . . 29015.3.4 .NOISE: Noise Analysis . . . . . . . . . . . . . . . . . . . . . . . . 29215.3.5 .OP: Operating Point Analysis . . . . . . . . . . . . . . . . . . . . . 29315.3.6 .PZ: Pole-Zero Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 29415.3.7 .SENS: DC or Small-Signal AC Sensitivity Analysis . . . . . . . . . 29515.3.8 .SP S-Parameter Analysis . . . . . . . . . . . . . . . . . . . . . . . 29515.3.9 .TF: Transfer Function Analysis . . . . . . . . . . . . . . . . . . . . 29615.3.10 .TRAN: Transient Analysis . . . . . . . . . . . . . . . . . . . . . . 29715.3.11 Transient noise analysis (at low frequency) . . . . . . . . . . . . . . 29715.3.12 .PSS: Periodic Steady State Analysis . . . . . . . . . . . . . . . . . 30115.4 Measurements after AC, DC and Transient Analysis . . . . . . . . . . . . . 30215.4.1 .meas(ure) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30215.4.2 batch versus interactive mode . . . . . . . . . . . . . . . . . . . . . 30215.4.3 General remarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . 30215.4.4 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30315.4.5 Trig Targ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304

14CONTENTS15.4.6 Find . When . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30515.4.7 AVG MIN MAX PP RMS MIN AT MAX AT . . . . . . . . . . . . . . . . 30615.4.8 Integ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.4.9 param . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.4.10 par(’expression’ ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30715.4.11 Deriv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30815.4.12 More examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30815.5 Safe Operating Area (SOA) warning messages . . . . . . . . . . . . . . . . 30915.5.1 Resistor and Capacitor SOA model parameters. . . . . . . . . . . 31015.5.2 Diode SOA model parameters . . . . . . . . . . . . . . . . . . . . . 31015.5.3 BJT SOA model parameters . . . . . . . . . . . . . . . . . . . . . . 31115.5.4 MOS SOA model parameters . . . . . . . . . . . . . . . . . . . . . 31115.5.5 VDMOS SOA model parameters. . . . . . . . . . . . . . . . . . . 31215.6 Batch Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31215.6.1 .SAVE: Name vector(s) to be saved in raw file . . . . . . . . . . . . 31215.6.2 .PRINT Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31315.6.3 .PLOT Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31415.6.4 .FOUR: Fourier Analysis of Transient Analysis Output . . . . . . . 31415.6.5 .PROBE: Save device node currents, device power dissipation, ordifferential voltages between arbitrary nodes . . . . . . . . . . . . . 31515.6.6 par(’expression’): Algebraic expressions for output . . . . . . . . . . 31915.6.7 .width . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32015.7 Measuring current through device terminals . . . . . . . . . . . . . . . . . 32015.7.1 Using the .probe command . . . . . . . . . . . . . . . . . . . . . . . 32015.7.2 Adding a voltage source in series . . . . . . . . . . . . . . . . . . . 32015.7.3 Using option ’savecurrents’ . . . . . . . . . . . . . . . . . . . . . . . 32116 Starting ngspice32316.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32316.2 Where to obtain ngspice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32316.3 Command line options for starting ngspice . . . . . . . . . . . . . . . . . . 32416.4 Starting options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32616.4.1 Batch mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32616.4.2 Interactive mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32616.4.3 Control mode (Interactive mode with control file or control section) 327

CONTENTS1516.5 Standard configuration file spinit . . . . . . . . . . . . . . . . . . . . . . . 32816.6 User defined configuration file .spiceinit . . . . . . . . . . . . . . . . . . . . 32916.7 Environmental variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33016.7.1 Ngspice specific variables . . . . . . . . . . . . . . . . . . . . . . . . 33016.7.2 Common environment variables . . . . . . . . . . . . . . . . . . . . 33016.8 Memory usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33116.9 Simulation time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33116.10Ngspice on multi-core processors using OpenMP . . . . . . . . . . . . . . . 33116.10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33116.10.2 Internals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33216.10.3 Some results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33216.10.4 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33316.10.5 Literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33416.11Server mode option -s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33416.12Pipe mode option -p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33516.13Ngspice control via input, output fifos . . . . . . . . . . . . . . . . . . . . . 33716.14Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33816.14.1 Compatibility mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 33816.14.2 Missing functions . . . . . . . . . . . . . . . . . . . . . . . . . .

ngspice-35 as manual version 35. 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. This manual is intended to provide a complete description of ngspice's functionality, features, commands, and procedures. This manual is not a book about .