Ngspice User's Manual (Version 32)
Total Page:16
File Type:pdf, Size:1020Kb
Ngspice User’s Manual Version 32 (Describes ngspice release version) Holger Vogt, Marcel Hendrix, Paolo Nenzi May 2nd, 2020 2 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. 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 SPICE usage, however 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’s Manual 3 Contents I Ngspice User’s Manual3 1 Introduction 33 1.1 Simulation Algorithms.............................. 34 1.1.1 Analog Simulation............................ 34 1.1.2 Device Models for Analog Simulation.................. 34 1.1.3 Digital Simulation............................ 35 1.1.4 Mixed-Signal Simulation......................... 35 1.1.5 Mixed-Level Simulation......................... 36 1.2 Supported Analyses................................ 37 1.2.1 DC Analysis............................... 37 1.2.2 AC Small-Signal Analysis........................ 38 1.2.3 Transient Analysis............................ 38 1.2.4 Pole-Zero Analysis............................ 38 1.2.5 Small-Signal Distortion Analysis.................... 39 1.2.6 Sensitivity Analysis........................... 39 1.2.7 Noise Analysis.............................. 40 1.2.8 Periodic Steady State Analysis...................... 40 1.3 Analysis at Different Temperatures........................ 40 1.4 Convergence................................... 42 1.4.1 Voltage convergence criterion...................... 42 1.4.2 Current convergence criterion...................... 42 1.4.3 Convergence failure........................... 43 2 Circuit Description 45 2.1 General Structure and Conventions........................ 45 2.1.1 Input file structure............................ 45 2.1.2 Circuit elements (device instances)................... 45 5 6 CONTENTS 2.1.3 Some naming conventions........................ 47 2.2 Basic lines..................................... 48 2.2.1 .TITLE line................................ 48 2.2.2 .END Line................................ 48 2.2.3 Comments................................ 49 2.2.4 End-of-line comments.......................... 49 2.3 .MODEL Device Models............................. 49 2.4 .SUBCKT Subcircuits............................... 50 2.4.1 .SUBCKT Line.............................. 51 2.4.2 .ENDS Line................................ 52 2.4.3 Subcircuit Calls.............................. 52 2.5 .GLOBAL..................................... 52 2.6 .INCLUDE.................................... 53 2.7 .LIB........................................ 53 2.8 .PARAM Parametric netlists........................... 53 2.8.1 .param line................................ 54 2.8.2 Brace expressions in circuit elements:.................. 54 2.8.3 Subcircuit parameters........................... 55 2.8.4 Symbol scope............................... 56 2.8.5 Syntax of expressions.......................... 56 2.8.6 Reserved words............................. 59 2.8.7 A word of caution on the three ngspice expression parsers....... 59 2.9 .FUNC....................................... 59 2.10 .CSPARAM.................................... 60 2.11 .TEMP....................................... 60 2.12 .IF Condition-Controlled Netlist......................... 61 2.13 Parameters, functions, expressions, and command scripts............ 62 2.13.1 Parameters................................ 62 2.13.2 Nonlinear sources............................. 62 2.13.3 Control commands, Command scripts.................. 62 3 Circuit Elements and Models 65 3.1 About netlists, device instances, models and model parameters......... 65 3.2 General options.................................. 66 3.2.1 Paralleling devices with multiplier m.................. 66 CONTENTS 7 3.2.2 Instance and model parameters...................... 68 3.2.3 Model binning.............................. 69 3.2.4 Initial conditions............................. 69 3.3 Elementary Devices................................ 70 3.3.1 Resistors................................. 70 3.3.2 Semiconductor Resistors......................... 71 3.3.3 Semiconductor Resistor Model (R)................... 72 3.3.4 Resistors, dependent on expressions (behavioral resistor)........ 73 3.3.5 Capacitors................................ 74 3.3.6 Semiconductor Capacitors........................ 75 3.3.7 Semiconductor Capacitor Model (C)................... 75 3.3.8 Capacitors, dependent on expressions (behavioral capacitor)...... 77 3.3.9 Inductors................................. 78 3.3.10 Inductor model.............................. 78 3.3.11 Coupled (Mutual) Inductors....................... 80 3.3.12 Inductors, dependent on expressions (behavioral inductor)....... 80 3.3.13 Capacitor or inductor with initial conditions............... 81 3.3.14 Switches................................. 82 3.3.15 Switch Model (SW/CSW)........................ 83 4 Voltage and Current Sources 85 4.1 Independent Sources for Voltage or Current................... 85 4.1.1 Pulse................................... 86 4.1.2 Sinusoidal................................. 87 4.1.3 Exponential................................ 87 4.1.4 Piece-Wise Linear............................ 88 4.1.5 Single-Frequency FM.......................... 89 4.1.6 Amplitude modulated source (AM)................... 89 4.1.7 Transient noise source.......................... 90 4.1.8 Random voltage source.......................... 91 4.1.9 External voltage or current input..................... 91 4.1.10 Arbitrary Phase Sources......................... 92 4.2 Linear Dependent Sources............................ 92 4.2.1 Gxxxx: Linear Voltage-Controlled Current Sources (VCCS)...... 92 4.2.2 Exxxx: Linear Voltage-Controlled Voltage Sources (VCVS)...... 93 4.2.3 Fxxxx: Linear Current-Controlled Current Sources (CCCS)...... 93 4.2.4 Hxxxx: Linear Current-Controlled Voltage Sources (CCVS)...... 93 4.2.5 Polynomial Source Compatibility.................... 94 8 CONTENTS 5 Non-linear Dependent Sources (Behavioral Sources) 95 5.1 Bxxxx: Nonlinear dependent source (ASRC).................. 95 5.1.1 Syntax and usage............................. 95 5.1.2 Special B-Source Variables time, temper, hertz............. 99 5.1.3 par(’expression’)............................. 99 5.1.4 Piecewise Linear Function: pwl..................... 99 5.2 Exxxx: non-linear voltage source......................... 102 5.2.1 VOL................................... 102 5.2.2 VALUE.................................. 102 5.2.3 TABLE.................................. 102 5.2.4 POLY................................... 103 5.2.5 LAPLACE................................ 103 5.3 Gxxxx: non-linear current source......................... 104 5.3.1 CUR................................... 104 5.3.2 VALUE.................................. 104 5.3.3 TABLE.................................. 105 5.3.4 POLY................................... 105 5.3.5 LAPLACE................................ 105 5.3.6 Example................................. 105 5.4 Debugging a behavioral source.......................... 106 5.5 POLY Sources................................... 107 5.5.1 E voltage source, G current source.................... 108 5.5.2 F voltage source, H current source.................... 108 6 Transmission Lines 111 6.1 Lossless Transmission Lines........................... 111 6.2 Lossy Transmission Lines............................ 112 6.2.1 Lossy Transmission Line Model (LTRA)................ 112 6.3 Uniform Distributed RC Lines.......................... 114 6.3.1 Uniform Distributed RC Model (URC)................. 114 6.4 KSPICE Lossy Transmission Lines........................ 115 6.4.1 Single Lossy Transmission Line (TXL)................. 115 6.4.2 Coupled Multiconductor Line (CPL)................... 116 CONTENTS 9 7 Diodes 119 7.1 Junction Diodes.................................. 119 7.2 Diode Model (D)................................. 119 7.3 Diode Equations.................................. 122 8 BJTs 127 8.1 Bipolar Junction Transistors (BJTs)....................... 127 8.2 BJT Models (NPN/PNP)............................. 127 8.2.1 Gummel-Poon Models.........................