512

Manual Analog Insydes.pdf

Embed Size (px)

Citation preview

  • Authors:

    Dr. rer. nat. Jochen BrozDipl.-Math. Alexander DreyerDipl.-Ing. Thomas HalfmannDr.-Ing. Eckhard HennigDr.-Ing. Manfred TholeDr. rer. nat. Tim Wichmann

    Copyright 20002005 by Fraunhofer-Institut fur Techno- und Wirtschaftsmathematik (ITWM)Fraunhofer-Platz 1, D-67663 Kaiserslautern, GermanyFax: +49-631-31600-1099Email: [email protected]: http://www.analog-insydes.de

    This document is furnished by Fraunhofer ITWM to licensed users of Analog Insydes for information purposes only. All information in thisdocument is subject to change without notice. This document is provided as is without any express or implied warranties.

    No part of this document may be reproduced or redistributed, on any media or by any means, without prior written permission of FraunhoferITWM.

    This document was typeset using the WRILaTeX Document System provided under license by Wolfram Research, Inc.

    The sparse matrix routines used in the Analog Insydes MathLink applications are copyright 1985, 86, 87, 88 by Kenneth S. Kundert andthe University of California.

    Analog Insydes and the Analog Insydes logo are trademarks of Fraunhofer ITWM.Mathematica and MathLink are registered trademarks of Wolfram Research, Inc.All other product names are trademarks of their respective owners.

  • Table of Contents

    Part 1. A Short Introduction1.1 Welcome to Analog Insydes.........................................................................................................................6

    How to Read this Book Feature List

    1.2 Getting Started............................................................................................................................................8Command Overview The First Step An Example Application The Online Help System The Analog Insydes

    Palette

    1.3 Whats New?.............................................................................................................................................25New in Version 2.1 New in Version 2: An Overview New in Version 2: A More Detailed DescriptionCompatibility

    Part 2. Tutorial2.1 Preface......................................................................................................................................................34

    How to Read this Tutorial Loading Analog Insydes

    2.2 Netlists.......................................................................................................................................................35The Netlist Format Circuit Elements A Brief Preview on Circuit Analysis More about Netlists

    2.3 Circuits and Subcircuits..............................................................................................................................48Circuits, Netlists, and Subcircuits Defining Subcircuits and Device Models Referencing Subcircuits Subcircuit

    Expansion Subcircuit Parameters The Scope Argument The Translation Argument

    2.4 Setting up and Solving Circuit Equations....................................................................................................72Naming Conventions Circuit Equations Circuit Equation Formulations Additional Options for

    CircuitEquations

    2.5 Graphics....................................................................................................................................................83Bode Plots Nyquist Plots Nichol Plots Root Locus Plots Transient Waveforms

    2.6 Modeling and Analysis of Nonlinear Circuits.............................................................................................92Behavioral Models Defining Behavioral Models Referencing Behavioral Models Nonlinear Circuit EquationsMulti-Dimensional Models Nonlinear DC Circuit Analysis References

    2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits...............................................................................106Transient Circuit Analysis Analysis of a Differential Amplifier Flow of Transient Circuit Analysis NDAESolve

    Options Transient Analysis with Initial Conditions TransientPlot Options

    2.8 Linear Symbolic Approximation................................................................................................................130Introduction to Symbolic Approximation Solution-Based Symbolic Approximation Equation-Based Symbolic

    Approximation Combining SBG and SAG Options for ApproximateMatrixEquation

    2.9 Frequency-Domain Analysis of Linear Circuits..........................................................................................145Transistor Models Transfer Functions Device Mismatch Input and Output Impedances Two-Port ParametersAdvanced Transistor Modeling AC Analysis of the CMOS Amplifier

    2.10 Nonlinear Symbolic Approximation..........................................................................................................167Introduction to Nonlinear Approximation Analyzing a Square Root Function Block

  • 2

    Part 3. Reference Manual3.1 Netlist Format..........................................................................................................................................180

    Netlist Circuit Netlist Entries Netlist Entry Options ElementTypes Value Specifications for IndependentSources Time and Frequency Model References Model and Subcircuit ModelParameters GlobalParameters

    3.2 Subcircuit and Device Model Definition....................................................................................................192Model Subcircuit

    3.3 Model Library Management.....................................................................................................................213ListLibrary FindModel FindModelParameters GlobalSubcircuits GlobalModelParameters LoadModelLoadModelParameters RemoveSubcircuit RemoveModelParameters

    3.4 Expanding Subcircuits and Device Models................................................................................................223ExpandSubcircuits

    3.5 Setting Up and Solving Circuit Equations.................................................................................................229CircuitEquations ACEquations DCEquations Solve

    3.6 Circuit and DAEObject Manipulation........................................................................................................257AddElements DeleteElements GetElements RenameNodes GetEquations GetMatrix GetVariables GetRHSGetParameters GetDAEOptions SetDAEOptions GetDesignPoint ApplyDesignPoint UpdateDesignPointMatchSymbols ShortenSymbols Statistics

    3.7 Numerical Analyses.................................................................................................................................282Analog Insydes Numerical Data Format Parameter Sweeps ACAnalysis NoiseAnalysis NDAESolve

    3.8 Pole/Zero Analysis..................................................................................................................................306GeneralizedEigensystem GeneralizedEigenvalues PolesAndZerosByQZ PolesByQZ ZerosByQZRootLocusByQZ LREigenpair ApproximateDeterminant

    3.9 Graphics Functions...................................................................................................................................332BodePlot FourierPlot NicholPlot NyquistPlot RootLocusPlot TransientPlot

    3.10 Interfaces.................................................................................................................................................366ReadNetlist Simulator-Specific Remarks on ReadNetlist ReadSimulationData WriteSimulationDataWriteModel

    3.11 Linear Simplification Techniques...............................................................................................................387ComplexityEstimate ApproximateTransferFunction ApproximateMatrixEquation CompressMatrixEquation

    3.12 Nonlinear Simplification Techniques..........................................................................................................403NonlinearSetup CompressNonlinearEquations CancelTerms SimplifySamplePoints NonlinearSettingsShowLevel ShowCancellations

    3.13 Miscellaneous Functions...........................................................................................................................420ConvertDataTo2D DXFGraphics MathLink Module MSBG MathLink Module QZ

    3.14 Global Options........................................................................................................................................427Options[AnalogInsydes] InstanceNameSeparator LibraryPath ModelLibrary Protocol SimulatorUseExternals Option Inheritance

    3.15 The Analog Insydes Environment..............................................................................................................434The Initialization Procedure ReleaseInfo ReleaseNumber License Version Info

  • Table of Contents 3

    Part 4. Appendix4.1 Stimuli Sources........................................................................................................................................440

    AMWave ExpWave PulseWave PWLWave SFFMWave SinWave

    4.2 Netlist Elements........................................................................................................................................448Resistor Conductance Admittance Impedance Capacitor Inductor OpenCircuit ShortCircuitCurrentSource VoltageSource CCCSource CCVSource VCCSource VCVSource OpAmp OTAmpNullator Norator Fixator SignalSource Amplifier Integrator Differentiator TransmissionLineTransferFunction

    4.3 Model Library..........................................................................................................................................462Diode Bipolar Junction Transistor MOS Field-Effect Transistor Junction Field-Effect Transistor

    Credits..............................................................................................................................................................500

    Index................................................................................................................................................................501

  • A Short Introduction

    1.1 Welcome to Analog Insydes . . . . . . . . . . . . . . . . . 6

    1.2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . 8

    1.3 Whats New? . . . . . . . . . . . . . . . . . . . . . . . . . 25

  • 6 1. A Short Introduction

    1.1 Welcome to Analog Insydes

    Welcome to Analog Insydes, a Mathematica toolbox for symbolic modeling, analysis, and design ofanalog electronic circuits. With Analog Insydes you can model and analyze linear and nonlinearcircuits, manipulate analysis results mathematically, produce graphical visualizations of circuitcharacteristics, exchange data with commercial circuit simulators, and document your solutionsall in one integrated environment.

    You will always get the latest information concerning Analog Insydes at our home page

    http://www.analoginsydes.de

    There you will also find a collection of demo notebooks, which show the application of AnalogInsydes on different tasks from the field of electrical engineering.

    If you have questions concerning Analog Insydes, please send an email to:

    [email protected]

    If you want to register to the Analog Insydes newsletter, please write an email to the above mentionedemail address with subject line "Newsletter" and body text "subscribe". You can find the list ofprevious newsletters at:

    http://www.analoginsydes.de/newsletter.html

    1.1.1 How to Read this BookThis book is divided into four parts: an introduction (Part 1), a tutorial (Part 2), a reference manual(Part 3), and an appendix (Part 4).

    The introduction part gives an overview of Analog Insydes functionality, highlights the new featuresof version 2, and shows the application of Analog Insydes on an practical example. We recommendto read this part, especially Section 1.2.1 and Section 1.2.3, before working with Analog Insydes.

    The tutorial part explains dedicated topics of Analog Insydes in detail. Although entitled Tutorial, itis not meant to be read completely before working with Analog Insydes. Rather, each chapter canbe read separately as soon as you need a closer look at special topics.

    The reference part explains each Analog Insydes command, shows its argument list, describes theavailable options, and shows the application on small examples. If you need information on a certaincommand, the reference manual is the preferred source.

    The appendix part explains all stimuli sources defined in Analog Insydes, shows all available netlistelements, and finally describes the content of the predefined symbolic device model library.

    1.1.2 Feature ListThe list below shows a summary of Analog Insydes main program features.

  • 1.1 Welcome to Analog Insydes 7

    Netlist-based input of electronic circuits and control systems

    Available linear circuit elements: resistor, impedance, conductance, admittance, capacitor, inductor,independent current and voltage source, all four types of controlled sources (VCVS, CCVS, VCCS,CCCS), operational amplifier (OP), operational transconductance amplifier (OTA), nullator, norator,fixator

    Available control network elements: proportional amplifier, differentiator, integrator, ideal trans-mission line, generic transfer function, signal source

    Hierarchical netlist entry and device modeling by means of subcircuits and behavioral modeldefinitions

    User-extendible device model library which includes bipolar (full Gummel-Poon small-signal andlarge-signal) and MOS (full Level 1-3 and BSIM3v3 small-signal, Level 1 large-signal) transistormodels

    Automatic setup of symbolic or mixed symbolic/numeric circuit equations by modified nodal(MNA), sparse tableau (STA), and extended sparse tableau analysis (ESTA) from netlists for linearand nonlinear circuits

    Automatic equation setup for AC, DC, transient, and noise analysis

    Symbolic calculation of transfer functions, input impedances, two-port parameters, etc.

    Design formula extraction by approximation of linear symbolic circuit equations and transferfunctions

    Simplification techniques for the approximation of nonlinear circuit descriptions

    Support for automated generation of behavioral models for nonlinear circuits

    Numerical AC, noise, and pole/zero analysis

    Numerical DC, DC-transfer, and transient analysis of nonlinear circuits

    Solution of circuit equations not only for currents and voltages but also for design parameters

    Graphics functions for Bode, Nyquist, Nichol, Fourier, and root locus plots, transient waveforms,DC-transfer, and parametric analyses

    Netlist import for Eldo, PSpice, Saber, and Spectre (via Analog Artist) netlist files, includingsmall-signal, operating-point, and model-card parameters

    Import filter for Eldo, PSpice, Saber, and Spectre simulation data

    Export filter of Analog Insydes simulation data for PSpice and Saber

    Export filter for Saber MAST model templates

    Import filter for circuit schematics and other line graphics from DXF files

  • 8 1. A Short Introduction

    1.2 Getting Started

    If this is your first contact with Analog Insydes, this chapter will help you to get familiar withthe system. To get an overview of the functionality of Analog Insydes, the first section providesa list of the most important commands (Section 1.2.1). Next, it is described how to load AnalogInsydes into the Mathematica kernel (Section 1.2.2), and an example application shows one possibleway to use Analog Insydes for solving a specific analysis task (Section 1.2.3). If you have never seenAnalog Insydes before, reading this example will give you a first impression of the system. Finally,Section 1.2.4 explains how to access the Analog Insydes online help system.

    1.2.1 Command OverviewThe most important Analog Insydes commands are listed in this section. For each command,references are given where to find more information. A link to the reference manual (Part 3 of thisbook) is given first, followed by links to related topics described in the tutorial (Part 2 of this book).

    Interfaces

    Analog Insydes provides import and export filters to Eldo, PSpice, Saber, and Spectre. (Chapter 3.10):

    ReadNetlist (Section 3.10.1, Section 2.9.2) translates external netlist files (including model cards,small-signal data, and operating-point information) into the Analog Insydes netlist language.

    ReadSimulationData (Section 3.10.3, Section 2.10.2) allows for importing and transformingnumerical simulation data into Mathematica InterpolatingFunction objects.

    WriteSimulationData (Section 3.10.4) exports numerical data calculated with Analog Insydes forfurther postprocessing in external waveform viewers.

    WriteModel (Section 3.10.5) generates behavioral model descriptions of symbolic (approximated)equation systems.

    Netlists, Circuits, and Models

    In Analog Insydes, analog circuits are expressed in terms of Netlist, Circuit, and Model objects:

    Netlist (Section 3.1.1, Chapter 2.2) is the basic data structure which contains the elements of aflat netlist.

    Circuit (Section 3.1.2, Chapter 2.3, Section 2.3.1) is a data structure which combines netlists,models, model parameters, and global parameters.

    Model (Section 3.2.1, Section 2.3.2, Section 2.6.2) is a data structure which defines netlist-based orequations-based models or subcircuits.

    AddElements (Section 3.6.1, Section 2.9.4),DeleteElements (Section 3.6.2, Section 2.9.4), GetElements (Section 3.6.3), and RenameNodes

  • 1.2 Getting Started 9

    (Section 3.6.4) allow for adding, deleting, or extracting netlist entries and changing node names,respectively, in a comfortable way.

    Statistics (Section 3.6.17) prints information on the contents of a Netlist or Circuit object.

    Analog Insydes provides a predefined symbolic device model library (Chapter 4.3), which can beextended by the user. Several commands allow for accessing the model data base (Chapter 3.3):

    LoadModel (Section 3.3.6) loads a specific model from a given model library.

    FindModel (Section 3.3.2) searches the default model library for a given name/selector pair.

    GlobalSubcircuits (Section 3.3.4, Section 2.3.6) prints the name/selector pairs of all globalmodels currently loaded.

    ListLibrary (Section 3.3.1) prints the contents of a specific model library.

    Equations

    Starting from Circuit or Netlist objects, circuit equations can be set up automatically in differentformulations and analysis modes. They are stored (together with additional information) in aDAEObject.

    CircuitEquations (Section 3.5.1, Chapter 2.4, Section 2.4.2, Section 2.6.4) sets up circuit equationsfrom a Circuit or Netlist object and returns a DAEObject.

    Solve (Section 3.5.4, Section 2.4.2) can be used to symbolically solve the equations stored in aDAEObject.

    GetEquations (Section 3.6.5, Section 2.10.2), GetVariables (Section 3.6.7, Section 2.10.2),GetDesignPoint (Section 3.6.12, Section 2.9.6), and GetParameters (Section 3.6.9, Section 2.10.2)give easy access to the data stored in a DAEObject.

    ApplyDesignPoint (Section 3.6.13), UpdateDesignPoint (Section 3.6.14, Section 2.10.2), andMatchSymbols (Section 3.6.15, Section 2.9.3) allow for modifying the contents of a DAEObject.

    GetDAEOptions (Section 3.6.10) andSetDAEOptions (Section 3.6.11) allow for accessing or modifying the options stored in a DAEObject.

    Statistics (Section 3.6.17, Section 2.9.7) prints information on the complexity of a DAEObject.

    Numerical Analyses

    The standard numerical circuit analyses can be carried out by the following commands (Chapter 3.7):

    NDAESolve (Section 3.7.5, Chapter 2.7) is used to solve nonlinear differential-algebraic equationsystems. It calculates the DC (Section 2.6.6), DC-transfer (Section 2.7.2), and transient solution(Section 2.7.1), also parametric (Section 2.7.2).

    ACAnalysis (Section 3.7.3, Section 2.9.7) computes the small-signal solution of a linear equationsystem.

  • 10 1. A Short Introduction

    NoiseAnalysis (Section 3.7.4) computes the output noise and the equivalent input noise of alinear equation system.

    Poles and Zeros

    Besides the standard numerical analyses, Analog Insydes provides functions for numerically computingpoles and zeros as well as root loci of linear systems (Chapter 3.8):

    PolesAndZerosByQZ (Section 3.8.3), PolesByQZ (Section 3.8.4), and ZerosByQZ (Section 3.8.5)numerically compute poles and zeros of a linear system using the QZ algorithm.

    RootLocusByQZ (Section 3.8.6) computes the root locus of a linear system.

    Graphical Postprocessing

    Analog Insydes provides special graphics functions for the most important electrical engineeringplots:

    BodePlot (Section 3.9.1, Section 2.5.1)

    FourierPlot (Section 3.9.2)

    NicholPlot (Section 3.9.3, Section 2.5.3)

    NyquistPlot (Section 3.9.4, Section 2.5.2)

    RootLocusPlot (Section 3.9.5, Section 2.5.4)

    TransientPlot (Section 3.9.6, Section 2.7.1, Section 2.7.6)

    Symbolic Approximation

    One of the most important features of Analog Insydes is its capability to reduce the complexity ofsymbolic equations and expressions with automatic error control. For linear circuits, Analog Insydesprovides SBG and SAG methods (Chapter 2.8):

    ApproximateTransferFunction(Section 3.11.2, Chapter 2.8, Section 2.8.2) approximates a symbolictransfer function by removing insignificant terms.

    ApproximateMatrixEquation (Section 3.11.3, Chapter 2.8, Section 2.8.3) approximates a symbolicmatrix equation with respect to a certain output variable.

    ApproximateDeterminant (Section 3.8.8) approximates a symbolic matrix equation with respectto a certain pole.

    As of Analog Insydes version 2 there are also simplification routines for nonlinear equations(Chapter 3.12):

    CompressNonlinearEquations (Section 3.12.2, Section 2.10.2) algebraically simplifies nonlinearequations by eliminating irrelevant variables.

  • 1.2 Getting Started 11

    CancelTerms (Section 3.12.3, Section 2.10.2) approximates a symbolic nonlinear equation systemwith respect to a certain output variable. The commandNonlinearSetup (Section 3.12.1, Section 2.10.2) prepares the application of CancelTerms.

    Miscellaneous

    DXFGraphics (Section 3.13.2) translates DXF files into Mathematica graphics objects. It can be usedto display circuit schematics in a Mathematica notebook for documentation purposes.

    Options[Analog Insydes] (Chapter 3.14) returns the list of global Analog Insydes options. SeeSection 3.14.8 for a description of the option inheritance mechanism in Analog Insydes.

    Info[AnalogInsydes] (Section 3.15.6) prints the exact location of your Analog Insydes installationand lists all loaded init files. For a description of init file loading see Section 3.15.1. For furtherinformation on the Analog Insydes environment see Chapter 3.15.

    1.2.2 The First StepTo work with Analog Insydes start Mathematica and open a new notebook window. Then loadAnalog Insydes by evaluating the command

  • 12 1. A Short Introduction

    Once you have loaded Analog Insydes into the Mathematica kernel you can obtain detailed informationconcerning your local Analog Insydes installation by means of the following commands:

    ReleaseInfo[AnalogInsydes] prints information about your Analog Insydes license type

    ReleaseNumber[AnalogInsydes] returns the release number of your Analog Insydesinstallation

    License[AnalogInsydes] returns your Analog Insydes license number

    Version[AnalogInsydes] prints a detailed description of your Analog Insydesversion

    Info[AnalogInsydes] prints the location of your Analog Insydes installation andthe list of loaded init files

    Obtaining Analog Insydes release information.

    If you encounter any bug in Analog Insydes, please send a bug report to:

    [email protected]

    When reporting problems, please proceed as follows: Evaluate all commands in a Mathematicanotebook until your problem occurs and describe it as detailed as possible. Whenever possible,print Netlist and Circuit objects as well as DAEObjects in InputForm. Afterwards, please addthe information concerning your Analog Insydes installation by evaluating each of the followingcommands in separate cells of the Mathematica notebook and attach this notebook to your problemreport:

    $VersionId$Path$LicenseIDReleaseInfo[AnalogInsydes]Version[AnalogInsydes]License[AnalogInsydes]Info[AnalogInsydes]

    Please be sure to evaluate the commands after your problem occurs, because otherwise somemodules might not be loaded during the evaluation of Version[AnalogInsydes]. If possible, attachadditional data such as netlist or data files to the email as well.

    1.2.3 An Example ApplicationThis example describes the standard way how to use Analog Insydes. It can easily be adapted todifferent analysis tasks and applications. The usage of many different commands, from netlist importto linear simplification techniques, is explained and cross references are given where to find moreinformation. Reading this section should give you a first overview of the capabilities of AnalogInsydes.

  • 1.2 Getting Started 13

    Analysis Task

    Following, we want to analyze the A741 operational amplifier. The task is to find an interpretablesymbolic formula for the corner frequency of the small-signal voltage transfer function. This is usefulto identify those circuit elements and parasitics, which have a dominant influence on it. In addition,the symbolic transfer function can be utilized for further investigation, such as the extraction of itspoles and zeros, to find methods for the compensation of certain effects.

    Importing Schematics

    To import the schematics picture of the operational amplifier, we use the Analog Insydes commandDXFGraphics (Section 3.13.2). This command translates two-dimensional DXF data into Mathematicagraphics objects which can be displayed in a Mathematica notebook. Most schematics entries ofcommercial circuit simulators support the export of schematics in DXF format. DXFGraphics allowsfor importing your schematics into Mathematica for documentation purposes.

    Before using DXFGraphics, of course we have to load the Analog Insydes master package as describedin Section 1.2.2.

    In[1]:=

  • 14 1. A Short Introduction

    which automatically translates an external netlist description into the Analog Insydes netlist format.You can import netlists written for or generated by Eldo, PSpice, Saber, and the Spectre to AnalogInsydes interface for Analog Artist.

    The first argument to ReadNetlist is the simulator input file. Since this file (*.cir in our case)only contains the numerical values of the elements, the operating-point information and the valuesfor the small-signal parameters of the transistors have to be extracted from the simulator output file(*.out in our case). This is performed automatically by ReadNetlist, too. All we have to do isspecifying the corresponding simulator output file as second argument.

    In[3]:= op741 = ReadNetlist["AnalogInsydes/DemoFiles/OP741.cir","AnalogInsydes/DemoFiles/OP741.out",Simulator > "PSpice", KeepPrefix > False]

    Out[3]= Circuit

    As the syntax of external netlist files varies for each simulator, you have to specify from whichexternal format you are reading by means of the Simulator option of ReadNetlist.

    The return value of ReadNetlist is a Circuit object which contains symbolic values for each netlistelement as well as the corresponding numerical reference information. By default, the Circuit objectis displayed as a single line in your output cell. To view the complete netlist apply the commandDisplayForm to the Circuit object (we will not evaluate the command since the output is too bigto be shown here):

    DisplayForm[op741]

    Additionally, you can use the command Statistics (Section 3.6.17) to get an impression of thecircuit complexity. This command prints the number of different element types occuring in thecircuit.

    In[4]:= Statistics[op741]

    Number of Resistors : 13

    Number of Capacitors : 1

    Number of VoltageSources : 5

    Number of models BJT/QNPN741 : 15

    Number of models BJT/QPNP741 : 11

    Total number of elements : 45

    Setting Up Circuit Equations

    Once the netlist is imported, the next step is to set up the symbolic circuit equations. In AnalogInsydes this can be done automatically using the command CircuitEquations (Section 3.5.1). TheAnalog Insydes netlist read by ReadNetlist contains generic model references for each transistor anddoes not specifiy a concrete model implementation. Thus, we have to instruct Analog Insydes whichmodel to use during equation setup by means of the option ModelLibrary. Analog Insydes comeswith a predefined SPICE-compatible, symbolic model library in three different complexity levelscalled "FullModels", "SimplifiedModels" , and "BasicModels" (the implemented models areexplained in detail in Chapter 4.3. For special tasks the model library can be extended by the user;

  • 1.2 Getting Started 15

    this topic is discussed in Chapter 2.3). In the following, we choose a complexity-reduced BJT modelfrom the Analog Insydes model library by setting the option ModelLibrary > "BasicModels".Note that a quote mark ("") is following the word BasicModels.

    In[5]:= mnaAC741 = CircuitEquations[op741,ElementValues > Symbolic,ModelLibrary > "BasicModels"]

    Out[5]= DAE@AC, 3333D The additional option ElementValues > Symbolic tells Analog Insydes to set up equations usingthe symbolic element values instead of the numerical ones. By default, CircuitEquations sets upsmall-signal equations in matrix formulation, but DC or transient equations can be set up, too. SeeSection 3.5.1 and Chapter 2.4 for details. CircuitEquations returns a DAEObject which containsthe equation system as well as additional data which is used and extracted automatically by otherAnalog Insydes commands. As for Circuit objects, a DAEObject is printed in short notation onlyand can be displayed using DisplayForm (we once more omit evaluating the command since theequation system is too big to be printed here):

    DisplayForm[mnaAC741]

    Again, you can use Statistics (Section 3.6.17) to get an impression of the equation size.

    In[6]:= Statistics[mnaAC741]

    Number of equations : 33

    Number of variables : 33

    Number of entries : 1089

    Number of nonzero entries : 171

    Complexity estimate : 1.6e21

    Importing Simulation Data

    When using netlists from external simulators we always have to verify that the models used duringequation setup are compatible to the ones used by the simulator. This is done by comparingthe numerical solution calculated by the external simulator with the solution calculated by AnalogInsydes. If both solutions do not coincide within a tolerable error range, we have to go back one stepand choose different models during equation setup before going on with the symbolic analysis. Tosimplify this procedure, Analog Insydes provides the command ReadSimulationData (Section 3.10.3)for importing numerical data generated by an external simulator. As for ReadNetlist we have tospecify from which format we are reading by means of the Simulator option. The list of supportedformats is shown in Section 3.10.1.

    In[7]:= op741data = ReadSimulationData["AnalogInsydes/DemoFiles/OP741.csd",Simulator > "PSpice"]

    Out[7]=88VH26L [email protected], 1.106

  • 16 1. A Short Introduction

    ReadSimulationData returns the result according to the Analog Insydes numerical data formatwhich is described in Section 3.7.1. It consists of a list of rules, where the variables (which arereturned as strings) are assigned InterpolatingFunction objects.

    Graphically Displaying Simulation Data

    We can use Mathematicas ReplaceAll operator (or /. in short notation) to extract a singleinterpolating function from the numerical data and assign it to a new variable.

    In[8]:= vout741PSpice = "V(26)" /. First[op741data]

    Out[8]= [email protected], 1.106

  • 1.2 Getting Started 17

    In[10]:= reference = ACAnalysis[mnaAC741, V$26, {f, 0.1, 10^6}]

    Out[10]=88V$26 [email protected], 1.106

  • 18 1. A Short Introduction

    Setting Up Circuit Equations for Approximation

    To prepare the simplification process we set up the system of circuit equations again. As againstthe previous call to the function CircuitEquations, where the circuit equations were given in themodified nodal analysis format, they are set up in sparse tableau formulation this time. Sparsetableau is the preferred equation formulation when performing linear approximation tasks. Detailsabout the Formulation option are given in Section 3.5.1.

    In[13]:= staAC741 = CircuitEquations[op741,ElementValues > Symbolic, Formulation > SparseTableau,ModelLibrary > "BasicModels"]

    Out[13]= DAE@AC, 402402D The returned equation system is a DAEObject with 402 equations and 402 variables.

    In[14]:= Statistics[staAC741]

    Number of equations : 402

    Number of variables : 402

    Number of entries : 161604

    Number of nonzero entries : 1392

    Complexity estimate : 1.6e21

    Although this sparse tableau system is more than 10 times bigger than the modified nodal system,it usually produces better approximation results.

    Performing Matrix Approximation

    Now we call the matrix approximation routine on the symbolic circuit equations of the A741 circuit.This routine simplifies the equations based on numerical constraints with respect to a given outputvariable. The required information is provided in form of several sampling points, specified incombination with a maximum error constraint each. The approximation routine then processes thematrix such that the sought output function is located within the defined error range around thegiven sampling points. For further information please refer to Section 3.11.3.

    To capture the first corner frequency, we place sampling points at 1 Hz and at 10 Hz with a maximumerror of 30% each.

    In[15]:= samplingpoints = {{s > 2. Pi I 1., MaxError > 0.3},{s > 2. Pi I 10., MaxError > 0.3}}

    Out[15]=88s 6.28319 , MaxError 0.3

  • 1.2 Getting Started 19

    In[16]:= op741approx = ApproximateMatrixEquation[staAC741, V$R13,samplingpoints]

    Out[16]= DAE@AC, 402402D In[17]:= Statistics[op741approx]

    Number of equations : 402

    Number of variables : 402

    Number of entries : 161604

    Number of nonzero entries : 455

    Complexity estimate : 14

    As another call to the function Statistics shows, the approximation routine could considerablyreduce the complexity of the DAEObject (i.e. the number of non-zero entries), although its equationsize did not change. With just a small number of terms remaining, a symbolic computation of thetransfer function is now possible.

    Calculating the Transfer Function

    To calculate the transfer function, we now solve the approximated system of equations for the outputvoltage:

    In[18]:= approximation = Solve[op741approx, V$R13]

    Out[18]=99V$R13 Igm$Q1 gm$Q16 gm$Q17 gm$Q2 gm$Q3gm$Q4 gm$Q5 R9 Ro$Q131 Ro$Q17 Ro$Q42 Rpi$Q16 Rpi$Q17 VIDM Igm$Q3 H-gm$Q1 gm$Q2 - gm$Q1 gm$Q4L gm$Q5 H-Ro$Q131 - Ro$Q17LHgm$Q16 gm$Q17 R8 R9 Ro$Q4 Rpi$Q16 Rpi$Q17 +

    Ro$Q4 HR9 Ro$Q4 + gm$Q17 R8 Ro$Q4 Rpi$Q17LL -C1 gm$Q16 gm$Q17 gm$Q3 H-gm$Q1 gm$Q2 - gm$Q1 gm$Q4L gm$Q5R9 Ro$Q131 Ro$Q17 Ro$Q42 Rpi$Q16 Rpi$Q17 sM==

    Again, we use Mathematicas ReplaceAll operator to extract the calculated solution and assign it toa new variable.

    In[19]:= vout741 = V$R13 /. First[approximation] // Simplify

    Out[19]=Hgm$Q16 gm$Q17 gm$Q2 gm$Q4 R9Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 VIDL HHgm$Q2 + gm$Q4L Hgm$Q17 R8 HRo$Q131 + Ro$Q17L Ro$Q4 Rpi$Q17 +R9 HRo$Q17 HRo$Q4 + gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17L +

    Ro$Q131 HRo$Q4 + gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17 +C1 gm$Q16 gm$Q17 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17 sLLLL

    This expression now represents the approximated symbolic transfer function of the A741 circuit. Itcontains only those circuit elements and parasitics that were not removed by the matrix approximationroutine. Thus, they have been identified as those elements, which have a major influence on thebehavior of the transfer function.

  • 20 1. A Short Introduction

    Verifying Approximation Results

    The quality of the approximation can be determined by performing a numerical comparison betweenthe simplified transfer function and the data imported from the numerical simulator (PSpice in thiscase). Therefore, we need to extract the design point from the DAEObject first using the commandGetDesignPoint (Section 3.6.12). The design point specifies those numerical values for each one ofthe circuit elements that were given in the netlist.

    In[20]:= designpoint = GetDesignPoint[staAC741]

    Out[20]=8Rpi$Q1 756000., Ro$Q1 2.19107, Cbc$Q1 3.710-13,Cbe$Q1 1.4710-12, gm$Q1 0.00029, Cbx$Q1 0.,

    Rpi$Q2 753000., Ro$Q2 2.18107, Cbc$Q2 3.710-13,

    Cbe$Q2 1.4710-12, gm$Q2 0.000291, Cbx$Q2 0.,

    Rpi$Q3 219000., Ro$Q3 8.46106, Cbc$Q3 3.8510-13,

    Cbe$Q3 1.4210-12, gm$Q3 0.000287, Cbx$Q3 0.,

    Rpi$Q4 217000., Ro$Q4 8.4106, Cbc$Q4 3.8710-13,

    Cbe$Q4 1.4210-12, gm$Q4 0.000288, Cbx$Q4 0.,

    Rpi$Q5 705000., Ro$Q5 2.04107, Cbc$Q5 8.2810-13,

    Cbe$Q5 1.4710-12, gm$Q5 0.000285, Cbx$Q5 0.,

    Rpi$Q6 705000., Ro$Q6 2.04107, Cbc$Q6 7.9310-13,

    Cbe$Q6 1.4710-12, gm$Q6 0.000285, Cbx$Q6 0.,

    Rpi$Q7 533000., Ro$Q7 1.55107, Cbc$Q7 2.9710-13,

    Cbe$Q7 1.4810-12, gm$Q7 0.000447, Cbx$Q7 0.,

    Rpi$Q8 89500., Ro$Q8 3.46106, Cbc$Q8 1.10-12,

    Cbe$Q8 1.4510-12, gm$Q8 0.000559, Cbx$Q8 0., R1 1000.,

    R2 1000., R3 50000., Rpi$Q9 89500., Ro$Q9 3.46106,

    Cbc$Q9 3.6210-13, Cbe$Q9 1.4510-12, gm$Q9 0.000732,

    Cbx$Q9 0., Rpi$Q10 293000., Ro$Q10 8.51106,

    Cbc$Q10 3.8110-13, Cbe$Q10 1.510-12, gm$Q10 0.000742,Cbx$Q10 0., Rpi$Q11 7260., 44, Ro$Q17 240000.,Cbc$Q17 3.8210-13, Cbe$Q17 1.610-12, gm$Q17 0.0263,Cbx$Q17 0., R6 27., R7 22., R8 100., R9 50000.,R10 50000., R11 50000., R12 300., Rpi$Q18 368000.,Ro$Q18 1.07107, Cbc$Q18 1.10-12, Cbe$Q18 1.4910-12,gm$Q18 0.000543, Cbx$Q18 0., Rpi$Q19 25500.,Ro$Q19 740000., Cbc$Q19 8.2610-13, Cbe$Q19 1.5710-12,gm$Q19 0.00787, Cbx$Q19 0., Rpi$Q20 5810.,Ro$Q20 225000., Cbc$Q20 1.1110-12, Cbe$Q20 4.4810-12,

    gm$Q20 0.0111, Cbx$Q20 0., Rpi$Q21 3.341013,

    Ro$Q21 6.241011, Cbc$Q21 3.6610-13, Cbe$Q21 1.10-12,

    gm$Q21 3.4310-13, Cbx$Q21 0., Rpi$Q24 1.861014,

    Ro$Q24 9.281011, Cbc$Q24 1.10-12, Cbe$Q24 1.10-12,

    gm$Q24 3.7710-18, Cbx$Q24 0., Rpi$Q23 1.861014,

    Ro$Q23 9.821011, Cbc$Q23 7.1310-13, Cbe$Q23 1.10-12,

    gm$Q23 6.9110-14, Cbx$Q23 0., C1 3.10-11,

    Rpi$Q222 7550., Ro$Q222 292000., Cbc$Q222 3.7510-13,

    Cbe$Q222 1.5210-12, gm$Q222 0.00845, Cbx$Q222 0.,

    Rpi$Q221 5.1013, Ro$Q221 7.671011, Cbc$Q221 3.7510-13,

    Cbe$Q221 3.8810-13, gm$Q221 -2.6810-14,Cbx$Q221 0., R13 1000., VID 1., Simulator PSpice

  • 1.2 Getting Started 21

    The numerical representation of the approximated transfer function depending on the Laplacevariable s is now found by applying the numerical design point data to the symbolic transferfunction.

    In[21]:= vout741N[s_] = vout741 /. designpoint // Simplify

    Out[21]=7.321521022

    2.902871017 + 1.517451016 s

    Another Bode plot shows the PSpice simulation data compared with the approximated numerictransfer function in the frequency range from 0.1 Hz to 1 MHz.

    In[22]:= BodePlot[{vout741PSpice[f], vout741N[2. Pi I f]},{f, 0.1, 10^6}, ShowLegend > False]

    1.0E-1 1.0E1 1.0E3 1.0E5Frequency

    0

    20

    40

    60

    80

    100

    Magnitude (dB)

    1.0E-1 1.0E1 1.0E3 1.0E5Frequency

    -80

    -60

    -40

    -20

    0

    Phase (deg)

    Out[22]= Graphics

    It is apparent that although the number of terms occuring in the transfer function has beenreduced from almost 1.6 1021 to 14 (!), the curves still match perfectly in the frequency rangeof interest. Therefore, the approximation is qualified to replace the actual transfer function forfurther computations.

    Further Processing

    From the approximated transfer function we can now extract additional information, such as thecalculation and graphical representation of its poles and zeros.

    The poles of the approximated symbolic transfer function can be found by calculating the zeros ofits denominator.

    In[23]:= poles1 = Solve[Denominator[vout741] == 0, s] // Simplify

    Out[23]=88s -HHRo$Q131 + Ro$Q17L Hgm$Q17 R8 Ro$Q4 Rpi$Q17 +R9 HRo$Q4 + gm$Q16 gm$Q17 R8 Rpi$Q16 Rpi$Q17LLL HC1 gm$Q16 gm$Q17 R9 Ro$Q131 Ro$Q17 Ro$Q4 Rpi$Q16 Rpi$Q17L

  • 22 1. A Short Introduction

    In[24]:= p1 = poles1 /. designpoint

    Out[24]= 88s -19.1299

  • 1.2 Getting Started 23

    comparison of the numerical pole values showed that indeed the formula represents the dominantpole. This symbolic formula now provides deeper insight into the corner frequency location.

    1.2.4 The Online Help SystemBecause Analog Insydes is a complex system, it comes with a detailed online documentation: Forquick information, a compact help text is available for each Analog Insydes symbol. This text can bedisplayed using the Mathematica ? operator (which is also called Information). For Analog Insydescommands, the purpose and function patterns are printed, for Analog Insydes options, the purposeand possible values are given. For example:

    Load Analog Insydes. In[1]:= Rebuild Help Index.

    1.2.5 The Analog Insydes PaletteAnalog Insydes provides a palette window which allows you to enter nearly all Analog Insydescommands by simply pressing a button.

    The palette is divided into subgroups which can be opened by clicking on the triangle symbol.Clicking on a button pastes the corresponding text into your session notebook. Clicking on a buttonmarked with a blue star pastes a more complex skeleton into your notebook. The status line of thepalette window indicates which skeleton is pasted.

  • 24 1. A Short Introduction

    The Analog Insydes palette

    By choosing the menu item File->Palettes->AnalogInsydes you launch the Analog Insydes palettewindow.

    Alternatively, you can find the Analog Insydes palette in the file

    aidir/FrontEnd/Palettes/AnalogInsydes.nb

    of your Analog Insydes installation. Use the command Info (Section 3.15.6) to obtain the path ofyour Analog Insydes installation directory.

  • 1.3 Whats New? 25

    1.3 Whats New?

    Since the first release in 1998, Analog Insydes has been successfully applied to real-world problemsby our customers. The key algorithms implemented in Analog Insydes particularly the symbolicapproximation methods proved to be very effective, but it turned out that improvements regardingtool functionality, user-friendliness, interfaces, processing speed, and the device model library wouldbe desirable. After three years of development Analog Insydes version 2 had been released in2001. Since then the integration of additional platform and circuit design environments were addedsuccessfully to our software, here is the result: Analog Insydes version 2.1. This chapter guides youthrough the most noticable enhancements of the new version and the last major release.

    1.3.1 New in Version 2.1

    New Interfaces for Spectre

    Simulation data import

    Analog Insydes 2.1 provides a new interface to the Spectre circuit design environment. The AnalogInsydes command ReadSimulationData has been extended for reading Spectre PSF files.

    Netlist import via Analog Artist

    A platform-independent netlist converter with small-signal data and model-card import functionalityis now available for files generated by the Spectre to Analog Insydes interface for Analog Artist.

    Extended Device Model Library

    The Analog Insydes device model library was extented to treat Spectre compatible models for R, L,C, D, BJT, MOS, and JFET.

    Full Integration of High-Performance MathLink Binaries on Mac OS X

    Analog Insydes 2.1 is now fully compatible with Mac OS X, including native high-performanceMathLink binaries for the QZ algorithm and matrix approximation.

    Compatibility to Version 2

    Despite the improvements of Analog Insydes version 2.1, it is 100% compatible with Analog Insydes 2.

  • 26 1. A Short Introduction

    1.3.2 New in Version 2: An Overview

    New Interfaces for Eldo, PSpice, and Saber

    Netlist import including small-signal and model-card parameters

    Behavioral model writer

    Simulation data import and export

    New Device Model Library

    Eldo and PSpice compatible models for R, L, C, D, BJT, MOS, and JFET

    BJT: full Gummel-Poon small-signal and large-signal models

    MOS: full Level 1-3 + BSIM3v3 small-signal models, Level 1 large-signal model

    Extended Circuit Description and Modeling Language

    Model parameter sets, global parameters, multiple source values

    Enhanced modeling language for nonlinear dynamic systems

    Improved Circuit Equation Setup

    Automatic model library search

    Automatic design-point extraction for linear and nonlinear circuits

    Consistent data handling through DAEObjects

    New and Improved Analysis Modes

    AC, noise, pole/zero, DC, DC transfer, temperature, transient, parametric, root locus

    New and Improved Symbolic Approximation Techniques

    New and improved linear approximation techniques for AC and pole/zero analysis

    New approximation techniques for nonlinear circuits

    Full Integration of High-Performance MathLink Binaries

    For symbolic matrix approximation and numerical pole/zero analysis (QZ algorithm)

    Multi-platform support (HP-UX, Linux, Solaris, Windows)

  • 1.3 Whats New? 27

    Graphics Functions

    New and improved graphics functions

    Improved command interfaces for a more comfortable use

    Improved User Interface

    Improved user interface allows for setting up and running circuit analyses from Eldo, PSpice, orSaber netlists with as few as three Analog Insydes commands

    1.3.3 New in Version 2: A More Detailed DescriptionThe most noticeable changes between Analog Insydes versions 1 and 2 were made to the circuitdescription and modeling language and to the way circuit equations are set up, stored, and presentedto the user:

    Netlist Format

    The circuit description language (netlist format) was extended by functionality for managing devicemodel parameter sets (model cards), global parameter settings, initial conditions, and multiplesource values for different analysis modes (AC, DC, transient). With these enhancements it is nowpossible to represent all netlist and device model information contained in a SPICE circuit descriptionconsistently in an Analog Insydes Circuit object.

    The netlist fragment shown below illustrates the use of some new language features. Note thatthe unspecific arguments of the keywords Model, Selector, and Parameters in the value fieldof the device reference Q1 permit an easy selection of device models and parameter sets at runtime using Mathematicas pattern rewriting functionality. The model expansion mechanism of AnalogInsydes 2 makes use of this approach to automatically select appropriate device models according tothe specified analysis mode.

  • 28 1. A Short Introduction

    Analog Insydes 2 netlistfragment

    amplifier = Circuit[Netlist[

    {V1, {1, 0}, Symbolic > V1,Value > {AC > 1, DC > 2.5,

    Transient>SinWave[Time, 2.5, 0.1, 1000]}},{Q1, {2 > C, 1 > B, 3 > E},

    Model>Model[BJT, NDEF, Q1],Selector > Selector[BJT, NDEF, Q1],Parameters > Parameters[BJT, NDEF, Q1],GM$ac > 0.02, RPI$ac > 5.0*10^3, },

    ],ModelParameters[Name > NDEF, Type > NPN,

    IS > 10^16, BF > 100, BR > 1, VAF > 150],GlobalParameters[TEMP > 300, GMIN > 10^12]

    ]

    Circuit Equations

    In Analog Insydes 1, symbolic circuit equations and corresponding numerical information (designpoint, initial conditions, etc.) were not handled in a consistent fashion. To prevent errors dueto potentially inconsistent data and to provide a unified and more user-friendly mechanism formanaging all additional data associated with a system of symbolic circuit equations, the internalrepresentation of circuit equations was fundamentally changed in version 2. Now, all equation setupand circuit analysis functionality is centered around a common data structure, the DAEObject.

    A DAEObject is generated by means of the command CircuitEquations. It represents a linearor nonlinear system of differential-algebraic equations (DAE) along with numerical data needed fornumerical analysis or symbolic approximation. In addition, a DAEObject contains information aboutthe type of equations it represents (AC/DC/transient, MNA/STA) plus a snapshot of all relevantoption settings taken at the point of time when the equations were set up. This data encapsulationapproach ensures the consistency of all data belonging to a particular circuit analysis context andreduces the number of parameters that need to be passed to functions which operate on circuitequations.

    Interfaces

    Analog Insydes 2 provides several new or improved modules for interfacing with commercial circuitdesign environments. Platform-independent netlist converters with small-signal data and model-card import functionality are now available for a variety of widely used circuit simulators, includingEldo, PSpice, and Saber. Waveforms can be imported from Eldo, PSpice, and Saber data files. Circuitschematics can be imported into Mathematica via a DXF file converter. Moreover, Analog Insydes 2features a model writer which is capable of generating behavioral model templates (e.g. Saber MAST)automatically from a DAEObject.

  • 1.3 Whats New? 29

    Modeling Language

    As a consequence of the requirements identified during recent work on symbolic modeling andanalysis of nonlinear circuits, the behavioral modeling capabilities for nonlinear dynamic systemswere substantially extended. With the enhanced model description format of Analog Insydes 2, itis now possible to designate model port nodes as optional, to specify default values for modelparameters as well as initial conditions and guesses for model variables, and to control how design-point information is generated for symbolic parameters of model equations.

    Library Concept

    Based on the modeling language extensions described above, a completely new device model libraryconcept was designed for Analog Insydes 2. Eldo and PSpice compatible models are available for R,L, C, D, BJT, MOS, and JFET devices. Three model simplification levels can be selected when settingup circuit equations to control the complexity of symbolic analysis.

    Nonlinear Symbolic Analysis

    Completely new functionality has been implemented for symbolic analysis and approximation ofnonlinear circuits. Based on a flexible user interface, the approximation routines allow an arbitrarychoice of analysis and error-control functions. In combination with the new model writer, AnalogInsydes 2 can be used for automated generation of nonlinear behavioral models.

    Pole/Zero Analysis

    Efficient numerical pole/zero and root locus analysis is now supported through two differentgeneralized eigenvalue problem solvers: an enhanced version of the QZ algorithm and a variantof the Jacobi orthogonal correction method (JOCM). The introduction of the DAEObject conceptreduces the amount of parameters passed to functions. In addition, a new matrix-based method forsymbolic pole/zero analysis has been implemented. The algorithm simplifies a symbolic generalizedeigenvalue problem with respect to a selected root, using the JOCM for efficient iterative errortracking.

    User Interface

    The use of Analog Insydes 2 has been considerably simplified by combining many frequently usedsteps in powerful macro commands and providing more default actions. With as few as threeAnalog Insydes commands it is possible to set up and run circuit analyses from Eldo, PSpice, orSaber netlists. In addition, the external binaries (QZ algorithm, matrix approximation) have beenfully integrated into Analog Insydes 2 and can be used transparently like built-in commands.

  • 30 1. A Short Introduction

    Multi-Platform Support

    Multi-platform support is available for all binaries: One Analog Insydes installation can be accessedfrom different platforms. Transparently for the user the correct binaries are automatically chosen.This allows for installing Analog Insydes on a site-wide file server and simultaneously using it fromdifferent platforms.

    1.3.4 CompatibilityTo realize the improvements made in version 2 of Analog Insydes, drastic changes on the internaldata format had to be performed, such that we could not keep 100% compatibility with version 1.As a consequence, version 1 notebooks may not evaluate without errors using Analog Insydes 2.But fortunately, only some minor changes (like modifying function arguments) are usually sufficientto evaluate with version 2. These changes are listed below. Note that this also applies to AnalogInsydes 2.1, because it is fully compatible to Analog Insydes 2.

    ApproximateMatrixEquation

    altered pattern according to ApproximateTransferFunction

    former option PrintProtocol now called Protocol, option values changed

    CircuitEquations

    option DefaultModelLibrary now called ModelLibrary

    option DifferentialOperator now called FrequencyVariable

    option setting SparseTableauVariant > Basic | Extended now obtained byFormulation > SparseTableau | ExtendedTableau

    option setting SymbolicValues > True | False now obtained byElementValues > Symbolic | Value

    option setting TimeDomain > True | False now obtained by AnalysisMode > Transient | AC

    option UnitValues is obsolete

    CSDFRead

    former command CSDFRead substituted by new implementation called ReadSimulationData

    DXFGraphics

    option FillColor now called FillColors, option values modified

    options LineThickness, LineAbsoluteThickness, PolylineWidthScale, PrimitivesOut,TextOffsetX, TextOffsetY, and TextAlignBottom are obsolete

  • 1.3 Whats New? 31

    NDAESolve, NDAESolveDC

    former command NDAESolveDC substituted by additional pattern for NDAESolve

    option AnalysisMethod now called AnalysisMode

    modified values for option Protocol

    RootLocusPlot

    modified values for options PoleStyle and ZeroStyle

    SolveCircuitEquations

    former command SolveCircuitEquations substituted by Solve

    spice2ai.exe, SpiceToAI, WhereIsSpice2ai

    former external executable spice2ai.exe and wrapper function SpiceToAI substituted by newimplementation ReadNetlist

    options Spice2aiOptions and Spice2aiPath are obsolete

    command WhereIsSpice2ai is obsolete

    CheckedCircuit, CheckedNetlist, FlatNetlist

    replaced by NetlistObject[Checked | Flat]

  • Tutorial

    2.1 Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    2.2 Netlists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2.3 Circuits and Subcircuits . . . . . . . . . . . . . . . . . . . 48

    2.4 Setting up and Solving Circuit Equations . . . . . . . . . . 72

    2.5 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    2.6 Modeling and Analysis of Nonlinear Circuits . . . . . . . . 92

    2.7 Time-Domain Analysis of Nonlinear Dynamic Circuits . . 106

    2.8 Linear Symbolic Approximation . . . . . . . . . . . . . . 130

    2.9 Frequency-Domain Analysis of Linear Circuits . . . . . . 145

    2.10 Nonlinear Symbolic Approximation . . . . . . . . . . . . 167

  • 34 2. Tutorial

    2.1 Preface

    2.1.1 How to Read this TutorialWhereas Part 3 of this book serves as a reference manual for all Analog Insydes commands,Part 2 explains dedicated topics of Analog Insydes in a tutorial manner. Although this part isentitled Tutorial, it is not meant to be read entirely at once by the novice user before working withAnalog Insydes. Rather, each chapter can be read separately to get a more detailed insight into thecorresponding topic. For example, Chapter 2.3 describes how to write your own subcircuits andmodels and how to use them during equation setup. However, in the usual application, netlists areimported automatically using the command ReadNetlist, and equations are set up using predefinedmodels of the Analog Insydes model library. Thus, in most cases there is no need to write netlistsand models by hand. Nevertheless, you may encounter a task that requires a special hand-writtendevice model. In this case it is recommended to consult Chapter 2.3 (and perhaps Chapter 2.2 aswell) to learn more about the fine points of Analog Insydes modeling capabilities. For the noviceuser we recommend to read Chapter 2.4, Chapter 2.5, Chapter 2.7, and Chapter 2.9.

    2.1.2 Loading Analog InsydesThe first thing we need to do before we can use any circuit analysis function is to load the AnalogInsydes master package. This file reads in the context AnalogInsydesMain which contains allfunction definitions for working with netlists. In addition, the master package sets up autoloaddeclarations for other Analog Insydes functions which are not defined in the Main context.

    Loading of Analog Insydes is performed by evaluating the command

  • 2.2 Netlists 35

    2.2 Netlists

    2.2.1 The Netlist FormatAnalog Insydes provides functions which can automatically set up several types of circuit equationsfrom the netlist description of a circuit. Netlists are sequences of Mathematica lists encapsulated bythe Analog Insydes command Netlist (Section 3.1.1). There must be one such list, or netlist entry,for each element in a circuit. Netlist entries are not required to be listed in any particular order.

    netlistname =Netlist[

    netlist entry 1,netlist entry 2,

    ]

    A Netlist object is the Analog Insydes data structure for representing flat netlists. For hierarchicalcircuit descriptions using subcircuits, the Circuit object is used which is discussed in Chapter 2.3.

    For a simple example refer to the voltage divider circuit shown in Figure 2.1.

    V0

    R2

    R1

    1

    2

    Figure 2.1: Voltage divider circuit

    An Analog Insydes netlist desribing the circuit looks as follows:

    In[1]:=

  • 36 2. Tutorial

    The Netlist command returns a raw netlist object which prints its content in short notation, i.e.only the number of elements is shown. To get a more detailed view of the netlist content use thecommand DisplayForm:

    In[3]:= DisplayForm[voltageDivider]

    Out[3]//DisplayForm= Netlist HRaw, 3 EntriesL:8V0, 81, 0

  • 2.2 Netlists 37

    V1

    gm*V1

    R

    1

    2 6

    4 out1

    out2

    Figure 2.2: Resistor and voltage-controlled current source

    For a two-terminal element, such as a resistor (Section 4.2.1), the connectivity list must containexactly two node identifiers whereas a controlled source, i.e. a four-terminal element, requires fournode identifiers: two for the controlling branch and two for the controlled branch. Netlist entries forthe resistor and the voltage-controlled current source (Section 4.2.13) shown in Figure 2.2 thus haveto be written as follows:

    {R1, {1, 2}, R}{VC2, {4, 6, out1, out2}, gm}

    Reference Directions for Currents and Voltages

    In Analog Insydes netlists, the order of the nodes in a connectivity list determines the positivereference direction for both the associated branch voltage and the branch current. In other words,the reference directions for voltages and currents always have the same orientation.

    V0

    I$V0

    2

    1

    Figure 2.3: Voltage source, reference directions for branch voltage and current

    In Figure 2.3, the positive terminal of the voltage source (Section 4.2.10) is connected to node 1,and the negative terminal is connected to node 2. The corresponding netlist entry then defines thepositive reference direction for the branch voltage as well as for the current I$V0 to be oriented fromnode 1 to node 2:

  • 38 2. Tutorial

    {V0, {1, 2}, V0}

    Hence, a positive value for the branch current, I$V0 > 0, denotes a current flowing from node 1 tonode 2. So whenever a circuit analysis yields a negative result for I$V0 there is nothing wrong. Thisjust means that the current is in fact flowing into the opposite direction, i.e. from node 2 to node 1.

    Element Values

    As opposed to SPICE, the values of circuit elements need not be purely numerical quantities. SinceMathematica is capable of performing mathematical calculations symbolically, the element values mayalso be any symbolic or mixed symbolic/numeric expressions. In the voltage-divider example (seeFigure 2.1) we assigned a numerical value of 10 (Volts) to the voltage source whereas we used thesymbolic values R1 and R2 for the two resistors. (Note that you dont have to specify any unitslike Volts for numerical values.) In this case, the symbols used for the values of the resistors areidentical to the reference designators, but we could also have supplied any other valid Mathematicaexpression.

    V0

    R2=2*R

    R1=R

    1

    out

    Figure 2.4: Voltage divider circuit with different node names and resistor values

    Lets make use of some of the facts presented in the preceding paragraphs by renaming node 2 ofthe voltage divider to out, arbitrarily making the assignments R1 = R and R2 = 2 R, and rewritingthe netlist accordingly (see Figure 2.4):

    In[4]:= voltageDivider2 =Netlist[

    {V0, {1, 0}, 10},{R1, {1, out}, R},{R2, {out, 0}, 2 R}

    ]

    Out[4]= Netlist@Raw, 3D

  • 2.2 Netlists 39

    2.2.2 Circuit Elements

    Element Types

    Having learned the basics about the netlist format we will now take a look at the circuit elementtypes (see Chapter 4.2) which are supported by Analog Insydes. The names of all available typesare stored in a globally accessible list named ElementTypes (Section 3.1.5):

    In[5]:= ElementTypes

    Out[5]=8Resistor, Conductance, Admittance, Impedance, Capacitor,Inductor, CurrentSource, VoltageSource, CCCSource, CCVSource,VCCSource, VCVSource, Nullator, Norator, Fixator, OpAmp, OTAmp,ABModel, OpenCircuit, ShortCircuit, SignalSource, Amplifier,Integrator, Differentiator, TransmissionLine, TransferFunction value1, option2 > value2, }

    There are several value-field option keywords which Analog Insydes understands (see Section 3.1.4):Value, Symbolic, Type, Pattern, InitialCondition, Model (Section 3.2.1), and Subcircuit(Section 3.2.2). Their meanings will be discussed in the following subsections.

    Value

    If the value field is written in its general sequence-of-options form then all of its components must beoptions. This necessitates an option which specifies the value of the circuit element, namely Value(see Section 3.1.4). With the Value option we can rewrite a netlist entry such as

    {R1, {1, 2}, R1}

    in the following semantically equivalent general form:

    {R1, {1, 2}, Value > R1}

    Of course, as long as the value field contains no more information than only the element value thesimple form is the preferred form. Note that if the value field is written in option form, then theValue option must be present.

    Symbolic

    The Symbolic option (see Section 3.1.4) is closely related to the Value option. It allows you tospecify an alternative symbolic element value in addition to a numerical value given as argument tothe Value option, for instance:

    {R1, {1, 2}, Value > 100, Symbolic > R1}

    By default, circuit equations are set up using the arguments of the Value options as element values,but CircuitEquations (Section 3.5.1) can be instructed to use the symbolic values instead wherever

  • 44 2. Tutorial

    the Symbolic option is given. This allows for assigning both a numerical as well as a symbolic valueto a circuit element. You will be able to assess the value of this feature better once you have learnedmore about the topics described in Chapter 2.3 and Chapter 2.8.

    Type

    The value field option Type (see Section 3.1.4) allows you to specify the type of an element explicitly,thus overriding the automatic type detection from an elements reference designator. The argumentto the Type option must be the full name of a circuit element type supported by Analog Insydes(see Chapter 4.2). The available types are listed in the global variable ElementTypes. Using theType option we could write a netlist entry for a resistor in the following way even though the nameShunt does not begin with the type tag R.

    {Shunt, {1, 2}, Type > Resistor, Value > R1}

    Moreover, as Analog Insydes generates voltage and current identifiers (see Section 2.4.1) by addingthe prefixes "V$" and "I$" to the reference designators, the Type option gives us some more influenceon the names of voltages and currents. In this example, the resistor current would be namedI$Shunt, whereas it would be named I$R1 for the netlist entries from the previous two subsections.

    The example below shows a more convincing application of the Type option. Assume that you havean amplifier circuit with an output load connected between nodes out and ground, and that youwish to calculate the amplifiers frequency responses for both resistive and capacitive loads. Youcould, of course, write two separate netlists for this purpose. On the other hand, the Type optionoffers you the alternative to set up only one single netlist but with a variable load type:

    amplifier =Netlist[

    {Load, {out, 0}, Type > loadtype, Value > loadval},

    ]

    Then, by replacing the type variable with a concrete type name, you can set up circuit equations fora particular type of load, e.g. for a capacitor:

    CircuitEquations[amplifier /. {loadtype > Capacitor, loadval > CL}]

    Note that in both cases the identifier for the load current will be I$Load, regardless of the loadelement type eventually selected.

    Finally, the Type option helps us to correct a frequently made mistake, which usually occurswhen a netlist contains a supply voltage source named VCC. If we relied on automatic typedetection from the reference designator VCC, Analog Insydes would give us the error message"Netlist::numnode: Expected 4 nodes but received 2 for VCCSource VCC". The reason for thiserror is that VC is the type tag for voltage-controlled current sources, so Analog Insydes interpretsVCC as (VC)C and not as a voltage source V(CC). This problem can be easily solved by means of theType directive:

  • 2.2 Netlists 45

    {VCC, {1, 0}, Type > VoltageSource, Value > VCC}

    Pattern

    The Pattern option (see Section 3.1.4) can be used only in conjunction with two-terminal immittances,i.e. impedance and admittance elements such as resistors (Section 4.2.1), conductances (Section 4.2.2),capacitors (Section 4.2.5), and inductors (Section 4.2.6). With this directive you can explicitly choosewhether the contribution of an immittance element to a system of modified nodal equations isentered into the matrix using the fill-in pattern for admittances or the pattern for impedances. Thetwo associated values of the Pattern option are Impedance and Admittance.

    When setting up modified nodal equations, Analog Insydes automatically converts impedanceelements such as resistors into their admittance equivalents in order to keep the matrix size assmall as possible. In other words, a resistor with the value R will be treated as an admittancewith the value 1/R and will be entered into the modified nodal matrix using the fill-in patternfor admittances (see the example in Section 2.2.3). However, if we are interested in computing thecurrent through a particular resistor it would be better to use the fill-in pattern for impedancesas this would augment the MNA system by the corresponding branch current. So if we want tocalculate the load current of the above-mentioned amplifier using the MNA formulation we wouldhave to select the impedance pattern for the load resistor in order to introduce the branch currentI$Load:

    {Load, {out, 0}, Type > Resistor, Value > RL,Pattern > Impedance}

    Lets experiment with some value-field options using the CCCS circuit from Section 2.2.2 (seeFigure 2.7). We replace the resistor RL by a variable load type and select the fill-in pattern forimpedances.

    In[15]:= cccsCircuit2 =Netlist[

    {V0, {1, 0}, V0},{RB, {1, 3}, RB},{CM, {1, 2}, CM},{CC1, {3, 0, 2, 0}, beta},{Load, {2, 0}, Type > loadtype, Value > loadval,

    Pattern > Impedance}]

    Out[15]= Netlist@Raw, 5D We choose a resistive load with the symbolic value RL and set up the MNA equations. Due to thePattern directive, the load current I$Load now appears as an additional variable for which we cansolve directly.

  • 46 2. Tutorial

    In[16]:= cccseqs2 = CircuitEquations[cccsCircuit2 /. {loadtype > Resistor, loadval > RL}];

    DisplayForm[cccseqs2]

    Out[17]//DisplayForm=i

    k

    jjjjjjjjjjjjjjjjjjjjjjjj

    1RB + CM s -CM s -1RB 1 0 0

    -CM s CM s 0 0 beta 1

    - 1RB 01RB 0 1 0

    1 0 0 0 0 00 0 1 0 0 00 -1 0 0 0 RL

    y

    {

    zzzzzzzzzzzzzzzzzzzzzzzz.

    ikjjjjjjjjjjjjjjjjjjjjj

    V$1V$2V$3I$V0IC$CC1I$Load

    y{zzzzzzzzzzzzzzzzzzzzz ==

    ikjjjjjjjjjjjjjjjjjjjjj000V000

    y{zzzzzzzzzzzzzzzzzzzzz

    In[18]:= Solve[cccseqs2, I$Load]

    Out[18]= 99I$Load - Hbeta - CM RB sL V0RB H1 + CM RL sL ==

    Next, we select a capacitive load CL and solve for the load current again.

    In[19]:= cccseqs3 = CircuitEquations[cccsCircuit2 /. {loadtype > Capacitor, loadval > CL}];

    DisplayForm[cccseqs3]

    Out[20]//DisplayForm=i

    k

    jjjjjjjjjjjjjjjjjjjjjjjjjj

    1RB + CM s -CM s -1RB 1 0 0

    -CM s CM s 0 0 beta 1

    - 1RB 01RB 0 1 0

    1 0 0 0 0 00 0 1 0 0 0

    0 -1 0 0 0 1CL s

    y

    {

    zzzzzzzzzzzzzzzzzzzzzzzzzz.

    ikjjjjjjjjjjjjjjjjjjjjj

    V$1V$2V$3I$V0IC$CC1I$Load

    y{zzzzzzzzzzzzzzzzzzzzz ==

    ikjjjjjjjjjjjjjjjjjjjjj000V000

    y{zzzzzzzzzzzzzzzzzzzzz

    In[21]:= Solve[cccseqs3, I$Load]

    Out[21]= 99I$Load CL H-beta + CM RB sL V0HCL + CML RB ==InitialCondition

    With the InitialCondition option (see Section 3.1.4), you can specify initial currents and voltagesfor the dynamic elements Inductor (Section 4.2.6) and Capacitor (Section 4.2.5), respectively. If noinitial condition is given explicitly, it will be assumed to be zero (AC analysis) or will be calculatedautomatically from the operating-point data (transient analysis).

    As an example, we set an initial capacitor voltage of V0 for the netlist entry C1 of the following filtercircuit:

    In[22]:= filter =Netlist[

    {V1, {1, 0}, V1},{R1, {1, 2}, R1},{C1, {2, 0}, Value > C1, InitialCondition > V0}

    ]

    Out[22]= Netlist@Raw, 3D

  • 2.2 Netlists 47

    In[23]:= filtereqs = CircuitEquations[filter,InitialConditions > Automatic];

    DisplayForm[filtereqs]

    Out[24]//DisplayForm=ikjjjjjjjjj

    1R1 -1R1 1

    - 1R11R1 + C1 s 0

    1 0 0

    y{zzzzzzzzz.ikjjjjjj

    V$1V$2I$V1

    y{zzzzzz == ikjjjjjj0

    C1 V0V1

    y{zzzzzzSee Section 2.7.5 for a description of initial condition handling during equation setup.

    Model, Subcircuit

    The purpose of the Model and Subcircuit directives is to mark a netlist entry as being a referenceto a device model or subcircuit definition. Chapter 2.3 deals with the details.

  • 48 2. Tutorial

    2.3 Circuits and Subcircuits

    2.3.1 Circuits, Netlists, and Subcircuits

    Hierarchical Netlist Entry

    The flat netlist representation we used so far is usually sufficient for small analysis tasks with nomore than a handful of circuit elements. Now imagine that we want to analyze active circuits likethe transistor amplifier shown in Figure 3.1, and want to do several transfer function calculationswith different transistor models. It would be rather inconvenient if we had to edit the netlistevery time we select another semiconductor device model. Therefore, Analog Insydes provides ahierarchical netlist entry scheme which allows us to regard the transistor object as a black box withthree terminals and lets us write a netlist for the circuit containing only a reference to the box butno specification of whats inside. Separately from this netlist, we can define one or more concreterealizations of the box in the form of equivalent (sub)circuits and let Analog Insydes automaticallyreplace the reference by one of the subcircuit definitions.

    V1 R2 RE

    R1

    Q1

    RC

    VCC

    Vout

    1

    2

    4

    3

    Figure 3.1: Common-emitter transistor amplifier

    The Circuit Object

    When structured hierarchically, a circuit description comprises a top-level netlist with subcircuit ormodel references, and a set of subcircuit definitions.

  • 2.3 Circuits and Subcircuits 49

    Throughout this text, the terms "subcircuit" and "model" shall be used as synonyms because small-signaldevice models are effectively implemented as subcircuits composed of circuit primitives like resistors andcontrolled sources.

    Keeping all netlist and subcircuit components of a circuit together is the task of the Analog Insydesdata structure Circuit (Section 3.1.2), whose content sequence may be any number of netlist andsubcircuit definitions.

    Circuit[Netlist[top-level netlist with subcircuit references],Model[subcircuit/model definition], Model[subcircuit/model definition]

    ]

    A Circuit object additionally may contain model parameters and global parameters, seeModelParameters (Section 3.1.10) and GlobalParameters (Section 3.1.11).

    When a Circuit object is defined, it is printed in short notation only. To view the entire circuitstructure use the command DisplayForm.

    2.3.2 Defining Subcircuits and Device Models

    The Model Object

    Lets start to work with hierarchically structured netlists by learning how to define subcircuits usingthe Analog Insydes objects Model (Section 3.2.1) or Subcircuit (Section 3.2.2). This section describeshow to write netlist-based models or subcircuits. Section 2.6.2 shows how to write equation-basedmodels.

    Model and Subcircuit are semantically equivalent symbols. In fact, Subcircuit is just an alias namefor Model. You may want to use both names in a Circuit if you wish to give visual cues as to whichsubcircuits represent device models by using the Model directive for these and the Subcircuit object for allother subcircuits.

    The Model object takes several arguments which must all be written in Mathematicas option syntaxkeyword > value. Four of the arguments must always be present whereas the remaining ones areoptional or have default values. Below, the optional arguments are printed in slanted typewriterfont. For now, we will restrict ourselves to the discussion of the required arguments. The optionalones will be introduced later in a step-by-step fashion, as this will help you to better understandwhy and when they are needed.

  • 50 2. Tutorial

    Model[Name > subcircuit class name,Selector > selector,Scope > scope,Ports > {port nodes},Parameters > {parameters},Defaults > {defaults},Translation > {parameter translation rules},Definition > Netlist[subcircuit netlist]

    ]

    The value of the Name argument must be a symbol which identifies an entire group, or class, ofdifferent subcircuit implementations of a non-primitive object, such as a transistor. The value of theSelector argument, which must also be a symbol, then selects one particular member from thisclass. The Ports argument defines the port nodes of a subcircuit structure. Its value must be a listof the identifiers of the subcircuit nodes which serve as external connection points.

    Finally, the netlist of the subcircuit must be specified by means of the Definition argument. Thereis no built-in limit for the nesting depth of subcircuits, so the netlist may itself contain referencesto other Model definitions. However, you may only reference but not define subcircuits withinsubcircuits.

    Small-Signal Transistor Models

    To fully understand this abstract description of the Model function, lets examine a practical example.Assume that we want to calculate the AC voltage transfer function of the common-emitter amplifierfrom Section 2.3.1 (see Figure 3.1) and want to replace the transistor by either one of the twosmall-signal equivalent circuits shown in Figure 3.2.

  • 2.3 Circuits and Subcircuits 51

    IBBB

    EE

    CC

    EE

    RB RBbeta*IB beta*IB

    X XIB

    CM

    R0

    C

    B

    E

    Figure 3.2: Different transistor small-signal models: simple (left), dynamic (right)

    Both circuits have in common that they represent the same object, namely an NPN transistor. Thus,they are two members of a subcircuit class we shall name NPNTransistor:

    Name > NPNTransistor

    Within this class, each member must have a unique selector by which it can be identified. We willdenote the simple small-signal model on the left-hand side of Figure 3.2 by

    Selector > ACsimple

    and the one on the right-hand side by

    Selector > ACdynamic

    From now on we will adopt the notation name/selector for denoting a subcircuit definition. Forinstance, we will refer to the model defined with Name > NPNTransistor and Selector > ACsimpleas NPNTransistor/ACsimple. Both subcircuits contain four nodes: B, C, E, and X, where B, C, and Erepresent the transistors base, collector, and emitter terminal respectively. The node X is an internalsubcircuit node which is needed for properly connecting the controlling branch of the current-controlled current source in series with the base resistor RB (see also Section 2.2.2). Therefore, wedeclare only B, C, and E as port nodes of the subcircuits in order to make X invisible from the outside:

    Ports > {"B", "C", "E"}

    Note that we use strings to denote the port nodes instead of symbols. Although this requires somemore typing this is the recommended way for specifying nodes: If we would have used symbolsin the above example, the symbol for the emitter node E could have been mixed up with theMathematica symbol E which denotes the exponential constant e.

  • 52 2. Tutorial

    Connections to subcircuits can only be made through designated port nodes. Any attempt to interfacedirectly with an internal node will cause the generation of an error message when the netlist hierarchyis flattened. However, there is one exception: since the ground node (0) is considered to be global,elements in subcircuit definitions may be connected directly with global ground without the needto specify 0 as a port node. In fact, 0 cannot be used as port node identifier in Analog Insydes.Finally, all which remains to do is to write the netlists of the two subcircuits and set up the Modeldefinitions as follows:

    Model[Name > NPNTransistor,Selector > ACsimple,Ports > {"B", "C", "E"},Definition >

    Netlist[{RB, {"X", "E"}, RB},{CC, {"B", "X", "C", "E"}, beta}

    ]]

    Model[Name > NPNTransistor,Selector > ACdynamic,Ports > {"B", "C", "E"},Definition >

    Netlist[{RB, {"X", "E"}, RB},{CM, {"B", "C"}, CM},{CC, {"B", "X", "C", "E"}, beta},{RO, {"C", "E"}, RO}

    ]]

    In this example, we used node names for all subcircuit nodes given by strings ("B", "C", "E", "X") butwe could have used positive integers just as well. However, using symbolic names is usually preferable. Thereason is that during subcircuit expansion all internal nodes of subcircuit objects will be instantiated andlabeled with unique identifiers such as X$Q1, which are automatically generated from the node names and thereference designator of the subcircuit instance. If an internal node identifier is an integer, e.g. 2, the generatedinstance identifier 2$Q1 could be confused easily with the product 2*$Q1.

    2.3.3 Referencing Subcircuits

    The Netlist Entry Format for Subcircuit References

    Subcircuits or device models defined with the Model command can be referenced from a netlist on ahigher hierarchy level by a netlist entry whose value field contains the options Model and Selector:

  • 2.3 Circuits and Subcircuits 53

    {subcircuit instance name, {port connections},Model > subcircuit class name, Selector > selector}

    To reference a subcircuit object (see Section 3.1.8) the subcircuit class name and the selector mustbe the same identifiers as those given as arguments to the Name and Selector parameters in thecorresponding Model statement. The subcircuit instance name may be any symbol or string which canserve as the unique identifier of this instance of the subcircuit object.

    You can even use subcircuit instance names which begin with an element type tag known to Analog Insydes.A subcircuit reference with an instance identifier such as RX will never be confused with a resistor becausethe reference will have been expanded before circuit equations are set up.

    A netlist entry which marks a reference to an instance of the NPN transistor modelNPNTransistor/ACsimple , using the instance identifier Q1, would be written as follows:

    {Q1, {connectivity},Model > NPNTransistor, Selector > ACsimple}

    This line does not yet specify how the instance Q1 of NPNTransistor/ACsimple should be embeddedinto the surrounding circuit structure, i.e. which nodes of the latter should be connected to thesubcircuits port nodes. Associating external nodes with subcircuit port nodes is done by means ofa special format of the connectivity field. All entries of this field must be written as rules of the form

    external node > subcircuit port node

    In our common-emitter amplifier (see Figure 3.1 in Section 2.3.1), node 1 of the top-level netlist isconnected to the base node "B" of the transistor, node 3 to the collector node "C", and node 4 to theemitter node "E", resulting in a node-to-port mapping such as this:

    {Q1, {1 > "B", 3 > "C", 4 > "E"},Model > NPNTransistor, Selector > ACsimple}

    Since the mapping is defined by names, the relative positions of the entries in the connectivity fieldare not important. We could have written the connectivity field as

    {3 > "C", 1 > "B", 4 > "E"}

    equally well.

    A Hierarchical Netlist Description of the Amplifier

    Having learned how to define and how to make references to subcircuits (see Section 3.1.8), we cannow write a hierarchically structured netlist for the common-emitter amplifier from Section 2.3.1 (seeFigure 3.1).

    In[1]:=

  • 54 2. Tutorial

    In[2]:= commonEmitterAmplifier=Circuit[

    Netlist[{V1, {1, 0}, inputVoltage},{VCC, {2, 0}, Type > VoltageSource,

    Value > supplyVoltage},{R1, {2, 1}, R1},{R2, {1, 0}, R2},{RC, {2, 3}, RC},{RE, {4, 0}, RE},{Q1, {1 > "B", 3 > "C", 4 > "E"},

    Model > NPNTransistor, Selector > BJTModel}],

    Model[Name > NPNTransistor,Selector > ACsimple,Ports > {"B", "C", "E"},Definition >

    Netlist[{RB, {"X", "E"}, RB},{CC, {"B", "X", "C", "E"}, beta}

    ]],

    Model[Name > NPNTransistor,Selector > ACdynamic,Ports > {"B", "C", "E"},Definition >

    Netlist[{RB, {"X", "E"}, RB},{CM, {"B", "C"}, CM},{CC, {"B", "X", "C", "E"}, beta},{RO, {"C", "E"}, RO}

    ]]

    ]

    Out[2]= Circuit

    Note that in the top-level netlist of this circuit description we used a generic subcircuit selectorBJTModel and not ACsimple or ACdynamic. This allows us to select the model at run time byreplacing BJTModel with ACsimple or ACdynamic just before the subcircuit hierarchy is expanded.In addition, for reasons which will become apparent in the next section, we have used the variablesinputVoltage and supplyVoltage to denote the values of the voltage sources V1 and VCC.

    Remember that the Type directive in the value field of VCC prevents Analog Insydes from falsely interpretingthe netlist entry as belonging to a voltage-controlled current source.

  • 2.3 Circuits and Subcircuits 55

    2.3.4 Subcircuit Expansion

    The ExpandSubcircuits Command

    Before we can set up circuit equations we must resolve all references to subcircuit objects. Subcircuitinstantiation and flattening the netlist is done by the command ExpandSubcircuits (Section 3.4.1)which accepts a Circuit (Section 3.1.2) or a Netlist (Section 3.1.1) object as argument and returnsa flat netlist object.Such a flat netlist is similar to a Netlist, except that it is guaranteed to containonly circuit primitives and no subcircuit references.

    Please note that subcircuit expansion is taken care of automatically by CircuitEquations, so that there isusually no need to call ExpandSubcircuits explicitly, except for inserting models into the global data base.Section 2.3.6 deals with this topic.

    We can now use ExpandSubcircuits to generate one flat netlist of the common-emmitter amplifierfrom Section 2.3.1 (see Figure 3.1) for each of the two transistor models we have defined. As thecircuit description is still generic we must first personalize it by replacing its variables according tothe specific analysis task. Our task was to calculate the small-signal voltage transfer function, sobesides choosing an appropriate transistor model we must set the value of the supply voltage sourceVCC to zero and the value of the input signal source to 1 (see Section 2.9.2). Then, the node voltageat the output node 3 will be identical to the transfer function. We apply these variable settings to thenetlist with the Mathematica command ReplaceAll (or /. in short notation) and pass the resultingnetlist to ExpandSubcircuits.

    In[3]:= flatAmpSimple = ExpandSubcircuits[commonEmitterAmplifier /.

    {supplyVoltage > 0, inputVoltage > 1,BJTModel > ACsimple}];

    DisplayForm[flatAmpSimple]

    Out[4]//DisplayForm=Netlist HFlat, 8 EntriesL:8V1, 81, 0

  • 56 2. Tutorial

    In[5]:= flatAmpDyn = ExpandSubcircuits[commonEmitterAmplifier /.

    {supplyVoltage > 0, inputVoltage > 1,BJTModel > ACdynamic}];

    DisplayForm[flatAmpDyn]

    Out[6]//DisplayForm=Netlist HFlat, 10 EntriesL:8V1, 81, 0

  • 2.3 Circuits and Subcircuits 57

    In[7]:= eqAmpSimple = CircuitEquations[flatAmpSimple];DisplayForm[eqAmpSimple]

    Out[8]//DisplayForm=i

    k

    jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

    1R1 +1R2 -

    1R1 0 0 0 1 0 1

    - 1R11R1 +

    1RC -1RC 0 0 0 1 0

    0 - 1RC1RC 0 0 0 0 beta

    0 0 0 1RB +1RE -

    1RB 0 0 -beta

    0 0 0 - 1RB1RB 0 0 -1

    1 0 0 0 0 0 0 00 1 0 0 0 0 0 01 0 0 0 -1 0 0 0

    y

    {

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.

    i

    k

    jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

    V$1V$2V$3V$4

    V$X$Q1I$V1I$VCC

    IC$CC$Q1

    y

    {

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz==

    i

    k

    jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

    00000100

    y

    {

    zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzTo compute the small-signal voltage transfer function we must solve the MNA equations for thenode voltage V$3 at the output node 3.

    In[9]:= v3 = Solve[eqAmpSimple, V$3]

    Out[9]= 99V$3 - beta RCRB + RE + beta RE

    ==The following command extracts the symbolic transfer function expression from the return value ofSolve.

    In[10]:= vtf = V$3 /. First[v3]

    Out[10]= -beta RC

    RB + RE + beta RE

    Now, lets see what happens when we make the (usually realistic) assumption that the transistorcurrent gain is very large:

    In[11]:= Limit[vtf, beta > Infinity]

    Out[11]= -RCRE

    The above result is indeed identical to the well-known approximate formula for the voltage gain ofa common-emitter amplifier. Doing the same calculations for the other transistor model shall be leftto the reader as an exercise.

  • 58 2. Tutorial

    2.3.5 Subcircuit Parameters

    Instantiating Element Values in Subcircuit Definitions

    Al