Workbook
Workbook
Workbook
Work Book
Thierry Scordilis Mike Brinson Gunther Kraut Stefan Jahn Chris Pitcher
Copyright Copyright Copyright Copyright Copyright c c c c c 2005 Thierry Scordilis <thierry.scordilis@free.fr> 2006, 2007 Mike Brinson <mbrin72043@yahoo.co.uk> 2006 Gunther Kraut <gn.kraut@online.de> 2005, 2006, 2007 Stefan Jahn <stefan@lkcc.org> 2005 Chris Pitcher <ozjp@chariot.net.au>
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled GNU Free Documentation License.
Contents
1 General Design Flow 2 Getting started with Qucs 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Tool suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Setting up schematics . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 DC simulation - A voltage divider . . . . . . . . . . . . . . 2.3.2 DC simulation - Characteristics of a transistor . . . . . . . 2.3.3 AC simulation - Transit frequency of a bipolar transistor . 2.3.4 AC simulation - A simple RC highpass . . . . . . . . . . . 2.3.5 Transient simulation - Amplication of a bipolar transistor 2.3.6 S-parameter simulation - Transit frequency of a BJT . . . 2.3.7 S-parameter and AC simulation - A Bessel band-pass lter 10 11 11 13 14 16 31 40 44 47 49 52 58 58 59 59 60 60 62 68 72 72 73 74 75 77 80 84 84 84 84 85
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
3 Understanding RF Data Sheet Parameters 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 DC specications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Maximum ratings and thermal characteristics . . . . . . . . . . . . . . . . 4 DC 4.1 4.2 4.3 Analysis, Parameter Sweep and Device Models DC Static Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . When Things Vary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Models and Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 Getting Started with Digital Circuit Simulation 5.1 Introduction . . . . . . . . . . . . . . . . . . 5.2 Simulating simple digital circuits . . . . . . 5.2.1 Notes on drawing digital schematics . 5.3 VHDL code generated by Qucs . . . . . . . 5.4 Truth tables . . . . . . . . . . . . . . . . . . 5.5 Digital subcircuits . . . . . . . . . . . . . . . 5.6 Building a digital component library . . . . 5.6.1 Logic zero . . . . . . . . . . . . . . . 5.6.2 Logic one . . . . . . . . . . . . . . . 5.6.3 G2bit - 2 bit pattern generator . . . 5.6.4 G4bit - 4 bit pattern generator . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . .
5.6.5 MUX2to1 - 2 input to 1 output multiplexer . . . . . . . . . . . . . 5.6.6 MUX4to1 - 4 input to 1 multiplexer . . . . . . . . . . . . . . . . . . 5.6.7 2 bit adder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7 Subcircuit VHDL code generated by Qucs . . . . . . . . . . . . . . . . . . 5.7.1 Gen2bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7.2 2 bit adder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.7.3 Notes on subcircuit VHDL generation . . . . . . . . . . . . . . . . . 5.8 Subcircuit nesting: A more complex design example . . . . . . . . . . . . . 5.8.1 4 bit RTL design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9 Update number one: May 2006 . . . . . . . . . . . . . . . . . . . . . . . . 5.9.1 Bugs, corrections and small changes to the Qucs digital simulation code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9.2 New digital simulation features . . . . . . . . . . . . . . . . . . . . 5.9.3 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9.4 Using the Qucs VHDL editor . . . . . . . . . . . . . . . . . . . . . 5.9.5 Linking VHDL entity-architecture models to Qucs schematic device symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.9.6 Generating VHDL code from Qucs schematic drawings . . . . . . . 5.10 Update number two: September 2006 . . . . . . . . . . . . . . . . . . . . . 5.10.1 Simulating VHDL code using Qucs and FreeHDL. . . . . . . . . . . 5.10.2 VHDL predened packages and libraries. . . . . . . . . . . . . . . . 5.10.3 VHDL simulation code structures. . . . . . . . . . . . . . . . . . . . 5.10.4 VHDL data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.10.5 An example VHDL simulation employing integer signals. . . . . . . 5.10.6 Multivalued logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.10.7 Run debugging of VHDL simulation code. . . . . . . . . . . . . . . 5.10.8 Testing digital systems using test vectors stored on disk. . . . . . . 5.11 End note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Transient Domain Flip-Flop Models for Mixed-Mode Simulation 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Latches and ip-ops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 The gated D latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.4 Edge-triggered D type ip-op . . . . . . . . . . . . . . . . . . . . . . . . . 6.5 The edge-triggered JK ip-op . . . . . . . . . . . . . . . . . . . . . . . . . 6.6 The edge-triggered T ip-op . . . . . . . . . . . . . . . . . . . . . . . . . 6.7 Two example digital circuits . . . . . . . . . . . . . . . . . . . . . . . . . . 6.8 VHDL code for the transient domain ip-op models . . . . . . . . . . . . 6.9 Generating a library of mixed-mode digital components . . . . . . . . . . . 6.10 Digital component propagation time delays and transient simulation numerical stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.11 Mixed-mode example simulations . . . . . . . . . . . . . . . . . . . . . . . 6.12 End Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86 87 88 88 88 89 90 91 92 96 96 97 99 100 108 113 122 123 126 126 129 130 130 138 146 152 153 153 153 154 157 159 162 164 168 171 172 174 182
7 Modelling Operational Ampliers 183 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 7.2 The Qucs built-in operational amplier model . . . . . . . . . . . . . . . . 183 7.3 Adding features to the Qucs OP AMP model . . . . . . . . . . . . . . . . . 189 7.4 Modular operational amplier macromodels . . . . . . . . . . . . . . . . . 189 7.5 A basic AC OP AMP macromodel. . . . . . . . . . . . . . . . . . . . . . . 190 7.5.1 The input stage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 7.5.2 Voltage gain stage 1. . . . . . . . . . . . . . . . . . . . . . . . . . . 193 7.5.3 Derivation of voltage gain stage 1 transfer function . . . . . . . . . 193 7.5.4 Output stage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 7.5.5 A subcircuit model for the basic AC OP AMP macromodel . . . . . 195 7.6 A more accurate OP AMP AC macromodel . . . . . . . . . . . . . . . . . 199 7.6.1 Derivation of voltage gain stage 2 transfer function. . . . . . . . . . 199 7.6.2 Simulating OP AMP open loop dierential gain . . . . . . . . . . . 200 7.7 Adding common mode eects to the OP AMP AC macromodel . . . . . . 202 7.7.1 Simulating OP AMP common-mode eects . . . . . . . . . . . . . . 203 7.8 Large signal transient domain OP AMP macromodels . . . . . . . . . . . . 207 7.8.1 Slew rate macromodel derivation . . . . . . . . . . . . . . . . . . . 207 7.8.2 Modelling OP AMP overdrive and output voltage limiting . . . . . 211 7.8.3 Modelling OP AMP output current limiting . . . . . . . . . . . . . 212 7.9 Obtaining OP AMP macromodel parameters from published device data . 217 7.10 More complete design examples. . . . . . . . . . . . . . . . . . . . . . . . . 217 7.10.1 Example 1: State variable lter design and simulation . . . . . . . . 217 7.10.2 Example 2: Sinusoidal signal generation with the Wien bridge oscillator219 7.11 Update number one: March 2007 . . . . . . . . . . . . . . . . . . . . . . . 228 7.11.1 Building a library component for the modular OP AMP macromodel 228 7.11.2 Changing model parameters: use of the SPICEPP preprocessor . . 228 7.11.3 The Boyle operational amplier SPICE model . . . . . . . . . . . . 230 7.11.4 Model accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 7.11.5 The PSpice modied Boyle model . . . . . . . . . . . . . . . . . . . 239 7.12 Constructing Qucs OPAMP libraries . . . . . . . . . . . . . . . . . . . . . 247 7.13 Extending existing OP AMP models . . . . . . . . . . . . . . . . . . . . . 249 7.14 End note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 8 Modelling the 555 Timer 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 8.2 The Qucs 555 timer model . . . . . . . . . . . . . . 8.2.1 The trigger comparator macromodel . . . . 8.2.2 The threshold comparator macromodel . . . 8.2.3 The digital logic macromodel . . . . . . . . 8.2.4 The 555 timer output amplier macromodel 8.2.5 The discharge switch macromodel . . . . . . 8.3 Published 555 timer test circuits . . . . . . . . . . . 257 257 258 259 260 261 262 263 264
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
8.4
8.5
8.3.1 The 555 timer monostable pulse generator 8.3.2 The 555 timer astable pulse oscillator . . . 8.3.3 Pulse width modulation . . . . . . . . . . 8.3.4 Pulse position modulation . . . . . . . . . Multiple 555 timer simulation examples . . . . . . 8.4.1 Sequential pulse train generation . . . . . 8.4.2 Frequency divider circuit . . . . . . . . . . End note . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
264 267 269 272 273 273 278 281 282 282 282 288 290 290 290 296 296 297 299 303 307 309
9 Qucs Simulation of SPICE Netlists 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.2 The basic SPICE netlist format . . . . . . . . . . . . . . . . . . 9.3 Dening symbols for Qucs SPICE netlist components . . . . . . 9.4 Handling SPICE subcircuits . . . . . . . . . . . . . . . . . . . . 9.4.1 Subcircuit example 1: a multisection LC delay line . . . 9.4.2 Subcircuit example 2: a two section CMOS ring counter 9.5 Limitations when converting SPICE netlists . . . . . . . . . . . 9.6 Extending the SPICE netlist language . . . . . . . . . . . . . . 9.6.1 The SPICEPP preprocessor . . . . . . . . . . . . . . . . 9.7 Circuit template models . . . . . . . . . . . . . . . . . . . . . . 9.8 Building circuit design equations into netlists . . . . . . . . . . . 9.9 Global nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.10 End Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
10 Biasing a BJT Transistor 311 10.1 Graphical methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 10.1.1 Graphical approach shows trade-os . . . . . . . . . . . . . . . . . 313 10.2 Simulation technics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 11 BJT Modeling and Verication 11.1 choice of transistor . . . . . . . . . . 11.2 library creation . . . . . . . . . . . . 11.3 device library verication . . . . . . . 11.4 parasitic description of the package . 11.5 small signal S parameter verication 12 Power Amplier Design 12.1 Field of interest . . . . . . . . 12.2 System consideration . . . . . 12.3 Biasing consideration . . . . . 12.4 Why thermal design ? . . . . 12.4.1 Thermal management 12.5 DC Power dissipation . . . . . 316 316 320 321 324 328 333 333 333 334 337 337 339
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
12.6 Small signal analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 13 Low Noise 13.0.1 13.0.2 13.0.3 13.0.4 13.0.5 13.0.6 13.0.7 Amplier Design System consideration . . . Choice of transistor . . . . library creation . . . . . . DC study . . . . . . . . . SP study . . . . . . . . . . Non linearities study . . . Possible improvement tips 342 342 343 343 344 344 344 344 345 345 345 347 347 347 349 354 356 357 357 357 358 359 359 362 363 364 369 369 379 436 463 463 467 472 480
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
14 Microstrip Design 14.1 10dB Directional Coupler Design . . . 14.1.1 Some boring theory beforehand 14.1.2 Design equations . . . . . . . . 14.1.3 Applying the design equations . 14.1.4 What next? . . . . . . . . . . . 14.1.5 Verication of the design . . . . 14.1.6 Suggested improvements . . . . 14.1.7 Remaining thinkabouts . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
15 Measurement Expressions Reference Manual 15.1 Introduction . . . . . . . . . . . . . . . . . . 15.2 Using Measurement Expressions . . . . . . . 15.2.1 Entering Measurement Expressions . 15.2.2 Changing Measurement Expressions . 15.2.3 Syntax of Measurement Expressions . 15.3 Functions Syntax and Overview . . . . . . . 15.3.1 Functions Reference Format . . . . . 15.3.2 Functions Listed by Category . . . . 15.4 Math Functions . . . . . . . . . . . . . . . . 15.4.1 Vectors and Matrices . . . . . . . . . 15.4.2 Elementary Mathematical Functions 15.4.3 Data Analysis . . . . . . . . . . . . . 15.5 Electronics Functions . . . . . . . . . . . . . 15.5.1 Unit Conversion . . . . . . . . . . . . 15.5.2 Reection Coecients and VSWR . . 15.5.3 N-Port Matrix Conversions . . . . . . 15.5.4 Ampliers . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
16 Component, compact device and circuit modelling using symbolic equations 494 16.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 16.2 Qucs electronic device and circuit modelling . . . . . . . . . . . . . . . . . 494
16.3 Extending circuit simulation capabilities with equations . . . . . . . . . 16.3.1 Low pass active lter design with embedded design equations . . 16.4 Introduction to Qucs subcircuit parameters . . . . . . . . . . . . . . . . 16.5 Building universal macromodels using subcircuits and parameters . . . 16.6 More complex nested subcircuit models . . . . . . . . . . . . . . . . . . 16.7 Introduction to equation dened devices (EDD) . . . . . . . . . . . . . 16.8 The Qucs EDD component . . . . . . . . . . . . . . . . . . . . . . . . . 16.9 Modelling nonlinear resistors . . . . . . . . . . . . . . . . . . . . . . . . 16.10Modelling nonlinear capacitors and inductors . . . . . . . . . . . . . . . 16.11Compact device modelling using EDD . . . . . . . . . . . . . . . . . . 16.12Constructing EDD compact device models and circuit macromodels . . 16.13End Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16.14Appendix A: Qucs constants, operators and functions . . . . . . . . . . 16.15Appendix B: Constructing subcircuits with parameters . . . . . . . . . 16.15.1 Enter the series resonance circuit and add input and output pins 16.15.2 Change the component names to Ls, Cs and Rs . . . . . . . . . 16.15.3 Construct symbol for new subcircuit . . . . . . . . . . . . . . . 16.15.4 Add the names of the subcircuit parameters to the LCR symbol 16.15.5 Test the LCR subcircuit . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
499 500 507 510 516 517 519 522 524 527 535 535 536 538 538 539 540 541 542
Introduction
Important note and warning
You should take into account the fact that this document is written on the y, so some mistakes are still possible, and the author is not responsible for any damage due to the use of this document. This document is intended to be a work book for RF and microwave designers. Our intention is not to provide an RF course, but some touchy RF topics. The goal is to insist on some design rules and work ow for RF desings using CAD programs. This work ow will be handled through dierent chapters on quite dierent subjects.
10
11
Figure 2.1: Qucs has been started On the left hand side you nd the Projects folder opened. Usually the projects folder will be empty if you use Qucs for the rst time. The large area on the right hand side is the schematic area. Above you can nd the menu bar and the toolbars. In the File Application Settings menu the user can congure the language and appearance of Qucs.
12
Figure 2.2: Application setting dialog To take eect of the language and font settings the application must be closed either via the Ctrl + Q shortcut or the File Exit menu entry. Then start Qucs again.
13
a component library, The component library manager holds models for real life devices (e.g. transistors, diodes, bridges, opamps). It can be extended by the user. an attenuator synthesis application, The program can be used to design various types of passive attenuators. a command line conversion program The conversion tool is used by the GUI to import and export datasets, netlists and schematics from and to other CAD/EDA software. The supported le formats as well as usage information can be found on the manpage of qucsconv. Additionally the GUI steers other EDA tools. For digital simulations (via VHDL) the program FreeHDL (see http://www.freehdl.seul.org) is used. And for circuit optimizations ASCO (see http://asco.sourceforge.net) is congured and run.
Figure 2.3: New project dialog Conrm the dialog by pressing the Create button. When done, the project is opened and Qucs switches to the Content tab.
14
Figure 2.4: New empty project has been created In the Content tab you will nd all data related to the project. It contains your schematics, the VHDL les, data display pages, datasets as well as any other data (e.g. datasheets). On the right hand side an untitled and empty schematic window is displayed. Now you can start to edit the schematic. The available components can be found in the Components tab.
15
Figure 2.5: Components tab In g. 2.5 is shown when clicking the Components tab. There are lumped components (e.g. resistors, capacitors), sources (e.g. DC and AC sources), transmission lines (e.g. microstrip, coaxial cable, twisted pair), nonlinear components (e.g. ideal opamp, transistors), digital components (e.g. ip-ops), le components (e.g. Touchstone les, SPICE les), simulations (e.g. AC or DC analysis), diagrams (e.g. cartesian or polar plot) and paintings (e.g. texts, arrows, circles). Each of the components can placed on the schematic by clicking it once, then move the mouse cursor onto the schematic and click again to put it on its nal position. During the mouse move you can right click in order to rotate the component into its nal position. The user can also drag-and-drop the components.
16
Figure 2.6: Components of the voltage divider place in the schematic area Wiring components Now you need to connect the components appropriately. This is done using the wiring tool. You enable the wiring mode either by clicking the wire icon or by pressing the Ctrl + E shortcut. Left clicking on the components ports (small red circles) starts a wire, clicking on a second port nishes the wire. In order to change the orientation of the wire right click it. You can leave the wiring mode by the pressing Esc key.
17
Figure 2.7: Components of the voltage divider appropriately wired For any analogue simulation (including the DC simulation) there is a reference potential required (for the nodal analysis). The ground symbol can be found in the Components tab in the lumped components category. The user can also choose the ground symbol icon or simply press the Ctrl + G shortcut. In the given circuit in g. 2.8 the ground symbol is placed at the negative terminal of the DC voltage source. Placing simulation blocks The type of simulation which is performed must also be placed on the schematic. You choose the DC simulation block which can be found in the Components tab in the simulations category.
18
Figure 2.8: Ground symbol as well as DC simulation in place Labelling wires If you want the voltage between the two resistors (the divided voltage) be output in the dataset after simulation the user need to label the wire. This is done by double clicking the wire and given an appropriate name. Wire labelling can also be issued using the icon in the toolbar, by pressing the Ctrl + L shortcut or by choosing the Insert Wire Label menu entry.
Figure 2.9: Node label dialog The dialog is ended by pressing the Enter key of pressing the Ok button. Now the complete schematic for the voltage divider is ready and can be saved. This can by achieved by choosing the File Save menu entry, clicking the single disk icon or by
19
shortcut.
20
Figure 2.11: Final voltage divider schematic The nal DC voltage divider is shown in g. 2.11. Issuing a simulation The schematic can now be simulated. This is started by choosing the Simulation Simulate menu entry, clicking the simulation button (the gearwheel) or by pressing the F2 shortcut.
21
Figure 2.12: Empty data display after simulation nished After the simulation has been nished the related data display is shown (see g.2.12). Also the Components tab has changed its category to diagrams. Placing diagrams Choose the tabular (list of values) diagram and place it on the data display page. After dropping the tabular, the diagram dialog appears as shown in g. 14.7.
22
Figure 2.13: Diagram dialog By double clicking the divided.V the graph (i.e. values in a tabular plot) is added to the diagram. Beside the node voltage divided.V also the current through the DC voltage source V1.I is available. Only items listed in the dataset list can be put into the graph. Available dataset items Depending on the type of simulation the user performed you nd the following types of items in the dataset. node.V DC voltage at node node name.I DC current through component name node.v AC voltage at node node name.i AC current through component name node.vn AC noise voltage at node node name.in AC noise current through component name node.Vt transient voltage at node node name.It transient current through component name S[1,1] S-parameter value
23
Please note that all voltages and currents are peak values and all noise voltages are RMS values at 1Hz bandwidth.
Figure 2.14: Diagram dialog with the node voltage added Depending on the type of graph you have various options to choose for the graph. For a tabular graph there is the the number precision as well as type of number notation (important for complex values). Press the Ok button to close the dialog.
24
Figure 2.15: Data display with tabular graph In the tabular graph you see now the value of the node voltage divided.V which is 0.5V. That was expected since the values of the resistors are equally sized and the DC voltage source produces 1V. Congratulations! You made your rst successful simulation using Qucs. Changing component properties If you want to change the resistor ratio then switch back to your schematic either by clicking on the divider.sch tab, by pressing the F4 shortcut or by choosing the Simulation View Data Display/Schematic menu entry. Afterwards double click the R1 resistor. This opens the component property dialog shown in g. 2.16.
25
Figure 2.16: Component property dialog for the R1 resistor In the component property dialog all the properties of a given component can be edited. A short description is given as well as there is a checkbox for each property display in schematic which can be used to add the property name and value on the schematic (or to hide it). Allowed property values For component values either standard (1000), scientic (1e-3) or an engineering (1k) number notation can be chosen. Some units are also allowed. The units are Ohm resistance / s time / Seconds S conductance / Siemens K temperature / Kelvin H inductance / Henry F capacitance / Farad Hz frequency / Hertz V voltage / Volt A current / Ampere W power / Watt m length / Meter (not usable standalone, see paragraph below)
26
The available engineering suxes are dBm 10 log (x/0.001) dB 10 log (x) T 1012 G 109 M 106 k 103 m 103 u 106 n 109 p 1012 f 1015 a 1018 Please note that all units and engineering suxes are case sensitive and also note the conict in m. When specifying one millimeter you can use 1mm. One meter (1m) cannot be specied and will always be interpreted as one milli (engineering notation). Now you can change the resistor value to 1, see g. 2.17.
Figure 2.17: Component property dialog for the R1 resistor Press the OK button to close the dialog. You will get the following schematic.
27
Figure 2.18: Value of resistor R1 changed In order to change the value of the resistor R2 you can just click on the 50 Ohm value directly on the schematic and edit the value.
Figure 2.19: Change value of resistor R2 directly on schematic Change the value to 3 which will give a resistor ratio of 3/(1 + 3) = 0.75. Now you have the following schematic.
28
Figure 2.20: Value of resistor R2 changed Diagrams are not limited to be placed on the data display, they can also reside on the schematic directly. Thus you can place again now a tabular diagram on the schematic and add the divided.V value. The diagram will show the result from the previous simulation. Changing document properties If you do not want Qucs to change automatically to the associated data display you can change the behaviour in the document setting dialog. You can go to the document settings dialog by right clicking on free space on the schematic area and choose the Document Settings menu item in the context menu which pops up or by choosing the File Document Settings menu entry.
29
Figure 2.21: Document settings dialog In the dialog you uncheck the open data display after simulation item. Press the OK button to apply the change. If you now resimulate the schematic by pressing the F2 shortcut the Qucs Simulation Messages dialog window opens and can be left by pressing Esc . The tabular diagram now show the new value for divided.V.
30
31
P t a r a m e e r e p w s N 2 4 0 1 Q _ W 1 1 S V C i D 1 0 m = I 1 = U l y p e o g b T = I b a r m = P 1 0 t t S n o p m i 1 s = P n i l i t c m a o n u d s C D 1
Figure 2.23: Swept DC simulation setup In the schematic in g. 2.23 there is a bipolar transistor placed in a common emitter conguration. Additionally a parameter sweep has been placed. Please note the Sim property of the parameter sweep. It contains the instance name of the DC simulation DC1 which is going to be swept. The parameter which is swept is Ib (the base current) and is put into the Param property of the parameter sweep. The parameter Ib is also put into the I property of the DC current source I1. Using the component library The bipolar transistor has been taken from the component library. You can start the program by choosing the Tools Component Library menu entry or by pressing the Ctrl + 4 shortcut.
32
Figure 2.24: Component library tool When choosing the Transistor category with the combobox you nd the 2N4401 transistor. By clicking the Copy to clipboard button the component is available in the clipboard and can be inserted in the schematic using the Ctrl + V shortcut or by choosing the Edit Paste menu entry. The component can also by dragged onto the schematic by clicking on the symbol in the library tool. So what do we want to simulate actually? It is the current transfer curve of the bipolar transistor. The input current (at the base) is given by the swept parameter Ib. The output current (at the collector) ows through the DC voltage source V1. The current transfer curve is: DC = f (IC ) = IC /IB The current through the voltage source V1 is the collector current owing out of the transistor. Placing equations on the schematic In order to compute the necessary values for the transfer curve we need to place some equations on the schematic. This is done by clicking the equation icon or by choosing the Insert Insert Equation menu entry. When double clicking the equation component you can edit the equations to be computed.
33
Figure 2.25: Equation dialog In the upper edit box you enter the name of the equation and in the lower one the computation formula. The resulting schematic is shown in g. 2.26.
34
P t a r a m e e r e p w s N 2 4 0 1 Q _ W 1 1 S V C i D 1 0 m = I 1 = U l y p e o g b T = I b a r m = P 1 0 t t S n o p m i 1 s = P n i t i l i t q a o n u c m a o n u E d s 1 q E n C D 1B I I c = : . V / b t e a c = l ( I ) t t v s c o s e a c = , P V B _ _
Figure 2.26: Swept DC simulation setup with equations Note that three equations have been added. The rst one Ic=-V1.I is the collector current owing into the transistor (current though voltage sources ow from the positive terminal to the negative terminal). The equation Beta=Ic/Ib computes the current gain and nally Beta vs Ic=PlotVs(Beta,Ic) changes the data dependency of the current gain to be the collector current. The original data dependency is the swept parameter Ib. The internal help system The full list of available functions in the equation solver can be seen in the internal help system. It is started by pressing the F1 shortcut or by choosing the Help Help Index menu entry. In the sidebar choose the Short Description of mathematical Functions entry.
35
Figure 2.27: Internal help system The help can be closed using the Ctrl + Q shortcut. Conguring cartesian diagrams In g. 2.28 the nal simulation result is shown. In the diagram dialog the Beta vs Ic dataset entry was chosen.
36
Additionally the x-axis has been chosen to be logarithmic. The x-axis label is Ic.
3 0 2 c I _ s v a 1 t 0 e B 1 8 1 7 1 6 1 5 1 4 1 3 1 1 1 e e e e e e . . 0 0 c I
Figure 2.28: Simulation result Figure 2.29: Editing diagram properties 37
Working with markers in diagrams The current gain curve in diagram in g. 2.28 shows a maximum value. If you want to know the appropriate values it is possible to use markers for this purpose.
This is achieved by pressing the Ctrl + B shortcut, clicking the marker icon or choosing the Insert Set Marker on Graph menu entry. Then click on the diagrams curve you want to have the marker at. If the marker is selected you can move it by pressing the arrow keys , and or for multi-dimensional graphs.
3 0 1 3 9 2 e r s u : . . V 0 0 c 4 6 t a v c I _ B I 2 _ s v a 1 t 0 e B 1 8 1 7 1 6 1 5 1 4 1 3 1 1 1 e e e e e e . . 0 0 c I
Figure 2.30: Cartesian diagram with marker Figure 2.31: Marker dialog IC = f (IB , VCE )
Double clicking the marker opens the marker dialog. There you can congure the precision as well as the number notation of the displayed values. A multi-dimensional sweep Now we are going to create a schematic for the output characteristics of the bipolar transistor. The characteristic curve is dened as follows:
Thus it is necessary to modify the schematic from the previous sections a bit.
38
P P t t a r a m e e r a r a m e e r e p e p w w s s N 2 4 0 1 Q _ W W 1 2 1 S S V C i D i W 1 1 m m c e = = I 1 = S U V l i l i y p e n y p e n b T T = I b a r m c e a r m = = P V P 0 0 1 t t t t m . S S 4 9 o p o p i i 8 1P 5 n s n s = = P i t i l i t q a o n u c m a o n u E d s 1 q n C D 1E I I c = : . V
Figure 2.32: Sweep setup for the output characteristics A second parameter sweep has been added. The rst order sweep is Vce specied in the parameter sweep SW1. The Sim parameter points to the instance name of the DC simulation DC1. The second order sweep is Ib specied in the parameter sweep SW2. The Sim parameter of this second sweep points to the instance name of the rst sweep SW1. The rst order sweep variable Vce is put into the U property of the DC voltage source V1.
0 . 2 5 1 0 . c I c e : 5 V 3 b 0 5 . I 8 1 4 01 2 3 4 c e V
39
In the next section we are going to determine the transit frequency of the bipolar transistor used in the previous DC sections. First a bias point is chosen. In g. 2.34 the DC setup was a bit modied.
P t a r a m e e r e p w s N 2 4 0 1 Q _ W 1 1 S V C i D 1 0 m = I 1 = U l y p e o g b T = I b a r m = P 1 0 t t S n o p m i 1 s = P n i i t t i l i t q a o n q a o n u u c m a o n u E E d s 1 2 q q E n E n C D 1B I I d i f ( I b ) 0 t c e a c = = : . , V B _ / b t e a c = l ( I ) t t v s c o s e a c = , P V B _ _
RF (f = 0) = Ic Ib
There is now an additional equation computing the RF current gain for zero frequency which is Beta 0=di(Ic,Ib). The equation denotes
In g. 2.35 the DC current gain from g. 2.30 is plotted versus the base current Ib choosing Beta in the diagram dialog instead of Beta vs Ic. The appropriate base current shown in the marker is 140A.
40
It can be seen that the maximum AC current gain (257 @ 53A) diers from the maximum DC gain. Also the AC current gain almostly equals the DC current gain at the base current for the maximum DC current gain. For maximum RF performance the base current with the maximum AC current gain could be chosen. But there may be other consideration, e.g. DC power dissipation, so we choose the bias point with the maximum DC current gain arbitrarily.
3 0 b 5 5 : e . I 2 0 7 t e a : B _ 2 0 1 3 8 0 0 a 4 5 _ t 2 e B b 1 3 8 : 1 . I 0 4 6 t e a 0 B 2 0 1 8 1 7 1 6 1 5 1 4 1 3 1 e e e e e e . 0 b I
Figure 2.35: DC current gain vs. base current Figure 2.36: Bias dependent AC simulation setup
I 2 A 1 u = i l i t t a r a m e e r a c s m a o n u P s e p w N 2 4 0 1 Q _ C A 1 l y p e o g = T W 1 1 k H 1 t t a r z S V S C A 1 0 m G = I 1 o = i U l t y p e s 0 1 b T n s = i = P i I b a r m = P l [ ] 5 3 1 4 0 5 0 u u ; u ; u V i t d i l i t q a o n u c s m a o n u E 1 q n E C 1b c = ( D . i V i / b t e a c = I I 2
41
In g. 2.36 is a DC bias dependent AC simulation setup shown. The DC base current Ib is swept for 53A, 140A and 500A. Additionally the AC simulation block has been placed on the schematic. The Sim parameter of the SW1 parameter sweep is set to the instance name of the AC
simulation AC1. Qucs automatically knows that the DC simulation has to be run before each AC simulation since it is required to determine the appropriate bias points.
The AC current current source I2 is in parallel to the DC current source and has an AC amplitude of 1A. During the AC simulation the DC current source I1 is an ideal open and the DC voltage source V1 is an ideal short. In the equations V1.i (mark the small i letter) denotes the AC current through the DC voltage source V1. The AC base current ib is taken from the input parameter I2.I denoting the value of the property I of the AC current source I2 (1A). After pressing F2 to start the simulation the following cartesian diagram can be placed on the data display page, see g. 2.37.
The marker clearly shows for the low frequency range (f 0) the DC current gain of 246 (for IB = 140A) which was already determined in g. 2.35.
3 0 5 2 0 a 1 5 t e b f 5 3 c r e q u n c y : e + . a 2 0 b 1 4 : 0 . I 0 / 5 4 t 2 0 5 0 1 3 1 4 1 5 1 6 1 7 1 8 1 9 e e e e e e e f c r q u n c y a
Figure 2.37: AC current gain of the bipolar transistor fT |h21 |2 = 1 RF = h21 = i2 i1
v2 =0
In the next AC simulation setup shown in g. 2.38 the parameter sweep is dropped to concentrate on the determination of the transit frequency. The transit frequency of a bipolar transistor denotes the frequency where the AC current gain drops to 1 (0 dB).
whereas port 1 is the base and port 2 the collector. The side condition (v2 = 0) is given in our setup since the DC voltage source is an ideal AC short.
42
There are two more equations in the setup. One calculates the AC current gain in dB (which is 20 log (beta) and the other one is ft=xvalue(beta dB,0). The equation searches for the nearest given x-value (in this case the frequency) where beta dB approaches 0.
b t n u m e r f 4 0 8 4 0 8 e + . 1 2 B d 2 _ a 8 0 8 c r e q u n c y : e + t e . a f 2 b d B b 0 6 5 t 0 _ 2 3 4 5 6 7 8 9 e e e e e e e 1 1 1 1 1 1 1 c r q u n c y a f
Figure 2.38: AC setup for determining the transit frequency Figure 2.39: Bode plot of the current transfer function 43
I 2 A 1 u = i l i t a c s m a o n u N 2 4 0 1 Q _ C A 1 l y p e o g = T 1 k H 1 t t a r z V S 0 G I 1 = o U 0 1 A P 4 0 n s u = = i i i t t d i l i t q a o n q a o n u u c s m a o n u E E 1 2 q n q n E E C 1b d B d B ( / ) 1 6 t c e a c e = = ' ' D . i V i b i _ / l ( d B 0 t t e a c x v u e e a = = , b f b _ I I 2
In g. 2.39 the Bode plot (double logarithmic plot) of the current transfer function of the bipolar transistor is shown. The current gain is constant up to the corner frequency and then drops by 20dB/decade. The marker nally denotes where the gain is nally 0dB. The equation for ft worked correctly as seen in the beside tabular. The transit frequency of the bipolar transistor in this bias point is approximately 288MHz.
Figure 2.40: simple RC high-pass lter schematic Performing the actual AC analysis is as easy as dragging and dropping an AC Simulation block available under the Simulations tab as can be seen in gure 2.41.
44
Figure 2.41: AC simulation block placed Once this is done one must congure the ranges of the simulation analysis by clicking twice on the AC Simulation box as can be seen in gure 2.42.
45
Figure 2.42: AC simulation block conguration dialog Finally by pressing F2 the simulation takes places and a graphic report can be generated by selecting the right plot as seen in the previous sections. The nal view of the network with its respective frequency analysis can be seen on gure 2.43.
46
47
48
Fig. 2.45 shows the results of the transient as well as DC simulation. The time dependent collector current oscillates around its bias point. The current gain of the transient signal corresponds perfectly with the DC value. That is because a rather small frequency of 1kHz was chosen.
C b H T R D t t t n u m e r c a e a e a I B B 3 4 6 . 2 4 5 2 4 5 2 4 6 0 . 1 0 3 4 c . 0 I 3 4 2 . 0 4 .2 . 0 0 0 im t e
Figure 2.45: Transient results Figure 2.46: S-parameter simulation setup for the bipolar transistor 49
In the following section the S-parameter simulation is introduced. The S-parameter simulation is similar to the AC simulation a small signal analysis in the frequency domain.
Q N 2 4 0 1 1 X _ 2 P 1 N u m = V 3 0 5 0 1 = 1 I U Z P A 1 4 0 u N C = u m = 5 0 Z i t d i l i q a o n t t u c s m a o n p a r m e r u E S i l i s o n u 2 n 1T H ( H ) ' w p r = D C , S [ ] 1 e 1 b d B t P e a y p e g b _ = k H tS a r z G o in 0 1 s
Similar to the AC setup in g. 2.38 the S-parameter setup in g. 2.46 uses the same biasing. The setup will be used to determine the transit frequency of the bipolar transistor. The two AC power sources P1 and P2 are required for a two-port S-parameter simulation. They can be found in the Components tab in the sources category. Depending on the number of these kind of sources one-port, two-port and multi-port simulations are performed. The Num property of the sources determines the location of the matrix entries in the resulting S-parameter matrix. The Z properties dene the reference impedance of the S-parameters. The additional DC block C1 at the base node and the bias tee X1 on the collector is used to decouple the signal path of the biasing DC sources from the internal impedance of the AC power sources. Also the bias tee ensures that the AC signal from the P2 source is not shorted by the DC source V1. The same functionality is achieved by the DC current source I3 at the base. It represents an ideal AC open. The S-parameter simulation itself is selected by placing the S-parameter block SP1 on the schematic. The same frequency range is chosen as in the previous AC simulations.
The equations contain a two-port conversion function which convert the resulting S-parameter S into the appropriate H-parameters H. Again the AC current gain h21 is calculated and converted in dB.
In g. 2.47 the four complex S-parameters are displayed in two Polar-Smith Combi diagrams. They represent what can be expected from a typical bipolar transistor.
S S [ [ 2 0 0 0 0 5 0 0 5 2 ] ] 1 . . . 1 4 6 8 1 1 1 , , 2 , , 1 ] ] [ [ S r e q u n c y f r e q u n c y f
Figure 2.47: S-parameters of the bipolar transistor
Using the computed H-parameters we can now compare the S-parameter simulation results with those of the AC simulation. Fig. 2.48 shows that the curves beta dB of both simulation setups cover perfectly each other. Again the transit frequency is approximately 288MHz.
50
The diagram implies that you can compare data curves from dierent setups. This is indicated by the bjtacft: prex. The appropriate dataset le bjtacft.dat can be selected in the diagram dialog as shown in g. 2.49.
4 0 B d _ 2 a t e b 2 8 0 8 r e q u n c y : e + : . f f d B 0 6 5 c t a 0 b _ j 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 e e e e e e e r q u n c y f
51
Figure 2.49: Choosing graphs from dierent datasets The current S-parameter setup is called bjtsp and the setup shown in g. 2.38 was called bjtacft. Please note that only datasets from the same project can be compared with each other.
52
Figure 2.50: Filter synthesis application In g. 2.50 the lter synthesis program coming with Qucs is shown. You can start it by the Ctrl + 2 shortcut or by choosing the Tools Filter synthesis menu entry. The user can choose between dierent types of lters and the lter class (lowpass, highpass, bandpass or bandstop). Also the appropriate corner frequencies and the order must be congured. When setup correctly you press the Calculate and put into Clipboard button. The program will indicate if it was possible to create the appropriate lter schematic. If so, the application passes the schematic to the system wide clipboard. Back in the schematic editor you can paste the lter design into the schematic using the Ctrl + V shortcut or by choosing the Edit Paste menu entry.
53
The schematic shown in g. 2.51 was automatically created by the lter synthesis program and can be simulated as is. It contains the LC-ladder network forming the actual lter, the two S-parameter ports (the AC power sources) as well the S-parameter simulation block with the appropriate frequencies pre-congured. Additionally there is an equation computing the transmission and reection of the lter network in dB.
The results of the S-parameter simulation are depicted in g. 2.52. In the logarithmic cartesian diagram the transmission of the lter clearly shows the band-pass behaviour between the selected frequencies 1MHz and 2MHz. Additionally the input- and output reections can be seen in the two Smith charts.
0 1 5 0 ] ] 2 2 1 S , , B [ [ S S d 1 0 5f 1 6 7 7f e e e e 2 r e q u n c yf r e q u n c y r q u n c y1
Figure 2.51: Schematic for 5th order Bessel band-pass lter Figure 2.52: S-parameters of the band-pass lter
L L 2 4 H H 4 0 3 6 8 1 = = . . u u 2 4 C C F F 3 1 8 1 3 2 = = . . n n L L L 1 3 5 1 2 P P H H H 2 8 4 9 1 7 6 2 m m = = = . u u u N u N u 5 0 5 0 Z Z 1 3 5 C C C F F F 5 4 9 2 5 9 7 1 8 = = = . . . p n n i t t l d i l q a o n u t p a r m e r e s a n p a s e r J E B b f S i l i H H I 2 p z z y m o n u J . , , 1 M M P s 1 i d h h 0 t m p c e m c n g m n 5 O S S B B ( [ ] ) 2 2 1 = , d d S 1 P l y e o g = T p H 0 t a r z k 2 M in o s
54
Now two AC setups will be created to calculate the same S-parameters as found in the previous simulation. In g. 2.53 the LC-ladder network is unchanged but the S-parameter ports are replaced by a 50 resistor and an AC voltage source in series. Also there is now an AC simulation block with the same frequency sweep chosen as in the previous S-parameter simulation.
L L 2 4 H H 4 0 3 6 8 1 1 2 = = . . u u P P 2 4 C C F F 3 1 8 1 3 2 R 2 = = . . n n R 1 5 0 = 5 0 = L L L 1 3 5 H H H 2 8 4 9 1 7 6 2 = . u u u 1 2 V V 0 = = U U 1 3 5 C C C F F F 5 4 9 2 5 9 7 1 8 = = = . . . p n n i i t t i l i t q a o n q a o n u u c s m o n u E E a a 1 2 n n 1 ( Z * i ) / ( * ( Z ) B B ( ) 0 1 2 0 1 1 t a v s q r + = = B . . A C P V d S d S l b / 1 2 y e o g a = T p S H 0 t 2 2 a r z S k 2 Z R 0 M in 1 o sb P ( Z * i ) / ( * ( Z ) 0 2 0 t v s q r = B . . P V 0 1 5 0 2 B 1 S S B d 1 0 B 5 1 6 1 7 2 7 e e e e f a c r e q c y f c r q c y u n a u n
Figure 2.53: S-parameters at port 1 of the band-pass lter using AC analysis 55
S-parameters are dened by ingoing (a) and outgoing (b) power waves: a= V + Z0 I 2 Z0 V Z0 I b= 2 Z0
whereas Z0 denotes the reference impedance the S-parameters will be normalized to. With this denition the two-port S-parameters can be written as: S11 = b1 a1 S21 =
b2 =0
b2 a1
S22 =
b2 =0
b2 a2
S12 =
b1 =0
b1 a2
b1 =0
Back at the schematic in g. 2.53. The amplitude of the AC voltage source V1 is set to 1V (but can be any other value dierent from zero) and the side condition b2 = 0 is fullled by setting the amplitude of the AC voltage source V2 to 0V. The additional equations just calculate the S-parameters as they are dened from the AC simulation values. Please note the current directions through the AC voltages sources V1.i and V2.i. They must be considered by the unary minus in the equations. The results of this simulation again show the lter transmission function as we already know it from the S-parameter simulation. Also the reections at port 1 look identical. In the second schematic shown in g. 2.54 the second port is handled. The amplitude of the AC voltage source V2 is set to 1V and the side condition b1 = 0 considered by a zero AC voltage source V1. Again the appropriate equations are used to compute the two remaining S-parameters. The below simulation results again veried that we can perform a partial S-parameter analysis using the AC simulation block and some additional equations. The diagrams in g. 2.54 and g. 2.52 are identical.
56
Recapitulating we learned from this example that a S-parameter simulation is a number of AC simulations with some additional calculation formulas. This is true though the actual simulation algorithms implemented in Qucs are completely dierent.
L L 2 4 H H 4 0 3 6 8 1 1 2 = = . . u u P P 2 4 C C F F 3 1 8 1 3 2 2 = = . . n n R 1 5 0 = R 5 0 = L L L 1 3 5 H H H 2 8 4 9 1 7 6 2 = . u u u 1 2 V V 0 1 = = U U 1 3 5 C C C F F F 5 4 9 2 5 9 7 1 8 = = = . . . p n n i i t t i l i t q a o q a o n u u c s m o n u E E a a 1 2 n n A 1 ( Z * i ) / ( * ( Z ) B B ( ) 2 0 2 0 2 t a v s q r + = = @ . . C P V d S d S l b / 2 1 1 y e o g a = T p S H 0 t a r z S k 2 0 M R in b 1 1 o sZ P ( Z * i ) / ( * ( Z ) 2 0 2 0 t v s q r = @ . . P V 0 2 5 0 @ 1 2 S B S d 0 @ 1 5 1 6 1 7 2 7 e e e e f f a c r e q c y a c r q c y u n u n
Figure 2.54: S-parameters at port 2 of the band-pass lter using AC analysis 57
3.1 Introduction
Data sheets are often the sole source of information about the capability and characteristics of a product. This is particularly true of unique RF semiconductor devices that are used by equipment designers all over the world. Because the circuit designer often cannot talk directly with the factory, he relies on the data sheet for his device information. And for RF devices, many of the specications are unique in themselves. Thus it is important that the user and the manufacturer of RF products speak a common language, what the semiconductor manufacturer says about his RF device is understood fully by the circuit designer. This paper reviews RF transistor and amplier module parameters from maximum ratings to functional characteristics. It is divided into ve basic sections: 1. DC specications, 2. power transistors, 3. low power transistor, 4. power modules, 5. linear modules. Comments are made about critical specications about how values are determined and what are their signicance.
1
This note could be found on old application notes databook from Motorola, if you have one keep them, it is a real treasure.
58
3.2 DC specications
Basically, RF transistors are characterized by two types of parameters: DC and functional. The DC specs consist of breakdown voltage, leakage current, hF E ( DC ) and capacitances, while the functional specs cover gain, ruggedness, noise gure, Zin and Zout , S parameters, distortion, etc . . . . Thermal characteristics do not fall cleanly into either category since thermal resistance and power dissipation can be either DC or AC. Thus we will treat the spec of thermal resistance as a special specication and give it its own heading called thermal characteristics.
59
60
Figure 4.1: resistor cube schematic All I did was select resistance in the left hand component window and paste them down, rotating as necessary, until I had twelve on the schematic. Then I wired two sets of four into squares, then connected the remaining four between the corners of the squares. Which Im sure is topologically the same as a cube. Which all might seem trivial, but is a good reminder right at the beginning that we are creating a virtual representation of a physical circuit. Sometimes we have to bend and squeeze things to get it into a format that our simulator will accept, which leaves us wondering whether we are working with an accurate representation. The Rule is: if we can correlate the junctions of our components with those of the real circuit, we are accurately representing the physical circuit. And, I might add, it is ALWAYS worth checking that we have done it right; simulate the wrong circuit and it will tell you lies. With my cube of resistors accurately drawn, I only have to hit the simulation button and the tabulated results will show me the voltage at the corner node. As I am forcing a constant current through the cube from one corner to another, Ohms Law tells me that
61
the voltage between those corners will give me the resistance. If I use a current of one amp, the output voltage will be equal to the resistance in ohms.1 Those with good attention to detail will be complaining about now that I havent really solved the problem, as the question mentioned one ohm resistors while I have used fty ohms. Well, yes, I cheated. Which I often do in simulations. To set all the resistances to the correct value I would have had to open the Properties Editor window twelve times; here is how it looks...
Figure 4.2: component property dialog and the highlighted value is inviting me to type in an alternative. I could have done this, but natural laziness got the better of me. I reasoned that fty ohms is fty times too high, but if I reduced the current source from one amp to twenty milliamps, the output voltage would be the same. You will nd such laziness (or acute perception, depending on is telling the story!) can save much time and eort.
I could tell you the value my simulation gave, but why should I spoil your fun.... go ahead and run it yourself. If you really want to be thorough you could then also build the circuit and measure the result.....
62
The simplest non-linear element is the diode, and the question we ask most often about a diode is: how does the diode forward voltage vary with current? So back to Qucs and draw this circuit...
This circuit looks deceptively simple, but it introduces a few more features of Qucs, so lets go through them in order. The components were again selected from the left hand window and wired together. Then the two boxes were selected from the simulations window. The DC simulation box can be pretty much left as is for now, but take note of the name of the simulation: DC1. The Parameter sweep box properties dialog looks like this when opened...
63
The rst two items to take note of are the Simulation entry (here DC1, corresponding to the name of the simulation box) and the Sweep Parameter entry, here entered as Id1. If you look at the current source driving our diode you will see that it just happens to be labeled Idrive. So the result of all this is that the component property value Id1 of the current sources property I will be swept through a range of values as determined by our parameter sweep function named SW1.2 The rest of the entries set the type of sweep (here logarithmic) and the range of values over which to sweep. You can try dierent values in any of these to see the eect; one of the advantages of a simulator over a physical prototype is that you cant blow up your diode by feeding too much current through it! So I hit the simulation button and it passed me over the results page, and I created a couple of graphs of the output. This is how my screen looked...
You can change this name if you wish, in the Properties menu of the Edit properties window.
64
In each case I have a plot of diode forward voltage (Y-axis) against forward current (Xaxis). The left hand graph has a logarithmic scale for forward current, while the right hand graph uses a linear current scale. How did I do that? Well, you should know by now that all things are easy with Qucs! When you select a graph type from the left hand window and drag it into the viewing area, it creates a graph and opens a dialog which looks like this
65
The left hand window shows the available variables and whether they are dependent or independent. Here the current Id1 is the independent variable, and the forward voltage Vdf.V is the dependent. Double-click on the entry for Vdf.V and it is transferred to the right hand side; hit OK and the graph will be drawn. That should give you something like the right hand graph in my screenshot above. Do it all again, but this time before clicking OK open the Properties window, which looks like this.
66
Here Ive selected a logarithmic X Axis, which gave me the graph on the left hand side. Ive also moved them around and re-sized them to pretty them up; you can do all kinds of fancy things if you want. Now Ive sneaked in another test to see if you are really following this. Those of you who did run this simulation are probably wondering about now why your graphs look rather dierent to mine. In particular, at high currents on the logarithmic scale your curve is a straight line, while mine curves upwards alarmingly. What is happening ? What I did was open the Properties dialog for the diode and set some parameters. This is what the dialog box looks like...
67
and each of these entries sets one parameter of the virtual component we are using to model the diode. So, what are these parameters? Time to explore one of the delights of computer circuit simulation, device modeling...
where Vt is the forward voltage drop at 25 degrees C of an ideal junction, also given by Vt = kB T q
68
where kB = Boltzmanns constant T = temperature in degrees Kelvin q = charge of the electron most of these are constants that the program already knows about. The ones we need to supply are the ones listed in the properties editor window. For the DC characteristics, most of the time, the only ones we need to worry about are Is, the saturation current, and T, the temperature. If we are going to push relatively high currents through the diode we can also include an estimate for the series resistance Rs; if we are worried about low current behaviour then we need to add the reverse current parameter Isr. How do we know what values to insert? Much could be written about device modeling; much indeed has been written about device modeling. As always, we really have two choices: use a value from someone else, or nd our own values, usually by trial and error. There are a great many models available for various simulation programs. Probably the most freely available are those for spice, many of which can be downloaded from the semiconductor companies. Here, for example, is a typical spice model for a 1N4148 diode:3 .model 1N4148 D(Is=0.1p Rs=16 CJO=2p Tt=12n Bv=100 Ibv=0.1p) 85-??-?? Original library Any values not supplied are assumed to be the defaults. The other way is to create your own device parameters, which is a bit like catching worms before you can go shing. Insert values, plot the resulting characteristics, see how they compare with the published data sheet values, go back and adjust the values; continue until satised or exhausted. Here, for example, is a circuit for quickly comparing the forward characteristics of diodes with dierent parameter values.
I dont know where this came from, so I cant acknowledge the author. Most libraries are copyright, even if freely available.
69
D1 Is=1e-15 A N=1 Cj0=10 fF M=0.5 Vj=0.7 V D2 Is=1e-14 A N=1 Cj0=10 fF M=0.5 Vj=0.7 V D3 Is=3e-18A N=1 Cj0=10 fF M=0.5 Vj=0.7 V D4 Is=1e-9A N=1.025 Cj0=10 fF M=0.5 Vj=0.35 V
Vi3
Parameter sweep
SW1 Sim=DC1 Type=log Param=Id1 Start=1e-6 Stop=1 Points=1000
Vi2
Vd1
dc simulation
DC1
Figure 4.3: Diode Forward Voltage The green and purple curves are typical of 1N4148 and 1N4448 devices; the others are medium and low-barrier Schottky devices. I have done a rst pass compare with the data sheets, but I cant guarantee that these curves are any more than my best estimates.4 If you want to know more details of what each parameter does, there has been a great deal written over the years, particularly for spice, on the subject; a google search will quickly
4
Im assuming you are sick of screenshots by now, so Ive just printed the schematic and display les from Qucs; youll nd the print item in the le menu, and if you ask it nicely it will print a postscript le.
70
reveal most of it. Qucs comes with a document which lists the details of its models, and, being open source, there is always the code itself. Most of us end up taking a great deal on trust, and matching curves to data sheets as best we can. This is yet another instance of one of the fundamentals of engineering, the Duck Principle5 : If you cant detect any dierence between the behaviour of your model and the physical device, then they are, for engineering purposes, the same. Put it another way, when the dierence between the model and the real device drops below the usual level of measurement uncertainty, it does matter any more. In any case, component spreads in the real world tend to make the ne details of model inaccuracies somewhat academic, as we shall see when we model more complex devices.
Usually expressed as: If it looks like a duck, walks like a duck, quacks like a duck and tastes like a duck, then, for all practical purposes, it is a duck.
71
72
Component connection wires (signals) can only be of type bit as dened in the standard VHDL library2 . Digital bus structures are not allowed in this release of the Qucs package. Digital subcircuits can be drawn as schematics and associated with a symbol in a similar fashion to analogue subcircuits. Digital subcircuit pins can have type in, out, inout or analog. Qucs treats pins of type analog the same as VHDL pin type inout. Once dened digital subcircuits may be placed and connected to other components on schematics. Multiple copies of the same digital subcircuit are allowed on a single schematic. Digital subcircuits may also be nested; nesting has been tested to a depth of four.
Signal type bit only denes logic signals 0 and 1. Care must be taken to ensure that signal contention does not occur during simulation because the resulting logic state cannot be modelled with type bit. Signal contention can happen when two or more digital devices attempt to drive the same wire with logic 0 and logic 1 signals at the same time. Moreover, it is not possible to simulate the performance of tristate devices using VHDL signal type bit.
A 0 0 0 0 1 1 1 1
B 0 0 1 1 0 0 1 1
C 0 1 0 1 0 1 0 1
F 0 1 1 0 0 1 1 0
Table 5.1: Truth table for a logic circuit with inputs A, B, C and output F.
73
F = A.C + B.C
The schematic for example 1 is illustrated in Fig. 5.1. This diagram was constructed using the same techniques employed for drawing analogue schematics.
74
digital simulation
Y1
B C
&
CB Y2
1 &
Y4
Y3
Please note, Qucs Linux release 0.0.8 will normally simulate single hierarchy digital circuits without
75
Qucs 0 . 0 . 9 t u t 1 e x 1 . s c h entity TestBench i s end entity ; use work . a l l ; architecture Arch TestBench of TestBench i s s i g n a l CB, A, B, F , C, nnnet0 , nnnet1 : b i t ; begin nnnet0 <= C and A; nnnet1 <= CB and B ; CB <= not C ; A: process begin A <= 0 ; wait f o r 40 ns ; A <= 1 ; wait f o r 40 ns ; end process ;
B : process begin B <= 0 ; wait f o r 20 ns ; B <= 1 ; wait f o r 20 ns ; end process ; F <= nnnet1 or nnnet0 ; C: process begin C <= 0 ; wait f o r 10 ns ; C <= 1 ; wait f o r 10 ns ; end process ; end architecture ;
Table 5.2: VHDL code for the circuit shown in Fig. 5.1.
76
10n
20n
30n
40n
50n
60n
70n
80n
90n
100n
110n
120n
130n
140n
150n
160n
170n
180n
190n
200n
Figure 5.2: Digital functional waveforms for the circuit shown in Fig. 5.1.
P = D.(A.B + B C )
The schematic for the sum of products equation for P is shown in Fig. 5.3(a). Similarly Fig. 5.3(b) presents the schematic for a minimised P equation. Setting the digital simulation type to TruthTable, rather than TimeList, causes Qucs on pressing key F2, to generate a truth table based on the information provided on a circuit schematic. The number of truth table inputs, and indeed outputs, correspond to the number of input generators and the number of named outputs. Truth tables for both schematics are given in Table 5.3(a) and 5.3(b). Comparing these two tables clearly indicates that they are not identical and moreover conrms that the minimised solution is not correct. Reworking the minimisation procedure points to the error being a missing signal inversion. The correct Boolean equation for P is
P = D.(A.B + B C )
error. However, Qucs 0.0.8 does fail at the VHDL to C++ conversion phase if a schematic includes more than one ground symbol.
77
A A Y1 B Y2
B C
C Y3 D
digital simulation
Digi1 Type=TruthTable
1 &
Y6
&
1
P
Y7
&
Y10
Y8
&
Y9
&
Y11
A A Y3
B B
C C
digital simulation
Digi1 Type=TruthTable
1 &
Y7
1
Y8 Y6
&
=1
Y4
78
79
The circuit simulator SPICE is a well known example of a widely used CAD program that makes extensive use of subcircuits in circuit design. 5 Qucs 0.0.8 has a bug which causes a VHDL compile error when subcircuit pins are specied as type out. A work around for this bug is to specify subcircuit output pins as type analog. The Qucs routines that generate the circuit VHDL code convert pin type analog into VHDL type inout. FreeHDL is then able to compile the generated VHDL code without error. This bug has been corrected in Qucs 0.0.9. 6 Ian, Kampel, A practical introduction to the new logic symbols, Butterworths, 1985, ISBN 0-408-01461X. 7 Subcircuit Gen4bit includes other nested subcircuits. Qucs 0.0.8 has a bug that causes VHDL compile errors with some congurations of nested subcircuits. This has been xed in version 0.0.9.
80
Z Y3
Y Y2
X Y1
1
XB
YB
&
IN1
Y4 X WB W
&
Y5
IN2
G G
Y8
&
IN3
Y6
&
In4
Y7
COMB1 W X Y Z W X G Y Z G
SUB File=name
Figure 5.5: Qucs symbol for a logic circuit with inputs W, X, Y, Z, and output G.
81
B0 B1 B2 B3
B0 W B1 X B2 Y B3 Z
COMB1
digital simulation
COMB1 Type=TimeList time=1000 ns
SUB1 File=dtut1_ex2.sch
Figure 5.6: Test schematic for a logic circuit with inputs W, X, Y, Z, and output G.
82
5n
10n
20n
30n
40n
50n
60n
70n
80n
90n
100n
110n
Figure 5.7: Digital functional waveforms for a logic circuit with inputs W, X, Y, Z, and output G.
83
L0
SUB File=name
1
Y1
L1
L1
SUB File=name
B0 B1
84
B0
1
SUB1 CLK CLK R J K
S
FF0 JK
1
B0 B0 Q SUB2
R
0
Q Q SUB2 J SQ K Q
B1 B1
B0b
B1b
FF0
FF1
B0 B1 B2 B3
B1 B1 B2 J K
S
B2 B3 J K
S
B3
0
Q0B
J K
Q Q
Q Q
Q Q Q3B
Q1B
Q2B
FF1
FF2
FF3
85
A A
1
Y1
& 1
Y2 Y Y
D0 D0 D1 D1
&
Y3
Y4
86
MUX ENB A B EN 0 1
}G
0 3 Y
D0 D1 D2 D3
0 1 2 3 SUB File=name
D3
D2
D1
D0
ENB ENB
Y8
Y7
Y6
1
BB
1
AB
1
EN
&
Y1 D2 D1 D0
D3
& 1
Y2 Y Y
&
Y5
Y3
&
Y4
87
}A
A2 B2
0 1
{
0 1 CO
S1 S2
CI
CI
C0
SUB File=name
CI
B2
A2
B1
A1
=1
S1
S1
&
CI B2 A2 B1 A1
Y1
1
Y4
& =1
Y5 Y10
Y7
=1
S2 S2
Y2
=1
Y6 Y8
& 1 &
Y9 Y3 C0 CO
5.7.1 Gen2bit
88
entity S u b g e n 2 b i t i s port (CLK: in b i t ; R: in b i t ; nnout B0 : out b i t ; nnout B1 : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b g e n 2 b i t of S u b g e n 2 b i t i s s i g n a l B0b , B1b , JK , nnnet0 , B0 , B1 : b i t ; begin FF0 : process ( nnnet0 , R, CLK) begin i f (R= 1 ) then B0 <= 0 ; e l s i f ( nnnet0 = 1 ) then B0 <= 1 ; e l s i f (CLK= 1 and CLK e v e n t ) then B0 <= (JK and not B0 ) or ( not JK and B0 ) ; end i f ; end process ; B0b <= not B0 ; FF1 : process ( nnnet0 , R, B0b ) begin i f (R= 1 ) then B1 <= 0 ; e l s i f ( nnnet0 = 1 ) then B1 <= 1 ; e l s i f ( B0b= 1 and B0b e v e n t ) then B1 <= (JK and not B1 ) or ( not JK and B1 ) ; end i f ; end process ; B1b <= not B1 ; SUB2 : entity S u b l o g i c z e r o port map ( nnnet0 ) ; nnout B0 <= B0 or 0 ; nnout B1 <= B1 or 0 ; SUB1 : entity S u b L o g i c o n e port map (JK ) ; end architecture ;
89
A2 : in b i t ; B2 : in b i t ; CI : in b i t ; nnout S1 : out b i t ; nnout S2 : out b i t ; nnout CO : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b f a d d 2 b i t of S u b f a d d 2 b i t i s s i g n a l nnnet0 , nnnet1 , nnnet2 , nnnet3 , nnnet4 , nnnet5 , nnnet6 , S2 , CO, S1 : b i t ; begin S1 <= CI xor B1 xor A1 ; nnnet0 <= B2 xor A2 ; nnnet1 <= nnnet0 and nnnet2 ; nnnet3 <= B2 and A2 ; nnnet2 <= nnnet4 or nnnet5 ; nnnet4 <= nnnet6 and CI ; nnnet5 <= B1 and A1 ; S2 <= B2 xor A2 xor nnnet2 ; CO <= nnnet3 or nnnet1 ; nnnet6 <= B1 xor A1 ; nnout S2 <= S2 or 0 ; nnout CO <= CO or 0 ; nnout S1 <= S1 or 0 ; end architecture ;
Attempting to read entity port signals of type out results in a VHDL compile error.
90
A VHDL use work . a l l ; statement is included before each subcircuit architecture denition to ensure that FreeHDL can nd any nested subcircuits 9 . The complete VHDL code le for a digital design is composed from an outer test bench entity-architecture model plus entity-architecture models for each subcircuit specied in the design,
Strictly speaking it should not be necessary to specically state the use of the work library as this library is normally visible at all times when compiling entity-architecture models. However, at this stage in the development of FreeHDL it does appear that it is necessary when using the default FreeHDL VHDL library mapping.
91
CONTROL1 REG 4bit R1D D0 D1 D2 D3 Q0 Q1 Q2 Q3 R1Q0 R1Q1 R1Q2 R1Q3 CONTROL1 CONTROL2 CONTROL2 Num=2 Y1 AND_LOAD
SUB5
SUB14
92
0} G
0 1 R3D0 R3D1 R3D2 R3D3 D0 D1 D2 D3 Q0 Q1 Q2 Q3 R3Q1 R3Q2 R3Q3 REG 4bit R3Q0
LOAD
MUX
LOAD
R2D
SUB1 File=quad_mux2to1.sch
SUB2 File=reg_4bit.sch
LOAD
digital simulation
VHDL Test circuit 2 Multi-hierarchy RTL circuit CONTROL2:R(SUB2)<- R(SUB4) not(CONTROL2) and CONTROL1 : R(SUB2)<-R(SUB3)
SUB4 File=reg_4bit.sch
Reg4bit
REG 4bit D0 D1 D2 D3 D0 D1 D2 D3 Q0 Q1 Q2 Q3 Q0 Q1 Q2 Q3
LOAD CLOCK
LOAD
SUB File=name
D0 D D0 Num=1 Q0 EN Q0
SUB4 File=d_flip_flop_l.sch
93
EN EN D
Mux2to1 0 G 0 1 0 1 D R Y1 Q
D CLOCK CLOCK
SUB1 File=mux2to1.sch
0
SUB2 File=logic_zero.sch
Mux2to1
A D0 D1 Mux2to1 0 G 0 1 0 1 SUB File=name Y
1
A Num=1 Y1
& 1
Y2
Y Y Num=4
D0
&
D0 Num=2 D1 Num=3 D1 Y3
Y4
94
QuadMux
SEL 0} G 0 1
A0 B0 A1 B1 A2 B2 A3 B3
0 1 0 1 0 1 0 1
MUX Y0
Y1
Y2
Y3
SUB File=name
Y0 Num=10
Y1 Num=11
A1 Num=3 B1 Num=7
A2 Num=4 B2 Num=8
A3 Num=5 B3 Num=9
1 SUB4 File=mux2to1.sch
95
dtime clock.X control1.X control2.X load.X r1q0.X r1q1.X r1q2.X r1q3.X r2q0.X r2q1.X r2q2.X r2q3.X r3d0.X r3d1.X r3d2.X r3d3.X r3q0.X r3q1.X r3q2.X r3q3.X
370n
380n
390n
400n
410n
420n
430n
440n
450n
460n
470n
480n
490n
500n
510n
520n
530n
540n
550n
5.9.1 Bugs, corrections and small changes to the Qucs digital simulation code
All the bugs reported in the rst version of these notes have been corrected in the latest Qucs CVS code. These corrections are, of course, also included in Qucs release 0.0.9. During testing a number of other annoying, but signicant, bugs have also been found and eliminated, these include Multiple input gates (three or more inputs) of types nand and nor failed at the FreeHDL compile stage due to an error in the VHDL code generated by Qucs.
10
A good introduction to the VHDL language and its application in digital system design can be found in Digital System Design using VHDL by Charles H. Roth, Jr, PWS Publishing Company, 1997, ISBN 0-534-95099-X.
96
Signals names and, for example, component names constructed from a single letter that was an abbreviation for a physical unit failed to compile. Changing digital component time delays caused component connections on a schematic to be removed. GUI problems caused by errors in the symbol rotation and mirror code. Qucsconv code conversion errors caused the Qucs digital simulation cycle to fail before plotting TimeList waveforms. A number of changes to either the VHDL code generated by Qucs or the schematic capture GUI have been introduced, these include The VHDL code generated by Qucs for the ground symbol has been changed from gnd <= gnd and 0 ; to gnd <= 0 ; The symbol for digital inout ports has been changed from the analogue pin symbol to one that consists of the digital in and out pins drawn back-to-back. This reects the bidirectional status of an inout port. A more complete list of all the bug corrections and other program modications can be found in the Qucs change log les.
97
Qucs GUI VHDL STD library elements Digital subcircuit symbols Generated using Qucs schematic capture
SIMULATE
VHDL Testbench code
FreeHDL
Com i!e VHDL code "nd #ener"te m"chine code simu!"tion ro#r"m $or circuit under test
Run
Qucs TimeList plot Simulation #utput data Qucs Truth Table View
98
5.9.3 Limitations
Before describing the new digital simulation features it is important that readers understand the limitations that are inherent in the various digital simulation routes described in the last section and illustrated in the ow diagram shown in Fig. 5.10. Qucs schematic capture allows users to draw circuits consisting of predened component symbols and subcircuit symbols. At this stage in the development of the GUI digital signals must be of type bit (as dened in the VHDL standard library - library STD in the FreeHDL package) where individual signals ow through a single wire. Qucs schematic drawing bus structures of VHDL type bit-vector, for example, have not been implemented yet. This implies that the device symbol port pins must represent single signals. Similarly the nets connecting pins on more than one device can only be single signal nets and not bus structures. It is anticipated that this will change in a future Qucs release. Although the current release of FreeHDL is 0.0.1 the package implements a substantial subset of the entire VHDL language11 . The major features not supported by release 0.0.1 are: Shared variables. The following attributes; transaction, quiet, stable and delayed. User dened attributes. Groups. Guarded signal assignments. Currently drivers cannot be switched o. The Qucs TimeList plotting program uses signal data output by the machine code simulation program generated by the FreeHDL package12 . A current limitation of the TimeList plotting program is that it can only display signals of type bit. Bus signal waveforms cannot be displayed. Given the above limitations it is therefore possible to write VHDL code that can be compiled by FreeHDL but will cause problems at either the schematic drawing or output waveform plotting stages in the Qucs simulation cycle. As Qucs develops it is expected that these limitations will be removed. On the subject of limitations one nal point to note: FreeHDL can simulate circuits described by the data types and other features found in the
11
A complete description of the 1987 and 1993 specications of the VHDL language can be found in The Designers Guide to VHDL by Peter J Ashenden, second edition 2002, Morgan Kaufmann Publishers, ISBN 1-55860-674-2. 12 The machine code simulation program outputs signal data in VCD format. This is then converted to the Qucs TimeList data format by the qucsconv utility program.
99
IEEE.std_logic_1164 library and other predened libraries. However, at this stage in the development of the Qucs software only the VHDL standard library may be used, implying that data type bit must be used to represent logic signals.
To launch the new VHDL editor click on the second icon from the left on the Qucs toolbar. It can also be activated using the key sequence Ctrl+Shift+V. 14 This is still the preferred method amongst many experienced users of VHDL. However, the circuit schematic drawing approach does seem to be growing in popularity. 15 The Boolean equation for function f has not been minimised. It is in a form derived directly from a truth table and is introduced purely as an example to demonstrate the use of the Qucs VHDL editor.
100
begin pz : process i s begin z <= 0 ; wait f o r 20 ns ; z <= 1 ; wait f o r 20 ns ; end process pz ; py : process i s begin y <= 0 ; wait f o r 40 ns ; y <= 1 ; wait f o r 40 ns ; end process py ; px : process i s begin x <= 0 ; wait f o r 80 ns ; x <= 1 ; wait f o r 80 ns ; end process px ; pw : process i s begin w <= 0 ; wait f o r 160 ns ; w <= 1 ; wait f o r 160 ns ; end process pw ; end architecture b e h a v i o u r a l ; entity and4 i s 4 i n p u t and g a t e . port ( in1 , in2 , in3 , i n 4 : in b i t ; out1 : out b i t ); end entity and4 ; architecture d a t a f l o w of and4 i s begin out1 <= i n 1 and i n 2 and i n 3 and i n 4 ; end architecture d a t a f l o w ; entity and3 i s 3 i n p u t and g a t e . port ( in1 , in2 , i n 3 : in b i t ; out1 : out b i t ); end entity and3 ; architecture d a t a f l o w of and3 i s begin out1 <= i n 1 and i n 2 and i n 3 ; end architecture d a t a f l o w ;
101
entity o r 4 i s 4 i n p u t or g a t e . port ( in1 , in2 , in3 , i n 4 : in b i t ; out1 : out b i t ); end entity o r 4 ; architecture d a t a f l o w of o r 4 i s begin out1 <= i n 1 or i n 2 or i n 3 or i n 4 ; end architecture d a t a f l o w ; entity i n v i s I n v e r t e r . port ( i n 1 : in b i t ; out1 : out b i t ); end entity i n v ; architecture d a t a f l o w of i n v i s begin out1 <= not i n 1 ; end architecture d a t a f l o w ; entity t e s t b e n c h i s Test bench o u t e r e n t i t y wrapper . end entity t e s t b e n c h ; l i b r a r y work ; use work . a l l ; architecture s t r u c t u r a l of t e s t b e n c h i s T e s t b e n c h a r c h i t e c t u r e . s i g n a l b0 , b1 , b2 , b3 , zb , yb , xb , wb , a , b , c , d , f : b i t ; begin d1 : entity t e s t v e c t o r port map( b0 , b1 , b2 , b3 ) ; d2 : entity i n v port map( b0 , wb ) ; d3 : entity i n v port map( b1 , xb ) ; d4 : entity i n v port map( b2 , yb ) ; d5 : entity i n v port map( b3 , zb ) ; d6 : entity and4 port map( zb , yb , b1 , wb , a ) ; d7 : entity and4 port map( zb , yb , xb , wb , b ) ; d8 : entity and3 port map( zb , yb , b0 , c ) ; d9 : entity and4 port map( b0 , b1 , b2 , b3 , d ) ; d10 : entity o r 4 port map( a , b , c , d , f ) ; end architecture s t r u c t u r a l ;
On entry of this code into the Qucs VHDL text editor the text is colour coded. Unfortunately, the colour coding is lost when printed, or pasted into a word processor,
102
or a layout package like LaTeX. The structure of the VHDL listing follows the normal convention for text based VHDL simulation. All component entity-architecture models must be dened before they are referenced in other component models. The simulation test bench must be the last entity-architecture model in the VHDL listing. During the VHDL compile phase FreeHDL compiles the component entityarchitecture models to the work library16 . These compiled models are then made available to the simulation test bench through the use of the VHDL use statement inserted in the listing prior to the testbench architecture statement. Once the VHDL listing for the simulation has been typed into the Qucs VHDL code editor, pressing key F2 starts the simulation process. The simulation duration can be set using the Document Settings in the File dropdown menu (or by pressing the Ctrl+. keys). Any VHDL syntax errors, or indeed typos, are written to le and can be viewed by pressing key F5. Obviously if errors are reported these need to be corrected using the VHDL text editor and the simulation cycle restarted. A typical TimeList output for editor example 1 is shown in Fig. 5.11.
dtime b0.X b1.X b2.X b3.X f.X 0 20n 40n 60n 80n 100n 120n 140n 160n 180n 200n 220n 240n 260n 280n 300n 320n
Figure 5.11: Sample simulation waveforms for VHDL editor example 1 design. Example 2: VHDL editor example 1 modelled using dataow VHDL statements. The VHDL code for the second example is given in the next listing. The VHDL style chosen to model the circuit is based on VHDL dataow concurrent signal assignments. The input text vectors are generated using a simple state machine rather than separate process statements. The test vector generator port specication uses entirely single signal bit types and can be easily interfaced, without problems, to other components connected on a Qucs schematic diagram. The procedure for generating schematic capture component symbols from entity - architecture models is introduced in a later section of these notes. The use of bit vector bus constructions is also illustrated in this example. Qucs allows the use of bit vectors as signals or variables in VHDL models provided all signals in the port statement of entity declaration are of type bit only.17 A typical TimeList output for editor example 2 is shown in Fig. 5.12.
16
In most VHDL implementations library work is always visible and there is no requirement to make it visible by using the library and use statements. However, FreeHDL appears to need these statements at the linking phase otherwise the VHDL compiler fails. 17 This is a restriction of Qucs 0.0.9 and will be removed in a later release of the package. Also note signals of type bit vector that are declared in architecture denitions are listed in the TimeList plot signal
103
Qucs VHDL e d i t o r example 2 entity t e s t v e c t o r a i s port ( RESET, CLOCK : in b i t ; B0 , B1 , B2 , B3 : out b i t ); end entity t e s t v e c t o r a ; architecture b e h a v i o u r a l of t e s t v e c t o r a i s s i g n a l p r e s e n t s t a t e , n e x t s t a t e : b i t v e c t o r ( 3 downto 0):= 1111 ; begin p1 : process (CLOCK ) i s begin i f (CLOCK e v e n t and CLOCK= 1 ) then p r e s e n t s t a t e <= n e x t s t a t e ; end i f ; end process p1 ; p2 : process (RESET, present state ) is begin i f (RESET = 1 ) then n e x t s t a t e <= 1111 ; end i f ; case p r e s e n t s t a t e i s when 0000 => n e x t s t a t e <= 0001 ; when 0001 => n e x t s t a t e <= 0010 ; when 0010 => n e x t s t a t e <= 0011 ; when 0011 => n e x t s t a t e <= 0100 ; when 0100 => n e x t s t a t e <= 0101 ; when 0101 => n e x t s t a t e <= 0110 ; when 0110 => n e x t s t a t e <= 0111 ; when 0111 => n e x t s t a t e <= 1000 ; when 1000 => n e x t s t a t e <= 1001 ; when 1001 => n e x t s t a t e <= 1010 ; when 1010 => n e x t s t a t e <= 1011 ; when 1011 => n e x t s t a t e <= 1100 ; when 1100 => n e x t s t a t e <= 1101 ; when 1101 => n e x t s t a t e <= 1110 ; when 1110 => n e x t s t a t e <= 1111 ; when 1111 => n e x t s t a t e <= 0000 ; end case ; B3 <= n e x t s t a t e ( 3 ) ; B2 <= n e x t s t a t e ( 2 ) ; B1 <= n e x t s t a t e ( 1 ) ; B0 <= n e x t s t a t e ( 0 ) ;
dialogue. However, a text message saying no data results if an attempt is made to display them. Again this limitation will be removed in a later release of Qucs.
104
end process p2 ; end architecture b e h a v i o u r a l ; l i b r a r y work ; use work . a l l ; entity t e s t b e n c h i s end entity t e s t b e n c h ; architecture d a t a f l o w of t e s t b e n c h i s s i g n a l r e s e t , c l k , b0 , b1 , b2 , b3 , zb : b i t ; s i g n a l yb , xb , wb , a , b , c , d , f : b i t ; begin p1 : process i s begin c l k <= 0 ; wait f o r 10 ns ; c l k <= 1 ; wait f o r 10 ns ; end process p1 ; p2 : process i s begin r e s e t <= 1 ; wait f o r 10 ns ; r e s e t <= 0 ; wait f o r 2000 ns ; end process p2 ; d1 : entity t e s t v e c t o r a port map( r e s e t , c l k , b0 , b1 , b2 , b3 ) ; Data f l o w model o f c o m b i n a t i o n a l c i r c u i t wb <= not b0 ; xb <= not b1 ; yb <= not b2 ; zb <= not b3 ; a <= (wb and b1 ) and ( yb and zb ) ; b <= (wb and xb ) and ( yb and zb ) ; c <= b0 and ( yb and zb ) ; d <= ( b0 and b1 ) and ( b2 and b3 ) ; f <= a or b or c or d ; end architecture d a t a f l o w ;
Example 3: VHDL editor example 1 modelled using VHDL process statements and variables. The VHDL code for the third example is given in the listing at the end of this paragraph. In this example the use of VHDL variables is illustrated. The VHDL code for the vector generator is a little unusual in that rather than using the traditional two process design employing signals, a single process statement employing variables undertakes both the calculation of the next state data and the transfer of the next state information to the present state. This approach is necessary because FreeHDL does not allowed shared variables. Once again in this example only single bit data
105
10n
20n
30n
40n
50n
60n
70n
80n
90n
100n
110n
120n
130n
140n
150n
160n
170n
Figure 5.12: Sample simulation waveforms for VHDL editor example 2 design. is passed via the entity statement to the device under test. The device under test is represented by a truth table encoded in a process statement. This is not the most elegant code but it does serve the purpose of demonstrating the use of dierent VHDL constructions and data types in Qucs digital simulation. A typical TimeList plot for VHDL editor example 3 is shown in Fig. 5.13. Comparison of the three output plots for the VHDL editor examples indicates that all the simulation results are very similar with some slight dierences in the start up phase following the RESET pulse changing from logic 1 to logic 0. This is probably an eect due to the dierent initialisation sequences for each of the test vector models.
Qucs VHDL e d i t o r example 3 entity t e s t v e c t o r b i s port ( RESET, CLOCK : in b i t ; B0 , B1 , B2 , B3 : out b i t ); end entity t e s t v e c t o r b ; architecture b e h a v i o u r a l of t e s t v e c t o r b i s begin p1 : process (RESET, CLOCK) i s variable p r e s e n t s t a t e , n e x t s t a t e : b i t v e c t o r ( 3 downto 0):= 0000 ; begin i f (RESET = 1 ) then n e x t s t a t e := 0000 ; e l s i f (CLOCK e v e n t and CLOCK= 1 ) then p r e s e n t s t a t e := n e x t s t a t e ; case p r e s e n t s t a t e i s when 0000 => n e x t s t a t e := 0001 ; when 0001 => n e x t s t a t e := 0010 ; when 0010 => n e x t s t a t e := 0011 ; when 0011 => n e x t s t a t e := 0100 ; when 0100 => n e x t s t a t e := 0101 ; when 0101 => n e x t s t a t e := 0110 ; when 0110 => n e x t s t a t e := 0111 ;
106
when 0111 => n e x t s t a t e := 1000 ; when 1000 => n e x t s t a t e := 1001 ; when 1001 => n e x t s t a t e := 1010 ; when 1010 => n e x t s t a t e := 1011 ; when 1011 => n e x t s t a t e := 1100 ; when 1100 => n e x t s t a t e := 1101 ; when 1101 => n e x t s t a t e := 1110 ; when 1110 => n e x t s t a t e := 1111 ; when 1111 => n e x t s t a t e := 0000 ; end case ; end i f ; B3 <= n e x t s t a t e ( 3 ) ; B2 <= n e x t s t a t e ( 2 ) ; B1 <= n e x t s t a t e ( 1 ) ; B0 <= n e x t s t a t e ( 0 ) ; end process p1 ; end architecture b e h a v i o u r a l ; l i b r a r y work ; use work . a l l ; entity t e s t b e n c h i s end entity t e s t b e n c h ; architecture d a t a f l o w of t e s t b e n c h i s s i g n a l r e s e t , c l k , b0 , b1 , b2 , b3 , f : bit ; begin p1 : process i s begin c l k <= 0 ; wait f o r 10 ns ; c l k <= 1 ; wait f o r 10 ns ; end process p1 ; p2 : process i s begin r e s e t <= 1 ; wait f o r 10 ns ; r e s e t <= 0 ; wait f o r 2000 ns ; end process p2 ; d1 : entity t e s t v e c t o r b port map( r e s e t , c l k , b0 , b1 , b2 , b3 ) ; B e h a v i o u r a l model o f c o m b i n a t i o n a l c i r c u i t p3 : process ( b3 , b2 , b1 , b0 ) i s variable SEL : b i t v e c t o r ( 3 downto 0 ) ; begin SEL := b3&b2&b1&b0 ; i f (SEL = 0010 ) then f <= 1 ;
107
e l s i f (SEL = 0000 ) e l s i f (SEL = 1111 ) e l s i f (SEL = 0001 ) e l s i f (SEL = 0011 ) e l s e f <= 0 ; end i f ; end process p3 ; end architecture d a t a f l o w ;
dtime reset.X b0.X b1.X b2.X b3.X f.X 0 10n 20n 30n 40n 50n 60n 70n 80n
f f f f
1 1 1 1
; ; ; ;
90n
100n
110n
120n
130n
140n
150n
160n
170n
Figure 5.13: Sample simulation waveforms for VHDL editor example 3 design.
See for example the XILINX, WebPACK software at http//www.xilinx.com/ise/logic_design_prod/ webpack.htm. 19 Please note that at the start of the VHDL simulation process schematic drawings are converted into a VHDL text le.
108
in the third VHDL editor example. After entering the VHDL entity-architecture model code using the Qucs VHDL editor the nished text is saved in a le with a suitable name and le extension vhdl. Qucs then lists the model under the VHDL project category. Simply clicking on a model name in the VHDL category, with the left hand mouse button, then moving the mouse pointer to a suitable position on a schematic, causes Qucs to move a symbol that represents the model onto the schematic drawing sheet. Placement of the symbol at the position located by the mouse pointer is achieved by clicking the left hand mouse button. The procedure is identical to that used to select and place the Qucs predened symbols on a schematic drawing. Qucs automatically generates a rectangular symbol with a name called VHDL that has the same number of pins as the port statement listed in the VHDL model entity statement. Each of the pins is given a name that corresponds to a name in the entity statement. Qucs xes the order of the pins on the generated symbol. It appears that it is not possible to edit this symbol. However, subcircuit in, out or inout port symbols can be attached to symbol VHDL and a user edited symbol generated. Fig. 5.14 shows the Qucs generated VHDL symbol with attached ports for the model listed in Table 5.4. The edited symbol for the 4 bit binary pattern generator is illustrated in Fig. 5.15. Notice that in Fig. 5.15 the order of the pins has been changed to reect the natural order for a device with its input pins on the left and output pins on the right. VHDL model symbols can also be generated by placing the VHDL le component, this is located in the digital components viewlist, on a schematic. On editing the VHDL le name property of this device to the name of a VHDL entity-architecture model le, Qucs automatically generates a VHDL symbol. Dening your own symbol then proceeds in a similar fashion to the way described above.
CLOCK Num=2
RESET
CLOCK
RESET Num=1
B0 vhdl B1
B1 Num=4
B0 Num=3
B2 B3
B3 Num=6
B2 Num=5
X1
Figure 5.14: Qucs generated VHDL symbol with subcircuit ports for test pattern generator.
109
entity p a t g e n 4 b i t i s port ( RESET, CLOCK : in b i t ; B0 , B1 , B2 , B3 : out b i t ); end entity p a t g e n 4 b i t ; architecture b e h a v i o u r a l of p a t g e n 4 b i t i s begin p1 : process (RESET, CLOCK) i s variable p r e s e n t s t a t e , n e x t s t a t e : b i t v e c t o r ( 3 downto 0):= 0000 ; begin i f (RESET = 1 ) then n e x t s t a t e := 0000 ; e l s i f (CLOCK e v e n t and CLOCK= 1 ) then p r e s e n t s t a t e := n e x t s t a t e ; case p r e s e n t s t a t e i s when 0000 => n e x t s t a t e := 0001 ; when 0001 => n e x t s t a t e := 0010 ; when 0010 => n e x t s t a t e := 0011 ; when 0011 => n e x t s t a t e := 0100 ; when 0100 => n e x t s t a t e := 0101 ; when 0101 => n e x t s t a t e := 0110 ; when 0110 => n e x t s t a t e := 0111 ; when 0111 => n e x t s t a t e := 1000 ; when 1000 => n e x t s t a t e := 1001 ; when 1001 => n e x t s t a t e := 1010 ; when 1010 => n e x t s t a t e := 1011 ; when 1011 => n e x t s t a t e := 1100 ; when 1100 => n e x t s t a t e := 1101 ; when 1101 => n e x t s t a t e := 1110 ; when 1110 => n e x t s t a t e := 1111 ; when 1111 => n e x t s t a t e := 0000 ; end case ; end i f ; B3 <= n e x t s t a t e ( 3 ) ; B2 <= n e x t s t a t e ( 2 ) ; B1 <= n e x t s t a t e ( 1 ) ; B0 <= n e x t s t a t e ( 0 ) ; end process p1 ; end architecture b e h a v i o u r a l ;
110
RESET CLOCK
patgen 4bit
SUB File=name B0 B1 B2 B3 B0 B1 B2 B3
F u l l adder 1 b i t entity f u l l a d d e r i s port ( a , b , c i n : in b i t ; sum , c o u t : out b i t ); end entity f u l l a d d e r ; architecture d a t a f l o w of f u l l a d d e r i s begin sum <= ( a xor b ) xor c i n ; c o u t <= ( a and b ) or ( a and c i n ) or ( b and c i n ) ; end architecture d a t a f l o w ;
Table 5.5: VHDL code for a 1 bit full adder. Example 5: A 4 bit full adder. VHDL model symbols may be combined with either the Qucs predened digital component symbols or other subcircuit symbols. In this example a VHDL model for a simple one bit full adder is connected four times in a serial fashion to form a 4 bit full adder. The VHDL model code for a simple one bit full adder is given in Table 5.5. The associated symbol diagrams for the one bit full adder are illustrated in Fig. 5.16 and Fig. 5.17.
111
a
cin vhdl sum
sum
cin
cout
cout
X1
Figure 5.16: Qucs generated VHDL symbol with subcircuit ports for one bit full adder.
a b cin CI CO
Figure 5.17: User dened one bit full symbol. Figure 5.18 shows the schematic for a simple 4 bit ripple adder. The corresponding user dened symbol for the 4 bit full adder is given in Fig. 5.19.
112
SUB1
sum0
a0 b0 cin
CI
CO
SUB2
sum1
a1 b1 CI
CO
SUB3
sum2
a3 b2 CI
CO
SUB4
sum3
a4 b3 CI
CO
cout
113
a0 a1 a3 a4 b0 b1 b2 b3 cin
sum0 a
}
3 0
}b
3 CI
CO
cout
SUB File=name
Figure 5.19: User dened 4 bit full adder symbol. b3 a3 a0b3 a1b3 a1b2 a2b3 a2b2 a2b1 a3b3 a3b2 a3b1 a3b0 r7 r6 r5 r4 r3 b2 a2 a0b2 a1b1 a2b0 r2 b1 b0 a1 a0 a0b1 a0b0 a1b0
r1
r0
Table 5.6: Product table for a 4 bit by 4 bit combinational multiplier. The VHDL code for this example is presented in the following listing. This listing was generated by Qucs20 . A small section of the TimeList waveform plot for the digital multiplier is shown in Fig. 5.21. At 1.74 micro seconds input a is 0101, input b is 0111 and the output r is 00100011 which is 35 in decimal. Taking a few random checks of the simulation results indicates that the 4 bit by 4 bit multiplier design works correctly. Notice that the VHDL code generated by Qucs for the 4 bit multiplier does not contain any propagation delay timing data. This could be added to the and gates, if required. However, at this stage in the development of Qucs digital simulation passing timing data, and other parameters, from device symbols generated from VHDL models has not been implemented yet. The use of VHDL generics is an obvious way this could be done. Generics are allowed,
20
Some readers will have noticed that the naming scheme for internal signal nets is dierent in the multiplier VHDL listing when compared to the VHDL listings in the rst version of these notes. Towards the end of the 0.0.9 development phase the naming convention employed by Qucs was changed to give a more exible structure.
114
115
Y1
CLOCK
digital simulation
Digi1 Type=TimeList time=5000 ns
SUB5
A3 A2 A1 A0
116
1
SUB3 R patgen 4bit B2 B3 B1 B0 B2 B3 B1 R B3 B2 B1 B0 patgen 4bit B0
R SUB1
CLOCK
&
Y2 &
R0
R1
}
3 0
}b
3 CI
CO
R2
SUB4
}
3 0
& Y10 & Y11 & Y12 & Y13 & Y14 & Y15 & Y16
Y17
}b
3 CI SUB6
CO
R3 R4
}a
3 0
R5 R6
R7 CO
}b
3 CI
Qucs 0 . 0 . 9 /mnt/ hda2 / v h d l c o m p l i b p r j / m u l t i p l i e r 4 b x 4 b i t . s c h entity p a t g e n 4 b i t i s port ( RESET, CLOCK : in b i t ; B0 , B1 , B2 , B3 : out b i t ); end entity p a t g e n 4 b i t ; architecture b e h a v i o u r a l of p a t g e n 4 b i t i s begin p1 : process (RESET, CLOCK) i s variable p r e s e n t s t a t e , n e x t s t a t e : b i t v e c t o r ( 3 downto 0 ) := 0000 ; begin i f (RESET = 1 ) then n e x t s t a t e := 0000 ; e l s i f (CLOCK e v e n t and CLOCK= 1 ) then p r e s e n t s t a t e := n e x t s t a t e ; case p r e s e n t s t a t e i s when 0000 => n e x t s t a t e := 0001 ; when 0001 => n e x t s t a t e := 0010 ; when 0010 => n e x t s t a t e := 0011 ; when 0011 => n e x t s t a t e := 0100 ; when 0100 => n e x t s t a t e := 0101 ; when 0101 => n e x t s t a t e := 0110 ; when 0110 => n e x t s t a t e := 0111 ; when 0111 => n e x t s t a t e := 1000 ; when 1000 => n e x t s t a t e := 1001 ; when 1001 => n e x t s t a t e := 1010 ; when 1010 => n e x t s t a t e := 1011 ; when 1011 => n e x t s t a t e := 1100 ; when 1100 => n e x t s t a t e := 1101 ; when 1101 => n e x t s t a t e := 1110 ; when 1110 => n e x t s t a t e := 1111 ; when 1111 => n e x t s t a t e := 0000 ; end case ; end i f ; B3 <= n e x t s t a t e ( 3 ) ; B2 <= n e x t s t a t e ( 2 ) ; B1 <= n e x t s t a t e ( 1 ) ; B0 <= n e x t s t a t e ( 0 ) ; end process p1 ; end architecture b e h a v i o u r a l ; entity S u b p a t g e n 4 b i t i s port ( n e t n e t 0 : in b i t ; n e t n e t 5 : in b i t ;
117
n e t o u t n e t n e t 1 : out b i t ; n e t o u t n e t n e t 3 : out b i t ; n e t o u t n e t n e t 2 : out b i t ; n e t o u t n e t n e t 4 : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b p a t g e n 4 b i t of S u b p a t g e n 4 b i t i s signal net net1 , net net2 , net net3 , net net4 : bit ; begin n e t o u t n e t n e t 1 <= n e t n e t 1 or 0 ; n e t o u t n e t n e t 2 <= n e t n e t 2 or 0 ; n e t o u t n e t n e t 3 <= n e t n e t 3 or 0 ; n e t o u t n e t n e t 4 <= n e t n e t 4 or 0 ; X1 : entity p a t g e n 4 b i t port map ( n e t n e t 0 , n e t n e t 5 , net net1 , net net3 , net net2 , net net4 ) ; end architecture ;
l o g i c z e r o . v h d l entity l o g i c z e r o i s port ( Y : out b i t ); end entity l o g i c z e r o ; architecture d a t a f l o w of l o g i c z e r o i s begin Y <= 0 ; end architecture d a t a f l o w ;
entity S u b l o g i c z e r o i s port ( n e t o u t n e t Y : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b l o g i c z e r o of S u b l o g i c z e r o i s s i g n a l netY : b i t ; begin X1 : entity l o g i c z e r o port map ( netY ) ; n e t o u t n e t Y <= netY or 0 ; end architecture ;
118
F u l l adder 1 b i t entity f u l l a d d e r i s port ( a , b , c i n : in b i t ; sum , c o u t : out b i t ); end entity f u l l a d d e r ; architecture d a t a f l o w of f u l l a d d e r i s begin sum <= ( a xor b ) xor c i n ; c o u t <= ( a and b ) or ( a and c i n ) or ( b and c i n ) ; end architecture d a t a f l o w ;
entity S u b f u l l a d d e r 1 b i t i s port ( n e t n e t 0 : in b i t ; n e t n e t 1 : in b i t ; n e t n e t 2 : in b i t ; n e t o u t n e t n e t 3 : out b i t ; n e t o u t n e t n e t 4 : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b f u l l a d d e r 1 b i t of S u b f u l l a d d e r 1 b i t i s signal net net3 , net net4 : bit ; begin X1 : entity f u l l a d d e r port map ( n e t n e t 0 , n e t n e t 1 , net net2 , net net3 , net net4 ) ; n e t o u t n e t n e t 3 <= n e t n e t 3 or 0 ; n e t o u t n e t n e t 4 <= n e t n e t 4 or 0 ; end architecture ;
entity S u b port ( n e t net net net net net net net net net net
119
n e t o u t n e t n e t 1 0 : out b i t ; n e t o u t n e t n e t 1 1 : out b i t ; n e t o u t n e t n e t 1 2 : out b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b f u l l a d d e r 4 b i t of S u b f u l l a d d e r 4 b i t i s signal net net14 , net net15 , net net16 , net net8 , net net9 , net net10 , net net11 , net net12 : bit ; begin n e t o u t n e t n e t 8 <= n e t n e t 8 or 0 ; n e t o u t n e t n e t 9 <= n e t n e t 9 or 0 ; n e t o u t n e t n e t 1 0 <= n e t n e t 1 0 or 0 ; n e t o u t n e t n e t 1 1 <= n e t n e t 1 1 or 0 ; n e t o u t n e t n e t 1 2 <= n e t n e t 1 2 or 0 ; SUB4 : entity S u b f u l l a d d e r 1 b i t port map ( n e t n e t 3 , n e t n e t 1 3 , net net14 , net net11 , net net12 ) ; SUB3 : entity S u b f u l l a d d e r 1 b i t port map ( n e t n e t 2 , n e t n e t 6 , net net15 , net net10 , net net14 ) ; SUB2 : entity S u b f u l l a d d e r 1 b i t port map ( n e t n e t 1 , n e t n e t 5 , net net16 , net net9 , net net15 ) ; SUB1 : entity S u b f u l l a d d e r 1 b i t port map ( n e t n e t 0 , n e t n e t 4 , net net7 , net net8 , net net16 ) ; end architecture ; entity TestBench i s end entity ; use work . a l l ; architecture Arch TestBench of TestBench i s s i g n a l netA0 , netA1 , netA2 , netA3 , netR , netB0 , netB1 , netB2 , netB3 , netR0 , netR1 , netR2 , netR3 , netR4 , netR5 , netR6 , netR7 , netCLOCK , net net0 , net net1 , net net2 , net net3 , net net4 , net net5 , net net6 , net net7 , net net8 , net net9 , net net10 , net net11 , net net12 , net net13 , net net14 , net net15 , net net16 , net net17 , net net18 , net net19 , net net20 , net net21 , net net22 , net net23 , net net24 : bit ; begin
120
SUB3 : entity S u b p a t g e n 4 b i t port map ( netR , n e t n e t 0 , netA0 , netA1 , netA2 , netA3 ) ; SUB1 : entity S u b p a t g e n 4 b i t port map ( netR , netCLOCK , netB0 , netB1 , netB2 , netB3 ) ; R: process begin netR <= 1 ; netR <= 0 ; end process ;
wait f o r 10 ns ; wait f o r 10 ns ;
n e t n e t 0 <= not netB3 ; netR0 <= netA0 and netB0 ; n e t n e t 1 <= netA0 and netB1 ; n e t n e t 2 <= netA0 and netB2 ; n e t n e t 3 <= netA0 and netB3 ; SUB5 : entity S u b l o g i c z e r o port map ( n e t n e t 4 ) ; n e t n e t 5 <= netA1 and netB0 ; n e t n e t 6 <= netA1 and netB1 ; n e t n e t 7 <= netA1 and netB2 ; n e t n e t 8 <= netA1 and netB3 ; n e t n e t 9 <= netA2 and netB0 ; n e t n e t 1 0 <= netA2 and netB1 ; n e t n e t 1 1 <= netA2 and netB2 ; n e t n e t 1 2 <= netA2 and netB3 ; SUB4 : entity S u b f u l l a d d e r 4 b i t port map ( n e t n e t 1 , n e t n e t 2 , net net3 , net net4 , net net5 , net net6 , net net7 , n e t n e t 8 , n e t n e t 4 , netR1 , n e t n e t 1 3 , n e t n e t 1 4 , net net15 , net net16 ) ; SUB6 : entity S u b f u l l a d d e r 4 b i t port map ( n e t n e t 1 3 , n e t n e t 1 4 , net net15 , net net16 , net net9 , net net10 , net net11 , n e t n e t 1 2 , n e t n e t 4 , netR2 , n e t n e t 1 7 , n e t n e t 1 8 , net net19 , net net20 ) ; n e t n e t 2 1 <= netA3 and netB0 ; n e t n e t 2 2 <= netA3 and netB1 ; n e t n e t 2 3 <= netA3 and netB2 ; n e t n e t 2 4 <= netA3 and netB3 ; SUB7 : entity S u b f u l l a d d e r 4 b i t port map ( n e t n e t 1 7 , n e t n e t 1 8 ,
121
net net19 , net net20 , net net21 , net net22 , n e t n e t 2 3 , n e t n e t 2 4 , n e t n e t 4 , netR3 , netR4 , netR5 , netR6 , netR7 ) ; end architecture ;
dtime clock.X a0.X a1.X a2.X a3.X b0.X b1.X b2.X b3.X r0.X r1.X r2.X r3.X r4.X r5.X r6.X r7.X 1.67u 1.68u 1.69u 1.7u 1.71u 1.72u 1.73u 1.74u 1.75u 1.76u 1.77u 1.78u 1.79u
Figure 5.21: A section of the 4 bit by 4 bit combinational digital multiplier TimeList output waveforms.
122
of testing has taken place it is likely that software bugs will come to light as more Qucs users try the new features - if you nd a bug please report it by posting a note on the Qucs Web site. Adding new signal types to Qucs digital simulation aects all sections of the simulation route from schematic capture to plotting and tabulating input and output signals. Hence, although it may seem the wrong way round, the place to rst implement the necessary changes to accommodate the new signal types is at the simulation results reporting stages of the Qucs package. In release 0.0.10 no attempt has been made to add the new signal types to the schematic capture part of the Qucs package.21 Recent work on the digital sections of the Qucs package has concentrated on (1) improvements to VHDL language entry using the Qucs colour coded VHDL text editor22 , (2) modications to FreeHDL which allow a cleaner interface between Qucs and FreeHDL, (3) upgrades to the data conversion of simulation results from the FreeHDL value change dump format to the native Qucs format, and (4) major changes to the results reporting routines that are accessed from the Qucs diagrams icon dialogue. A detailed list of the software changes and bug xes can be found in the Qucs and FreeHDL change log les.
Adding new signal types to Qucs schematic capture is on the to-do list. A number of editor bugs have been xed and it is now possible for users to dene their own colour scheme for the various classes of VHDL reserved words and data types. 23 For the FreeHDL package to operate correctly the directory where the software is installed must be included in the shell PATH from which Qucs is launched.
123
Program freeehdl-v2cc converts VHDL code into C++ functions. These are then compiled along with a main C++ function. The next stage in the sequence links the compiled object code with the object code from any references to items in the predened VHDL libraries to produce an executable digital simulation program. This is then run by Qucs outputting a set of simulation results in value change dump (VCD) format24 . Finally a program called qucsconv converts the VCD simulation results into the Qucs native data format ready for post processing as graphical or tabular diagrams by Qucs.
24
The value change dump language was originally designed as a simulation waveform interchange format for Verilog HDL. The specication of the VCD format can be found at http://wwwee.eng.hawaii.edu/ msmith/ASICs/HTML/Verilog/LRM/HTML/15/ch15.2.htm
124
Compiling functions,,,
0
log,t%t log,t%t #RROR an! ot$er results !ata QUCS (imeList plot
Compiling main,,,
Lin'ing,,,,
VHDL st! li)rar* stan!ar!,o +### li)rar* st!_logic_--./,o
file_name_main_,o
FreeHDL Lin'ing
file_name log,t%t
Simulating,,,,
file_name,"c!
Figure 5.22: Detailed ow diagram showing VHDL code compilation and simulation results processing.
125
126
VHDL data types, functions and operators in package standard are always visible to VHDL test bench code and reference to their use need not be added explicitly. However, if the test bench entity-architecture uses data types or other items dened in other libraries, for example the std_logic type in the IEEE library, then reference to them needs to be added before each entity-architecture pair where they are used. Libraries are referenced using the VHDL library and use statements. An example showing how these statements are employed is outlined in the following VHDL code segment:
library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity t e s t b e n c h i s e n t i t y body s t a t e m e n t s end entity t e s t b e n c h ; architecture b e h a v i o u r a l of t e s t b e n c h i s a r c h i t e c t u r e body s t a t e m e n t s end architecture b e h a v i o u r a l ;
Here the VHDL code word all signies that all items in a specic library are to be made available for use in the following entity/architecture pair; testbench in the above example. If more than one library is to be used then a library/use statement is needed for each library reference. Most complete VHDL circuit simulation programs consist of more than one entity/architecture pair. In such cases the circuit test bench, with its signal test vectors, must be the last entry in the program. An example of a more complex VHDL program structure is
library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity comp1 i s e n t i t y body s t a t e m e n t s end entity comp1 ; architecture b e h a v i o u r a l of comp1 i s a r c h i t e c t u r e body s t a t e m e n t s end architecture b e h a v i o u r a l ; library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity comp2 i s e n t i t y body s t a t e m e n t s end entity comp2 ; architecture b e h a v i o u r a l of comp2 i s a r c h i t e c t u r e body s t a t e m e n t s
127
end architecture b e h a v i o u r a l ; library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; use work . a l l ; entity t e s t b e n c h i s e n t i t y body s t a t e m e n t s end entity t e s t b e n c h ; architecture b e h a v i o u r a l of t e s t b e n c h i s a r c h i t e c t u r e body s t a t e m e n t s end architecture b e h a v i o u r a l ;
During the conversion of VHDL code to a machine code simulation program each entity/architecture pair, prior to the nal test bench entry, is compiled as a separate design unit and stored in the work library26 . Compiled design units held in the work library can be referenced in other entity/architecture models provided the VHDL statement use work.all; 27 is inserted in the VHDL simulation code prior to each entity/architecture statement where they are referenced.
26
The testbench entity/architecture pair is also, of course, compiled but this design unit is the one that is run as the executable simulation program. 27 References to individual items are also allowed by inserting, for example, use.work.comb1; use.work.comb2; in the VHDL code.
128
Scalar
File
Access
Composite
Array Record
The chart shown in Fig. 5.23 indicates the dierent data types that are available in the VHDL language. FreeHDL implements all these data types. In practical circuit simulation the dierent VHDL data types are normally used to specify (1) signals, (2) variables and (3) constants28 . During simulation Qucs/FreeHDL automatically stores the values of integer, real and enumerated bit signals as simulation time progresses. Furthermore, bit_vector and IEEE signal types including std_logic_vector are also stored. Signals of these types are then available for plotting and tabulation using the Timing, Truth table, Tabular and Cartesian output diagrams. Selected elements in user dened composite signals, those that are stored in arrays for example29 , can be assigned to the basic signal types then displayed.30 . An example of how this is done is given in later sections of these update tutorial notes. Note - the values of variables and constants are not recorded during simulation.
28
Type le is of course dierent in that it is used to store either test vectors, component data such as ROM contents and output simulation results. 29 Please note that signal types based on the composite type record will probably cause the Qucs simulation cycle to fail - work on this data type has been added to the to-do list. 30 Qucs/FreeHDL also automatically collects waveform data for composite signals based on arrays of bit and IEEE signal types. However, in the case of large arrays care is needed when plotting or tabulating these directly because the entire contents of an array is output each time a signal is displayed.
129
Figure 5.24: Output results for a simple test bench example employing integer signals.
The specication for the FreeHDL library STD can be found in text le freehdl-0.0.3/std/standard.vhdl.
130
systems simply using only logic 0 and logic 1 signal encoding. Moreover, circuits where bus signal contention occurs often result in simulation failure. The IEEE std_logic_1164 package overcomes this limitation through the introduction of a multivalued logic system which denes nine dierent logic values to represent signal types and signal strengths. Not only is the bus contention problem solved through logic resolving functions but the multivalued logic system allows devices constructed from dierent manufacturing technologies to be simulated at the same time, ensuring that the simulation process mirrors real circuit design practices. The next two simulation examples introduce the nine value logic system and demonstrate its use in the design of digital bus systems. Signals of type real are also introduced to show their representation by Qucs. Listed below is the VHDL code for a basic simulation which generates a set of IEEE std_logic, integer and real signals. Figure 5.25 illustrates how the Qucs Timing diagram displays dierent signal types. A section of tabulated results are also given in Fig. 5.26.
library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity t e s t b e n c h i s end entity t e s t b e n c h ; architecture b e h a v i o u r a l of t e s t b e n c h i s signal c l k : b i t ; s i g n a l bv1 : b i t v e c t o r ( 8 downto 0 ) ; s i g n a l s t d l 1 : s t d l o g i c v e c t o r ( 8 downto 0 ) ; s i g n a l INT1 : i n t e g e r := 0 ; s i g n a l INT2 : i n t e g e r := 9 9 ; s i g n a l R1 : r e a l := 0 . 3 3 ; s i g n a l R2 : r e a l := 9 9 . 0 ; s i g n a l R3 : r e a l := 0 . 0 ; s i g n a l R4 : r e a l := 0 . 0 ; begin p0 : process i s begin c l k <= 0 ; wait f o r 10 ns ; c l k <= 1 ; wait f o r 10 ns ; end process p0 ; p1 : process ( c l k ) i s variable v1 : i n t e g e r := 0 ; begin i f ( c l k e v e n t and c l k = 1 ) then v1 := v1 +1; case v1 i s when 1 => bv1 <= 000000000 ; s t d l 1 <= 000000000 ;
131
when 2 => bv1 <= 000000001 ; when 3 => bv1 <= 000000011 ; when 4 => bv1 <= 000000111 ; when 5 => bv1 <= 000001111 ; when 6 => bv1 <= 000011111 ; when 7 => bv1 <= 000111111 ; when 8 => bv1 <= 001111111 ; when 9 => bv1 <= 111111111 ; when others => v1 := 0 ; end case ; end i f ; end process p1 ; p3 : process ( c l k ) i s begin i f ( c l k e v e n t and c l k = 1 ) INT1 <= INT1 + 1 ; INT2 <= INT2 20; end i f ; i f ( INT1 >= 9 ) then INT1 <= 0 ; INT2 <= 9 9 ; end i f ; end process p3 ; p4 : process ( c l k ) i s Variable V2 : r e a l ; begin i f ( c l k e v e n t and c l k = 1 ) R1 <= R1 + 1 . 0 ; R2 <= R2 20.0; R3 <= R1 R2 ; R4 <= R2/ (R1 + 0 . 0 0 0 1 ) ; end i f ; i f (R1 >= 2 0 . 0 ) then R1 <= 0 . 0 ; R2 <= 9 9 . 0 ; end i f ; end process p4 ; end architecture b e h a v i o u r a l ;
then
then
132
dtime clk.X r1.R r2.R r3.R r4.R stdl1.X int1.R int2.R bv1.X
dtime clk.X r1.R r2.R r3.R r4.R stdl1.X int1.R int2.R bv1.X
The VCD waveform interchange standard encodes digital signals as four dierent logic levels. These are 0, 1, Z (high impedance) and X (unknown). Table 5.7 lists how the nine ieee.std_logic signal levels are represented using the VCD format. Until the VCD standard is revised the Qucs/FreeHDL package is restricted to displaying simulation output data using the basic 0, 1, Z and X signal encoding. The next example shows how the IEEE std_logic signal type can be used to simulate bus logic. The demonstration has been kept simple in order to keep the VHDL code short. The code fragment simulates two tri-state buers which pass their outputs to bus drivers whos outputs connect on a common signal bus. The bus drivers ensure that the outputs from the tri-state buers are kept separate before combining onto the common bus line. This allows the output signals from the tri-state buers and the combined signal to be plotted separately. The resulting waveforms clearly show the std_logic resolution function in operation, see Fig. 5.27 . Note
133
VHDL signal levels 0 Forcing logic 0 1 Forcing logic 1 X Forcing unknown Z High impedance U Uninitialised W Weak unknown L Weak logic 0 H Weak logic 1 - Dont care
VCD 0 1 X Z X 0 0 1 X
Table 5.7: IEEE multivalue logic and VCD representation. the eect of the 7 ns delay on the plotted waveforms and the use of the VHDL generic statement to set the invert device delay value.
Demonstration o f a s i m p l e bus s t r u c t u r e u s i n g t h e IEEE s t d l o g i c d a t a t y p e . library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity buf i s generic ( d e l a y : time := 0 ns ) ; port ( in1 , c o n t r o l : in s t d l o g i c ; out1 : out s t d l o g i c ); end entity buf ; architecture b e h a v i o u r a l of buf i s begin p0 : process ( in1 , c o n t r o l ) i s begin i f ( c o n t r o l = 1 ) then out1 <= i n 1 a f t e r d e l a y ; e l s e out1 <= Z ; end i f ; end process p0 ; end architecture b e h a v i o u r a l ; library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity i n v e r t i s generic ( d e l a y : time := 0 ns ) ; port ( i n 1 : in s t d l o g i c ;
134
out1 : out s t d l o g i c ); end entity i n v e r t ; architecture b e h a v i o u r a l of i n v e r t i s begin out1 <= not i n 1 a f t e r d e l a y ; end architecture b e h a v i o u r a l ; library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; entity buf2 i s port ( i n 1 : in s t d l o g i c ; out1 : out s t d l o g i c ); end entity buf2 ; architecture d a t a f l o w of buf2 i s begin out1 <= i n 1 ; end architecture d a t a f l o w ; library i e e e ; use i e e e . s t d l o g i c 1 1 6 4 . a l l ; use work . a l l ; entity t e s t b e n c h i s end entity t e s t b e n c h ; architecture s t r u c t u r a l of t e s t b e n c h i s signal data in 1 , data in 2 : s t d l o g i c ; signal data out 1 , data out 2 : s t d l o g i c ; signal data control , control buf1 : std logic ; signal r e s u l t : s t d l o g i c ; begin p0 : process i s begin d a t a i n 1 <= 0 ; wait f o r 5 ns ; d a t a i n 1 <= 1 ; wait f o r 5 ns ; end process p0 ;
135
d a t a i n 2 <= not d a t a i n 1 ; p1 : process i s begin d a t a c o n t r o l <= 1 ; wait f o r 40 ns ; d a t a c o n t r o l <= 0 ; wait f o r 40 ns ; end process p1 ; c1g1 : entity buf port map( i n 1 => d a t a i n 1 , c o n t r o l => d a t a c o n t r o l , out1 => d a t a o u t 1 ) ; c1g2 : entity i n v e r t generic map ( d e l a y => 7 ns ) port map( i n 1 => d a t a c o n t r o l , out1 => c o n t r o l b u f 1 ) ; c1g3 : entity buf port map( i n 1 => d a t a i n 2 , c o n t r o l => c o n t r o l b u f 1 , out1 => d a t a o u t 2 ) ; c1g4 : entity buf2 port map( i n 1 => d a t a o u t 1 , out1 => r e s u l t ) ; c1g5 : entity buf2 port map( i n 1 => d a t a o u t 2 , out1 => r e s u l t ) ; end architecture s t r u c t u r a l ;
136
dtime 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 1.3e-7 1.4e-7 1.5e-7 1.6e-7 1.7e-7 1.8e-7 1.9e-7
clk.X 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
int1.R 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 0 1
r1.R 0.33 1.33 1.33 2.33 2.33 3.33 3.33 4.33 4.33 5.33 5.33 6.33 6.33 7.33 7.33 8.33 8.33 9.33 9.33 10.3
r2.R 99 79 79 59 59 39 39 19 19 -1 -1 -21 -21 -41 -41 -61 -61 -81 -81 -101
r3.R 0 32.7 32.7 105 105 137 137 130 130 82.3 82.3 -5.33 -5.33 -133 -133 -301 -301 -508 -508 -756
r4.R 0 300 300 59.4 59.4 25.3 25.3 11.7 11.7 4.39 4.39 -0.188 -0.188 -3.32 -3.32 -5.59 -5.59 -7.32 -7.32 -8.68
bv1.X 000000000 000000000 000000000 000000001 000000001 000000011 000000011 000000111 000000111 000001111 000001111 000011111 000011111 000111111 000111111 001111111 001111111 111111111 111111111 111111111
stdl1.X XXXXXXXXX 000000000 000000000 000000001 000000001 00000001X 00000001X 0000001XZ 0000001XZ 000001XZX 000001XZX 00001XZX0 00001XZX0 0001XZX00 0001XZX00 001XZX001 001XZX001 01XZX001X 01XZX001X 01XZX001X
00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111 10000 10001 10010 10011 10100
clk.X 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
int1.R 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 0 1 1
int2.R 99 79 79 59 59 39 39 19 19 1 1 21 21 41 41 61 61 81 99 79 79
r1.R 0.33 1.33 1.33 2.33 2.33 3.33 3.33 4.33 4.33 5.33 5.33 6.33 6.33 7.33 7.33 8.33 8.33 9.33 9.33 10.33 10.33
r3.R 0 32.67 32.67 105.07 105.07 137.47 137.47 129.87 129.87 82.27 82.27 5.33 5.33 132.93 132.93 300.53 300.53 508.13 508.13 755.73 755.73
r4.R 0 299.909 299.909 59.394 59.394 25.3208 25.3208 11.7114 11.7114 4.38789 4.38789 0.187614 0.187614 3.31748 3.31748 5.59338 5.59338 7.32284 7.32284 8.68158 8.68158
bv1.X 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 001 001 111 111 111 111
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
stdl1.X XXXXXXXXX 000000000 000000000 000000001 000000001 00000001X 00000001X 0 0 0 0 0 0 1 XZ 0 0 0 0 0 0 1 XZ 0 0 0 0 0 1 XZX 0 0 0 0 0 1 XZX 0 0 0 0 1 XZX0 0 0 0 0 1 XZX0 0 0 0 1 XZ X0 0 0 0 0 1 XZ X0 0 0 0 1 XZX0 0 1 0 0 1 XZX0 0 1 0 1 XZ X0 0 1 X 0 1 XZ X0 0 1 X 0 1 XZ X0 0 1 X 0 1 XZ X0 0 1 X
137
5n
7n
10n
15n
20n
25n
30n
35n
40n
45n
47n
50n
55n
60n
65n
70n
75n
80n
Z X
Z X
Z Z
Z Z
80n
85n
87n
90n
95n
100n
105n
110n
115n
120n
125n
127n
130n
135n
140n
145n
150n
155n
Z Z
Z Z
138
and functional_multiplier architecture code. During simulation these text strings, and the simulation time when they were actioned, are written to the Qucs log.txt le, giving a trace record of the simulation activity. In cases where an error occurs at severity level failure the simulation will terminate. FreeHDL allows VHDL report statements without an accompanying assert statement.32 A typical Timing diagram plot for this design is shown in Fig. 5.29
X
Data generator 16 16
Res_bit
32
CLK
CLOCK X= Y= bit_!ector"1# $o%nto &' bit_!ector"1# $o%nto &' bit_!ector"31 $o%nto &'
Res_bit =
One of the changes at the 1993 revision of the IEEE VHDL 1076-1987 standard was to allow report statements without the previous mandatory assert clause. FreeHDL attempts to comply with the 1993 revision.
139
end process p0 ; end architecture b e h a v i o u r a l ; entity d a t a g e n e r a t o r i s port ( c l k : in b i t ; x , y : out b i t v e c t o r ( 1 5 downto 0 ) ); end entity d a t a g e n e r a t o r ; architecture b e h a v i o u r a l of d a t a g e n e r a t o r i s type mem array 16 i s array ( 1 to 8 ) of i n t e g e r ; s i g n a l count : i n t e g e r := 0 ; function i n t e g e r t o v e c t o r 1 6 ( i n t n o : i n t e g e r ) return b i t v e c t o r i s variable n i : i n t e g e r ; variable r e t u r n v a l u e : b i t v e c t o r ( 1 5 downto 0 ) ; begin assert ( n i < 0 ) report Function i n t e g e r t o v e c t o r 3 2 : i n t e g e r number must be >= 0 severity f a i l u r e ; n i := i n t n o ; for i in r e t u r n v a l u e Reverse Range loop i f ( ( n i mod 2 ) =1 ) then r e t u r n v a l u e ( i ) := 1 ; e l s e r e t u r n v a l u e ( i ) := 0 ; end i f ; n i := n i / 2 ; end loop ; return r e t u r n v a l u e ; end i n t e g e r t o v e c t o r 1 6 ; begin p1 : process ( c l k ) i s variable x i : mem array 16 := ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ) ; variable y i : mem array 16 := ( 2 , 4 , 6 , 8 , 1 0 , 1 2 , 1 4 , 1 6 ) ; variable xh , yh : i n t e g e r ; variable c o u n t i : i n t e g e r ; begin c o u n t i := count +1; i f ( c o u n t i > 8 ) then c o u n t i := 1 ; end i f ; xh := x i ( c o u n t i ) ; yh := y i ( c o u n t i ) ; x <= i n t e g e r t o v e c t o r 1 6 ( xh ) ;
140
y <= i n t e g e r t o v e c t o r 1 6 ( yh ) ; count <= c o u n t i ; report In p r o c e s s p1 . d a t a g e n e r a t o r . ; end process p1 ; end architecture b e h a v i o u r a l ; entity f u n c t i o n a l m u l t i p l i e r i s port ( x , y : in b i t v e c t o r ( 1 5 downto 0 ) ; r e s b i t : out b i t v e c t o r ( 3 1 downto 0 ) ); end entity f u n c t i o n a l m u l t i p l i e r ; architecture b e h a v i o u r a l of f u n c t i o n a l m u l t i p l i e r i s function v e c t o r t o i n t e g e r ( v1 : b i t v e c t o r ) return i n t e g e r i s variable r e t u r n v a l u e : i n t e g e r : = 0 ; a l i a s v2 : b i t v e c t o r ( v1 l e n g t h 1 downto 0 ) i s v1 ; begin for i in v2 h i g h downto 1 loop i f ( v2 ( i ) = 1 ) then r e t u r n v a l u e := ( r e t u r n v a l u e +1) 2; else r e t u r n v a l u e := r e t u r n v a l u e 2 ; end i f ; end loop ; i f v2 ( 0 ) = 1 then r e t u r n v a l u e := r e t u r n v a l u e +1; end i f ; return r e t u r n v a l u e ; end v e c t o r t o i n t e g e r ; function i n t e g e r t o v e c t o r 3 2 ( i n t n o : i n t e g e r ) return b i t v e c t o r i s variable n i : i n t e g e r ; variable v a l u e : b i t v e c t o r ( 3 1 downto 0 ) ; begin assert ( n i < 0 ) report Function i n t e g e r t o v e c t o r 3 2 : i n t e g e r number must be >= 0 severity f a i l u r e ; n i := i n t n o ; for i in 0 to 31 loop i f ( ( n i mod 2 ) =1 ) then v a l u e ( i ) := 1 ; e l s e v a l u e ( i ) := 0 ; end i f ; i f n i > 0 then n i := n i / 2 ;
141
e l s e n i := ( ni 1)/2; end i f ; end loop ; return v a l u e ; end i n t e g e r t o v e c t o r 3 2 ; begin p0 : process ( x , y ) i s variable xi , yi , prod mult : i n t e g e r ; begin x i := v e c t o r t o i n t e g e r ( x ) ; y i := v e c t o r t o i n t e g e r ( y ) ; prod mult := x i y i ; r e s b i t <= i n t e g e r t o v e c t o r 3 2 ( prod mult ) ; report In p r o c e s s p1 . f u n c t i o n a l m u l t i p l i e r ; end process p0 ; end architecture b e h a v i o u r a l ; entity t e s t 2 v h d l 1 i s end entity t e s t 2 v h d l 1 ; architecture b e h a v i o u r a l of t e s t 2 v h d l 1 i s signal c l k : b i t ; s i g n a l x , y : b i t v e c t o r ( 1 5 downto 0 ) ; s i g n a l r e s b i t : b i t v e c t o r ( 3 1 downto 0 ) ; begin d1 : entity work . c l o c k port map ( c l k ) ; d2 : entity work . d a t a g e n e r a t o r port map( c l k , x , y ) ; d3 : entity work . f u n c t i o n a l m u l t i p l i e r port map ( x , y , r e s b i t ) ; end architecture b e h a v i o u r a l ;
142
30n
40n
60n
80n
Figure 5.29: Typical timing diagram for the 16 bit functional multiplier. More advanced output debug messages, and results tables, can be written to Qucs message le log.txt by using the predened data handling routines in STD library package textio33 . This package contains functions for reading and writing STD data types from and to les34 . The next segment of VHDL code illustrates how a simple table of results can be written to le log.txt. The results table is shown in Table 5.8.
Test t e x t i o p a c k a g e . l i b r a r y STD ; use STD . t e x t i o . a l l ; entity Q u c s w r i t e t e s t i s end entity Q u c s w r i t e t e s t ;
33 34
The specication for the FreeHDL package textio can be found in text le freehdl-0.0.3/std/textio.vhdl. VHDL allows data to be read from and written to the standard input and output streams as well as user dened les. At this time only writing data to le log.txt and reading data from user dened data les has been tested. Please note that the use of the textio package is very much a cutting edge feature of the Qucs/FreeHDL software and is probably not bug free.
143
architecture b e h a v i o u r a l of Q u c s w r i t e t e s t i s begin w r i t e t e s t : process i s variable i n p u t l i n e , o u t p u t l i n e : l i n e ; variable i n t 1 : i n t e g e r := 1 0 ; begin write ( output line , string ( ) ) ; w r i t e l i n e ( output , o u t p u t l i n e ) ; w r i t e ( o u t p u t l i n e , s t r i n g ( S t r i n g > l o g . t x t ) ) ; w r i t e l i n e ( output , o u t p u t l i n e ) ; test L1 : f o r i c in 1 to 5 loop i n t 1 := i n t 1 + 1 ; write ( output line , string ( int1 = ) ); write ( output line , int1 ) ; write ( output line , string ( i n t 1 2 = ) ); write ( output line , int1 int1 ) ; w r i t e l i n e ( output , o u t p u t l i n e ) ; end loop t e s t L 1 ; report F i n i s h e d t e s t f o r l o o p . ; end process w r i t e t e s t ; end architecture b e h a v i o u r a l ;
144
Output: ---------Starting new simulation on Thu 24. Aug 2006 at 13:10:56 running C++ conversion... done. compiling functions... done. compiling main... done. linking... done. simulating... Output to STD output -> log.txt int1 = 11 int1^2 = 121 int1 = 12 int1^2 = 144 int1 = 13 int1^2 = 169 int1 = 14 int1^2 = 196 int1 = 15 int1^2 = 225 0 fs + 0d: NOTE: Finished test for loop. running VCD conversion... done. Simulation ended on Thu 24. Aug 2006 at 13:10:57 Ready. Errors: -------Table 5.8: Log.txt le showing tabular output results.
145
146
r e a d ( i n l i n e , d3 ) ; r e a d ( i n l i n e , d2 ) ; r e a d ( i n l i n e , d1 ) ; v1sd ( i ) <= d1 ; v2sd ( i ) <= d2 ; v3sd ( i ) <= d3 ; v4sd ( i ) <= d4 ; report In f i l e r e a d l o o p . ; i := i +1; i f ( i > 2 0 ) then e xi t ; end i f ; number:= i ; end loop ; end procedure s t o r e d a t a ; begin p0 : process i s Generate a c l o c k s i g n a l . begin c l o c k <= 1 ; wait f o r 10 ns ; c l o c k <= 0 ; wait f o r 10 ns ; end process p0 ; g0 : entity work . comb1 port map ( v1 , v2 , v3 , v4 , y o u t ) ; p1 : process i s Read t e s t v e c t o r s from d i s k and apply data to c i r c u i t inputs . variable n o r e a d s : i n t e g e r ; variable i n l i n e , o u t l i n e : l i n e ; begin store data ( no reads ) ; w r i t e ( o u t l i n e , s t r i n g ( count = ) ) ; w r i t e ( o u t l i n e , n o r e a d s 1); w r i t e l i n e ( output , o u t l i n e ) ; for k in 1 to n o r e a d s 1 loop Count up . wait u n t i l ( c l o c k e v e n t and c l o c k = 1 ) ; v1 <= v1sd ( k ) ; v2 <= v2sd ( k ) ; v3 <= v3sd ( k ) ; v4 <= v4sd ( k ) ; w r i t e ( o u t l i n e , s t r i n g ( Time = ) , l e f t , 8 ) ; w r i t e ( o u t l i n e , now , r i g h t , 1 0 ) ; w r i t e ( o u t l i n e , s t r i n g ( Test v e c t o r s > ) , r i g h t , 20 ) ; w r i t e ( o u t l i n e , v4 , l e f t , 2 ) ; w r i t e ( o u t l i n e , v3 , l e f t , 2 ) ;
147
w r i t e ( o u t l i n e , v2 , l e f t , 2 ) ; w r i t e ( o u t l i n e , v1 , l e f t , 2 ) ; w r i t e ( o u t l i n e , s t r i n g ( k = ) , r i g h t , 10 ) ; write ( out line , k ) ; w r i t e l i n e ( output , o u t l i n e ) ; wait u n t i l ( c l o c k e v e n t and c l o c k = 0 ) ; end loop ; for k in n o r e a d s 1 downto 1 loop Count down . wait u n t i l ( c l o c k e v e n t and c l o c k = 1 ) ; v1 <= v1sd ( k ) ; v2 <= v2sd ( k ) ; v3 <= v3sd ( k ) ; v4 <= v4sd ( k ) ; w r i t e ( o u t l i n e , s t r i n g ( Time = ) , l e f t , 8 ) ; w r i t e ( o u t l i n e , now , r i g h t , 1 0 ) ; w r i t e ( o u t l i n e , s t r i n g ( Test v e c t o r s > ) , r i g h t , 20 ) ; w r i t e ( o u t l i n e , v4 , l e f t , 2 ) ; w r i t e ( o u t l i n e , v3 , l e f t , 2 ) ; w r i t e ( o u t l i n e , v2 , l e f t , 2 ) ; w r i t e ( o u t l i n e , v1 , l e f t , 2 ) ; w r i t e ( o u t l i n e , s t r i n g ( k = ) , r i g h t , 10 ) ; write ( out line , k ) ; w r i t e l i n e ( output , o u t l i n e ) ; wait u n t i l ( c l o c k e v e n t and c l o c k = 0 ) ; end loop ; wait ; end process p1 ; end architecture b e h a v i o u r a l ;
Although the listing above is relatively short, careful study of its contents should allow readers to identify many of the new Qucs/FreeHDL features introduced earlier. Moreover in some sections, the code illustrates extra features which will be familiar to those Qucs/FreeHDL users who have a more advanced knowledge of the VHDL language. These are listed below with a number of general points: The VHDL code simulates the performance of a simple combinational logic circuit called comb1: this has four inputs (a, b, c, d) of type bit and one output (y) of type bit35 . The testbench being simulated consists of two processes: process p0 generates a clock signal with a period of 20 ns; process p1 inputs test data held in le test1_data 36 and stores it in four signal arrays (v1sd, v2sd, v3sd and v4sd), applying this data
35
Type bit was chosen for this example rather than one of the IEEE signal types because package textio does not handle the IEEE multivalue logic types. 36 I use the Knoppix version of the Linux/GNU operating system for all work on the Qucs project. The
148
to the inputs of the circuit under test at the leading edges of the clock pulse. Note process p1 only executes once due to the wait statement at its end. An instantiation of the comb1 component is included in the testbench architecture. Note the use of the VHDL entity work.comb1 construction, this is an alternative for use work.all ; The test vector data held in le test_data is read by procedure store_data which returns the number of lines of data read in variable number. File handling, including reading data from disk, is undertaken with predened routines in package textio. The rst report statement in procedure store_data writes string my_string to le log.txt. My_string is an example of the VHDL constrained string type, consisting of non-printable control characters37 concatenated with printable characters. Two loops are employed in process p1 to apply signal test vectors to the input of comb1: the rst loop counts up from one and the second loop counts down from the number of lines of test vectors read by procedure store_data, eectively generating test vectors in a way similar to using an up-down pattern generator counter. Note that the signal data is applied to the circuit under test on the rising edge of the clock signal and that the applied signal vector sequence is really up to the imagination of the VHDL programmer. The write statements in the process p1 for loops demonstrate the formatted version of the textio write statement. This greatly assists in setting up tables of results. Table 5.9 gives a typical log.txt content for the comb1 test simulation. In process p1 signals v1, v2, v3 and v4 are assigned an indexed value from (type array_list) v1sd, v2sd, v3sd and v4sd signals. During simulation Qucs/FreeHDL stores signal values as a simulation progresses. Hence, it is theoretically possible to display both the standard and composite signal types. A typical waveform plot for signals v1, v2, v3, v4 and y_out is given in Fig. 5.30. Fig. 5.31 illustrates a waveform plot of the composite signals v1sd, v2sd, v3sd and v4sd. In Fig. 5.31 each group is plotted at a clock edge change yielding identical groups of values; each vertical set of bits represents the bit values for a single line in le test1_data. Compare the displayed values in Fig. 5.31 with the contents of the test1_data le shown in Fig. 5.32. As mentioned before some care is needed when plotting, or tabulating, composite signals, particularly when the array sizes are large; array dimensions above roughly 50 become dicult to plot on a normal resolution screen. In such cases it is better to slice part of an array and assign the required values to a signal that can be easily displayed.
absolute location of the test data le will depend on where Qucs and FreeHDL have been installed and the location where work les are kept. 37 Type character in package standard lists the two letter codes used by VHDL to represent non-printable control characters.
149
Output : S t a r t i n g new s i m u l a t i o n on F r i 25 . Aug 2006 a t 14 : 35 : 48 r u n n in g C++ c o n v e r s i o n . . . done . c o m p i l i n g f u n c t i o n s . . . done . c o m p i l i n g main . . . done . l i n k i n g . . . done . simulating . . . 0 f s + 0d : NOTE : Constrained s t r i n g 0 f s + 0d : NOTE : In f i l e r e a d l o o p . . 0 f s + 0d : NOTE : In f i l e r e a d l o o p . count = 16 Time = 0 ns Test v e c t o r s > 0 0 0 0 k = 1 Time = 20 ns Test v e c t o r s > 0 0 0 0 k = 2 Time = 40 ns Test v e c t o r s > 0 0 0 1 k = 3 Time = 60 ns Test v e c t o r s > 0 0 1 0 k = 4 . Time = 200 ns Test v e c t o r s > 1 0 0 1 k = 11 Time = 220 ns Test v e c t o r s > 1 0 1 0 k = 12 Time = 240 ns Test v e c t o r s > 1 0 1 1 k = 13 Time = 260 ns Test v e c t o r s > 1 1 0 0 k = 14 Time = 280 ns Test v e c t o r s > 1 1 0 1 k = 15 Time = 300 ns Test v e c t o r s > 1 1 1 0 k = 16 Time = 320 ns Test v e c t o r s > 1 1 1 1 k = 16 Time = 340 ns Test v e c t o r s > 1 1 1 1 k = 15 Time = 360 ns Test v e c t o r s > 1 1 1 0 k = 14 Time = 380 ns Test v e c t o r s > 1 1 0 1 k = 13 Time = 400 ns Test v e c t o r s > 1 1 0 0 k = 12 . Time = 560 ns Test v e c t o r s > 0 1 0 0 k = 4 Time = 580 ns Test v e c t o r s > 0 0 1 1 k = 3 r u n n in g VCD c o n v e r s i o n . . . done . S i m u l a t i o n ended on F r i 25 . Aug 2006 a t 14 : 35 : 50 Ready . Errors :
Table 5.9: An edited version of the formatted tabular output results written to le log.txt.
150
10n
20n
30n
40n
50n
60n
70n
80n
90n
100n
110n
120n
130n
140n
150n
160n
170n
180n
180n
190n
200n
210n
220n
230n
240n
250n
260n
270n
280n
290n
300n
310n
320n
330n
340n
350n
360n
220n
230n
240n
250n
260n
270n
280n
290n
300n
310n
320n
330n
340n
350n
360n
370n
380n
390n
400n
400n
410n
420n
430n
440n
450n
460n
470n
480n
490n
500n
510n
520n
530n
540n
550n
560n
570n
580n
80n
Figure 5.31: Typical timing diagram for composite signals v1sd, v2sd, v3sd and v4sd.
151
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
152
153
As the speed of electronic systems has increased so has the popularity of the single edgetriggered ip-ops over the slower master slave devices. Today most IC designs are based on D type edge-triggered devices rather than the earlier JK master slave devices. Our concern here is the development of a consistant set of models that allow the common ipops to be modelled accurately, and reliably, in the transient time domain. In order to keep these models simple the D gated and edge-triggered devices have been chosen as the fundamental building blocks for the transient domain Qucs models. Using basic Boolean logic concepts it is straightforward to show that JK and T edge-triggered ip-op models can be derived from the D ip-op models.
154
&
D times=20ns; 20ns C Y3 Y1
&
C times=5ns; 5ns Y5
&
Y4
&
Y2
&
QB
transient simulation
TR1 Type=lin Start=0 Stop=100 ns
1 D.Vt 0 0 1 C.Vt 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7 0 0 1 Q.Vt 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7 1 QB.Vt 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
155
D D Q D C C Q C Num=2
transient simulation
QB TR1 Type=lin Start=0 Stop=200 ns
SUB1 File=gated_d_latch.sch
156
&
SET Y7
I0
&
Y8
&
I1 Y10
CLOCK Num=1
&
Y11 I3
I2
&
QB Y2
QB
&
David A. Hodges and Horace G. Jackson, Analysis and Design of Digital Integrated Circuits, 1998, Second edition, McGraw-Hill Book Company.
157
1 R.Vt 0 0 1 0 0 CLOCK.Vt 1 0 0 5e-8 1e-7 1.5e-7 2e-7 2.5e-7 time 3e-7 3.5e-7 4e-7 4.5e-7 5e-7 5e-8 1e-7 1.5e-7 2e-7 2.5e-7 time 3e-7 3.5e-7 4e-7 4.5e-7 5e-7 5e-8 1e-7 1.5e-7 2e-7 2.5e-7 time 3e-7 3.5e-7 4e-7 4.5e-7 5e-7 DIN.Vt Q.Vt 1 0 0 5e-8 1e-7 1.5e-7 2e-7 2.5e-7 time 3e-7 3.5e-7 4e-7 4.5e-7 5e-7 QB.Vt 1 0 0 5e-8 1e-7 1.5e-7 2e-7 2.5e-7 time 3e-7 3.5e-7 4e-7 4.5e-7 5e-7
Figure 6.5: Transient waveforms for the circuit shown in Fig. 6.6
1
DIN D S4 times=40ns; 40ns CLOCK Q S2 times=5ns; 5ns R S3 times=20ns; 1000ns R SUB1 QB S SUB2 Q Q
transient simulation
TR1 Type=lin Start=0 Stop=500 ns
158
Q+ = J.Q + K.Q
Were Q, Q, J and K are the current state values of the device signals and Q+ is the next state value of Q following the rising edge of the device clock pulse. The schematic diagram for the edge triggered ip op is shown in Fig. 6.7 and a typical set of test waveforms in Fig. 6.8. These were obtained using the test circuit shown in Fig. 6.9.
SET
&
Y1 Y2
Q QB
CLOCK K
1
Y4 Y3
&
Q R SUB1 File=dff_sr.sch
RESET
M. Morris Mano and Charles R Kime, Logic and Computer Design Fundamentals, 2004, Third edition, Pearson Education International, Prentice Hall
159
1 RESET.Vt 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 time 6e-8 7e-8 8e-8 9e-8 1e-7 1 CLOCK.Vt 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 time 6e-8 7e-8 8e-8 9e-8 1e-7 1 Q.Vt 0 0 1 QB.Vt 1e-8 2e-8 3e-8 4e-8 5e-8 time 6e-8 7e-8 8e-8 9e-8 1e-7 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 time 6e-8 7e-8 8e-8 9e-8 1e-7
Figure 6.8: Transient waveforms for the circuit shown in Fig. 6.9
160
1
SUB2
transient simulation
TR1 Type=lin Start=0 Stop=100 ns
CLOCK Num=1
RESET
161
Q+ = T Q
where the symbols have the same meaning as the JK ip-op. The circuit diagram, test waveforms and test circuit for the edge-triggered ip-op are given in Figures 6.10 to 6.12.
SET SET
TFF
=1
Y1 CLOCK
QQ Q QB Q
TFF
QB
CLOCK R R
R SUB1 File=dff_sr.sch
See footnote 2.
162
SET.Vt
0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
CLOCK.Vt
0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
TFF.Vt
0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
Q.Vt
1 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
QB.Vt
1 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 time 1.2e-7 1.4e-7 1.6e-7 1.8e-7 2e-7
Figure 6.11: Transient waveforms for the circuit shown in Fig. 6.12
SET
SET times=10 ns; 1000 ns TFF T T1 times=30 ns; 60 ns CLOCK R CLOCK times=5 ns; 5 ns S Q QB Q Q
transient simulation
TR1 Type=lin Start=0 Stop=200ns IntegrationMethod=Trapezoidal Order=2
1
SUB2 File=Logic_one.sch SUB1 File=tff.sch
163
&
Y2
&
Y3 Q1 J S Q
&
Q2 J S Q
Q3
CLOCK K Q R K Q R K Q R K Q R
CLOCK times=5 ns; 5ns COUNT COUNT Y4 times=5 ns; 1000ns CLEAR
&
SUB1 File=jkff.sch
SUB2 File=jkff.sch
SUB3 File=jkff.sch
SUB4 File=jkff.sch
transient simulation
TR1 Type=lin Start=0 Stop=120ns IntegrationMethod=Trapezoidal Order=2
Figure 6.13: Synchronous BCD up-counter circuit At the start of simulation signal CLEAR is set to logic 1 which in turn causes the counter to be reset to 0000. Similarly signal COUNT has to be set to 1 for counting to take place. Notice that the counter counts from 0 to 9 and then resets to 0. A simple state machine: Figure 6.15 shows a simple sequential state machine with input X and outputs Y1 and Y2. The outputs are synchronised to the input clock. The state equations for this example are
J = X , K = 1, Y 1 = Q0.X , Y 2 = Q0
164
CLEAR.Vt
1 0 0 1 0 0 1 0 0 1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q0.Vt Q1.Vt
COUNT.Vt
CLOCK.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q2.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q3.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Figure 6.14: Transient waveforms for the circuit shown in Fig. 6.13
165
1
X SUB4 File=Logic_one.sch
Y2 Q
X Y2 20ns times=100ns; K Q R Q R
transient simulation
TR1 Type=lin Start=0 Stop=350 ns IntegrationMethod=Trapezoidal SUB2 Order=2 File=dff_sr.sch
CLOCK
SUB1 File=jkff.sch
&
Y1
Y1 Q
digital simulation
Digi1 Type=TimeList time=350 ns SUB3 File=dff_sr.sch
Q RESET R
166
CLOCK.Vt
0 0 2e-8 4e-8 6e-8 8e-8 1e-7 1.2e-7 1.4e-7 1.6e-7 1.8e-7 time 2e-7 2.2e-7 2.4e-7 2.6e-7 2.8e-7 3e-7 3.2e-7 3.4e-7
RESET.Vt
0 0 1 2e-8 4e-8 6e-8 8e-8 1e-7 1.2e-7 1.4e-7 1.6e-7 1.8e-7 time 2e-7 2.2e-7 2.4e-7 2.6e-7 2.8e-7 3e-7 3.2e-7 3.4e-7
X.Vt 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 1.2e-7 1.4e-7 1.6e-7 1.8e-7 time 2e-7 2.2e-7 2.4e-7 2.6e-7 2.8e-7 3e-7 3.2e-7 3.4e-7 Y1.Vt 1 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 1.2e-7 1.4e-7 1.6e-7 1.8e-7 time 2e-7 2.2e-7 2.4e-7 2.6e-7 2.8e-7 3e-7 3.2e-7 3.4e-7 Y2.Vt 1 0 0 2e-8 4e-8 6e-8 8e-8 1e-7 1.2e-7 1.4e-7 1.6e-7 1.8e-7 time 2e-7 2.2e-7 2.4e-7 2.6e-7 2.8e-7 3e-7 3.2e-7 3.4e-7
Figure 6.16: Transient waveforms for the circuit shown in Fig. 6.15
167
Figure 6.17: Digital TimeList waveforms for the circuit shown in Fig. 6.13
Listing 6.1: VHDL testbench code for the circuit shown in Fig. 6.13 Qucs 0 . 0 . 9 /mnt/ hda2 / D i g i t a l S u b c i r c u i t s p r j / Sync BCD counter . s c h entity S u b L o g i c o n e i s port ( nnout L1 : out b i t ) ; end entity ; use work . a l l ; architecture Arch Sub Logic one of S u b L o g i c o n e i s s i g n a l gnd , L1 : b i t ; begin gnd <= 0 ; L1 <= not gnd ; nnout L1 <= L1 or 0 ; end architecture ;
168
entity S u b d f f s r i s port (CLOCK: in b i t ; DIN : in b i t ; nnout Q : out b i t ; nnout QB : out b i t ; RESET: in b i t ; SET : in b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b d f f s r of S u b d f f s r i s s i g n a l I0 , I2 , I1 , I3 , QB, Q : bit ; begin nnout QB <= QB or 0 ; nnout Q <= Q or 0 ; I 1 <= not (CLOCK and RESET and I 0 ) ; I 3 <= not (DIN and I 2 and RESET ) ; QB <= not (RESET and I 2 and Q) ; Q <= not ( I 1 and QB and SET ) ; I 0 <= not ( I 3 and I 1 and SET ) ; I 2 <= not (CLOCK and I 3 and I 1 ) ; end architecture ;
entity S u b j k f f i s port ( nnnet6 : in b i t ; nnnet1 : in b i t ; nnnet8 : in b i t ; nnout nnnet3 : out b i t ; nnout nnnet7 : out b i t ; nnnet9 : in b i t ; nnnet10 : in b i t ) ; end entity ; use work . a l l ; architecture A r c h S u b j k f f of S u b j k f f i s s i g n a l nnnet0 , nnnet2 , nnnet4 , nnnet5 ,
169
nnnet7 , nnnet3 : b i t ; begin nnnet0 <= not nnnet1 ; nnnet2 <= nnnet3 and nnnet0 ; nnnet4 <= nnnet2 or nnnet5 ; nnnet5 <= nnnet6 and nnnet7 ; nnout nnnet7 <= nnnet7 or 0 ; nnout nnnet3 <= nnnet3 or 0 ; SUB1 : entity S u b d f f s r port map ( nnnet8 , nnnet4 , nnnet3 , nnnet7 , nnnet10 , nnnet9 ) ; end architecture ; entity TestBench i s end entity ; use work . a l l ; architecture Arch TestBench of TestBench i s s i g n a l CLEAR, COUNT, CLOCK, Q3 , Q0 , Q1 , Q2 , nnnet0 , nnnet1 , nnnet2 , nnnet3 , nnnet4 , nnnet5 , nnnet6 , nnnet7 , nnnet8 , nnnet9 : b i t ; begin SUB5 : entity S u b L o g i c o n e port map ( nnnet0 ) ; nnnet1 <= Q0 and nnnet2 ; nnnet3 <= Q1 and nnnet1 ; nnnet4 <= Q2 and nnnet3 ; SUB2 : entity S u b j k f f port map ( nnnet1 , nnnet1 , nnnet5 , Q1 , nnnet6 , nnnet0 , nnnet7 ) ;
170
SUB3 : entity S u b j k f f port map ( nnnet3 , nnnet3 , nnnet5 , Q2 , nnnet8 , nnnet0 , nnnet7 ) ; SUB1 : entity S u b j k f f port map ( nnnet0 , nnnet0 , nnnet5 , Q0 , nnnet9 , nnnet0 , nnnet7 ) ; nnnet5 <= COUNT and CLOCK; nnnet7 <= not CLEAR; CLEAR: process begin CLEAR <= 1 ; CLEAR <= 0 ; end process ;
SUB4 : entity S u b j k f f port map ( nnnet4 , Q0 , nnnet5 , Q3 , nnnet2 , nnnet0 , nnnet7 ) ; end architecture ;
171
Next move into the new library folder a copy of each of the schematic capture les for the ip-op models introduced in these notes. These are: d f f s r . sch , j k f f . sch , t f f . sch , and gated d l a t c h . sch . A copy of the schematic for setting nodes to logic one is also required ( l o g i c one . sch ) . These models are then freely available for use in any projects which users are working on. They can be copied into such projects using the Add les to Project... menu button found under the Qucs Project drop-down menu. Similarly any new models developed as part of a project can be added to the library and used again in the future.
6.10 Digital component propagation time delays and transient simulation numerical stability
Transient simulation is in general much slower than digital simulation using VHDL generated machine code. The large signal transient simulation models of ip-ops and other sequential digital devices are intended for use in mixed-mode circuit simulation rather than being used for pure digital circuit simulation. An interesting, and indeed very important question, relates to the eciency, and accuracy, of the numerical analysis algorithms employed in the integration routines that are central to transient circuit simulation. Qucs allows users to select the algorithm they wish to employ for transient simulation. The available algorithms are Trapezoidal, Euler, Gear and Adams Moulton; in each case the algorithm order can be set from 1 to 6. The second order Trapezoidal integration algorithm is used by Qucs as the default for transient simulation. To test which of these algorithms oers the most time ecient solution to the transient simulation of digital circuits, that include ip-ops, the BCD counter shown in Fig. 6.13 was used as a test case and repeatedly simulated using dierent integration routines and algorithm orders. The test results are shown in Table 6.1. Very little dierence was found between circuits where the cross coupled gates both had zero propagation delays and the case where one gate had 0.5ns delay and the other zero delay. One obvious fact emerges from the data given in Table 6.1; namely that the Adams Moulton Order 1 2 4 6 Trapezoidal 1 1 1 1 Euler 1.62 1.62 1.62 1.62 Gear 1.65 0.44 1.28 0.28 Adams Moulton 1.62 1 0.39 0.18
Table 6.1: Relative simulation times for the circuit shown in Fig. 6.13
172
Order 1 2 4 6
Number or rejections Average time step 1470 5.17737e-12 1750 9.4585e-12 1454 2.866e-11 61 5.76646e-11
Table 6.2: Number of rejections and average time step data for the Adams Moulton algorithm higher order integration routines appear to be faster than the default trapezoidal algorithm. This is corroborated by the average time step and number of rejection data points output by Qucs at the end of a simulation. Table 6.2 lists this data for the Adams Moulton algorithm tabulated in Table 6.1. Table 6.2 points to the increase in average time step and the dramatic reduction in the number of simulation solution rejections as the probable reason for the reduction in transient simulation time when using the higher order Adams Moulton integration routines. However, other factors may inuence the choice of integration routine. Often speed is not the only criteria that is of importance when simulating large complex circuits. Consider the following case (the circuit shown in Fig. 6.13 with order 6 Adams Moulton transient analysis integration); setting one of the gate delays to 1ns, and the other to 0ns, in each of the RS latches in the edge-triggered D ip-op yields the signal waveforms illustrated in Fig. 6.18. Clearly here the solution is incorrect pointing to probable numerical instability caused by the choice of integration routine.
173
CLEAR.Vt
1 0 0 1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
COUNT.Vt
CLOCK.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q0.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q1.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q2.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Q3.Vt
1 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
Figure 6.18: Digital TimeList waveforms for the circuit shown in Fig. 6.13
174
like the trapezoidal routine, numerical instability results if the simulation time step becomes much larger than the smallest time constant in a circuit. Hence, to achieve successful completion of a simulation the integration time step must be reduced which in turn makes the overall simulation time increase signicantly. The implicit Gear algorithm5 does not suer from this problem and is the natural choice for circuits with components that have widely diering time constants. Example 1: Analogue waveform driven digital devices with output node-bridge. The circuit in Fig. 6.19 shows an analogue voltage source driving a digital inverter with a node-bridge element processing the inverter output signal. The input signal is a sinusoidal voltage of amplitude 1V peak. The inverter output signal, V1 in Fig. 6.19, has an nonsymmetrical mark to space ratio because the threshold point for the inverter is set at 0.5V; the halfway point for the two logic levels. The nodebridge element is basically a voltage controlled voltage source where the device gain and time delay can be programmed. In this rst example the gain has been set to 5 and the time delay to 0.5ns. Figure 6.20 illustrates the simulation TimeList waveforms for this example mixed-mode circuit. The node-bridge shown in Fig. 6.19 is a very basic device. Moreover, by adding additional features, parameters like fall and rise time can set to specic values. The next example demonstrates the use of an active node-bridge.
Vin V1 U=1 V
1
Y1
V1
VINP VOUTP D to A Node Bridge VINN VOUTN
V5D
transient simulation
TR1 Type=lin Start=0 Stop=20us IntegrationMethod=Gear Order=6
SUB1 File=a_node_bridge.sch
Figure 6.19: Analogue waveform driven digital device with output node-bridge
The Gear integration algorithm is a powerful method for solving sti systems of dierential equations, see Donald A. Calahan, Computer Aided Network Design, Revised edition, 1972, McGraw-Hill.
175
Vin.Vt
0 1 0 0 5
2e-6
4e-6
6e-6
8e-6
1e-5 time
1.2e-5
1.4e-5
1.6e-5
1.8e-5
2e-5
V1.Vt
2e-6
4e-6
6e-6
8e-6
1e-5 time
1.2e-5
1.4e-5
1.6e-5
1.8e-5
2e-5
V5D.Vt
0 0 2e-6 4e-6 6e-6 8e-6 1e-5 time 1.2e-5 1.4e-5 1.6e-5 1.8e-5 2e-5
Figure 6.20: Digital TimeList waveforms for the circuit shown in Fig. 6.19 Example 2: Pulse driven digital inverter with an active node bridge. Illustrated in Fig. 6.21 is a similar circuit to the previous example. In Fig. 6.21 a pulse generator drives a digital inverter. The inverter output signal is processed by an active node-bridge derived from a basic BJT switching amplier. The output waveforms for this circuit are shown in Fig. 6.22. Notice that the pulse rise and fall times are determined by the node-bridge amplier and that the resulting analogue signal amplitude is set to 5V.
176
transient simulation
TR1 Type=lin Start=0 Stop=30ns IntegrationMethod=Gear Order=6 VPIN V1 VB V2 U=5 V R2 R=4.7 k Ohm VC T1 Type=npn Is=1e-16 Nf=1 Vaf=0 Bf=100 C1 C=0.1 pF
R1 R=10k Ohm
177
1 VPIN.Vt 0 0 V1.Vt 1 0 0 1 VB.Vt 2e-9 4e-9 6e-9 8e-9 1e-8 1.2e-8 1.4e-8 1.6e-8 time 1.8e-8 2e-8 2.2e-8 2.4e-8 2.6e-8 2.8e-8 3e-8 2e-9 4e-9 6e-9 8e-9 1e-8 1.2e-8 1.4e-8 1.6e-8 time 1.8e-8 2e-8 2.2e-8 2.4e-8 2.6e-8 2.8e-8 3e-8 0 0 6 4 2 0 0 2e-9 4e-9 6e-9 8e-9 1e-8 1.2e-8 1.4e-8 1.6e-8 time 1.8e-8 2e-8 2.2e-8 2.4e-8 2.6e-8 2.8e-8 3e-8 2e-9 4e-9 6e-9 8e-9 1e-8 1.2e-8 1.4e-8 1.6e-8 time 1.8e-8 2e-8 2.2e-8 2.4e-8 2.6e-8 2.8e-8 3e-8 VC.Vt
Figure 6.22: Digital TimeList waveforms for the circuit shown in Fig. 6.21
178
Example 3: A more complex mixed-mode simulation example. The circuit shown in Fig. 6.23 brings together a number of the ideas outlined in these tutorial notes. A 4-bit digital signal is generated from a simple asynchronous binary counter operated from a digital clock signal. The counter output is transformed to the analogue domain using a simple node-bridge, of the type introduced in mixedmode example 1. A 4-bit binary weighted DAC converts the transformed nodebridge signals into the nal analogue output signal. The DAC operational amplier is modelled as a gain block with a single pole frequency response and DC voltage output limiting. The output waveforms for this example are shown in Fig. 6.24 and the details of the operational amplier model in Fig. 6.25.
S1 SUB5 Num=1 File=tff.sch CLOCK T R Q S Q
1
SUB9 File=Logic_one.sch B0
VINP VOUTP D to A Node Bridge VINN VOUTN
SUB6 File=tff.sch
R1 R=10k Ohm
A_VOUT
R Q
S Q B1
SUB10 File=a_node_bridge.sch
VINP VOUTP D to A Node Bridge VINN VOUTN
SUB7 File=tff.sch
R Q
S Q B2
SUB11 File=a_node_bridge.sch
VINP VOUTP D to A Node Bridge VINN VOUTN
V+
V2 U=18 V
R4 R=2.5k
transient simulation
TR1 Type=lin Start=0 Stop=40 m IntegrationMethod=Gear Order=6
R Q
S Q B3
SUB12 File=a_node_bridge.sch
VINP VOUTP D to A Node Bridge VINN VOUTN
S2 Num=2
R5 R=1.25k Ohm
SUB13 File=a_node_bridge.sch
179
RESET.Vt
1 0 0 1 0 0 1 0 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time
B0.Vt B1.Vt
CLOCK.Vt
1 0 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time
B2.Vt
1 0 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time
B3.Vt
1 0 0 0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04 time
A_VOUT.Vt
-20
0.002 0.004 0.006 0.008 0.01 0.012 0.014 0.016 0.018 0.02 time
0.022 0.024 0.026 0.028 0.03 0.032 0.034 0.036 0.038 0.04
Figure 6.24: Digital TimeList waveforms for the circuit shown in Fig. 6.23
180
VINP Num=1
R1 R=200k Ohm
C1 C=3.2uF
R6 R=5 Ohm
VINN Num=2
VDCN Num=5
Figure 6.25: Operational amplier model with Rin = 200k , pole frequency = 5Hz, DC dierential gain = 200k and Rout = 50
181
182
The UA741 operational amplier is one of the most studied devices. It is almost unique in that a transistor level model has been constructed for the device. Details of the circuit operation and modelling of this device can be found in (1) Paul R. Grey et. al., Analysis and Design of Analog Integrated Circuits, Fourth Edition, 2001, John Wiley and Sons INC., ISBN 0-471-32168-0, and (2) Andrei Vladimirescu, The SPICE book, 1994, John Wiley and Sons, ISBN 0-471-60926-9.
183
Equation R3 R=47 k Vin V1 U=1 V R4 R=4.7 k OP1 G=1e6 Eqn1 d1=dB(Vout.v) d2=phase(Vout.v)
Vout
dc simulation
DC1
ac simulation
AC1 Type=log Start=1 Hz Stop=100 MHz Points=801
Figure 7.1: Qucs schematic for a basic OP AMP inverting amplier:Qucs OP AMP has G=1e6 and Umax=15V. ampliers the quality of the OP AMP model can often be a limiting factor in the accuracy of the overall simulation results. Accurate OP AMP models normally include a range of the following device characteristics: (1) DC and AC dierential gain, (2) input bias current, (3) input current and voltage osets, (4) input impedance, (5) common mode eects, (6) slew rate eects, (7) output impedance, (8) power supply rejection eects, (9) noise, (10) output voltage limiting, (11) output current limiting and (12) signal overload recovery eects. The exact mix of selected properties largely depends on the purpose for which the model is being used; for example, if a model is only required for small signal AC transfer function simulation then including the output voltage limiting section of an OP AMP model is not necessary or indeed may be considered inappropriate. In the following sections of this tutorial article macromodels for a number of the OP AMP parameters listed above are developed and in each case the necessary techniques are outlined showing how to derive macromodel parameters from manufacturers data sheets.
184
Vout.v
-10
-20
10
100
1e3
1e4 Frequency Hz
1e5
1e6
1e7
1e8
40
dB(Vout.v)
20
10
100
1e3
1e4 Frequency Hz
1e5
1e6
1e7
1e8
200
10
100
1e3
1e4 Frequency Hz
1e5
1e6
1e7
1e8
Figure 7.2: Gain and phase curves for a basic OP AMP inverting amplier.
185
T6 P_VCC
T7
T14
T15
T24 T27
T3 VIN_P
T4
T21 T26
VOUT
T2
T5 T17 T13
R9 R=40k T23
T11
T12
T8
T19
R4 R=1k
R3 R=50k
R2 R=1k
R7 R=50
R8 R=50k
T20
P_VEE
Figure 7.3: Transistor level circuit for the UA741 operational amplier.
186
10
Vout.v
20 dB(Vout.v)
phas(Vout.v)
100
10
100
1e5
1e6
1e7
Figure 7.4: Gain and phase curves for a times 10 inverting amplier with the OP AMP represented by a transistor level UA741 model.
187
R2 R=47k Ohm Vin V1 U=1 V R3 R=4.7k Ohm SRC1 G=1 S T=0 R1 R=200k Ohm C1 C=159.15nF OP1 G=1 Equation Eqn1 d2=phase(Vout.v) d1=dB(Vout.v) Vout
dc simulation
DC1
ac simulation
AC1 Type=lin Start=1 Hz Stop=10 MHz Points=1800
Figure 7.5: Modied Qucs OP AMP model to include single pole frequency response.
10
Vout.v
20 dB(Vout.v)
-20 1 200 phase(Vout.v) Degrees 10 100 1e3 Frequency Hz 1e4 1e5 1e6 1e7
150
Figure 7.6: Gain and phase curves for the circuit shown in Fig. 7.5.
188
Computational eciency is increased mainly due to the fact that operational amplier macromodels have, on average, about one sixth of the number of nodes and branches when compared to a transistor level model. Furthermore, the number of non-linear p-n junctions included in a macromodel is often less than ten which compares favorable with the forty to fty needed to model an amplier at transistor level. 3 Brinson M. E. and Faulkner D. J., Modular SPICE macromodel for operational ampliers, IEE Proc.Circuits Devices Syst., Vol. 141, No. 5, October 1994, pp. 417-420. 4 Models employing non-linear controlled sources, for example the SPICE B voltage and current sources, are not allowed in Qucs release 0.0.9. Non-linear controlled sources are one of the features on the Qucs to-do list.
189
users. Since the device characteristics specied by each block are separate from all other device characteristics only those amplier characteristics which are needed are included in a given macromodel. This approach leads to a genuinely structured macromodel. The following sections present the detail and derivation of the electrical networks forming the blocks drawn in Fig. 7.7. To illustrate the operation of the modular OP AMP macromodel the values of the block parameters are calculated for the UA741 OP AMP and used in a series of example simulations. Towards the end of this tutorial note data are presented for a number of other popular general purpose operational ampliers.
190
In+
In-
Input Stage
Signal adder
Vcc In+
InVee
Output stage
Vcc
Vee
191
The dierential output signal (VD) is given by V D P 1 V D N 1 and the common mode output signal (VCM ) by (V D P 1 + V D N 1)/2.
Voff1 U=0.35mV Ib1 I=80nA Ioff1 I=10nA Voff2 U=0.35mV Ib2 I=80nA R1 R=1M Ohm VCM1 Input stage InVd-
IN_N1
Vcm
R2 R=1M Ohm
In+
Vd+
IN_P1
VD_P1
SUB1 File=input_stage.sch
192
POLE1 IN+ IN_P1 RD1 R=100M RADC1 R=200k Ohm CP1 C=159.15 nF POLE_1_OUT1 OUT INSUB1 File=pole1.sch
IN_N1
193
Aol Aol(DC)
fp1
GBP
f Hz
Figure 7.10: OP AMP open loop dierential voltage gain as a function of frequency. Where
1 2 RADO CP 1 Let RADC = Aol(DC) and GMP1 = 1 S. Then, because fp1*AOL(DC) = GBP, fP 1 = CP 1 = 1 2 GBP
(7.2)
(7.3)
194
IN_N1
195
SUB2 File=input_stage.sch
In+ IN_P1
Vd+
POLE1 IN+ Output stage In+ Out InIn+ SUB3 File=out_stage.sch SUB5 File=op_amp_ac_IP1O.sch InOUT1
OUT
OP AMP IP1O
SUB4 File=pole1.sch
196
dc simulation
DC1 number 1 vout.V 0.0068 vout3.V 0.0069
ac simulation
AC1 Type=lin Start=1 Hz Stop=10 MHz Points=1801 R1 R=10k Ohm
OP AMP IP1O
SUB5 In+
vout3
V2 U=15 V
V3 U=15 V
Figure 7.13: Test circuit for an inverting amplier. Output signals: (1) vout for AC macromodel, (2) vout3 for UA741 transistor model.
197
20 dB(vout.v)
200
150
100
-20
10
100
1e6
1e7
20 db(vout3.v)
200
100
-20
10
100
1e6
1e7
Figure 7.14: Simulation test results for the circuit shown in Fig. 7.13.
198
Let RP2 = 1 and GMP2 = 1 S. Then vout(P OLE 2 OU T 1) = and CP 2 = 1 2 f p2 (7.6) V (IN P 2) V (IN N 2) 1 + j ( CP 2) (7.5)
POLE2 IN+ IN_P2 RD2 R=100M RP2 R=1 Ohm CP2 C=53.05nF POLE_2_OUT1 OUT INSUB1 File=pole2.sch
IN_N2
199
ac simulation
R1 R=10M Ohm C1 C=100mF vin V1 U=1 V
In-
AC1 Type=log Start=1 Hz Stop=100MHz Points=241 vout Equation Eqn1 y4=rad2deg(unwrap(angle(vout3.v))) y=dB(vout.v) y3=dB(vout3.v) y2=phase(vout.v)
OP AMP IP1P2O
In+
dc simulation
DC1 V2 U=15 V
SUB2
C2 C=100 mF
vout3
V3 U=15 V
Figure 7.16: Test circuit for simulating OP AMP open loop dierential gain.
Aol(f ) << 1, equation (7) becomes vout(f ) Aol(f ) vin(f ). Hence, for RC those frequencies where this condition applies vout(f ) = Aol(f ) when vin(f ) = 1 V. Figure 17 shows plots of the open loop simulation data. Clearly with the test circuit time constant set at 1e6 seconds the data is accurate for frequencies down to 1 Hz.
200
1e5 1e4 vout3.v 1 10 100 1e3 1e4 1e5 1e6 1e7 1e8 Frequency Hz 1e3 100 10 1 0.1 0.03
vout.v
10
100 dB(vout3.v) 1 10 100 1e3 1e4 1e5 1e6 1e7 1e8 Frequency Hz phase(vout3.v) degrees dB(vout.v)
100
-100
10
phase(vout.v) degrees
-100
-200
-200
10
10
Figure 7.17: Simulation test results for the circuit shown in Fig. 7.16.
201
Similarly, the common-mode gain ACM (f ) can be represented by the same single-pole response and a single zero response given by 1+j ACM (f ) = ACM (0) f (7.9) fCM Z f 1+j fP D
Dening the common-mode rejection ratio CM RR(f ) of an OP AMP as CM RR(f ) = gives CM RR(f ) = CM RR(0) 1+j where CM RR(0) = AD (0) ACM (0) 1 f fCM Z (7.12) (7.11) A D (f ) ACM (f ) (7.10)
Common-mode eects can be added to OP AMP macromodels by including a stage in the modular macromodel that introduces a zero in the amplier frequency response. Output VCM from the macromodel input stage senses an amplier common mode signal. This signal, when passed through a CR network generates the required common mode zero. Figure 18 gives the model of the zero generating network, where. 1. RDCMZ = 650 M = common-mode input resistance/2. 2. RCM1 = 1 M RCM 1 3. ECM1 G = 31.623 = RCM 2 . (NOTE: RCM1/RCM2 is a scaling factor.) CM RR(0) 4. CCM1 = 795.8 pF = 1 . 2 RCM 1 fCM Z
202
IN_P1
RDCMZ R=650M
RCM1 R=1M
IN_N1
CCM1 C=795.8 pF
Figure 7.18: Common-mode zero macromodel 5. RCM2 = 1 Typical values for the UA741 OP AMP are: 1. Common-mode input resistance = 1300 M. 2. CMRR(0) = 90 dB 3. fCM Z = 200 Hz. The AC voltage transfer function for the common-mode zero transfer function is RCM 2 1 + j RCM 1 CCM 1 [V (IN_P1) V (IN_N1)] RCM 1 1 + j RCM 2 CCM 1 (7.13)
V out(CMV_OUT1) = G(ECM 1)
RCM 2 As << 1, the pole introduced by the common-mode RC network is at a very high RCM 1 frequency and can be neglected. Combining the common-mode zero with the previously dened stage models yields the macromodel shown in Fig. 7.19. In this model the dierential and common-mode signals are combined using a simple analogue adder based on voltage conrolled current generators.
Brinson M.E. and Faulkner D.J., New approaches to measurement of operational amplier commonmode rejection ratio in the frequency domain, IEE Proc-Circuits Devices Sys., Vol 142, NO. 4, August 1995, pp 247-253.
203
SUB6
In+ IN_N1
Vd+
VSUM IN1+
IN1-
Vcm
POLE1 IN+ OUT INSUB4 INSUB3 InOP_AMP ICMZP1P2O In+ InSUB2 POLE2 IN+ OUT Output stage In+ Out
OUT IN2+
InIN_P1
IN2-
OUT1
SUB5
SUB7 File=op_amp_ac_ICMZP1P2O.sch
WHERE
VSUM IN1+
IN1_P1
RSUM1 R=1
SUM_OUT1
IN1OUT IN2+
IN1_N1
IN2-
IN2_P1
SUB8 File=VSUM.sch
IN2_N1
204
dc simulation
DC1 vin V1 U=1 V R2 R=10k In+ R3 R=10k In-
R1 R=10k
ac simulation
AC1 Type=log Start=1 Hz Stop=10 kHz Points=401
OP_AMP ICMZP1P2O
vout
vout3
V2 U=15 V
+
R7 R=10k R8 R=10k
V3 U=15 V
Figure 7.20: Simulation of OP AMP common-mode performance. for the macromodel and the UA741 transistor model are very similar. In the case of the macromodel typical device parameters were used to calculate the macromodel component values. However, in the transistor level model the exact values of the component parameters are unknown.6
The UA741 transistor level model is based on an estimate of the process parameters that determine the UA741 transistor characteristics. Hence, the device level model is unlikely to be absolutely identical to the model derived from typical parameters values found on OP AMP data sheets. From the simulation results the CMRR(0) values are approximately (1) macromodel 90 dB, (2) UA741 transistor model 101 dB. Similarly, the common-mode zero frequencies are approximately (1) macromodel 200 Hz, (2) UA741 transistor model 500 Hz.
205
1e-3
10
100 Frequency Hz
1e3
1e4
1e-4
10
100 Frequency Hz
1e3
1e4
Figure 7.21: Simulation test results for the circuit shown in Fig. 7.20.
206
GM P 1 (V (IN P 1) V (IN N 1)) 1 But CP 1 = 2 GBP Yielding GM P 1 (V (IN P 1) V (IN N 1)) Moreover, if
CP 1
dV (P OLE 1 OU T 1) dt
(7.15)
dV (P OLE 1 OU T 1) 1 2 GBP dt
(7.16)
dV (P OLE 1 OU T 1) is set equal to the OP-AMP slew rate then the current dt
charging CP1 will be limited to the maximum allowed. In Fig. 7.9 GM P 1 is 1 S. Therefore, voltage dierence V (IN P 1) V (IN N 1) must be set to dV (P OLE 1 OU T 1) 1 . 2 GBP dt
This condition is normally true because RADO is set to the DC open loop dierential gain in macromodule POLE1.
207
D1
IN_P1
IN_N1
Figure 7.22: OP AMP slew rate macromodel. 1. RSCALE1 = 100 = Scaling resistance (Scale factor x 100). 2. SRC1 G = 1 S. 3. VSR1 = V1. 4. GMSRT1 G = 0.01 S. (Scale factor = 1/100). 5. RSRT1 = 1 And, 100 P ositive slew rate 0.7V 2 GBP 100 N egative slew rate 2. V 2 = 0.7V 2 GBP 3. The diode parameters are IS=1e-12 IBV=20mA BV=V1+V2, others default. 1. V 1 = Typical values for the UA741 OP AMP are: 1. P ositive slew rate = N egative slew rate = 0.5V/S. 2. V 1 = V 2 = 7.25V. Scaling is used in the slew rate model to allow the use of higher voltages in the clamping circuit. Increased voltages reduce errors due to the forward biased junction voltage. Current limiting results by clamping the voltage across resistor RSCALE 1 with a diode. This diode acts as a zener diode and saves one nonlinear junction when compared to conventional clamping circuits. The output section of the SLEWRT circuit removes the internal scaling yielding an overall gain of unity for the module. The circuit in Fig. 7.23 demonstrates the eect of slew rate limiting on OP AMP transient performance. Three identical OP AMP inverter circuits are driven from a common input 10 kHz AC signal source. Voltage controlled voltage sources are used to amplify the input signal to the second and third circuits. The three input signals are (1) 5 V peak, (2) 10 V peak and (3) 15 V peak respectively. The input and output waveforms for this circuit are illustrated in Fig. 7.24. The eect of slew rate limiting on large signal transient performance is clearly demonstrated by these curves. In the case of the 15 V peak input signal the output signal (vout3.Vt) has a slope that is roughly 0.5 V per S.
208
transient simulation
InOP_AMP ICMZ SLEWRT P1P2O vout1 TR1 Type=lin Start=0 Stop=200us
SUB1 File=op_amp_ac_ICMZP1P2O.sch
In+
SUB2 File=op_amp_ac_ICMZP1P2O.sch SRC1 G=2 T=0 InOP_AMP ICMZ SLEWRT P1P2O vout3
In+
209
vin.Vt
-5 0 2e-5 4e-5 6e-5 8e-5 1e-4 time 1.2e-4 1.4e-4 1.6e-4 1.8e-4 2e-4
vout1.Vt
-5 0 2e-5 4e-5 6e-5 8e-5 1e-4 time 1.2e-4 1.4e-4 1.6e-4 1.8e-4 2e-4
10
vout2.Vt
-10 0 20 2e-5 4e-5 6e-5 8e-5 1e-4 time 1.2e-4 1.4e-4 1.6e-4 1.8e-4 2e-4
10 vout3.Vt
-10 0 2e-5 4e-5 6e-5 8e-5 1e-4 time 1.2e-4 1.4e-4 1.6e-4 1.8e-4 2e-4
Figure 7.24: OP AMP slew rate simulation waveforms for the circuit shown in Fig. 7.23.
210
P_VCC1 P_VCC2 VOVDRV1 U=2.5 V DOVRV1 Is=8e-16 A VLIM1 U=2 V VCC OVDRV SUB1 File=OVDRV.sch IN P_IN1 DOVDRV1 Is=8e-16 A VOVDRV2 U=2.5 V VEE P_IN2
DVL1 Is=8e-16 A
DVL2 Is=8e-16 A
VCC
P_VEE1
P_VEE2
Overload recovery time of an OP AMP is the time required for the output voltage to recover to a rated output voltage from a saturated condition. Typical values are in the S region.
211
4. VLIM2 = 2.0 V = (- supply voltage) - (Maximum negative output voltage) + 1 V. 5. The diode parameters are Is = 8e-16 A, others default. Typical values for the UA741 OP AMP are: 1. Amplier recovery time 5 S. 2. + supply voltage = 15 V. 3. - supply voltage = -15 V. 4. Maximum positive output voltage = 14 V. 5. Maximum negative output voltage = -14 V. The test circuit given in Fig. 7.26 illustrates the eects of signal overdrive and output voltage clamping on a unity gain buer circuit. The test input signal is a 1 kHz signal with the following drive voltages (1) vin1 = 10 V peak, (2) vin2 = 18 V peak, and (3) vin3 = 22 V peak. The corresponding output waveforms are shown in Fig. 7.27. These indicate that increasing overdrive signals results in longer OP AMP recovery times before the amplier returns to linear behaviour.
212
In-
vin1 V1 U=10 V
V3 U=15 V
transient simulation
TR1 Type=lin Start=0 Stop=1.20 ms InVCC vout2
vin2
dc simulation
DC1
VCC vout3
vin3
Figure 7.26: OP AMP overdrive and output voltage limiting test circuit.
213
10 vout1.Vt vin1.Vt
-10 0 1e-4 2e-4 3e-4 4e-4 5e-4 6e-4 Time 7e-4 8e-4 9e-4 1e-3 0.0011 0.0012
20 vout2.Vt vin2.Vt
-20 0 1e-4 2e-4 3e-4 4e-4 5e-4 6e-4 Time 7e-4 8e-4 9e-4 1e-3 0.0011 0.0012
20 vout3.Vt vin3.Vt
-20 0 1e-4 2e-4 3e-4 4e-4 5e-4 6e-4 Time 7e-4 8e-4 9e-4 1e-3 0.0011 0.0012
Figure 7.27: OP AMP overdrive and output voltage limiting waveforms for the circuit shown in Fig. 7.26.
D2 Is=1e-15 A
P_IN1 RDCL1 R=100M HCL1 G=36 T=0 ECL1 G=1 T=0 SUB1 File=CLIMIT.sch
214
V2 U=15 V InVCC OP_AMP ICMZ SLEWRT OVDRV P1P2O CLIMIT In+ V1 U=10 V SUB1 V3 U=15 V R1 R=1k S1 S2 S3 S4 S5 VEE
vout
vin
R2 R=1k
R3 R=2k
R4 R=2k
R5 R=2k
R6 R=2k
dc simulation
DC1
transient simulation
TR1 Type=lin Start=0 Stop=8 ms
10
vin.Vt
-10 0 5e-4 1e-3 0.0015 0.002 0.0025 0.003 0.0035 0.004 Time 0.0045 0.005 0.0055 0.006 0.0065 0.007 0.0075 0.008
10
vout.Vt
-10 0 5e-4 1e-3 0.0015 0.002 0.0025 0.003 0.0035 0.004 Time 0.0045 0.005 0.0055 0.006 0.0065 0.007 0.0075 0.008
Figure 7.30: Simulation waveforms for current limiter test circuit shown in Fig. 7.29.
215
Parameter Oset voltage (V) Bias current (A) Oset current (A) Dierential input res. (ohm) Dierential input cap. (F) Avd(0) dB fp1 (Hz) fp2 (Hz) CMRR(0) dB fcm (Hz) GBP (Hz) Rout (ohm) Slew rate (V per micro sec.) Overdrive recovery time (S) DC supply current (A) Short circuit output current(A) Common-mode input res. (ohm) Common-mode input cap. (F)
UA741 7e-4 80e-9 20e-9 2e6 1.4e-12 106 5 3e6 90 200 1e6 75 0.5 5e-6 1.4e-3 34e-3 1.3e8
OP42 4e-4 130e-12 6e-12 1e12 6e-12 125 120 6 20 17e6 20e6 125 96 2e3 100e3 8e6 10e6 70 50 2.8 50 700e-9 2.5e-3 5.1e-3 32e-3 30e-3 2e9
OPA134 5e-4 5e-12 2e-12 1e13 2e-12 120 5 10e6 100 500 8e6 10 20 0.5e-6 4e-3 40e-3 1e13 5e-12
AD746 3e-4 110e-12 45e-12 2e11 5.5e-12 109 0.25 35e6 85 3e3 13e6 10 75 7e-3 25e-3 2.5e11 5.5e-12
AD826 5e-4 3-3e-6 25e-9 300e3 1.5e-12 75 10e3 100e6 100 2e3 35e6 8 300 6.6e-3 90e-3
Table 7.1: Typical OP AMP parameters taken from device data sheets. A typical value for the UA741 OP AMP short circuit current is 34 mA at 25o C. Figures 7.29 and 7.30 show a simple current limiter test circuit and the resulting test waveforms. In this test circuit time controlled switches decrease the load resistors at 1 mS intervals. When the load current reaches roughly 34 mA the output voltage is clamped preventing further increases in load current.
216
R1 R1 R1 vin vlp + 1 + R6 R7 R7 R6
R4 vbp R4 + R5
(7.17)
The magnitude of the output signals from the lter should also be checked to ensure that these signals do not exceed the power supply voltages.
217
3R4 vbp R4 + R5
(7.18)
1
f jf 0
vhp
(7.19)
1 1 = 2R2 C1 2R3 C2 1
f 2 (f ) 0
(7.20)
vbp =
vhp
(7.21)
4. Hence
f 2 (f ) vhp 0 = f 2 j f vin 1 (f )( f ) + (Q ) 0 0
(7.22)
(7.23)
(7.24)
Assuming f0 = 1 kHz and the required bandwidth of the band pass lter is 10 Hz, on setting R1 = R6 = R7 = 47k and C 1 = C 2 = 2.2nF , calculation yields R2 = R3 = 72.33k 10 In this design Q = 1k/10 = 100. Hence setting R4 = 1k yields R5 = 294k (1 % tolerance). The simulation waveforms for the band pass output are given in Fig. 7.32 11 . When the circuit Q factor is reduced to lower values the other lter outputs act as traditional high and low pass lters. The simulation results for Q factor one are shown in Fig. 7.33.
10
The values of R2 and R3 need to be trimmed if the lter center frequency and bandwidth are required to high accuracy. 11 Note that the input signal vin has been set at 0.1 V peak. The circuit has a Q factor of 100 which means that the band pass output voltage is 10 V peak. Input signals of amplitude much greater than 0.1 V are likely to drive the output signal into saturation when the power supply voltages are 15V .
218
R7 R=47k vin
number 1
vbp.V -0.00149
vhp.V -0.00149
vlp.V 0.000514
R1 R=47k
R2 R=72.33k
C1 C=2.2n
R3 R=72.33k
C2 C=2.2n In-
InOP27 ICMZ P1P2O vhp OP27 ICMZ P1P2O In+ SUB2 vbp
vlp
In+ SUB1
R4 R=1k
R5 R=294 k
dc simulation
DC1
ac simulation
AC1 Type=lin Start=100Hz Stop=1900 Hz Points=500
7.10.2 Example 2: Sinusoidal signal generation with the Wien bridge oscillator
The Wien bridge sinusoidal oscillator has become a classic due to its simplicity and low distortion capabilities. It is an ideal vehicle for demonstrating the properties of OP AMP macromodels and indeed the performance of circuit simulators. Shown in Fig. 7.34 is the basic Wien bridge oscillator which consists of a single OP AMP with negative and positive feedback circuits. The design equations for this circuit are 1. Non-inverting amplier. R3 vout =1+ v+ R4 2. Feedback factor b= Where f0 = 3. Loop gain The oscillator loop gain bAv must equal one for stable oscillations. Hence, bAv = 1+
R3 R4 f0 ) f f 3 + j( f 0
(7.26)
vout 1 = f v+ 3 + j( f 0
f0 ) f
(7.27)
1 1 = 2R1C 1 2R2C 2
(7.28)
219
40
Av_BP in dB
20
-20 200 400 600 800 1e3 Frequency Hz 1.2e3 1.4e3 1.6e3 1.8e3
100
AV_phase in degrees
50
-50
-100 200 400 600 800 1e3 Frequency Hz 1.2e3 1.4e3 1.6e3 1.8e3
Figure 7.32: Simulation waveforms for current state variable lter circuit shown in Fig. 7.31.
220
0.1
vhp.v
0.05
0.1
vlp.v
0.05
Figure 7.33: State variable low pass and high pass response for Q = 1, R5 = 2k . Moreover, at f = f0 , bAv =
3 1+ R R4 3
(7.29)
Setting R3/R4 slightly greater than two causes oscillations to start and increase in amplitude during each oscillatory cycle. Furthermore, if R3/R4 is less than two oscillations will never start or decrease to zero. Figure 7.35 shows a set of Wien bridge oscillator waveforms. In this example the OP AMP is modelled using the OP27 AC macromodel. This has been done deliberately to demonstrate what happens with a poor choice of OP AMP model. The oscillator frequency is 10 kHz with both feedback capacitors and resistors having equal values. Notice that the oscillatory output voltage continues to grow with increasing time until its value far exceeds the limit set by a practical OP AMP power supply voltages. The lower of the two curves in Fig. 7.35 illustrates the frequency spectrum of the oscillator output signal. The data for this curve has been generated using the Time2Freq function. Adding slew rate and voltage limiting to the OP27 macromodel will limit the oscillator output voltage excursions to the OP AMP power supply values. The waveforms for this simulation are shown in Fig. 7.36. When analysing transient response data using function Time2Freq it is advisable to restrict the analysis to regions of the response where the output waveform has reached a steady state otherwise the frequency spectrum will include eects due to growing, or decreasing, transients. The voltage limiting network clips the oscillator output voltage restricting its excursions to below the OP AMP power supply voltages. The clipping is
221
very visible in Fig. 7.36. Notice also that the output waveform is distorted and is no longer a pure sinusoidal waveform of 10 kHz frequency. Odd harmonics are clearly visible and the fundamental frequency has also decreased due to the signal saturation distortion. In a practical Wien bridge oscillator the output waveform should be a pure sinusoid with zero or little harmonic distortion. One way to achieve this is to change the amplitude of the OP AMP gain with changing signal level: as the output signal increases so Av is decreased or as the output signal level decreases Av is increased. At all times the circuit parameters are changed to achieve the condition bAv = 1. The circuit shown in Fig. 7.37 uses two diodes and a resistor to automatically change the OP AMP closed loop gain with changing signal level. Fig. 7.38 shows the corresponding waveforms for the Wien bridge circuit with automatic gain control. Changing the value of resistor R5 causes the amplitude of the oscillator output voltage to stabilise at a dierent value; decreasing R5 also decreases vout. The automatic gain control version of the Wien bridge oscillator also reduces the amount of harmonic distortion generated by the oscillator. This can be clearly observed in Fig. 7.38. Changing the oscillator frequency can be accomplished by either changing the capacitor or resistor values in the feedback network b. To demonstrate how this can be done using Qucs, consider the circuit shown in Fig. 7.39. In this circuit time controlled switches change the value of both capacitors as the simulation progresses. The recorded output waveform for this circuit is shown in Fig. 7.40.
222
C2 C=1 nF
R2 R=15.8k
C1 C=1nF
R1 R=15.8k
dc simulation
DC1 In-
vout
transient simulation
TR1 Type=lin Start=0 Stop=10 ms R4 R=10k R3 R=21k
vout.Vt
-1e11
1e-3
0.002
0.003
0.004
0.005 time
0.006
0.007
0.008
0.009
0.01
Frequency Spectrum
1e9
0 0 5e3 1e4 1.5e4 2e4 2.5e4 Frequency Hz 3e4 3.5e4 4e4 4.5e4 5e4
Figure 7.35: Simulation waveforms for the circuit shown in Fig. 7.34: OP27 AC macromodel.
223
10
vout.Vt
-10
1e-3
0.002
0.003
0.004
0.005 time
0.006
0.007
0.008
0.009
0.01
Freq-Specrum
0 0 3e3 6e3 9e3 1.2e4 1.5e4 1.8e4 2.1e4 2.4e4 2.7e4 Frequency 3e4 3.3e4 3.6e4 3.9e4 4.2e4 4.5e4 4.8e4
Figure 7.36: Simulation waveforms for the circuit shown in Fig. 7.34: OP27 AC + slew rate + vlimit macromodel.
C2 C=1 nF R2 R=15.8k
C1 C=1nF SUB1
R1 R=15.8k
dc simulation
DC1
VEE vout
V1 U=15 V V2 U=15 V
VCC
transient simulation
TR1 Type=lin Start=0 Stop=10 ms IntegrationMethod=Trapezoidal Equation Eqn1 fscan=Time2Freq(vout.Vt,time[700:1000]) R4 R=10k R3 R=21k
R5 R=50k
D1
D2
224
vout.Vt
-1 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
0.4 Freq-Spectrum
0.2
0 0 3e3 6e3 9e3 1.2e4 1.5e4 1.8e4 2.1e4 2.4e4 2.7e4 Frequency Hz 3e4 3.3e4 3.6e4 3.9e4 4.2e4 4.5e4 4.8e4
Figure 7.38: Simulation waveforms for the circuit shown in Fig. 7.37: OP27 AC + slew rate + vlimit macromodel.
225
dc simulation
DC1
S6 C8 C=0.0625nF S5
transient simulation
TR1 Type=lin Start=0 Stop=10 ms IntegrationMethod=Trapezoidal S3 time=8 ms S1 time=7 ms S2 time=6 ms C4 C=0.25nF C2 C=0.5 nF
C7 C=0.125nF
C6 C=0.25nF
S4 R1 R=15.8k
C1 C=0.5nF SUB1 In+ OP27 ICMZ SLWRT R2 R=15.8k P1P2 VLIM O InVEE
C5 C3 C=0.0625nF C=0.125nF
VCC
R4 R=10k
R3 R=21k
R5 R=50k
D1
D2
Figure 7.39: Wien bridge oscillator with switched capacitor frequency control.
226
vout.Vt
-1 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
1 vout.Vt
-1 0.005 0.0051 0.0052 0.0053 0.0054 time 0.0055 0.0056 0.0057 0.0058 0.0059
vout.Vt
-1 0.006 0.0061 0.0062 0.0063 0.0064 time 1 0.0065 0.0066 0.0067 0.0068 0.0069
vout.Vt
-1 0.007 0.0071 0.0072 0.0073 0.0074 time 0.0075 0.0076 0.0077 0.0078 0.0079
vout.Vt
-1 0.008 0.0081 0.0082 0.0083 0.0084 time 0.0085 0.0086 0.0087 0.0088 0.0089
Figure 7.40: Simulation waveforms for the circuit shown in Fig. 7.39: OP27 AC + slew rate + vlimit macromodel.
227
Qucs 0.0.10, and earlier releases, were distributed with an OP AMP library called OpAmps. However, this only contained a component level model for the 741 OP AMP. Many of the models discussed in this text have been added to the Qucs OpAmps library. These should assist readers who wish to experiment with their own OP AMP circuits. 13 One of the important future tasks is the development of component libraries for use with Qucs - this will take time but should be possible given enough eort by everyone interested in Qucs.
228
Voff1 U=0.35m V Ib1 I=80nA Ioff1 I=10nA Ib2 I=80nA R1 R=1M Cin1 C=1.4 pF R2 R=1M RSUM1 R=1
P_INN
SRC1 G=1 S
Voff2 U=0.35m V
ECM1 G=31.623
RSCALE1 R=100
VSR1 U=7.26 V
RSRT1 R=1
RADO R=200k
CP1 C=159.15nF
SRC3 G=1 S
GMP1 G=1 S
RP2 R=1
CP2 C=53.05nF
GMP2 G=1 S
D2 Is=1e-15 A
D3 Is=1e-15 A
DVL1 Is=8e-16 A
RDCCL1 R=100M
HCL1 G=35
P_OUT
VLIM2 U=2 V
P_VEE
Figure 7.41: Modular OP AMP macromodel in schematic form - this model does not include signal overloading.
229
computer to do the tedious work involving component value calculation from device data. With this approach users are only required to enter the device data; as a simple list derived from manufacturers data sheets. One way to do this is to write a SPICE preprocessor template14 and let a SPICE preprocessor generate the model for a specic OP AMP. The PS2SP template le for an OP27 OP AMP modular macromodel is given in Fig. 7.42. The resulting SPICE le is shown in Fig. 7.43. After construction of the SPICE OP27 netlist the Qucs OP27 model is generated via the schematic capture SPICE netlist facility.15
V OS = IS 1 1 + Vt
,where V t = 26e-3 V.
2. IC 1 =
3. IC 2 = IC 1 4. IB 1 = IB
14
The use of the SPICE preprocessors SPICEPP and SPICEPRM are described in Qucs tutorial Qucs simulation of SPICE netlists. Since both SPICEPP and SPICEPRM were rst written, Friedrch Schmidt has developed a PSpice to SPICE3/XSPICE preprocessor which combines, and extends, the features found in both SPICEPP and SPICEPRM. This preprocessor is called PS2SP. The Perl script version of PS2SP is licensed under GPL and may be downloaded from http://members.aon.at/fschmid7/. 15 See the tutorial Qucs simulation of SPICE netlist for instructions on how this can be done. 16 G.R. Boyle, B.M. Cohn, D. Pederson, and J.E. Solomon, Macromodelling of integrated circuit operational ampliers, IEEE Journal of Solid State Circuits, vol. SC-9, pp. 353-364, 1974. 17 See Fig. 7.3. Tests show that the Boyle macromodel reduces simulation times for common amplier, timer and lter circuits by a factor between six and ten.
230
5. B1 =
IC 2 IC 1 and B2 = IB 1 IB 2 B1 + 1 B2 + 1 + IC 1 B1 B2 1 2GBP C2 B1 + B2 1 IC 1 RC 1 , where gm1 = , and RE 2 = RE 1 2 + B1 + B2 gm1 Vt C2 tan 2 , where 180 = 90o m and m is the phase margin.
6. IEE = 7. RC 1 =
1 CM M RRC 1
15. RC =
Rather than calculate the Boyle macromodel component values by hand using a calculator it is better to use a PS2SP preprocessor template that does these calculations and also generates the Boyle SPICE netlist. A template for this task is given in Fig. 7.45. The parameters at the beginning of the listing are for the UA741 OP AMP. In Fig. 7.45 the macromodel internal nodes are indicated by numbers and external nodes by descriptive names. This makes it easier to attach the macromodel interface nodes to a Qucs schematic symbol. The SPICE netlist shown in Fig. 7.46 was generated by SP2SP.
231
s u b c i r c u i t p o r t s : in+ in p out p v c c p v e e . s u b c k t opamp ac in p in n p out p v c c p v e e OP27 OP AMP p a r a m e t e r s . param v o f f = 30 . 0u i b = 15n i o f f = 12n . param rd = 4meg cd = 1 . 4p cmrrdc = 1 . 778 e6 . param fcmz = 2000 . 0 a o l d c = 1 . 778 e6 gbp = 8meg . param f p 2 = 17meg p s l e w r=2 . 8 e6 n s l e w r=2 . 8 e6 . param vccm=15 vpoutm=14 veem=15 . param vnoutm=14 idcoutm=32m r o=70 . 0 . param p1={ ( 1 0 0 p s l e w r ) / ( 2 3 . 1412 gbp ) 0 . 7 } . param p2={ ( 1 0 0 n s l e w r ) / ( 2 3 . 1412 gbp ) 0 . 7 } input stage v o f f 1 in n 6 { v o f f /2 } v o f f 2 7 in p { v o f f /2 } ib1 0 6 {ib} ib2 7 0 {ib} i o f f 1 7 6 { i o f f /2 } r1 6 8 { rd /2 } r2 7 8 { rd /2 } c i n 1 6 7 { cd } commonmode z e r o s t a g e ecm1 12 0 8 0 { 1 e6 / cmrrdc } rcm1 12 13 1meg ccm1 12 13 { 1 / ( 2 3 . 1412 1 e6 fcmz ) } rcm2 13 0 1 d i f f e r e n t i a l and commonmode s i g n a l summing s t a g e gmsum1 0 14 7 6 1 gmsum2 0 14 13 0 1 rsum1 14 0 1 slew rate stage g s r c 1 0 15 13 0 1 r s c a l e 1 15 0 100 d s l 15 16 { d s l e w r a t e } . model d s l e w r a t e d ( i s=1 e 12 bv= { p1+p2 } ) v s r 1 16 0 { p1 } gmsrt1 0 17 15 0 0 . 01 r s r t 1 17 0 1 voltage gain stage 1 gmp1 0 9 17 0 1 rado 9 0 { a o l d c } cp1 9 0 { 1 / ( 2 3 . 1412 gbp ) } voltage gain stage 2 gmp2 0 11 9 0 1 rp2 11 0 1 cp2 11 0 { 1 / ( 2 3 . 1412 f p 2 ) } out put s t a g e e o s 1 10 0 11 0 1 r o s 1 10 50 { r o } out put c u r r e n t l i m i t e r s t a g e r d c l 1 50 0 100meg d c l 1 21 50 d c l i m d c l 2 50 21 d c l i m . model d c l i m d ( i s=1 e 15 c j 0=0 . 0 ) v c l 1 50 p out 0v h c l 1 0 22 v c l 1 { 0 . 9/ idcoutm } e c l 1 21 22 50 0 1 voltage limiting stage d v l 1 p out 30 d v l i m i t . model d v l i m i t d ( i s=8 e 16) d v l 2 40 p out d v l i m i t v l i m 1 p v c c 30 { vcc vccm+1} v l i m 2 40 p v e e { v e e +veem+1} . ends . end
Figure 7.42: PS2SP template for the OP27 modular macromodel. 232
s u b c i r c u i t p o r t s : in+ in p out p v c c p v e e i n f i l e =op27 . pp d a t e=Tue Feb 13 17 : 32 : 37 2007 Converted with p s 2 s p . p l V4 . 11 o p t i o n s : sp3=0 l t s p i c e =0 fromsub=0 f r o m l i b=0 c h e c k=0 ( t i n y l i n e s=1 ) c o p y r i g h t 2007 by F r i e d r i c h Schmidt terms of Gnu L i c e n c e . s u b c k t opamp ac in p in n p out p v c c p v e e v o f f 1 in n 6 1 . 5 e 05 v o f f 2 7 in p 1 . 5 e 05 i b 1 0 6 1 . 5 e 08 i b 2 7 0 1 . 5 e 08 i o f f 1 7 6 6 e 09 r 1 6 8 2000000 r 2 7 8 2000000 c i n 1 6 7 1 . 4 e 12 ecm1 12 0 8 0 0 . 56 2429 6962 8796 4 rcm1 12 13 1meg ccm1 12 13 7 . 95874188208328 e 11 rcm2 13 0 1 gmsum1 0 14 7 6 1 gmsum2 0 14 13 0 1 rsum1 14 0 1 g s r c 1 0 15 13 0 1 r s c a l e 1 15 0 100 d s l 15 16 0 . model d s l e w r a t e d ( i s=1 e 12 bv= 9 . 7422386349166 ) v s r 1 16 0 4 . 8711193174583 gmsrt1 0 17 15 0 0 . 01 r s r t 1 17 0 1 gmp1 0 9 17 0 1 rado 9 0 1778000 cp1 9 0 1 . 98968547052082 e 08 gmp2 0 11 9 0 1 rp2 11 0 1 cp2 11 0 9 . 36322574362739 e 09 e o s 1 10 0 11 0 1 r o s 1 10 50 70 r d c l 1 50 0 100meg d c l 1 21 50 d c l i m d c l 2 50 21 d c l i m . model d c l i m d ( i s=1 e 15 c j 0=0 . 0 ) v c l 1 50 p out 0v h c l 1 0 22 v c l 1 28 . 125 e c l 1 21 22 50 0 1 d v l 1 p out 30 d v l i m i t . model d v l i m i t d ( i s=8 e 16) d v l 2 40 p out d v l i m i t v l i m 1 p v c c 30 14 v l i m 2 40 p v e e 14 . ends . end
233
P_VCC
RO1
CEE
IEE
REE
P_VEE
P_INP
18
An interesting series of articles by Ron Mancini, on verication and use of SPICE models in circuit design can be found in the following editions of EDN magazine:Validate SPICE models before use, EDN March 31, 2005 p.22; Understanding SPICE models, EDN April 14, p 32; Verify your ac SPICE model, EDN May 26, 2005; Beyond the SPICE models dc and ac performance, EDN June 23 2005, and Compare SPICE-model performance, EDN August 18, 2005.
234
Boyle macromodel t e m p l a t e f o r Qucs . D e s i g n p a r a m e t e r s ( For UA741 ) . param v t=26 e 3 $ Thermal v o l t a g e a t room temp . . param c2=30 e 12 $ Compensation c a p a c i t a n c e . param p o s i t i v e s l e w r a t e=0 . 625 e6 n e g a t i v e s l e w r a t e=0 . 50 e6 $ Slew r a t e s . param i s 1=8 . 0 e 16 $ T1 l e a k a g e c u r r e n t . param v o s=0 . 7 e 3 i b=80n i o s=20n $ I n p u t v o l t a g e and c u r r e n t p a r a m e t e r s . param va=200 $ Nominal e a r l y v o l t a g e . param gbp=1 . 0 e6 $ Gain bandwidth p r o d u c t . param pm =70 $ E x c e s s phase a t u n i t y g a i n . . param cmrr=31622 . 8 $ Commonmode r e j e c t i o n r a t i o ( 9 0 dB) . param a v o l=200 k $ DC open l o o p d i f f e r e n t i a l g a i n . param r o 2=489 . 2 $ DC outpu t r e s i s t a n c e . param r o 1=76 . 8 $ High f r e q u e n c y AC outp ut r e s i s t a n c e . param r 2=100 k =15 v . param vout p=14 . 2 $ P o s i t i v e s a t u r a t i o n v o l t a g e f o r VCC . param vout n=13 . 5 $ N e g a t i v e s a t u r a t i o n v o l t a g e f o r VCC =15v . param v c c=15 $ P o s i t i v e power s u p p l y v o l t a g e . param v e e=15 $ N e g a t i v e power s u p p l y v o l t a g e . param i s c p=25m $ S h o r t c i r c u i t out put c u r r e n t . param i s c n=25m $ S h o r t c i r c u i t out put c u r r e n t . param pd=59 . 4m $ T y p i c a l power d i s s i p a t i o n Design e q u a t i o n s . param i s 2={ i s 1 (1+ v o s / v t ) } . param i c 1={ 0 . 5 c2 p o s i t i v e s l e w r a t e } i c 2={ i c 1 } . param i b 1={ ib 0 . 5 i o s } i b 2={ i b +0 . 5 i o s } . param b1={ i c 1 / i b 1 } b2={ i c 2 / i b 2 } . param i e e={ ( ( b1 +1)/ b1+(b2 +1)/ b2 ) i c 1 } . param gm1={ i c 1 / v t } r c 1={ 1 / ( 2 3 . 1412 gbp c2 ) } r c 2=r c 1 . param r e 1={ ( ( b1+b2 )/(2+ b1+b2 ) ) ( rc1 1/gm1 ) } r e 2=r e 1 . param r e e={ va / i e e } c e e={ ( 2 i c 1 / n e g a t i v e s l e w r a t e ) c2 } . param dphi={ 90pm} c1={ ( c2 / 2 ) tan ( dphi 3 . 1 4 1 2 / 1 8 0 ) } . param gcm={ 1 / ( cmrr r c 1 ) } ga={ 1/ r c 1 } gb={ ( a v o l r c 1 ) / ( r 2 r o 2 ) } . param i x={ 2 i c 1 r 2 gb i s 1 } tmp1={1 . 0 / ( r o 1 i s 1 / vt ) } i s d 1={ i x exp ( tmp1)+1e 32 } . param tmp2={ i x / i s d 1 } r c={ v t / ( 1 0 0 i x ) l n ( tmp2 ) } . param gc={ 1/ r c } . param vc={ abs ( v c c ) vout p+vt l n ( i s c p/ i s 1 ) } ve={ abs ( v e e )+ vout n+vt l n ( i s c n/ i s 1 ) } . param rp={ ( vcc v e e ) ( vcc v e e ) / pd } Nodes : I n p u t n i n p n i n n n v c c n v e e Output n out Q1 8 n i n n 10 qmod1 Q2 9 n i n p 11 qmod2 RC1 n v c c 8 { r c 1 } RC2 n v c c 9 { r c 2 } RE1 1 10 { r e 1 } RE2 1 11 { r e 2 } RE 1 0 { r e e } CE 1 0 { c e e } IEE 1 n v e e { i e e } C1 8 9 { c1 } RP n v c c n v e e { rp } GCM 0 12 1 0 { gcm } GA 12 0 8 9 { ga } R2 12 0 { r 2 } C2 12 13 30p GB 13 0 12 0 { gb } RO2 13 0 { r o 2 } RO1 13 n out { r o 1 } D1 13 14 dmod1 D2 14 13 dmod1 GC 0 14 n out 0 { gc } RC 14 0 { r c } D3 n out 15 DMOD3 D4 16 n out DMOD3 VC n v c c 15 { vc } VE 16 n v e e { ve } . model dmod1 d ( i s={ i s d 1 } r s=1 ) . model dmod3 d ( i s=8 e 16 r s=1 ) . model qmod1 npn ( i s={ i s 1 } BF ={ b1 } ) . model qmod2 npn ( i s={ i s 2 } BF ={ b2 } ) . end
235
Figure 7.45: PS2SP template for the Boyle macromodel with UA741 parameters listed.
b o y l e macromodel t e m p l a t e f o r q u c s . i n f i l e =ua741 b o y l e . p s 2 s p d a t e=Tue Feb 6 20 : 58 : 12 2007 Converted with p s 2 s p . p l V4 . 11 o p t i o n s : sp3=0 l t s p i c e =0 fromsub=0 f r o m l i b=0 c h e c k=0 ( t i n y l i n e s=1 ) c o p y r i g h t 2007 by F r i e d r i c h Schmidt terms of Gnu L i c e n c e q1 8 n i n n 10 qmod1 q2 9 n i n p 11 qmod2 r c 1 n v c c 8 5305 . 82792138885 r c 2 n v c c 9 5305 . 82792138885 r e 1 1 10 1820 . 05072213971 r e 2 1 11 1820 . 05072213971 r e 1 0 13192612 . 1372032 c e 1 0 7 . 5 e 12 i e e 1 n v e e 1 . 516 e 05 c1 8 9 5 . 4588124089082 e 12 rp n v c c n v e e 15151 . 5151515152 gcm 0 12 1 0 5 . 96000354174836 e 09 ga 12 0 8 9 0 . 000188472 r 2 12 0 100000 c2 12 13 30p gb 13 0 12 0 21 . 6918557701915 r o 2 13 0 489 . 2 r o 1 13 n out 76 . 8 d1 13 14 dmod1 d2 14 13 dmod1 gc 0 14 n out 0 1621 . 78603105575 r c 14 0 0 . 0 0 0 6 1 6 6 0 4 1 5 1 7 5 0 5 3 9 d3 n out 15 dmod3 d4 16 n out dmod3 vc n v c c 15 1 . 60789905279489 ve 16 n v e e 2 . 30789905279488 . model dmod1 d ( i s=1 e 32 r s=1 ) . model dmod3 d ( i s=8 e 16 r s=1 ) . model qmod1 npn ( i s=8 e 16 b f=107 . 1 4 2 8 5 7 1 4 2 8 5 7 ) . model qmod2 npn ( i s=8 . 21538461538461 e 16 b f=83 . 3 3 3 3 3 3 3 3 3 3 3 3 3 ) . end
236
R1 R=0.00001
C1 C=1000F
VCC
V2 U=15 V
+
SUB1
VEE
V3 U=15 V
vout_boyle
Equation Eqn1 gain_mod_27_dB=dB(vout_mod_27.v) gain_mod_dB=dB(vout_mod.v) gain_boyle_dB=dB(vout_boyle.v) gain_boyle_27_dB=dB(vout_boyle_27.v) phase_boyle_deg=rad2deg(unwrap(angle(vout_boyle.v))) phase_boyle_27_deg=rad2deg(unwrap(angle(vout_boyle_27.v))) phase_mod_deg=rad2deg(unwrap(angle(vout_mod.v))) phase_mod_27_deg=rad2deg(unwrap(angle(vout_mod_27.v)))
C2 C=1000F
L2 L=1000H
R2 R=0.00001
UA741(Boyle)
VCC
+
SUB2
VEE
L3 L=1000H
R3 R=0.00001
C3 C=1000F vin
OP27 (MOD)
dc simulation
VCC DC1
+
SUB5
VEE
ac simulation
AC1 Type=log Start=1Hz Stop=100MHz Points=200
vout_boyle_27
C4 C=1000F
L4 L=1000H
R4 R=0.00001
RL2 R=2k
OP27 (Boyle)
VCC
+
SUB6
VEE
Figure 7.47: Test circuit for simulating OP AMP model open loop voltage gain.
237
100 phase_mod_deg 1 10 100 1e3 1e4 1e5 1e6 1e7 1e8 acfrequency gain_mod_dB
-50
-100
100 phase_boyle_deg 1 10 100 1e3 1e4 1e5 1e6 1e7 1e8 acfrequency gain_boyle_dB
-100
-100
gain_mod_27_dB
100
-100
gain_boyle_27_dB
100
-100
Figure 7.48: Open loop voltage gain simulation waveforms for the modular and Boyle UA741 and OP27 macromodels.
238
See for example the OP AMP section of the Texas Instruments (TI) Web site and the TI Operational Amplier Circuits, Linear Circuits, Data Manual, 1990. 20 Taking the OP AMP reference voltage to be the average of VCC and VEE allows devices with nonsymmetrical power supply voltages to be simulated. 21 The denition of these polynomial functions was changed in the SPICE 3 series simulators to a more conventional algebraic form when specifying the B type source components. This often gives compatibility problems when attempting to simulate SPICE 2 models with circuit simulators developed from SPICE 3f4 or earlier simulators. Most popular SPICE based circuit simulators now accept both types of nonlinear syntax. 22 If only one P coecient is given in the single dimension polynomial case, then SPICE assumes that this is P1 and that P0 equals zero. Similarly if the POLY keyword is not explicitly stated in a controlled source denition then it is assumed by SPICE to be POLY(1).
239
Similarly: Fname N(+) N(-) POLY(n) V1 V2 V3 ...... P0 P1 P2 ....., where V1, V2 .... are independent voltage sources whose current controls the output. This becomes: For POLY(1): Fname N(+) N(-) V1 P0 P1 P2........
For POLY(2): Fname N(+) N(-) POLY(2) V1 V2 P0 P1 P2....... For POLY(3): Fname N(+) N(-) POLY(3) V1 V2 V3 P0 P1 P2 P3......., and so on.
The meaning of the coecients in the nonlinear controlled source denitions depends on the dimension of the polynomial. The following examples indicate how SPICE calculates current or voltage values. For POLY(1): The polynomial function f v is calculated using f v = P 0 + (P 1 f a) + (P 2 f a2 ) + (P 3 f a3 ) + (P 4 f a4 ) + ........., where f a is either a voltage or current independent variable. For POLY(2): The polynomial function f v is calculated using f v = P 0 + (P 1 f a) + (P 2 f b) + (P 3 f a2 ) + (P 4 f a f b) + (P 5 f b2 ) + (P 6 f a3 ) +(P 7 f a2 f b) + .........., where f a and f b are both either voltage or current independent variables. For POLY(3): The polynomial function f v is calculated using f v = P 0 + (P 1 f a) + (P 2 f b) + (P 3 f c) + (P 4 f a2 ) + (P 5 f a f b) +(P 6 f a f c) + (P 7 f b2 ) + (P 8 f b f c) + (P 9 f c2 ) + (P 10 f a3 ) +(P 11 f a2 f b) + (P 12 f a2 f c) + (P 13 f a f b2 ) + (P 14 f a f b f c) +(P 15 f a f c2 ) + (P 16 f b3 ) + (P 17 f b2 f c) + (P 18 f b f c2 ) +(P 19 f c3 )............., where f a, f b, and f c are all either voltage or current independent variables. From Fig. 7.49 the controlled generators egnd and fb are: egnd 99 0 poly(2) (3,0) (4,0) 0 .5 .5 Which is the same as egnd 99 0 poly(2) 3 0 4 0 0 0.5 0.5 By comparison with the SPICE polynomial equations for controlled sources, V (4) V (3) + implying that the controlled voltage source V (egnd) is V (egnd) = 2 2 the sum of two linear voltage sources. fb 7 99 poly(5) vb vc ve vlp vln 0 10.61E6 -10E6 10E6 10E6 -10E6 By comparison with the SPICE polynomial equations for controlled sources I(fb) = 10.61e6*I(vb) - 10e6*I(vc) + 10e6*I(ve) + 10e6*I(vlp) -10e6*I(vlp) implying that the controlled current I (f b) is the sum of ve linear controlled current sources.
240
SPICE sources engd and fb can therefore be replaced in the modied Boyle model by the following SPICE code23 :
* egnd 99 0 poly(2) (3,0) (4,0) 0 .5 .5 * Forms voltage source with output * V=0.5*V(4)+0.5*V(3) egnd1 999 0 4 0 0.5 egnd2 99 999 3 0 0.5 * *fb 7 99 poly(5) vb vc ve vlp vln 0 10.61e6 -10e6 10e6 10e6 -10e6 * * Forms current source with output * I=10.61e6*i(vb)-10e6*i(vc)+10e6*i(ve)+10e6*i(vlp)-10e6*i(vln) * *Sum 5 current sources to give fb. fb1 7 99 vb 10.61e6 fb2 7 99 vc -10e6 fb3 7 99 ve 10e6 fb4 7 99 vlp 10e6 fb5 7 99 vln -10e6 Modied Boyle macromodels are often generated using the PSpice Parts24 program. Such models have similar structured SPICE netlists with dierent component values. However, changes in technology do result in changes in the input stage that reect the use of npn, pnp and JFET input transistors in real OP AMPs. Hence to use manufacturers published modied Boyle models with Qucs all that is required is the replacement of the SPICE polynomial controlled sources with linear sources and the correct component values. Again this is best done using a SPICE preprocessor template. The templates for OP AMPS with npn and PJF input transistors are shown in Figures 7.50 and 7.51. The SPICE netlists shown in Figs. 7.52 and 7.53 were generated by the PS2SP preprocessor. For OP AMPS with pnp input transistors simply change the BJT model reference from npn to pnp and use the same template.
23
It is worth noting that the code for the polynomial form of controlled sources can only be replaced by a series connection of linear controlled voltage sources or a parallel connection of linear controlled current sources provided no higher order polynomial coecients are present in the original SPICE code. Some SPICE models use these higher order coecients to generate multiply functions. Such cases cannot be converted to code which will simulate using Qucs 0.0.10. Sometime in the future this restriction will be removed when nonlinear voltage and current sources are added to Qucs. 24 The Parts modelling program is an integral component in the PSpice circuit simulation software originally developed by the MicroSim Corporation, 1993, The Design Centre:Parts (Irvine, Calif.). It now forms part of Cadence Design Systems OrCad suite of CAD software.
241
connections : non i n v e r t i n g i n p u t | i n v e r t i n g input | | p o s i t i v e power s u p p l y | | | n e g a t i v e power s u p p l y | | | | out put | | | | | . s u b c k t uA741 1 2 3 4 5 c1 11 12 8 . 661E12 c2 6 7 30 . 00E12 dc 5 53 dx de 54 5 dx d l p 90 91 dx d l n 92 90 dx dp 4 3 dx egnd 99 0 p o l y ( 2 ) ( 3 , 0 ) ( 4 , 0 ) 0 . 5 . 5 fb 7 99 p o l y ( 5 ) vb vc ve v l p v l n 0 10 . 61E6 10E6 10E6 10E6 10E6 ga 6 0 11 12 188 . 5E6 gcm 0 6 10 99 5 . 961E9 iee 10 4 dc 15 . 16E6 hlim 90 0 v l i m 1K q1 11 2 13 qx q2 12 1 14 qx r2 6 9 100 . 0E3 rc1 3 11 5 . 305E3 rc2 3 12 5 . 305E3 r e 1 13 10 1 . 836E3 r e 2 14 10 1 . 836E3 r e e 10 99 13 . 19E6 ro1 8 5 50 ro2 7 99 100 rp 3 4 18 . 16E3 vb 9 0 dc 0 vc 3 53 dc 1 ve 54 4 dc 1 v l i m 7 8 dc 0 v l p 91 0 dc 40 vln 0 92 dc 40 . model dx D( I s=800 . 0E18 Rs=1 ) . model qx NPN( I s=800 . 0E18 Bf=93 . 7 5 ) . ends
Figure 7.49: PSpice modied Boyle macromodel for the UA741 OP AMP.
242
M o d i f i e d Boyle OP AMP model t e m p l a t e npn BJT i n p u t d e v i c e s . UA741C OP AMP p a r a m e t e r s , m a n u f a c t u r e r Texas I n s t r u m e n t s . param c1=4 . 664 p c2=20 . 0p . param ep1=0 . 5 ep2=0 . 5 . param f p 1=10 . 61 e6 f p 2=10e6 f p 3=10 e6 f p 4=10 e6 f p 5=10e6 . param vc=2 . 6 ve=2 . 6 v l p=25 v l n=25 . param ga=137 . 7 e 6 gcm=2 . 57 e 9 . param i e e=10 . 16 e 6 hlim=1k . param r 2=100 k . param r c 1=7 . 957 k r c 2=7 . 957 k . param r e 1=2 . 74 k r e 2=2 . 74 k . param r e e=19 . 69 e6 r o 1=150 r o 2=150 . param rp=18 . 11 k . s u b c k t ua741 TI P INP P INN P VCC P VEE P OUT c1 11 12 { c1 } c2 6 7 { c2 } dc P OUT 53 dx de 54 P OUT dx d l p 90 91 dx d l n 92 90 dx egnd 99 0 p o l y ( 2 ) ( 3 , 0 ) ( 4 , 0 ) 0 0 . 5 0 . 5 Qucs m o d i f i c a t i o n , Mike Brinson , Feb 2007 egnd1 999 0 P VCC 0 { ep1 } egnd2 99 999 P VEE 0 { ep2 } f b 7 99 p o l y ( 5 ) vb vc ve v l p v l n 0 10 . 61 e6 10e6 10 e6 10 e6 10e6 Forms c u r r e n t s o u r c e with out put I=10 . 61 e6 i ( vb) 10 e6 i ( vc )+10 e6 i ( ve )+10 e6 i ( v l p ) 10 e6 i ( v l n ) Qucs m o d i f i c a t i o n , Mike Brinson , Feb 2007 . Sum 5 c u r r e n t s o u r c e s t o g i v e f b . f b 1 7 99 vb { f p 1 } f b 2 7 99 vc { f p 2 } f b 3 7 99 ve { f p 3 } f b 4 7 99 v l p { f p 4 } f b 5 7 99 v l n { f p 5 } ga 6 0 11 12 { ga } gcm 0 6 10 99 { gcm } i e e 10 P VEE { i e e } hlim 90 0 v l i m { hlim } q1 11 P INN 13 qx q2 12 P INP 14 qx r 2 6 9 100 k r c 1 P VCC 11 { r c 1 } r c 2 P VCC 12 { r c 2 } r e 1 13 10 { r e 1 } r e 2 14 10 { r e 2 } r e e 10 99 { r e e } r o 1 8 P OUT { r o 1 } r o 2 7 99 { r o 2 } rp P VCC P VEE { rp } vb 9 0 dc 0 vc P VCC 53 dc { vc } ve 54 P VEE dc { ve } v l i m 7 8 dc 0 v l p 91 0 dc { v l p } v l n 0 92 dc { v l p } . model dx d ( i s=800 . 0 e 18) . model qx npn ( i s=800 . 0 e 18 b f=62 . 5 ) . ends . end
Figure 7.50: Modied Boyle PS2SP netlist for the UA741 OP AMP. 243
M o d i f i e d Boyle OP AMP model t e m p l a t e JFET i n p u t d e v i c e s . TL081 OP AMP p a r a m e t e r s , m a n u f a c t u r e r Texas I n s t r u m e n t s . param c1=3 . 498 p c2=15 . 0p . param ep1=0 . 5 ep2=0 . 5 . param f p 1=4 . 715 e6 f p 2=5e6 f p 3=5 e6 f p 4=5 e6 f p 5=5e6 . param vc=2 . 2 ve=2 . 2 v l p=25 v l n=25 . param ga=282 . 8 e 6 gcm=8 . 942 e 9 . param i s s =195 . 0 e 6 hlim=1k . param r 2=100 k . param rd1=3 . 536 k rd2=3 . 536 k . param r s s=1 . 026 e6 r o 1=150 r o 2=150 . param rp=2 . 14 k . s u b c k t ua741 TI P INP P INN P VCC P VEE P OUT c1 11 12 { c1 } c2 6 7 { c2 } dc P OUT 53 dx de 54 P OUT dx d l p 90 91 dx d l n 92 90 dx egnd 99 0 p o l y ( 2 ) ( 3 , 0 ) ( 4 , 0 ) 0 0 . 5 0 . 5 Qucs m o d i f i c a t i o n , Mike Brinson , Feb 2007 egnd1 999 0 P VCC 0 { ep1 } egnd2 99 999 P VEE 0 { ep2 } f b 7 99 p o l y ( 5 ) vb vc ve v l p v l n 0 10 . 61 e6 10e6 10 e6 10 e6 10e6 Forms c u r r e n t s o u r c e with out put I=10 . 61 e6 i ( vb) 10 e6 i ( vc )+10 e6 i ( ve )+10 e6 i ( v l p ) 10 e6 i ( v l n ) Qucs m o d i f i c a t i o n , Mike Brinson , Feb 2007 . Sum 5 c u r r e n t s o u r c e s t o g i v e f b . f b 1 7 99 vb { f p 1 } f b 2 7 99 vc { f p 2 } f b 3 7 99 ve { f p 3 } f b 4 7 99 v l p { f p 4 } f b 5 7 99 v l n { f p 5 } ga 6 0 11 12 { ga } gcm 0 6 10 99 { gcm } i s s P VCC 10 { i s s } hlim 90 0 v l i m { hlim } j 1 11 P INN 10 j x j 2 12 P INP 10 j x r 2 6 9 100 k rd1 P VEE 11 { rd1 } rd2 P VEE 12 { rd2 } r o 1 8 P OUT { r o 1 } r o 2 7 99 { r o 2 } rp P VCC P VEE { rp } r s s 10 99 { r s s } vb 9 0 dc 0 vc P VCC 53 dc { vc } ve 54 P VEE dc { ve } v l i m 7 8 dc 0 v l p 91 0 dc { v l p } v l n 0 92 dc { v l p } . model dx d ( i s=800 . 0 e 18) . model j x p j f ( i s=15 . 0 e 12 b e t a=270 . 1 e 6 v t o=1) . ends . end
Figure 7.51: Modied Boyle PS2SP netlist for the TL081 OP AMP.
244
m o d i f i e d b o y l e op amp model t e m p l a t e i n f i l e= Mod b o y l e t e m p l a t e npn . pp d a t e=Thu Feb 8 23 : 54 : 59 2007 Converted with p s 2 s p . p l V4 . 11 o p t i o n s : sp3=1 l t s p i c e =0 fromsub=0 f r o m l i b=0 c h e c k=0 ( t i n y l i n e s=1 ) c o p y r i g h t 2007 by F r i e d r i c h Schmidt terms of Gnu L i c e n c e . s u b c k t ua741 t i p i n p p i n n p v c c p v e e p out c1 11 12 4 . 664 e 12 c2 6 7 2 e 11 dc p out 53 dx de 54 p out dx d l p 90 91 dx d l n 92 90 dx egnd1 999 0 p v c c 0 0 . 5 egnd2 99 999 p v e e 0 0 . 5 f b 1 7 99 vb 9 . 42507068803016 e 08 f b 2 7 99 vc 1e 07 f b 3 7 99 ve 1 e 07 f b 4 7 99 v l p 1 e 07 f b 5 7 99 v l n 1e 07 ga 6 0 11 12 0 . 0001377 gcm 0 6 10 99 2 . 57 e 09 i e e 10 p v e e 1 . 016 e 05 hlim 90 0 v l i m 0 . 001 q1 11 p i n n 13 qx q2 12 p i n p 14 qx r 2 6 9 100 k r c 1 p v c c 11 7957 r c 2 p v c c 12 7957 r e 1 13 10 2740 r e 2 14 10 2740 r e e 10 99 19690000 r o 1 8 p out 150 r o 2 7 99 150 rp p v c c p v e e 18110 vb 9 0 0 vc p v c c 53 2 . 6 ve 54 p v e e 2 . 6 vlim 7 8 0 v l p 91 0 25 v l n 0 92 25 . model dx d ( i s=800 . 0 e 18) . model qx npn ( i s=800 . 0 e 18 b f=62 . 5 ) . ends . end
Figure 7.52: Modied Boyle SPICE netlist for the TI UA741 OP AMP.
245
m o d i f i e d b o y l e op amp model t e m p l a t e i n f i l e =TL081 TI . pp d a t e=Sun Feb 11 16 : 04 : 22 2007 Converted with p s 2 s p . p l V4 . 11 o p t i o n s : sp3=0 l t s p i c e =0 fromsub=0 f r o m l i b=0 c h e c k=0 ( t i n y l i n e s=1 ) c o p y r i g h t 2007 by F r i e d r i c h Schmidt terms of Gnu L i c e n c e . s u b c k t ua741 t i p i n p p i n n p v c c p v e e p out t i m e s c1 11 12 3 . 498 e 12 c2 6 7 1 . 5 e 11 dc p out 53 dx de 54 p out dx d l p 90 91 dx d l n 92 90 dx egnd1 999 0 p v c c 0 0 . 5 egnd2 99 999 p v e e 0 0 . 5 f b 1 7 99 vb 4715000 f b 2 7 99 vc 5000000 f b 3 7 99 ve 5000000 f b 4 7 99 v l p 5000000 f b 5 7 99 v l n 5000000 ga 6 0 11 12 0 . 0002828 gcm 0 6 10 99 8 . 942 e 09 i s s p v c c 10 0 . 000195 hlim 90 0 v l i m 1000 j 1 11 p i n n 10 j x j 2 12 p i n p 10 j x r 2 6 9 100 k rd1 p v e e 11 3536 rd2 p v e e 12 3536 r o 1 8 p out 150 r o 2 7 99 150 rp p v c c p v e e 2140 r s s 10 99 1026000 vb 9 0 dc 0 vc p v c c 53 dc 2 . 2 ve 54 p v e e dc 2 . 2 v l i m 7 8 dc 0 v l p 91 0 dc 25 v l n 0 92 dc 25 . model dx d ( i s=800 . 0 e 18) . model j x p j f ( i s=15 . 0 e 12 b e t a=270 . 1 e 6 v t o=1) . ends . end
Figure 7.53: Modied Boyle SPICE netlist for the TI TL081 OP AMP.
246
The procedure presented here must be considered a work around and may change as Qucs develops. The location of the user created libraries will dier from system to system depending where .qucs is installed.
247
< L i n e 80 0 15 0 #00007 f 2 1> < . PortSym 35 35 1 0> < . PortSym 35 40 2 0> < . PortSym 95 0 3 180 > < L i n e 60 50 0 40 #00007 f 2 1> < L i n e 60 15 0 40 #00007 f 2 1> <Text 15 55 30 #000000 0 > <Text 15 30 20 #000000 0 +> <Text 15 5 12 #000000 0 UA741 ( Boyle ) > < . PortSym 60 55 4 180 > < . PortSym 60 50 5 180 > <Text 65 30 12 #000000 0 VCC> <Text 65 20 12 #000000 0 VEE> </Symbol> </Component>
Note that the model requires a subcircuit of type ua741_boyle_cir which is not included when the library is created by Qucs. After completing the cut and paste operation described in steps 3 and 4 above the resulting library entry becomes the Qucs netlist shown next.
<Component ua741 ( b o y l e )> <D e s c r i p t i o n > UA741 Boyle macromodel </ D e s c r i p t i o n > <Model> net0 net1 net2 net3 net4 . Def : Lib OPAMP ua741 b o y l e Sub : X1 n e t 0 n e t 1 n e t 2 n e t 3 n e t 4 gnd Type=ua741 b o y l e c i r . Def : End . Def : ua741 b o y l e c i r netN INN netN INP netN OUT netN VCC netN VEE r e f Vdc : VE n e t 1 6 netN VEE U =2 . 3079 Vdc : VC netN VCC n e t 1 5 U =1 . 6079 Diode : D4 netN OUT n e t 1 6 I s=8 e 16 Rs=1 N =1 M =0 . 5 Cj0=1 e 14 Vj=0 . 7 Diode : D3 n e t 1 5 netN OUT I s=8 e 16 Rs=1 N =1 M =0 . 5 Cj0=1 e 14 Vj=0 . 7 R : RC n e t 1 4 ref R =0 . 000616604 VCCS : GC netN OUT r e f net14 ref G =1621 . 79 Diode : D2 n e t 1 3 n e t 1 4 I s=1 e 32 Rs=1 N =1 M =0 . 5 Cj0=1 e 14 Vj=0 . 7 Diode : D1 n e t 1 4 n e t 1 3 I s=1 e 32 Rs=1 N =1 M =0 . 5 Cj0=1 e 14 Vj=0 . 7 R : RO1 n e t 1 3 netN OUT R =76 . 8 R : RO2 n e t 1 3 ref R =489 . 2 VCCS : GB n e t 1 2 n e t 1 3 ref ref G =21 . 6919 C : C2 n e t 1 2 n e t 1 3 C =30p R : R2 n e t 1 2 ref R =100000 VCCS : GA n e t 8 n e t 1 2 ref net9 G =0 . 000188472 VCCS :GCM n e t 1 ref net12 ref G =5 . 96 e 09 R : RP netN VCC netN VEE R =15151 . 5 C : C1 n e t 8 n e t 9 C =5 . 45881 e 12 I d c : IEE netN VEE n e t 1 I=1 . 516 e 05 C : CE n e t 1 ref C =0 ref R =1 . 31926 e+07 R : RE n e t 1 R : RE2 n e t 1 n e t 1 1 R =1820 . 05 R : RE1 n e t 1 n e t 1 0 R =1820 . 05 R : RC2 netN VCC n e t 9 R =5305 . 83 R : RC1 netN VCC n e t 8 R =5305 . 83 BJT : Q2 netN INP n e t 9 n e t 1 1 r e f Type=npn I s=8 . 21538 e 16 Bf=83 . 3333 Nf=1 Nr=1 I k f=0 I k r=0 Vaf=0 Var=0 I s e=0 Ne=1 . 5 I s c=0 Nc=2 Br=1 Rbm =0 I r b=0 Cje=0 Vje=0 . 75 Mje=0 . 33 Cjc=0 Vjc=0 . 75 Mjc=0 . 33 Xcjc=1 C js=0 Vjs=0 . 75 Mjs=0 Fc=0 . 5 Vtf=0 Tf=0 Xtf=0 I t f =0 Tr=0 BJT : Q1 netN INN n e t 8 n e t 1 0 r e f Type=npn I s=8 e 16 Bf=107 . 143 Nf=1 Nr=1 I k f=0 I k r=0 Vaf=0 Var=0 I s e=0 Ne=1 . 5 I s c=0 Nc=2 Br=1 Rbm =0 I r b=0 Cje=0 Vje=0 . 75 Mje=0 . 33 Cjc=0 Vjc=0 . 75 Mjc=0 . 33 Xcjc=1 C js=0 Vjs=0 . 75 Mjs=0 Fc=0 . 5 Vtf=0 Tf=0 Xtf=0 I t f =0 Tr=0 . Def : End </Model> <Symbol>
248
< . ID 20 74 SUB> < L i n e 20 60 0 125 #00007 f 2 1> < L i n e 20 65 100 65 #00007 f 2 1> < L i n e 20 60 100 60 #00007 f 2 1> < L i n e 35 35 15 0 #00007 f 2 1> < L i n e 35 40 15 0 #00007 f 2 1> < L i n e 80 0 15 0 #00007 f 2 1> < . PortSym 35 35 1 0> < . PortSym 35 40 2 0> < . PortSym 95 0 3 180 > < L i n e 60 50 0 40 #00007 f 2 1> < L i n e 60 15 0 40 #00007 f 2 1> <Text 15 55 30 #000000 0 > <Text 15 30 20 #000000 0 +> <Text 15 5 12 #000000 0 UA741 ( Boyle ) > < . PortSym 60 55 4 180 > < . PortSym 60 50 5 180 > <Text 65 30 12 #000000 0 VCC> <Text 65 20 12 #000000 0 VEE> </Symbol> </Component>
See for example: Ray Kendall, User-friendly model simplies SPICE OP-AMP simulation, EDN magazine, January 4, 2007, pp. 63-69. 28 This section is based on unpublished work by David Faulkner and Mike Brinson., Department of Computing, Communications Technology and Mathematical Sciences, London Metropolitan University, UK.
249
CEE C=7.5p
RE3 R=106.1M
RE5 R=15.06M
GCM G=6.32e-2
RE4 R=10
Figure 7.54: AC CMRR modication for Boyle macromodel The new value of CEE must have the same value as the original CEE value29 if the same slew-rate is to be maintained, so for a 200 Hz cut-o this gives RE3=106.1M. RE4 is arbitrarily xed at 10 , which introduces another pole at about 2 GHz, well outside the frequency of interest. The value of REE is increased to RE5 (15.06meg), so that RE5 in parallel with RE3 equals the original value of REE. GCM is also increased by the factor RE 3 maintaining the correct low frequency common-mode gain. Dierential frequency reRE 4 sponse and slew rate are unchanged by these modications. The simulation results for the common-mode test circuit shown in Fig. 7.20 are given in Fig. 7.55. These indicate close agreement between the modular and ac Boyle macromodels. Modifying the circuit of an existing OP AMP macromodel is at best a complex process or at worst impossible because the model details are either not known or well understood. One way to add features to an existing model is to add an external circuit to a models terminals. This circuit acts as a signal processing element adding additional capabilities to the original macromodel. One circuit feature not modelled by any of the macromodels introduced in earlier sections is power supply rejection. By adding a simple passive electrical network to the terminals of a macromodel it is possible to model OP AMP power supply rejection. Power supply rejection(PSRR) is a measure of the ability of an OP AMP to reject unwanted signals that enter at the power terminals. It is dened as the ratio of dierential-mode gain to power supply injected signal gain. The simulation of OP AMP power supply rejection30
29
1 . 2 CEE RE 3
In the Boyle macromodel the value of CEE is set by the OP AMP slew rate. Adjusting both the positive and negative slew rates changes the value of CEE. For the UA741 these have been set at 0.625e6 and 0.500e6 respectively. This gives CEE=7.5pF which is commonly quoted for the UA741 value of CEE, see Andrei Vladimirescu, The SPICE Book,1994, John Wiley and Sons, Inc., ISBN 0-471-60926-9, pp 228-239. Also note care must be taken when choosing values for the two slew rates because negative values of CEE can occur which are physically not realisable. 30 M. E. Brinson and D. J. Faulkner, Measurement and modelling of operational amplier power supply rejection, Int. J. Electronics, 1995, vol. 78, NO. 4, 667-678.
250
2e-4
1.5e-4 vout_boyle_orig.v
1e-4
5e-5
1.5e-4 vout_boyle_ac.v
1e-4
5e-5
1.5e-4 vout_mod.v
1e-4
5e-5
Figure 7.55: AC common-mode simulation results for (1) Boyle macromodel, (2) ac Boyle macromodel and (3) the modular macromodel
251
V3 U=1 V R1 R=100k
R2 R=10 UA741(Boyle)
VCC
vout
V1 U=15 V
+
R3 R=10 SUB1 R4 R=100k
VEE
V2 U=15 V
dc simulation
DC1
ac simulation
AC1 Type=log Start=1 Hz Stop=10 MHz Points=500
Figure 7.56: Test circuit for the simulation of PSRR(f) voltage transfer function characteristic is possible using the test circuit given in Fig. 7.56, where V++V + AP S (f ) VS , Vout (f ) = AD (f ) [V + V ] + ACM (f ) 2 where AD (f ) is the OP AMP dierential-mode gain, ACM (f ) is the OP AMP commonmode gain, and AP S (f ) is the OP AMP power supply injected gain. The superscript indicates that the ac signal source is connected to either the OP AMP positive or negative power supply terminals but not simultaneously to both. Assuming that the OP AMP power supply injected gain has a single dominant zero at fP SZ 1 , analysis yields 1 PSRR VOU T (f ) = VS 1+j
(0)
1+j
f
fP SZ 1
f GBP 1+j f
fP SZ 1
P SRR(0) AD (0) AD (0) and P SRR(0) = . , P SRR(0)+ = + f AP S (0) AP S (0) 1+j fP SZ 1 + Typical values for the UA741 are P SRR(0)+ = 110000, P SRR(0) = 170000, fP SZ 1 = 685Hz, fP SZ 1 = 6.2Hz . The considerable dierence in the dominant zero frequencies of the injected power supply gains is normally due to the fact that the OP AMP circuits are not symmetric when viewed from the power supply signal injection terminals. By adding
f fp 1
,=
R2 = 1e 4 R1 + R2
252
external components to an OP AMP macromodel power supply rejection eects can be easily simulated. The schematic shown in Fig. 7.57 shows the TI UA741 model with RC networks connected between the power supply terminals and earth. The voltage controlled voltage sources probe the voltages at the center nodes of the additional RC networks. These networks generate the power supply injected signals at dc. They also generate the dominant zero in the power supply rejection characteristic. The values for the passive components can be calculated using: RA = 106 106 1 1 , RB = , CA = , CA = + + P SRR(0) P SRR(0) 2 106 fP SZ 1 2 106 fP SZ 1
Which gives, for the example UA741 device data, RA = 9, CA = 232pF , RB = 5.9 and CB = 25.7pF . Simulation waveforms for the small signal frequency response of the test circuit are shown in Fig. 7.58. In the case of the modular UA741 model the simulation signal plot clearly demonstrates the fact that the model does not correctly represent the eects due to power supply injected signals.
253
Vout_mod
dc simulation
DC1
R1 R=100k
VS U=1 V
R2 R=10
UA741 (MOD)
VCC
V1 U=15 V
+
R3 R=10 R4 R=100k
V2 U=15 V VEE
ac simulation
AC1 Type=log Start=1 Hz Stop=10 kHz Points=400
SUB5
R11 R=100k
R9 R=10
+
SUB4 EP1 EN1 G=0.5 G=0.5
VEE
R10 R=10
R6 R=1M RB R=5.9
R12 R=100k Equation Eqn1 PSRR_P=dB(p1/(vout_TI.v*p2*alpha)) fpz1=685 alpha=1e-4 gbp=1e-6 p1=mag(1+j*acfrequency/fpz1) p2=mag(1+j*acfrequency/alpha*gbp)
CB C=25.7nF
Figure 7.57: Test circuit showing OP AMP with external power supply rejection modelling network
254
0.03
0.025 vout_TI.v
0.02
0.015
110 PSRR_P
105
3e-21
Vout_mod.v
2e-21
1e-21
Figure 7.58: Simulation waveforms for the circuit illustrated in Fig. 7.57
255
256
See The 555 Timer IC. An interview with Hans Camenzind - The designer of the most successful integrated circuit ever developed, http://semiconductormuseum.com/Transistors/LectureHall/ Camenzind/ 2 Now part of the Philips organisation. 3 Recent manufacturing volumes indicate that the 555 timer is as popular as ever, with for example, Samsung (Korea) producing over one billion devices in 2003; see Wikipedia entry at http://en. wikipedia.org/ 4 Typically between ground and a voltage close to power rail VCC.
257
and reduced circuit simulation times. The approach adopted is centred on established macromodelling techniques where signals at the timer device pins accurately model real device signals but internal macromodel signals often bare no relation to those found in an actual device. Internally, the macromodel simply processes input signal information and outputs signals, in the correct format, to the device output pins. In no way is an attempt made to simulate the actual 555 timer circuitry.
555
GND P_VCC1 TRIG OUT R1 R=5k RES VCC DIS TRESH CON
P_RESET1
+
P_THRESH1 THRESH
DIGITAL LOGIC
SUB6 File=timer_555.sch
P_CONTROL1 R2 R=5k
SUB3
Q QB
+
AMP
P_OUTPUT1
+
TRIG
SUB5 P_GND1
P_TRIGGER1 R3 R=5k
SUB4
Discharge Switch
SUB2
P_DISCHARGE1
SUB1
258
555 timer model, rather than describing the function of the device5 . The 555 timer is an 8 pin device with: Pin 1 Ground [GND] - Most negative supply connected to the device, normally this is common ground (0V). Pin 2 Trigger [TRIG] - Input pin to the lower comparator. Used to set the RS latch. Pin 3 Output [OUT] - The 555 timer output signal pin. Pin 4 Reset [RES] - Used to reset the RS latch. Pin 5 Control [CON] - Direct access point to the (2/3)VCC divider node. Used to set the reference voltage for the upper comparator. Pin 6 Threshold [THRESH] - Input pin to upper comparator. Used to reset the RS latch. Pin 7 Discharge [DIS] - Collector output of an npn BJT switch. Used to discharge the external timing capacitor. Pin 8 VCC [VCC] - Most positive supply connected to device, normally this is 5V, 10V or 15V.
A good tutorial guide to the operation of the 555 timer can be found at http://www.uoguelph.ca/ ~antoon/gadgets/555/555.html 6 At VCC = 5V this resistance is roughly 3.3M.
259
+
TRIG
I1 I=500 nA
SUB1 File=timer_trig.sch
I1 I=0.1 uA
POUT1 Num=3 PinP1 Num=1 R1 R=1k PinN1 Num=2 OP1 G=1e6 Umax=1 V C1 C=1 nF
+
THRESH
SUB1 File=timer_thresh.sch
The threshold DC current sets the upper limit to the value of the external resistor that can be connected between pin 6 and the VCC supply - for VCC = 5V this is approximately 16M, with VCC = 15 V this rises to roughly 20M.
260
Set (S) Reset (R) Q (P-Q1) QB (P-QB1) Notes 1 0 1 0 Set state 0 0 1 0 0 1 0 1 Reset state 0 0 0 1 1 1 0 0 Undened Table 8.1: Truth table for an SR latch constructed using NOR gates.
In mixed mode circuit simulation transient analysis problems can occur when devices change state in zero seconds, see later notes for comments on this topic.
261
P_Q1
1
P_reset1 Y2 R1 R=1k C1 C=0.5nF Y3
1
R2 R=1k C2 C=0.5nF Y4
1
R4 R=1k C5 C=0.05nF Y1
1
R5 R=1k
P_QB1
C3 C=1nF
P_tresh1
1
P_trig1 Y5 R3 R=1k C4 C=0.09nF
DIGITAL LOGIC
Q QB
SUB1 File=timer_digital_comb.sch
At this time Qucs does not allow parameters to be passed to subcircuits, making it dicult to write generalised macromodels. Adding parameter passing to subcircuits and the calculation of component values using equations is on the to-do list. Suggested values for the amplier gain are: (1) VCC = 5V, G = 3.5, (2) VCC = 10V, G = 8.5V and (3) VCC = 15V, G = 13.5. These gain values correct for the voltage drop in the 555 timer totem-pole output stage.
262
+
Pamp_P1 R1 R=7 P_vout1 AMP
SUB1 File=timer_amp.sch
10
Normally the external timing capacitor is discharged through a resistor in series with the collector to ground path. However, if this series resistor is very small, or indeed does not exist, it is theoretically possible for the discharge current to become very large, which in turn leads to DC convergence errors or very long transient simulation times.
263
P_control_in1
R1 R=10K
Discharge Switch
P_GND1
P_Discharge1
R2 R=200
SUB1 File=timer_Discharge.sch
See for example the Applications Information section of the National Semiconductor LM555 Timer data sheet, July 2006, www.national.com. 12 One of the simulation tests also presents results using the standard trapezoidal second order integration method.
264
555
VCC DIS TRESH
transient simulation
C1 C=0.01 uF TR1 Type=lin Start=0 Stop=0.6ms IntegrationMethod=Gear Order=6
vout OUT reset RES CON V4 U1=5 V U2=0V T1=0.1ms SUB1 T2=0.15ms C2 C=0.01uF
vdis
265
5 reset.Vt 0 0 5e-5 1e-4 1.5e-4 2e-4 2.5e-4 3e-4 time 3.5e-4 4e-4 4.5e-4 5e-4 5.5e-4 6e-4 5 vtrig.Vt 0 0 5 5e-5 1e-4 1.5e-4 2e-4 2.5e-4 3e-4 time 3.5e-4 4e-4 4.5e-4 5e-4 5.5e-4 6e-4 vdis.Vt 0 0 4
5e-5
1e-4
1.5e-4
2e-4
2.5e-4
3e-4 time
3.5e-4
4e-4
4.5e-4
5e-4
5.5e-4
6e-4
vout.Vt
0 0 5e-5 1e-4 1.5e-4 2e-4 2.5e-4 3e-4 time 3.5e-4 4e-4 4.5e-4 5e-4 5.5e-4 6e-4
Figure 8.8: Simulation waveforms for the basic monostable pulse generator.
266
555
VCC vdis TRIG DIS TRESH CON C2 C=0.01uF SUB1 File=timer_555.sch
R6 R=3k
transient simulation
TR1 Type=lin Start=0 Stop=0.3ms Points=1000 IntegrationMethod=Gear Order=6
C1 C=0.01 uF
13
The value of R6 needs to be trimmed to set the duty cycle to exactly 50 percent.
267
5 reset.Vt 0 0 4 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4 vtrig.Vt 2 0 0 5 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4 vout.Vt 0 0 5 vdis.Vt
2e-5
4e-5
6e-5
8e-5
1e-4
1.2e-4
1.4e-4
1.6e-4 time
1.8e-4
2e-4
2.2e-4
2.4e-4
2.6e-4
2.8e-4
3e-4
0 0 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4
Figure 8.10: Simulation waveforms for the basic astable pulse generator.
R5 R=3k
555
VCC vdis TRIG DIS TRESH CON C2 C=0.01uF SUB1 File=timer_555.sch
D1
R6 R=3.6k
transient simulation
TR1 Type=lin Start=0 Stop=0.3ms Points=4000 IntegrationMethod=Gear Order=6
C1 C=0.01 uF
Figure 8.11: 555 timer astable pulse generator with 50 percent duty cycle.
268
5 reset.Vt 0 0 5 vtrig.Vt 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4 0 0 5 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4 vout.Vt 0 0 5
2e-5
4e-5
6e-5
8e-5
1e-4
1.2e-4
1.8e-4
2e-4
2.2e-4
2.4e-4
2.6e-4
2.8e-4
3e-4
vdis.Vt 0 0 2e-5 4e-5 6e-5 8e-5 1e-4 1.2e-4 1.4e-4 1.6e-4 time 1.8e-4 2e-4 2.2e-4 2.4e-4 2.6e-4 2.8e-4 3e-4
Figure 8.12: Simulation waveforms for 50 percent duty cycle astable pulse generator.
269
R5 R=20k
V1 U=5 V
R6 D1 R=4.7k
555
GND VCC DIS TRESH vcon RES CON
transient simulation
TR1 Type=lin Start=0 Stop=20ms IntegrationMethod=Gear Order=6
vsig TRIG V7 U=5 V TH=0.75 ms TL=0.5 ms Tr=20 ns Tf=20 ns C1 C=0.01 uF C2 C=0.01uF vtrig reset V4 U1=5 V U2=0V T1=0.2ms T2=0.5ms Tr=10 ns Tf=10 ns vout OUT
vdis
SUB1 File=timer_555.sch
270
reset.Vt
0 0 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02
vcon.Vt
0 0 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02
5 vsig.Vt 0 0 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02 10 vtrig.Vt 0 0 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02 5 vdis.Vt 0 0 5 vout.Vt 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02 0 0 0.002 0.004 0.006 0.008 0.01 time 0.012 0.014 0.016 0.018 0.02
271
555
VCC vdis
transient simulation
TR1 Type=lin Start=0 Stop=10ms Points=30000 IntegrationMethod=Trapezoidal Order=2
C1 C=0.01 uF
SUB1 File=timer_555.sch
14
The transient simulation never nishes and can only be terminated by clicking the simulation abort button.
272
reset.Vt
0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
5 vtrig.Vt 0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 5 vdis.Vt 0 0 5 vout.Vt 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 vcon.Vt 5 4 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
Figure 8.16: Simulation waveforms for pulse position modulator obtained using trapezoidal integration.
273
pulse is set by external capacitors C1 to C415 . The specication of the monostable pulse generator subcircuit is given in Fig. 8.18. The sequential pulse generator is a complex circuit with: 60 R instances, 40 C instances, 4 VCVS instances, 1 Vdc instances, 8 Idc instances, 2 Vpulse instances, 8 OpAmp instances, 4 Diode instances, 4 BJT instances, 8 Inv instances, 8 NOR instances and 4 OR instances.
V1 U=5 V
RES
GND
C1 C=0.01uF
RES
RES
GND
GND
transient simulation
TR1 Type=lin Start=0 Stop=5 ms IntegrationMethod=Gear Order=6 MinStep=1e-15
GND
C4 C=0.1uF
SUB4
15
The pulse duration times set by C1 to C4, in Fig. 8.17, have simply been chosen for demonstration purposes and do not represent any particular control timing sequence.
274
P_VCC
R5 R=20k
R6 D1 R=4.7k
555
GND VCC DIS TRESH CON C3 C=0.01uF SUB1
P_GND P_OUT
P_RES
VCC
IN RES
OUT CAP
GND
SUB2 File=555_timer_mono.sch
275
The large number of components, and indeed the complexity of the circuit, tend to make the simulation time of the pulse train generator circuit much greater than typical times recorded when simulating single 555 timer circuits. Also, circuit DC convergence and transient analysis time step errors can be a problem, due to switching discontinuities, making careful selection of the non-linear diode parameters and the transient analysis conditions essential. In Fig. 8.18 a diode is used to clamp the 555 timer trigger input at ve volts when the signal attempts to rise above 5 volts. The default Qucs diode parameters are similar to those specied by SPICE16 . By default the diode emission constant is set to 1 and the diode series resistance to zero ohms. Neither of these values are particularly representative for silicon diodes. For silicon devices, rather than germanium diodes, n needs to be between roughly 1.5 and 2. Similarly, all diodes have some series resistance, often in the range 0.1 to 10 ohms depending on the power rating of the diode. To aid simulation these parameters have been set to n = 2 and Rs = 10. Figure. 8.19 illustrates a typical set of signal waveforms obtained from the simulation of the sequential pulse generator: the simulation conditions employed to generate these results are; Integration method = Gear, Order = 6, initialStep = 1 ns, MinStep = 1e-15, reltol = 0.001, abstol = 10A, vntol = 10V, Solver = CroutLU and initialDC = yes.
16
The default values were set in an early version of SPICE, probably version 1, and appear to have not been changed as the simulator was developed.
276
5 vres.Vt 0 0 5e-4 1e-3 0.0015 0.002 0.0025 time 0.003 0.0035 0.004 0.0045 0.005 5 vin.Vt 0 0 5 vout1.Vt 5e-4 1e-3 0.0015 0.002 0.0025 time 0.003 0.0035 0.004 0.0045 0.005 0 0 5 vout2.Vt 5e-4 1e-3 0.0015 0.002 0.0025 time 0.003 0.0035 0.004 0.0045 0.005 0 0 5 vout3.Vt 5e-4 1e-3 0.0015 0.002 0.0025 time 0.003 0.0035 0.004 0.0045 0.005 0 0 5e-4 1e-3 0.0015 0.002 0.0025 time 0.003 0.0035 0.004 0.0045 0.005 5 vout4.Vt 0 0
5e-4
1e-3
0.0015
0.002
0.0025 time
0.003
0.0035
0.004
0.0045
0.005
Figure 8.19: Simulation waveforms for the monostable pulse generator circuit.
277
555
VCC
transient simulation
TR1 Type=lin Start=0 Stop=10ms IntegrationMethod=Gear Order=6
SUB1 File=timer_555.sch
Figure 8.20: A monostable mode 555 timer circuit with a pulse train applied to the trigger input.
17
Often the resulting frequency is in the region 1 to 5 Hz and is used to ash an LED, or some other optical actuator, on/o. 18 555 timers are normally more ecient than ip-ops in this application because single devices can have divisors greater than two. 19 E. A Parr, IC 555 Projects, Bernard Babani (publishing) Ltd, 1981, p. 109.
278
5 reset.Vt 0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 5 vtrig1.Vt 0 0 4 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 vout1.Vt 2 0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
Figure 8.21: Simulation waveforms for the circuit given in Fig. 8.20: these show 555 retriggering.
279
R5 R=20k
V1 U=5 V GND vtrig1 TRIG V7 U=5 V TH=0.2 ms TL=0.1 ms Tr=20 ns Tf=20 ns vout1 OUT reset V4 U1=5 V U2=0V T1=0 T2=0.2ms Tr=10 ns Tf=10 ns RES
555
VCC DIS TRESH CON
transient simulation
TR1 Type=lin Start=0 Stop=10ms IntegrationMethod=Gear Order=6
C1 C=0.0525 uF
SUB1
R6 R=20k
555
GND TRIG vout2 OUT C2 C=0.26 uF RES TRESH CON VCC DIS
SUB2
280
5 reset.Vt 0 0 5 vtrig1.Vt 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 0 0 4 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 vout1.Vt 2 0 0 4 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01 vout2.Vt 2 0 0 1e-3 0.002 0.003 0.004 0.005 time 0.006 0.007 0.008 0.009 0.01
Figure 8.23: Simulation waveforms for the circuit given in Fig. 8.22.
281
The origins and background to the development of the SPICE simulator are described by Ronald A. Rohrer in Circuit Simulation - the early years, illuminating SPICEs strengths, uncovering weaknesses, and projecting its future, IEEE Circuits and Devices, 1992, pp 32-37. 2 The Qucs netlist grammar is dened in appendix A1, of the Qucs Technical Papers.
282
A title statement Circuit node names Circuit element values Voltage and current source descriptions Analysis command statements Output data statements Other command statements In SPICE 23 circuit node names (nets) are identied by integers numbered from 0 to 9999. SPICE 34 allows a mixture of letters and numbers for node names. All circuit nodes must have a DC path to ground. Ground node is always node 0 and is considered global. Circuit element values are expressed as integers or real numbers in scientic notation, for example 5, 0.5e1 5.0, or in engineering notation using suxes. The available SPICE suxes are f = 1e-15 (femto), p = 1e-12 (pico), n = 1e-9 (nano), u = 1e-6 (micro), mil = 25e-6, m = 1e-3 (milli), k = 1e3 (kilo), meg = 1e6 (mega), g = 1e9 (giga) and t = 1e12 (tera). Component unit abbreviations are allowed in circuit value descriptions. However, these must not be separated from their associated values by spaces. Commonly used unit abbreviations are V = Volt, A = Amps. Hz = Hertz, ohm = Ohm(), H = Henry, F = Farad and deg = Degree. SPICE input data les have the following format: 1. Title 2. * starts a comment line 3. Circuit description 4. Simulation directives 5. Data output directives 6. .end
3
A guide to SPICE 2 features and simulation data format is given in SPICE Version 2G Users Guide, A Vladimirescu, Kaihe Zhang, A.R. Newton, D. O. Pederson and A. Sangiovanni-Vincentelli, August 1981, Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, Ca., 94720, US. 4 See SPICE 3 Version 3F Users Manual, B. Johnson, T. Quarles,A.R. Newton, D. O. Pederson and A. Sangiovanni-Vincentelli, October 1992, Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, Ca., 94720, US.
283
A typical SPICE input data le for a discreet component circuit is shown in Fig. 9.1. In this netlist all nodes are shown numbered, following the SPICE 2 node naming convention. Also the power supply, AC input signal generator and output load are not included. Essentially, the netlist shown in Fig. 9.1 represents the amplier without any external components connected to it. Although Qucs cannot directly simulate SPICE netlists the software does contain a SPICE to Qucs netlist conversion program called QUCSCONV. This routine takes as input a SPICE netlist le and outputs an equivalent Qucs formatted netlist le. The Qucs netlist le can be read and simulated by the Qucs simulation engine. To make the process transparent, and indeed straightforward for users, the conversion stage in simulating SPICE netlist les5 has been automated via the Qucs GUI simulate command (F2 key). SPICE netlist les can be linked to a Qucs SPICE netlist schematic symbol.6 These in turn can be connected, on a schematic, to any other appropriate Qucs component symbol or user dened symbol. Figure 9.2 shows the resulting schematic for the two stage BJT circuit. In this diagram the external voltage sources and amplier load have been added together with the usual Qucs icons for DC and AC simulation of the circuit. During simulation Qucs treats the SPICE netlist component as a subcircuit7 and generates the appropriate Qucs netlist code. For example, the netlist shown in Fig. 9.3 illustrates the Qucs style netlist code for the two stage BJT amplier. Simulation of the two stage BJT amplier gives the output waveforms displayed in Fig. 9.4.
For convenience SPICE netlist les are often denoted with the extention cir and stored in a Qucs project under the other category. 6 The schematic symbol SPICE netlist can be found in the le components section of the components icon lists on the left hand side of the GUI. Its connection pin list may be setup and edited via the Edit SPICE component properties dialogue. 7 Hence the need to separate the external voltage sources and amplier load from the main amplier circuit.
284
A two s t a g e BJT a m p l i f i e r . I n p u t node 2 , outpu t node 9 Power s u p p l y Vcc c o n n e c t e d t o node 10 c1 2 3 10 u f r 1 3 10 200 k r 2 3 0 50 k r 5 10 4 12 k q1 4 3 5 qmod r6 5 0 3.6 k c2 4 6 10 u f c4 5 0 15 u f r 3 10 6 120 k r 4 6 0 30 k r 7 10 7 6 . 8 k q2 7 6 8 qmod r8 8 0 3.6 k c5 8 0 25 u f c3 7 9 10 u f . model qmod npn ( i s =2e 16 b f =50 br=1 rb=5 r c =1 r e =0 + c j e =0.4 p f v j e =0.8 me=0.4 c j c =0.5 p f v j c =0.8 c c s =1p f va =100) . end
Figure 9.1: SPICE netlist for a simple two stage BJT amplier.
dc simulation
vin V1 U=1m V
10
X1 File=stoq_nl1.cir
2 9
DC1
ac simulation
spice
vout
RL R=10k Ohm
V2 U=15 V
Ref
AC1 Type=log Start=10 Hz Stop=100 MHz Points=200 Equation Eqn1 Phase=phase(vout.v) gain=dB(vout.v/vin.v)
Figure 9.2: Qucs schematic for the two stage amplier represented by the SPICE netlist shown in Fig. 9.1.
285
. Def : s t o q n l 1 c i r n e t 2 n e t 9 n e t 1 0 ref C : C3 n e t 7 n e t 9 C=10uF C : C5 n e t 8 r e f C=25uF r e f R=3.6 k R: R8 n e t 8 BJT : Q2 n e t 6 n e t 7 n e t 8 r e f Type=npn I s =2e 16 Bf =50 Br =1 Rb=5 Rc=1 Re=0 Cje =0. 4pF Vje = 0 . 8 Mje = 0 . 4 Cjc =0. 5pF Vjc = 0 . 8 C j s =1pF Vaf =100 Nf =1 Nr=1 I k f =0 I k r =0 Var =0 I s e =0 Ne = 1 . 5 I s c =0 Nc=2 Rbm=0 I r b =0 Mjc = 0 . 3 3 Xcjc =1 Vjs = 0 . 7 5 Mjs =0 Fc = 0 . 5 Vtf =0 Tf =0 Xtf =0 I t f =0 Tr =0 R: R7 n e t 1 0 n e t 7 R=6.8 k R: R4 n e t 6 r e f R=30k R: R3 n e t 1 0 n e t 6 R=120k C : C4 n e t 5 r e f C=15uF C : C2 n e t 4 n e t 6 C=10uF R: R6 n e t 5 r e f R=3.6 k BJT : Q1 n e t 3 n e t 4 n e t 5 r e f Type=npn I s =2e 16 Bf =50 Br =1 Rb=5 Rc=1 Re=0 Cje =0. 4pF Vje = 0 . 8 Mje = 0 . 4 Cjc =0. 5pF Vjc = 0 . 8 C j s =1pF Vaf =100 Nf =1 Nr=1 I k f =0 I k r =0 Var =0 I s e =0 Ne = 1 . 5 I s c =0 Nc=2 Rbm=0 I r b =0 Mjc = 0 . 3 3 Xcjc =1 Vjs = 0 . 7 5 Mjs =0 Fc = 0 . 5 Vtf =0 Tf =0 Xtf =0 I t f =0 Tr =0 R: R5 n e t 1 0 n e t 4 R=12k R: R2 n e t 3 r e f R=50k R: R1 n e t 3 n e t 1 0 R=200k C : C1 n e t 2 n e t 3 C=10uF . Def : End
Figure 9.3: Qucs format netlist for the two stage BJT amplier: NOTE -In this listing the entries for Q1 and Q2 have been edited so that they t on the text page.
286
vout.v
60 Phase 40 10 100 1e3 1e4 1e5 acfrequency 1e6 1e7 1e8 gain
10
100
1e3
1e6
1e7
1e8
287
X1 File=stoq_nl1.cir
2 9
P_OUT1 VCC
P_IN1
10
spice
P_VCC1
Ref
SUB1
Figure 9.5: User dened symbol for the two stage BJT amplier.
288
ref . Def : s t o q n l 1 c i r n e t 2 n e t 9 n e t 1 0 C : C3 n e t 7 n e t 9 C=10uF C : C5 n e t 8 r e f C=25uF r e f R=3.6 k R: R8 n e t 8 BJT : Q2 n e t 6 n e t 7 n e t 8 r e f Type=npn I s =2e 16 Bf =50 Br =1 Rb=5 Rc=1 Re=0 Cje =0. 4pF Vje = 0 . 8 Mje = 0 . 4 Cjc =0. 5pF Vjc = 0 . 8 C j s =1pF Vaf =100 Nf =1 Nr=1 I k f =0 I k r =0 Var =0 I s e =0 Ne = 1 . 5 I s c =0 Nc=2 Rbm=0 I r b =0 Mjc = 0 . 3 3 Xcjc =1 Vjs = 0 . 7 5 Mjs =0 Fc = 0 . 5 Vtf =0 Tf =0 Xtf =0 I t f =0 Tr =0 R: R7 n e t 1 0 n e t 7 R=6.8 k R: R4 n e t 6 r e f R=30k R: R3 n e t 1 0 n e t 6 R=120k C : C4 n e t 5 r e f C=15uF C : C2 n e t 4 n e t 6 C=10uF R: R6 n e t 5 r e f R=3.6 k BJT : Q1 n e t 3 n e t 4 n e t 5 r e f Type=npn I s =2e 16 Bf =50 Br =1 Rb=5 Rc=1 Re=0 Cje =0. 4pF Vje = 0 . 8 Mje = 0 . 4 Cjc =0. 5pF Vjc = 0 . 8 C j s =1pF Vaf =100 Nf =1 Nr=1 I k f =0 I k r =0 Var =0 I s e =0 Ne = 1 . 5 I s c =0 Nc=2 Rbm=0 I r b =0 Mjc = 0 . 3 3 Xcjc =1 Vjs = 0 . 7 5 Mjs =0 Fc = 0 . 5 Vtf =0 Tf =0 Xtf =0 I t f =0 Tr =0 R: R5 n e t 1 0 n e t 4 R=12k R: R2 n e t 3 r e f R=50k R: R1 n e t 3 n e t 1 0 R=200k C : C1 n e t 2 n e t 3 C=10uF . Def : End
Figure 9.6: Qucs format netlist for the two stage BJT amplier represented by a user dened symbol: NOTE -In this listing the entries for Q1 and Q2 have been edited so that they t on the text page.
289
One signicant advantage that Qucs has when compared to netlist entry only circuit simulators is that it is possible the dene schematic symbols for subsystem blocks that comprise discreet components and one or more local subcircuits. These may then be employed like any other Qucs symbols when constructing circuit schematics.
290
Z0 = 320 Ohm. . s u b c k t l c n1 n2 l 1 n1 n2 10 uh c1 n2 0 10 p f . ends r s n9 n10 320ohm x1 n10 n11 l c x2 n11 n12 l c x3 n12 n13 l c x4 n13 n14 l c x5 n14 n15 l c x6 n15 n16 l c x7 n16 n17 l c x8 n17 n18 l c x9 n18 n19 l c x10 n19 n20 l c r l n20 0 320ohm . end
net0 net10 net1 net2 net3 net4 net5 net6 net7 net8 net9 net10 net1 net2 net3 net4 n e t 5 n e t 6 n e t 7 n e t 8 n e t 9 gnd Type=t e s t 3 p p c i r
netN9 netN11 netN12 netN15 netN16 netN17 R: RL netN20 r e f R=320Ohm Sub : X10 r e f netN19 netN20 Type=LC Sub : X9 r e f netN18 netN19 Type=LC Sub : X8 r e f netN17 netN18 Type=LC Sub : X7 r e f netN16 netN17 Type=LC Sub : X6 r e f netN15 netN16 Type=LC Sub : X5 r e f netN14 netN15 Type=LC Sub : X4 r e f netN13 netN14 Type=LC Sub : X3 r e f netN12 netN13 Type=LC Sub : X2 r e f netN11 netN12 Type=LC Sub : X1 r e f netN10 netN11 Type=LC R: RS netN9 netN10 R=320Ohm . Def : LC r e f netN1 netN2 L : L1 netN1 netN2 L=10uH C : C1 netN2 r e f C=10pF . Def : End . Def : End
. Def : t e s t 3 p p c i r
netN13 netN18
netN14 netN19
netN20
ref
Figure 9.8: Qucs netlist for a 10 section LC delay line: NOTE -In this listing the entries for the .Def statements have been edited so that they t on the text page.
291
1 vin.Vt 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7 0.2 v10.Vt 0 0
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
0.2 v20.Vt
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
v40.Vt
0 0.2
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
v50.Vt
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
v60.Vt
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
v70.Vt
1e-8
2e-8
3e-8
4e-8
5e-8
6e-8 time
7e-8
8e-8
9e-8
1e-7
1.1e-7
1.2e-7
0.2
v80.Vt
-0.2 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
0.1 v90.Vt
-0.1 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
0.05 v100.Vt 0 0 1e-8 2e-8 3e-8 4e-8 5e-8 6e-8 time 7e-8 8e-8 9e-8 1e-7 1.1e-7 1.2e-7
292
v10 vin V1 U1=0 V U2=1 V T1=0 T2=5 n 10nS 20nS 30nS 40nS 50nS 60nS 70nS v20 v30 v40 v50 v60 v70 v80 v90 v100
transient simulation
TR1 Type=lin Start=0 Stop=120 ns IntegrationMethod=Gear Order=6
SUB1
Figure 9.11: SPICE netlist for a two section CMOS ring counter.
293
# Qucs 0 . 0 . 1 1 / media / hda2 /OPAMP templates/ t e s t s t o q f i g 1 1 a . s c h . Def : s t o q f i g 1 1 a c i r n e t 1 n e t 4 ref . Def :NOR2 r e f n e t 1 n e t 2 n e t 3 Vpulse :VCC n e t 7 c n e t 0 U1=0 U2=5 T1=0 Tr=1 ns Tf=1 ns T2=1 MOSFET:M1 n e t 1 n e t 4 n e t 7 n e t 7 Type=p f e t W=40u L=5u Vt0=1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 MOSFET:M2 n e t 2 n e t 3 n e t 4 n e t 4 Type=p f e t W=40u L=5u Vt0=1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 ref r e f Type=n f e t W=20u L=5u Vt0 =1 MOSFET:M3 n e t 2 n e t 3 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 MOSFET:M4 n e t 1 n e t 3 ref r e f Type=n f e t W=20u L=5u Vt0 =1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 r e f C=10p C : C1 n e t 1 r e f C=10p C : C2 n e t 2 Vdc :VCC c n e t 0 r e f U=0 . Def : End . Def :NAND2 r e f n e t 1 n e t 2 n e t 3 Vpulse :VCC n e t 4 c n e t 1 U1=0 U2=5 T1=0 Tr=1 ns Tf=1 ns T2=1 MOSFET:M1 n e t 1 n e t 3 n e t 4 n e t 4 Type=p f e t W=40u L=5u Vt0=1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 MOSFET:M2 n e t 2 n e t 3 n e t 4 n e t 4 Type=p f e t W=40u L=5u Vt0=1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 MOSFET:M3 n e t 1 n e t 5 ref r e f Type=n f e t W=20u L=5u Vt0 =1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 MOSFET:M4 n e t 2 n e t 3 n e t 5 n e t 5 Type=n f e t W=20u L=5u Vt0 =1 Kp=10u Cgdo =0 .2 n Cgso = 0.2 n Cgbo=2n I s =1e 14 N=1 Lambda=0 Gamma=0 Phi = 0 . 6 r e f C=10p C : C1 n e t 1 C : C2 n e t 2 r e f C=10p Vdc :VCC c n e t 1 r e f U=0 . Def : End Sub : X8 r e f n e t 4 n e t 9 n e t 5 Type=NOR2 Sub : X7 r e f n e t 5 n e t 8 n e t 4 Type=NOR2 Sub : X6 r e f n e t 1 n e t 8 n e t 9 Type=NOR2 Sub : X5 r e f n e t 1 n e t 2 n e t 8 Type=NOR2 Sub : X4 r e f n e t 2 n e t 7 n e t 3 Type= NAND2 Sub : X3 r e f n e t 3 n e t 6 n e t 2 Type= NAND2 Sub : X2 r e f n e t 1 n e t 6 n e t 7 Type= NAND2 Sub : X1 r e f n e t 1 n e t 5 n e t 6 Type= NAND2 . Def : End Sub : X1 v i n vout gnd Type=s t o q f i g 1 1 a c i r V r e c t : V1 v i n gnd U=5 V TH=1 us TL=1 us Tr=1 ns Tf=1 ns Td=0 ns .TR: TR1 Type=l i n S t a r t =0 Stop =30u P o i n t s =1000 I n t e g r a t i o n M e t h o d =T r a p e z o i d a l Order =2 I n i t i a l S t e p = 0 . 0 1 ns MinStep =1e 18 MaxIter =150 r e l t o l = 0 . 0 1 a b s t o l =1 uA v n t o l =100 uV Temp= 2 6 . 8 5 L T E r e l t o l =1e 3 LTEabstol =1e 4 LTEfactor =1 S o l v e r =CroutLU relaxTSR=no i n i t i a l D C =y e s MaxStep =0
Figure 9.12: Qucs netlist for a two section CMOS ring counter: NOTE -In this listing the entries for MOSFETs and transient analysis have been edited so that they t on the text page.
294
4 vin.Vt 2 0 0 2e-6 4e-6 6e-6 8e-6 1e-5 1.2e-5 1.4e-5 1.6e-5 time 1.8e-5 2e-5 2.2e-5 2.4e-5 2.6e-5 2.8e-5 3e-5 6 4 vout.Vt 2 0 0 2e-6 4e-6 6e-6 8e-6 1e-5 1.2e-5 1.4e-5 1.6e-5 time 1.8e-5 2e-5 2.2e-5 2.4e-5 2.6e-5 2.8e-5 3e-5
295
296
based on the use of a preprocessor, similar to that found in the C language, which takes as input a parameter and equation style netlist and outputs a standard SPICE netlist with the parameters and equations evaluated to give a numerical result. The advantage of this approach is that the preprocessor can be used with any SPICE simulator or indeed with Qucs. Two such preprocessors are SPICEPRM and SPICEPP.17 The ow diagram for the Qucs simulation sequence including a SPICE preprocessing stage is shown in Fig. 9.14. This diagram clearly shows how both standard SPICE and parameterised netlists can be linked into the Qucs simulation cycle. Of the two SPICE preprocessors introduced above SPICEPP is probably the most useful from a Qucs users point of view18 as it adds more features to the overall simulation process. Hence the notes that follow will concentrate on describing how SPICEPP can be used with Qucs.
17
(1) Andrew J. Borsa, SPICEPRM, A SPICE preprocessor for parameterised subcircuits, V 0.11, 1996, <andy@moose.mv.com> (SPICEPRM can be downloaded from the Sourceforge.net ngspice project.) and (2) John Shaehen, SPICEPP, A SPICE proprocessor for SPICE 3F5, V 1.5, 2000, <john@reptechnic.com.au>. (SPICEPP can be downloaded from the Sourceforge.net tclspice project.) 18 SPICEPP was written after SPICEPRM and extends the facilities oered by SPICEPRM. 19 SPICEPP is written in PERL. The SPICEPP.pl script should be copied to a directory on your search path. On my system I keep it in the Qucs bin directory. PERL must also be installed on your system. 20 The character can be found on the most left key on the row of numerical keys ( 1 2 3 4 5 6 7 8 9 0 .......) - this is the case on my keyboard.
297
Qucs GUI
CIRCUIT entered using Qucs schematic capture
Generate Qucs netlist code from GUI schematic, including conversion of SPICE code to Qucs netlist format
SIMULATE
Run
QUCSATOR
Figure 9.14: Flow diagram of Qucs simulator stages including SPICE preprocessing.
298
21
Details of the model derivation can be found in the Qucs Modelling Operational Ampliers tutorial, Qucs Web site. 22 The SPICEPP PERL script can be run from a shell using the command spicepp.pl name.pp > name.cir , where name is the name of the le to be processed.
299
Device pins 1 . input in n , in p 2 . ou tput out ua741 OP AMP p a r a m e t e r s . param v o f f = 0 . 7m . param i b = 80n . param i o f f = 20n . param rd = 2meg . param cd = 1 . 4 p . param cmrrdc = 3 1 6 2 2 . 8 . param fcmz = 2 0 0 . 0 . param a o l d c = 199526 . param gbp = 1meg . param f p 2 = 3meg . param r o = 7 5 . 0 input stage v o f f 1 in n 6 v o f f /2 v o f f 2 7 in p v o f f /2 ib1 0 6 ib ib2 7 0 ib i o f f 1 7 6 i o f f /2 r1 6 8 rd / 2 r2 7 8 rd / 2 c i n 1 6 7 cd commonmode z e r o s t a g e ecm1 12 0 8 0 1 e6 / cmrrdc rcm1 12 13 1meg ccm1 12 13 1 / ( 2 3 . 1 4 1 2 1 e6 fcmz ) rcm2 13 0 1 d i f f e r e n t i a l and commonmode s i g n a l summing s t a g e gmsum1 0 14 7 6 1 gmsum2 0 14 13 0 1 rsum1 14 0 1 voltage gain stage 1 gmp1 0 9 14 0 1 rado 9 0 a o l d c cp1 9 0 1 / ( 2 3 . 1 4 1 2 gbp ) voltage gain stage 2 gmp2 0 11 9 0 1 rp2 11 0 1 cp2 11 0 1 / ( 2 3 . 1 4 1 2 f p 2 ) out put s t a g e e o s 1 10 0 11 0 1 r o s 1 10 out r o
Figure 9.15: SPICE template preprocessor netlist for a UA741 AC modular OP AMP model.
300
. Def : s t o q f i g 1 7 n e t 0 n e t 1 n e t 2 Sub : X1 n e t 0 n e t 1 n e t 2 gnd Type=s t o q f i g 1 5 c i r . Def : End ref . Def : s t o q f i g 1 5 c i r netIN N netOUT n e t I N P R: ROS1 n e t 1 0 netOUT R=75 VCVS: EOS1 n e t 1 1 n e t 1 0 ref r e f G=1 C : CP2 n e t 1 1 r e f C= 5 . 3 0 5 8 3 e 08 r e f R=1 R: RP2 n e t 1 1 VCCS:GMP2 n e t 9 r e f net11 r e f G=1 C : CP1 n e t 9 r e f C= 1 . 5 9 1 7 5 e 07 r e f R=199526 R:RADO n e t 9 r e f net9 r e f G=1 VCCS:GMP1 n e t 1 4 R:RSUM1 n e t 1 4 r e f R=1 VCCS:GMSUM2 n e t 1 3 r e f net14 r e f G=1 VCCS:GMSUM1 n e t 7 r e f n e t 1 4 n e t 6 G=1 r e f R=1 R:RCM2 n e t 1 3 C :CCM1 n e t 1 2 n e t 1 3 C= 7 . 9 5 8 7 4 e 10 R:RCM1 n e t 1 2 n e t 1 3 R=1M VCVS:ECM1 n e t 8 n e t 1 2 ref r e f G= 3 1 . 6 2 2 8 C : CIN1 n e t 6 n e t 7 C=1.4 e 12 R: R2 n e t 7 n e t 8 R=1 e +06 R: R1 n e t 6 n e t 8 R=1 e +06 I d c : IOFF1 n e t 7 n e t 6 I =1e 08 r e f I =8e 08 I d c : IB2 n e t 7 I d c : IB1 r e f n e t 6 I =8e 08 Vdc : VOFF2 n e t 7 n e t I N P U= 0 . 0 0 0 3 5 Vdc : VOFF1 netIN N n e t 6 U= 0 . 0 0 0 3 5 . Def : End
X1 File=stoq_fig15.cir
IN_N OUT
P_IN_N
IN_P
spice
P_OUT
+
SUB1
P_IN_P
Ref
301
dc simulation
DC1
ac simulation
AC1 Type=lin Start=10 Hz Stop=101 Hz Points=200
R1 R=100k
+
SUB1 R2 R=100
vout
R4 R=20k
R6 R=15k
R3 R=22k C2 C=0.45u
R5 R=6.8k
C1 C=2.2u
15
vout.v
10
phase_deg
10 acfrequency
100
Figure 9.19: Small signal transfer characteristics for a twin-T notch lter circuit.
302
1 R3 C 1 f0 = B 2 R3 R1 R2
When designing a lter for a specic specication, for example say f0 = 1kHz , B = 200Hz and H0 = 10, values for the lter resistor and capacitor values need to be calculated. This can, of course, be done manually. However, this process is often tedious, especially if a number of lters need to be designed each with dierent specications. Circuit simulators are by their very nature primarily designed to analyse and simulate the performance of circuits whos component values are known. As such they are tools for analysis rather than design. In practice, of course, engineers employ circuit simulators to check their circuit designs. Qucs is attempting to bridge the gap between design and analysis by using addon software components for designing circuits with well understood structures and design procedures23 . In the previous section it was shown that the SPICEPP preprocessor could be used to calculate model component values. By a simple extension of this concept it is also possible to embed design equations into a netlist. Shown in Fig. 9.21 is a SPICEPP netlist for the Dalyiannis-Friend lter. The UA741 OP AMP is modelled with a SPICE subcircuit called opamp_ac and has its own set of parameters24 . The rst set of design parameters represent the lter specication and are used in the SPICEPP conversion process to calculate the lter resistor and capacitor component values. Note also the use of inline comments for documenting the netlist code. Figures. 9.22 and 9.23 show a basic lter test circuit and the resulting simulation transfer functions. Hence, not only can the SPICEPP preprocessor be used for setting up device models but it can also aid the design of entire circuit blocks provided design equations are available for a given circuit conguration. By combining SPICEPP with Qucs a very signicant design/analysis tool becomes available opening up new possibilities for Qucs users.
23
The Qucs Tools drop-down menu lists the currently available design functions that have been implemented with release of Qucs you are using. 24 These are dened within a subcircuit and should have names unique to the subcircuit model being dened.
303
C2
R3 OP1 Vout
Vin
R1 R2
C1
304
D e l y i a n n i s F r i e n d Bandpass f i l t e r d e s i g n Design parameters . param f c = 2000.0 $ F i l t e r c e n t e r f r e q u e n c y ( Hz ) . param bw = 2 0 0 . 0 $ F i l t e r bandwidth ( Hz ) . param q = 10.0 $ F i l t e r q f a c t o r = f 0 /bw . param r 3 i v = 200 k $ Assumed v a l u e f o r r f 3 . param h0 = 10.0 $ F i l t e r f 0 g a i n magnitude F i l t e r c i r c u i t p i n s : i n p u t n1 , outpu t n3 r 3 n3 n4 r 3 i v c1 n2 n3 q / ( 3 . 1 4 1 2 f c r 3 i v ) c2 n2 n4 q / ( 3 . 1 4 1 2 f c r 3 i v ) r 1 n1 n2 r 3 i v / ( 2 h0 ) r 2 n2 0 r 3 i v / ( ( 4 q q ) (2 h0 ) ) x1 0 n4 n3 opamp ac s u b c i r c u i t p o r t s : i n+ in out . s u b c k t opamp ac i n p i n n out ua741 OP AMP p a r a m e t e r s . param v o f f = 0 . 7m . param i b = 80n . param i o f f = 20n . param rd = 2meg . param cd = 1 . 4 p . param cmrrdc = 3 1 6 2 2 . 8 . param fcmz = 2 0 0 . 0 . param a o l d c = 199526 . param gbp = 1meg . param f p 2 = 3meg . param r o = 7 5 . 0 input stage v o f f 1 in n 6 v o f f /2 v o f f 2 7 in p v o f f /2 ib1 0 6 ib ib2 7 0 ib i o f f 1 7 6 i o f f /2 r1 6 8 rd / 2 r2 7 8 rd / 2 c i n 1 6 7 cd commonmode z e r o s t a g e ecm1 12 0 8 0 1 e6 / cmrrdc rcm1 12 13 1meg ccm1 12 13 1 / ( 2 3 . 1 4 1 2 1 e6 fcmz ) rcm2 13 0 1 d i f f e r e n t i a l and commonmode s i g n a l summing s t a g e gmsum1 0 14 7 6 1 gmsum2 0 14 13 0 1 rsum1 14 0 1 voltage gain stage 1 gmp1 0 9 14 0 1 rado 9 0 a o l d c cp1 9 0 1 / ( 2 3 . 1 4 1 2 gbp ) voltage gain stage 2 gmp2 0 11 9 0 1 rp2 11 0 1 cp2 11 0 1 / ( 2 3 . 1 4 1 2 f p 2 ) out put s t a g e e o s 1 10 0 11 0 1 r o s 1 10 out r o . ends
X1 File=df_filter.cir vin
vout
ac simulation
AC1 Type=lin Start=1000Hz Stop=3000Hz Points=200 Equation Eqn1 phase_deg=phase(vout.v) gain_dB=dB(vout.v) V1 U=1 V
N1 spice Ref
N3
10
10
vout.v
0 1e3
200
-200 1e3
20
gain_dB
10
1e3
1.5e3
2e3 acfrequency
2.5e3
3e3
Figure 9.23: Simulated small signal AC transfer functions for the Dalyiannis-Friend bandpass lter.
306
25
The DC voltage supply for each logic block is generated by a pulse source. This has the eect of simulating the rising edge of the power supply switch on transient and aids DC convergence.
307
Two s t a g e CMOS r i n g c o u n t e r c i r c u i t . E x t e r n a l nodes : i n p u t 1 , outpu t 4 , +ve s u p p l y nvcc g l o b a l node . g l o b a l nvcc x1 1 5 6 nand2 x2 1 6 7 nand2 x3 3 6 2 nand2 x4 2 7 3 nand2 x5 1 2 8 nor2 x6 1 8 9 nor2 x7 5 8 4 nor2 x8 4 9 5 nor2 . model modp pmos ( v t o=1 kp=10u + cgdo =0.2n c g s o =0.2n cgbo=2n ) . model modn nmos ( v t o=1 kp=10u + cgdo =0.2n c g s o =0.2n cgbo=2n ) . s u b c k t nand2 1 2 3 m1 3 1 nvcc nvcc modp w=40u l =5u m2 3 2 nvcc nvcc modp w=40u l =5u m3 5 1 0 0 modn w=20u l =5u m4 3 2 5 5 modn w=20u l =5u c1 1 0 10p c2 2 0 10p v c c 4 0 p u l s e ( 0 5 0 1 ns 1 ns 1 2 ) . ends . s u b c k t nor2 1 2 3 m1 4 1 nvcc nvcc modp w=40u l =5u m2 3 2 4 4 modp w=40u l =5u m3 3 2 0 0 modn w=20u l =5u m4 3 1 0 0 modn w=20u l =5u c1 1 0 10p c2 2 0 10p v c c 7 0 p u l s e ( 0 5 0 1 ns 1 ns 1 2 ) . ends
Figure 9.24: SPICEPP netlist for a two section CMOS ring counter with global power supply net node nvcc.
308
Two s t a g e CMOS r i n g c o u n t e r c i r c u i t . x1 1 5 6 nvcc nand2 x2 1 6 7 nvcc nand2 x3 3 6 2 nvcc nand2 x4 2 7 3 nvcc nand2 x5 1 2 8 nvcc nor2 x6 1 8 9 nvcc nor2 x7 5 8 4 nvcc nor2 x8 4 9 5 nvcc nor2 . model modp pmos v t o=1 kp=10u cgdo =0.2n c g s o =0.2n cgbo=2n . model modn nmos v t o=1 kp=10u cgdo =0.2n c g s o =0.2n cgbo=2n . s u b c k t nand2 1 2 3 nvcc m1 3 1 nvcc nvcc modp w=40u l =5u m2 3 2 nvcc nvcc modp w=40u l =5u m3 5 1 0 0 modn w=20u l =5u m4 3 2 5 5 modn w=20u l =5u c1 1 0 10p c2 2 0 10p . ends . s u b c k t nor2 1 2 3 nvcc m1 4 1 nvcc nvcc modp w=40u l =5u m2 3 2 4 4 modp w=40u l =5u m3 3 2 0 0 modn w=20u l =5u m4 3 1 0 0 modn w=20u l =5u c1 1 0 10p c2 2 0 10p . ends
Figure 9.25: SPICE netlist for a two section CMOS ring counter with global power supply net node nvcc.
Michael Magraf has recently added a four terminal transmission line to Qucs. Future testing will conrm if this is similar to the SPICE T component.
309
then be able to simulate circuits containing nonlinear voltage and current sources like the SPICE 3 B component. These notes are very much a report on some of the work on Qucs device modelling I have been doing in recent months. Again if there is enough interest in this area of Qucs development I will upgrade them in the future. My thanks to Stefan Jahn for all his encouragement while I have been developing the material reported in this tutorial note.
310
Biasing-technique analysis for BJTs generally progresses in complexity from the xed-bias
311
method (see g 10.1, to the shunt circuit, to the stabilized circuit, . Studies do not usually cover the shunt-divider and universal circuit. However, questions still arise about the bias stability of the shunt bias circuit. It is usable in some noncritical applications, but how inferior is it to the stabilized circuit? Designers are generally taught that the stabilized circuit is the one to use for repeatable biasing. One way to analyze the stability of the various biasing methods is to use stability factors, which characterize the change in collector current due to changes in the transistors HFE (current gain), ICBO (collector-to-base leakage current), and VBE . Although these factors are useful, comparing bias circuits and bias-resistor values requires tedious calculations. A visual presentation that compares the stability of the various circuits is more useful. Looking at the equation for IC in Figure 1b, note that much of the change in IC is due to the diering voltages developed across R1 because of the range of HFE. This dierence leads to a question: If some of the current through R1 is xed, would the result be less voltage change across R1 and hence, less change in IC? This thinking leads to the shunt-divider circuit (Figure 1c). Because VBE changes little, R2 supplies a relatively xed component of the current through R1, making R1 a smaller value than it would be without R2. The equation for the shunt divider shows that a smaller value of R1 in the denominator causes less change in IC due to changes in HFE. However, along with RC and R2, R1 shows up in the numerator as a multiplying factor for VBE. You can next look at how strongly each of these factors inuences IC. Because you can derive all the circuits in Figure 1 from the universal circuit (Figure 1e) by making the appropriate resistors either innite (open circuits) or zero (short circuits), the same universality is possible for the equations. Considering the circuit equations and a range of parameters and bias-resistor values, you can produce graphs in which the Y axis represents the change in IC. To make valid comparisons of the circuits, you need a common parameter related to the biasing for the X axis. The ratio of the collector current to the bias current in R1 works. This ratio is common to the circuits and reects how sti the biasing is. To show realistic conditions, the data also includes temperature eects on VBE and HFE for a temperature range of 25 to 75 C and a 3-to-1 spread in HFE. For comparison purposes, all the circuits use a 10V supply for VCC at a nominal collector current of 1 mA, with HFE of 100 and VBE of 0.60V at 25 C. Calculating resistors for 5V VCE and selecting RE to develop 1V at the emitter produces the results for the graphical technique. The model for temperature eects of the device is VBE=0.60?0.002?(T(actual) 25 C), representing the standard 2-mV/ C coecient for diodes. Calculations from the data sheet of the 2N2222A transistor produce an average temperature coecient for HFE of about 0.58% / C, which you can represent by HF ET emp = HF EM ax [1 + (T (actual)?25 C )0.0058] (10.1)
Calculating IC for a minimum HF E = 50 at 25 C and for the maximum HF E = 150 at 75 C yields an HF ET emp of 194 and VBE of 0.50V.
312
This analysis ignores the eects of ICBO. For the nominal collector current of 1 mA and a maximum temperature of 75 C, the contribution of ICBO to IC is a few percent, at most, for the xed-bias and shunt-bias circuits in Figures 1a and 1b and less for the bias circuits of Figures 1c, 1d, and 1e.
Figure 10.2: You can compare the performance of the BJT bias circuit by graphing the change in collector current vs the ratio of the collector current to the current in R1. The horizontal axis is the ratio of the collector current, IC, to the current in resistor R1. This bias ratio applies to all the circuits and indicates how much current is in the basebiasing network compared with the collector current. Thus, a ratio of 1 indicates a sti bias circuit, with as much current in R1 of the bias network as in the collector, whereas a ratio of 50 indicates that the collector current is 50 times the current in R1 of the bias network. Because some of the results are unexpected, they give renewed consideration to some of the bias circuits previously ignored. The universal-bias method is obviously the best of the group. The price you pay for its dc stability is the reduction in ac input resistance due to the negative feedback on R1, a sort of Miller eect on resistors. R1 reduces by a factor of the voltage gain plus 1. This feedback may improve distortion and bandwidth as well as reduce the output impedance
313
Figure 10.3: To eliminate the ac eects of feedback, split R1, and bypass the center to ground.
at the collector. If you dont want these ac eects of feedback, you can eliminate them by splitting R1 into two parts and bypassing the center to ground (Figure 10.3). You can improve performance of this circuit at any bias ratio by increasing the voltage drop across RE, increasing the voltage drop across the collector resistor, or both. The stabilized circuit has good stability to bias ratios as high as about 12. Above this ratio, its stability rapidly decreases. The stabilized circuit relies on the voltage changes fed back by the emitter current through RE, compared with the voltage, VB, at the base. When the bias ratio becomes less sti, changes in base current owing through R1 due to changes in HFE cause signicant variations in VB. These variations result in changes in IE and IC. As with the universal circuit, you can improve performance of the stabilized circuit at any bias ratio by increasing the voltage drop across RE. Keep in mind that these results are for a nominal HFE range of 50 to 150 plus temperature eects. Lower minimum values of HFE require stier bias ratios for the same performance. The superior performance of the shunt-divider circuit at bias ratios greater than 12, compared with that of the stabilized circuit, is a surprise. When the shunt-divider circuits bias is sti, VC is strongly inuenced by the ratio of R1 to R2 times VBE. As VBE changes because of temperature, VC and, thus, IC, change approximately as the ratio of R1 to R2 times VBE changes. Because IC plays the major role in determining VC, IC experiences wide variations for these sti biasing ratios. As the ratio becomes less sti, the changes in VBE with temperature, multiplied by the voltage-divider action, become less dominant, and performance improves until, at the ratio of about 12, the shunt dividers stability starts to surpass that of the stabilized circuit. You can account for this performance by the negative feedback from the collector resistor through R1. Because the collector resistor is usually much larger than
314
the emitter resistor of the stabilized circuit, the stability of the universal circuit holds up better for less sti bias ratios. Because the shunt-divider circuit is more stable than the shunt circuit, consider the divider circuit for applications that need less stability than the stabilized or universal circuits oer. Because it saves the cost of the emitter-bypass capacitor necessary in the universal and stabilized circuits, the shunt divider can be more cost-eective. Negative feedback through R1 in the shunt-divider circuit reduces the input resistance and may improve distortion and bandwidth, as well as reduce the output impedance in the same manner as in the universal circuit. Again, you can negate these eects with a bypass capacitor in the center of R1. This bypass capacitor is typically much smaller than the emitter-bypass capacitor for the stabilized circuit. Because the bias current for the shunt-bias circuit consists of only the base current, it has only one ratio of IC to IR1, namely HFE, and is plotted as a single point. As the bias ratio for the universal and shunt-divider circuits increases, the value of R2 increases until it becomes innite at an HFE of 100. Under these conditions, the circuits bias ratios converge with the shunt-circuit ratio. Figure 10.2 leads you to several general conclusions. The universal circuit has the best stability over the widest range of bias ratios. The stabilized circuit has good stability for sti bias ratios, but you should take care if biasing ratios exceed 12. And, nally, the shunt-divider circuit is a signicant improvement over the shunt circuit and is better than the stabilized circuit for large bias ratios.
This point is obviously not understood in the same way when discussing with marketing or development or research teams, who knows why ?
315
316
317
Q1 4 5 6 6 NPN .MODEL NPN NPN + IS = 4.717E-17 + BF = 145 + NF = 0.9934 + VAF = 31.12 + IKF = 0.304 + ISE = 3.002E-13 + NE = 3 + BR = 11.37 + NR = 0.985 + VAR = 1.874 + IKR = 0.121 + ISC = 4.848E-16 + NC = 1.546 + RB = 14.41 + IRB = 0 + RBM = 6.175 + RE = 0.1779 + RC = 1.780 + CJE = 3.109E-13 + VJE = 0.9 + MJE = 0.3456 + CJC = 1.377E-13 + VJC = 0.5569 + MJC = 0.2079 + CJS = 6.675E-13 + VJS = 0.4183 + MJS = 0.2391 + XCJC = 0.5 + TR = 0.0 + TF = 4.122E-12 + XTF = 68.2 + VTF = 2.004 + ITF = 1.525 + PTF = 0 + FC = 0.5501 + EG = 1.11 + XTI = 3 + XTB = 1.5 .ENDS
Since the model used in SPICE and in QUCS rely on a gummel-poon modelisation, and since the level of modelisation is the same, some quite direct conversion could be used to create the library for QUCS. To use directly this le, you will need to store the le in an other directory from the project one ( a small bug taken into account ). Then it should work but some there are still some issues on the parameters itselves, This is the reason why we will proceed in an other way. The data sheet could be found on the philips web site.
318
319
320
and add the description and the markup language boundaries. The syntaxe is explained in the help at the topic description of the qucs le formats. Then the device is visible in the Component Library Tool as mentionned in gure 11.3.
By doing this you haved the possibility to reuse the device as much as you want, and you can debug devices in a more easy way. Warning : in this section we have only describe the die of the device, for the parasitic from the package, we will be obliged to describe this circuit, but later on.
321
322
323
324
325
Figure 11.7: die connection if the fth generation transistor from philips
326
327
The components used to verify the model could be strange ( inductor of 1H and capacitor of 1F ) It is normal since we need to have a very wide band response on the circuit, and since we want to caracterize only the active device, and compare with the datasheet. An other way is to use DC bloc or DC feed or bias Tee to provide the power supply to the component. This is the right way to do it. you should then create a display to visualize the S parameters : generally s11 and s22 are in the smith and s12 and s21 are in polar We have now to compare these results with the measured parameters from philips : ! Filename: 225bfg425.001 ! BFG425W Field C1 ! V1=8.667E-001V,V2=2.000E+000V, I1=3.585E-004A, I2=2.496E-002A ! S11 S21 S12 S22 !Freq(GHz) Mag Ang Mag Ang Mag Ang Mag Ang # GHz S MA R 50 0.040 0.325 -8.696 38.472 173.381 0.002 71.865 0.923 -3.072 0.100 0.331 -23.004 37.457 164.549 0.005 83.280 0.915 -9.551
2
We will another method when we will use the device in a real project
328
329
0.200 0.315 -44.455 0.300 0.296 -63.008 0.400 0.278 -79.654 0.500 0.265 -94.339 0.600 0.254 -106.508 0.700 0.246 -116.820 0.800 0.240 -126.472 0.900 0.235 -134.500 1.000 0.232 -141.743 1.100 0.230 -148.265 1.200 0.230 -154.216 1.300 0.230 -159.761 1.400 0.231 -164.776 1.500 0.233 -169.782 1.600 0.234 -174.382 1.700 0.236 -178.496 1.800 0.238 177.334 1.900 0.241 173.487 2.000 0.244 169.856 2.200 0.251 162.836 2.400 0.259 156.208 2.600 0.268 150.081 2.800 0.277 144.221 3.000 0.288 138.650 3.500 0.319 125.843 4.000 0.352 113.999 4.500 0.389 103.406 5.000 0.431 92.903 5.500 0.463 82.559 6.000 0.506 73.164 6.500 0.516 66.705 7.000 0.551 59.664 7.500 0.610 50.773 8.000 0.644 43.502 8.500 0.683 35.816 9.000 0.709 27.972 9.500 0.736 20.858 10.000 0.764 14.187 10.500 0.785 7.330 11.000 0.802 0.219 11.500 0.815 -6.751 12.000 0.822 -13.843 ! DEEMBEDDED NOISE DATA
34.771 150.487 31.364 138.811 27.951 128.829 24.856 120.248 22.159 113.362 19.885 107.530 17.964 102.255 16.345 97.645 14.958 93.487 13.770 89.661 12.748 86.091 11.850 82.773 11.070 79.671 10.383 76.687 9.766 73.821 9.213 71.086 8.725 68.404 8.277 65.836 7.874 63.295 7.172 58.413 6.578 53.682 6.068 49.042 5.628 44.575 5.244 40.174 4.470 29.452 3.873 18.944 3.406 8.713 3.011 -1.792 2.658 -11.364 2.374 -21.684 2.179 -28.681 2.011 -37.894 1.808 -49.313 1.653 -58.585 1.496 -68.478 1.338 -77.310 1.212 -85.841 1.105 -95.600 0.997 -104.961 0.884 -113.744 0.791 -122.965 0.690 -131.882
0.008 75.947 0.012 71.608 0.015 68.186 0.017 65.974 0.020 64.514 0.022 63.362 0.024 62.701 0.027 61.910 0.029 61.280 0.031 60.570 0.033 59.878 0.036 59.238 0.038 58.509 0.040 57.719 0.043 56.846 0.045 56.001 0.047 54.999 0.050 53.983 0.052 52.923 0.057 50.729 0.062 48.414 0.067 45.958 0.072 43.380 0.077 40.713 0.090 33.634 0.102 26.177 0.113 18.415 0.123 9.782 0.131 2.534 0.138 -6.413 0.152 -10.089 0.164 -17.920 0.166 -29.630 0.172 -37.580 0.175 -46.984 0.173 -55.176 0.172 -63.448 0.173 -72.751 0.171 -81.774 0.164 -91.275 0.158 -100.952 0.149 -111.108
0.863 -18.965 0.794 -26.449 0.725 -32.076 0.664 -36.332 0.613 -39.533 0.569 -42.071 0.533 -44.121 0.504 -45.968 0.479 -47.614 0.457 -49.172 0.438 -50.696 0.421 -52.103 0.406 -53.483 0.392 -54.842 0.380 -56.285 0.369 -57.740 0.358 -59.199 0.348 -60.790 0.338 -62.399 0.319 -65.657 0.301 -68.988 0.283 -72.558 0.266 -76.167 0.248 -80.054 0.204 -90.648 0.158 -103.541 0.113 -121.590 0.071 -156.899 0.054 148.652 0.095 100.575 0.112 92.309 0.164 82.321 0.246 65.957 0.300 56.971 0.361 47.167 0.412 37.289 0.449 29.117 0.505 22.602 0.554 14.956 0.593 6.422 0.631 -0.521 0.667 -8.548
330
!FREQUENCY ! (GHz)
FMIN (dB)
Rn (NORMALIZED)
Using these parameter, we shoul compare on the sample display the modelised results and the measurements results, or directly show the error using equations. First we compare the results.
In the display that is used for the S parameters that we have simulated from our modelisation, you can add the results from the meaurements les by adding a measurement of Si,j using the right dataset with the combo box. You should obtain the dierence between the two. By doing this, you should obtain the results presented in the gure 11.12. IMPORTANT NOTE : The dierences, you should obtain are still on investigation for now.
331
Figure 11.12: Results from model and from meaures compared together
332
15 5 2.45
8 12 2.55
333
Cost issue is very important, therefore only one active component is allowed, and the BOM 1 should be reduced as much as possible. This design should work on a FR4 PCB used in a production line. The parameters of such substrate is quite uncontrolled but can be caracterized, as long as you keep the same supplier ( avoid strange suppliers who can change the FR4 composition without notice ). As mentionned previously you can describe a substrate inside the library with the following lines : <SUBST FR4_ 1 0 0 -30 24 0 0 "4.7" 1 "0.7 mm" 1 "35 um" 1 "2e-4" 1 "0.022e-6" 1 "0.15e-6" 1 > The height of the substrate is 0.7mm but this describe only one RF layer of the full implementation of the circuit which is a four layour board. The two inner layer are power and ground, the top and bottom layer are RF layers.
Bill Of Material
334
335
Vcc = 2.5V Vbe = 0.412V Ic = 15mA the results are : R1 = 1K R2 = 600 Re = 33 Using these values on the schematics, we can now see the stability of the design. Adding the fact that the voltage regulator used in this case has an ondulation of 5 mV in the working domain. You need to simulate the DC schematics by modifying the BF parameter of the transistor from 50 to 120 ( since this feature is not enabled in the current version of Qucs 0.0.7 ).
Table 12.2: Variation of Ic in mA, due to the Vcc and Vcc vs 2.45 2.50 2.55 50 12.21 12.62 13.03 80 13.34 13.78 14.23 120 14.07 14.54 15.01
From this table we can extract some stability factor : Icc | =80 = 8.9A/mV V Icc |V =2.5 = 30A cc Icc | =seenote,Vcc =2.5 = . . . A/C T (12.7)
(12.8)
(12.9)
Note : For the temperature dependance, we need to take the minimum for the minimum temperature, and the maximum for the maximum temperature.
336
337
approching the problem During the denition stage of a product, the choice of enclosure is sometimes dictated by a competitor, the customer, or marketing. Frequently the choice is as small as possible, thus unwittingly passing judgment on a particular choice, it is possible to make a thermal analysis of the proposed enclosure. If the environment created for the component is unsuitable, then additional cooling mechanisms must be developped. One approch is to simplify the problem to one dimensionnal analysis. Heat energy sources azre assumed to be evenly distributed throughout the volume. The enclosure surface is assumed to be isothermal. The enclosure is assuemd to made of a perfect thermal conductor. ( unfortunately, enclosures are more and more being made of plastic, a thermal insulator, which complicates this sample approch). The external environment is considered to be the walls of a large room of surface emissivity , , of 1.0 at the same temperature, T , as the surrounding air, and is capable of absorbing an innite amount of heat energy. Heat transfert by conduction, radiation, free convection, venting, and forced convection are basically representated by the equation : Qt = Qk + Qr + Qc + Qv + Qf (12.10)
The most elusive component, thermal resistance x , can vary from simple to very complex. Fortunately, most electronic enclosures do not have more than three cooling paths and in many cases, the third path is minor one that can be neglected for ease of calculation. The following are some generally accepted guidelines that can be used to quickly evaluate a design or conguration. These were obtained from notes provided by [?]. Maximum power density : for small painted uniformly heated sealed enclosure naturally cooled < 4mW/cm3 taller than 60cm < 2mW/cm3 for naturally cooled printed circuit boards < 16mW/cm2 for forced air cooled printed circuit board < 110mW/cm2 for small ( 60cm or less ) induced draft cooled enclosure < 20mW/cm3 forced air velocities : for PCB cages > 4m/sec for enclosures < 7.6m/sec
338
Note the possiblity to place the results of the simulation directly on the schematics, and some comments on the schematics such as document name, revision, and so on.
339
340
341
120 1.4
90 1.6
note : for the DC supply voltage, we will have to nd the correct ripple that is acceptable on this design in order to be able to specify the voltage regulator and its PSRR regarding the other voltage in the design. To proceed, due to the fact that some functionnalities are still missing on QUCS2 we will use some workaround for the DC study.
1 2
be careful when I usually use the term low power , I mean extremlly low power , below the mA generally normal it is still in development . . .
342
I do not have any stock option with philips, but they provide quite easily some prototypes and the models of their transistors, further more their strategy is to continue to provide small wideband RF transistor, so why not ?
343
reasons why, we need specicaly a non linear model to describe the transistor. Of course a preliminary calculus could be done using these regular parameters, but since we need also some other features such as distortion and so on, a non linear model is mandatory. In order to conduct these test, we need to create a model of our component. To perform this you should create or edit the le that contain all the libraries, this le is stored under /usr/local/share/qucs/library/philips_RF_widebande_npn.lib You can edit this le with vi. You need to add the following line : <Qucs Library 0.0.7 "philips RF wideBand"> ... ... ... <Component BFG403W> <Description> RF wideband NPN 25GHz 2V, 3mA, 20dB , 2000MHz Manufacturer: Philips Inc. NPN complement: BFG403W -------------------------based on spice parameter from philips -------------------------sept 2005 thierry </Description> <Model> <_BJT T_BFG403W_ 1 480 280 8 -26 0 0 "npn" bla bla bla bla> </Model> </Component> ... ... ...
13.0.4 DC study 13.0.5 SP study 13.0.6 Non linearities study 13.0.7 Possible improvement tips
344
14 Microstrip Design
14.1 10dB Directional Coupler Design
The below pictures shows two parallel conductor strips on a dielectric substrate with a backplane metalization. Both the conductor strips have the width W , the height t and the length l. There is a nite gap S between the conductors. The substrates height is denoted by h. With the gap between the conductor strips small enough a capacitive as well as inductive coupling occurs.
2 3
t W
l h 1 S 4
Figure 14.1: microstrip directional coupler Such a microstrip structure is called microstrip coupled lines. Also dened in gure 14.1 the port numbers 1. . . 4.
345
In a three conductor system as the microstrip coupled lines are there are two types of modes: even and odd. Thus such a system is described by odd and even characteristic impedances (ZL,o and ZL,e ) and odd and even eective dielectric constants (r,ef f,o and r,ef f,e ). The characteristic equations for an ideal backward coupler are r,ef f,e = r,ef f,o ZL,e = ZL,o and those for an ideal forward coupler are r,ef f,e = r,ef f,o ZL,e = ZL,o
The S-parameters of the ideal directional forward coupler are as follows. S21 S31 S41 = S44 = 1 C2 =C =0 =0
For both ideal forward and backward couplers the reection coecients are zero. Port 1 is called the injection port. Port 2 is the transmission port. In a backward coupler port 4 is the coupled port and port 3 is called the isolated port. In a forward coupler its the other way around. Please note: The given S-parameters for forward and backward couplers are valid for all side termination of each port with the reference impedance ZL usually 50.
346
the length l of such a coupler is dened by a quarter wavelength. Both the characteristic impedances can be computed by the reference impedance ZL , i.e. 50, and the coupling coecient C .
347
Just select Tools Line Calculation in the menubar or press Ctrl+3 to start the transmission line calculator. Then choose Coupled Microstrip in the Transmission Line Type selection box. Something likely shown in gure 14.2 should appear.
Type in the calculated 69.4 in the Z0e eld, 36.0 in the Z0o eld and 90 in the Ang l eld of the Electrical Parameters panel. The Ang l eld denotes the desired electrical length of the line (remember: 90 /2). Choose the Deg unit. Our selected design frequency is 2GHz. Thus type in this value in the Freq eld of the Component Parameters panel. Then press the Synthesize button or press F4. The program calculates the physical parameters W, S and L in the Physical Parameters panel. Please note: Depending on the substrate (shown in the Substrate Parameters panel) the calculated values may vary.
348
Finally we got W = 520m S = 199m L = 14.93mm All done with designing... Feel any better?
349
Figure 14.3: coupled microstrip lines in a Qucs schematic Now press the equation button (shown in gure 14.4) in Qucss toolbar.
350
Figure 14.4: equation button Place the equation into the schematic and enter the following equations. Press Add in the equation dialog (see gure 14.5) to add new equations. Finally press the OK button.
Figure 14.5: equation dialog Also edit the properties of the MSTC1 component reducing the number of digits. This will ensure that your technology is able to use these values when (if) they decide to produce your design. Now edit the S-parameter simulation properties. You can do that either by double clicking the component and use the component dialog. Or you can directly click on the values in the schematic and ll in 0.2 GHz for Start, 4.2 GHz for Stop and 101 for Points. Finally save your schematic by pressing Ctrl+S. Check whether all looks like as shown in gure 14.6.
351
P3 Num=3 Z=50 Ohm SubstTC1 er=9.8 h=0.635 mm t=17.5 um tand=0.0001 rho=2.43902e-08 D=1.5e-07
S parameter simulation
SPTC1 Type=lin Start=0.2 GHz Stop=4.2 GHz Points=101 Equation Eqn1 reflect=dB(S[1,1]) isolated=dB(S[3,1]) through=dB(S[2,1]) coupled=dB(S[4,1])
Figure 14.6: nal microstrip coupler schematic Now select Simulation Simulate from the menubar or just press F2 to simulate the schematic. When the simulation windows disappears then choose a Cartesian diagram from the left hand selection view and place the diagram into the (yet empty) data display area. Double click the through, reect, isolated and coupled data items in order to add it to the diagram within the diagram dialog as shown in gure 14.7.
352
Figure 14.7: diagram dialog Press OK to nish the diagram dialog. Afterwards you will see the following diagram.
353
354
frequency: 2e+09 coupled: -10.3223 10 0 through reflect isolated coupled -10 -20 -30 -40 -50 0 1e9 2e9 3e9 frequency / Hz 4e9 frequency: 2e+09 reflect: -32.0135
Figure 14.9: directional coupler simulation result diagram The marker on the coupled curve shows a coupling factor of -10.32 at a frequency of 2GHz (double click marker to change precision of the marker data). This is a bit way o for which we tried to design it for. Seems like coupling between the lines is a bit too weak. So we reduce the gap between the strip conductors S by 16.5m to be 0.1825 mm and simulate again.
355
frequency: 2e+09 coupled: -10.0062 10 0 through reflect isolated coupled -10 -20 -30 -40 -50 0 1e9 2e9 3e9 frequency / Hz 4e9 frequency: 2e+09 reflect: -31.6542
Figure 14.10: optimized directional coupler simulation result diagram Finally a perfect2 10dB coupling as shown in gure 14.10.
356
357
You can now place the equation symbol by mouse click anywhere in the schematic. Each mouse click creates a new equation instance each consisting of a variable number of measurement expressions. Press the Esc key if you do not like further equations. Another option is to select an existing equation, copy it (either by menu item Edit Copy or by Ctrl + C 1 ) and paste it (either by menu item Edit Paste or by Ctrl + V ). After having successfully created an equation instance, you are now able to modify it.
1
Ctrl + C
means that you have to press the Ctrl key and the C
key simultaneously.
358
Figure 15.2: Newly created equation You can now manipulate the current name of the equation instance. Simply click onto Eqn1, which becomes highlighted. Then type in a new name for it and nalise your inputs with the Enter key. After that, you can enter a new equation. Again, click onto y=1. Only the 1 is marked, and you can enter a new expression there. Please use the variables, operators and constants described in chapter Syntax of Measurement Expressions. Note that you can also refer to results (dependents) of other equations. But how to change the name of the current dependent y? Right click onto the equation, and a context menu opens. Select the rst item called Edit properties. A sub window appears, which should look like the one in g. 15.3. The alternative for entering equations is to double click onto the equation. You can now change the name of the dependent, the equation itself (which is 1 in the example shown) and the name of the equation. If you do not want the result to be exported into the data display tab, but temporarily need it for further calculations, select no in the Export value cell.
359
Figure 15.3: Editing equation properties Variable Names User dened variable names consist of a letter, followed by any number of letters, digits, or underscores. The syntax of variable names created by the Qucs simulator is as specied in table 15.1. Please note that all voltages and currents inQucsare peak values except the noise voltages and currents which are rms values at 1Hz bandwidth.
Numbers Numbers are written in conventional decimal way, with an optional decimal point between the digits. For powers of ten, the familiar scientic notation with an e is used. In this way, 1.234e6 is an example for the real oating point number 1234000. Imaginary numbers can be entered by a multiplication factor i or j (see also table 15.2). An example would be 1+2*i or - if you want to leave out the multiplication sign - 1+i2.
Built-in constants The constants which can be used within measurement expressions are given in table 15.2.
360
Variable Name nodename.V name.I nodename.v name.i nodename.vn name.in nodename.Vt name.It name.OP S[x,y] Rn Sopt Fmin F nodename.Vb
Description DC voltage at node nodename DC current through circuit component name AC voltage at node nodename AC current through circuit component name AC noise voltage at node nodename AC noise current through circuit component name Transient voltage at node nodename Transient current through circuit component name name = component name, OP = operating point (device dependent), e.g. D1.Id S-parameter, e.g. S[1,1] equivalent noise resistance optimal reection coecient for minimum noise minimum noise gure noise gure Harmonic balance voltage at node nodename Table 15.1: Syntax of simulator generated variable names Constant e i,j kB pi Description Eulers constant Imaginary unit 1 Boltzmanns constant Value 2.718282 i1 1.380658e23 J/K 3.141593
Table 15.2: Built-in Constants Operators Operator Precedence Expressions are evaluated in the standard way, meaning from left to right, unless there are parentheses. The priority of operators is also handled familiarly, thus for example multiplication has precedence to addition. Table 15.3 species a sorted list of all operators, the topmost having highest priority. Operators on the same line have the same precedence.
Ranges The general nomenclature of ranges is displayed in table 15.4. It shows onedimensional ranges, whereas also n-dimensional ranges are possible, if you consider nested sweeps.
361
Operator () * / % + :
Name Parentheses, function call Exponentiation Multiplication Division Modulo Addition Subtraction Range operator
Table 15.3: Operator priorities Syntax m:n :n m: : Explanation Range from index m to index n Range up to index n Range starting from index m No range limitations
Post Processing of Simulation Data by Expressions After a simulation has run the results are stored in datasets. Usually, such a dataset is a vector or a matrix, but may also be a real or complex scalar. For transient analysis, this dataset contains voltage or current information over time, for Harmonic Balance it contains amplitudes at dedicated frequencies, while for S-parameter analysis a vector of matrices (thus matrices in dependency of frequency) is returned. In further generalisation the components of vectors and matrices consist of complex numbers. Additionally, datasets can be generated by using expressions. As an example the linspace() function shall be named, which creates a vector of linearly spaced elements.
362
Functions Reference Format In the subsequent two chapters, each function is described using the following structure: <Function Name> Outlines briey the functionality of the function. Syntax Denes the general syntax of this function. Arguments Name, type, denition range and whether the argument is optional, are tabulated here. In case of an optional parameter the default value is specied. Type is a list dening the arguments allowed and may contain the following symbols: Symbol R C Rn Cn Rmn Cmn Rmnp Cmnp Description Real number Complex number Vector consisting of n real elements Vector consisting of n complex elements Real matrix consisting of m rows and n columns Complex matrix consisting of m rows and n columns Vector of p real m n matrices Vector of p complex m n matrices
Denition range species the allowed range. Each range is introduced by a bracket, either [ or ] , meaning that the following start value of the range is either included or excluded.
363
The start value is separated from the end value by a comma. Then the end value follows, nished by a bracket again, either [ or ]. The rst bracket mentioned means excluding the end value, the second means including. If a range is given for a complex number, this species the real or imaginary value of that number. If a range is given for a real or complex vector or matrix, this species the real or imaginary value of each element of that vector or matrix. The symbols mean includes listed value and excludes listed value. Description Gives a more detailed description on what the function does and what it returns. In case some background knowledge is presented. Examples Shows an application of the function by one or several simple examples. See also Shows links to related functions. A mouse click onto the desired link leads to an immediate jump to that function.
Math Functions Vectors and Matrices: Creation eye() linspace() logspace() ... ... ... Creates n x n identity matrix Creates a real vector with linearly spaced components Creates a real vector with logarithmically spaced components
364
Vectors and Matrices: Basic Matrix Functions adjoint() array() det() inverse() transpose() ... ... ... ... ... Adjoint matrix Read out single elements Determinant of a matrix Matrix inverse Matrix transpose
Elementary Mathematical Functions: Basic Real and Complex Functions abs() angle() arg() conj() deg2rad() imag() mag() norm() phase() polar() rad2deg() real() signum() sign() sqr() sqrt() unwrap() ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... Absolute value Phase angle in radians of a complex number. Synonym for arg Phase angle in radians of a complex number Conjugate of a complex number Converts phase from degrees into radians Imaginary value of a complex number Magnitude of a complex number Square of the absolute value of a vector Phase angle in degrees of a complex number Transform from polar coordinates into complex number Converts phase from degrees into radians Real value of a complex number Signum function Sign function Square of a number Square root Unwraps a phase vector in radians
Elementary Mathematical Functions: Exponential and Logarithmic Functions exp() log10() log2() ln() ... ... ... ... Exponential function Decimal logarithm Binary logarithm Natural logarithm (base e )
365
Elementary Mathematical Functions: Trigonometry cos() cosec() cot() sec() sin() tan() ... ... ... ... ... ... Cosine function Cosecant Cotangent function Secant Sine function Tangent function
Elementary Mathematical Functions: Inverse Trigonometric Functions arccos() arccot() arcsin() arctan() ... ... ... ... Arc Arc Arc Arc cosine (also known as inverse cosine) cotangent sine (also known as inverse sine) tangent (also known as inverse tangent)
Elementary Mathematical Functions: Hyperbolic Functions cosh() cosech() coth() sech() sinh() tanh() ... ... ... ... ... ... Hyperbolic Hyperbolic Hyperbolic Hyperbolic Hyperbolic Hyperbolic cosine cosecant cotangent secant sine tangent
Elementary Mathematical Functions: Inverse Hyperbolic Functions arcosh() arcoth() arsinh() artanh() ... ... ... ... Hyperbolic Hyperbolic Hyperbolic Hyperbolic area area area area cosine cotangent sine tangent
Elementary Mathematical Functions: Rounding ceil() x() oor() round() ... ... ... ... Round to the next higher integer Truncate decimal places from real number Round to the next lower integer Round to nearest integer
366
Elementary Mathematical Functions: Special Mathematical Functions besseli0() besselj() bessely() erf() erfc() ernv() erfcinv() sinc() step() ... ... ... ... ... ... ... ... ... Modied Bessel function of order zero Bessel function of n-th order Bessel function of second kind and n-th order Error function Complementary error function Inverse error function Inverse complementary error function Sinc function Step function
Data Analysis: Basic Statistics avg() cumavg() max() min() rms() runavg() stddev() variance() ... ... ... ... ... ... ... ... Average of vector elements Cumulative average of vector elements Maximum value Minimum value Root Mean Square of vector elements Running average of vector elements Standard deviation of vector elements Variance of vector elements
Data Analysis: Basic Operation cumprod() cumsum() interpolate() prod() sum() xvalue() yvalue() ... ... ... ... ... ... ... Cumulative product of vector elements Cumulative sum of vector elements Equidistant spline interpolation of data vector Product of vector elements Sum of vector elements Returns x-value which is associated with the y-value nearest to a specied y-value in a given vector Returns y-value of a given vector which is located nearest to the specied x-value
Data Analysis: Dierentiation and Integration di() integrate() ... ... Dierentiate vector with respect to another vector Integrate vector
367
Data Analysis: Signal Processing dft() t() idft() it() Time2Freq() Freq2Time() kbd() ... ... ... ... ... ... ... Discrete Fourier Transform Fast Fourier Transform Inverse Discrete Fourier Transform Inverse Fast Fourier Transform Interpreted Discrete Fourier Transform Interpreted Inverse Discrete Fourier Transform Kaiser-Bessel derived window
Electronics Functions Unit Conversion dB() dbm() dbm2w() w2dbm() ... ... ... ... dB value Convert voltage to power in dBm Convert power in dBm to power in Watts Convert power in Watts to power in dBm
Reection Coecients and VSWR rtoswr() rtoy() rtoz() ytor() ztor() ... ... ... ... ... Converts Converts Converts Converts Converts reection coecient to voltage standing wave ratio (VSWR) reection coecient to admittance reection coecient to impedance admittance to reection coecient impedance to reection coecient
N-Port Matrix Conversions stos() stoy() stoz() twoport() ytos() ytoz() ztos() ztoy() ... ... ... ... ... ... ... ... Converts reference Converts Converts Converts Converts Converts Converts Converts S-parameter matrix to S-parameter matrix with dierent impedance(s) S-parameter matrix to Y-parameter matrix S-parameter matrix to Z-parameter matrix a two-port matrix from one representation into another Y-parameter matrix to S-parameter matrix Y-parameter matrix to Z-parameter matrix Z-parameter matrix to S-parameter matrix Z-parameter matrix to Y-parameter matrix
368
Ampliers GaCircle() GpCircle() Mu() Mu2() NoiseCircle() PlotVs() Rollet() StabCircleL() StabCircleS() ... ... ... ... ... ... ... ... ... Circle(s) with constant available power gain Ga in the source plane Circle(s) with constant operating power gain Gp in the load plane Mu stability factor of a two-port S-parameter matrix Mu stability factor of a two-port S-parameter matrix Generates circle(s) with constant Noise Figure(s) Returns a data item based upon vector or matrix vector with dependency on a given vector Rollet stability factor of a two-port S-parameter matrix Stability circle in the load plane Stability circle in the source plane
eye()
Creates n x n identity matrix. Syntax y=eye(n) Arguments Name n Type N Def. Range [1, +[ Required
369
1 0 . . .
0 0 .. . 0 0 0 0 1 0 0 0 0 1
0 1
0 0 . . .
370
linspace()
Creates a real vector with linearly spaced components. Syntax y=linspace(xs,xe,n) Arguments Name xs xe n Type R R N Def. Range ], +[ ], +[ [2, +[ Required
Description This function creates a real vector with n linearly spaced components. The rst component is xs, the last one is xe. Example y=linspace(1,2,3) returns 1, 1.5, 2. See also logspace()
371
logspace()
Creates a real vector with logarithmically spaced components. Syntax y=logspace(xs,xe,n) Arguments Name xs xe n Type R R N Def. Range ], +[ ], +[ [2, +[ Required
Description This function creates a real vector with n logarithmically spaced components. The rst component is xs, the last one is xe. Example y=logspace(1,2,3) returns 1, 1.41, 2. See also linspace()
372
adjoint()
Adjoint matrix. Syntax Y=adjoint(X) Arguments Name X Type , Rmnp , Cmnp Def. Range ], +[ Required
mn
,C
mn
Description This function calculates the adjoint matrix Y of a matrix X : Y = X H = (X )T , where X is the complex conjugate matrix of X and X T is the transposed of the matrix X . Example X=eye(2)*(3+i) returns Y=adjoint(X) returns See also transpose(), conj() 3+j1 0 0 . Then, 3+j1
3-j1 0
0 . 3-j1
373
array()
Read out single elements. Syntax The array() function is an implicit command. Thus normally the respective rst expression (preferred) is used. Syntax 1 2 3 4 5 6 Preferred y=VM[i,j] y=M[i,j] y=VM[k] y=v[i] y=v[i,r] y=v[i,j] y=s[i] Alternative y=array(VM,i,j) y=array(M,i,j) y=array(VM,k) y=array(v,i) y=array(v,i,r) y=array(v,i,j) y=array(s,i) Preferred Alternative
Arguments
Name VM M v r, r1, r2 i j k s
Required (Syntax 1 and 3) (Syntax 2) (Syntax 4 and 5) (Syntax 4 and 5) (Syntax 1, 2, 4, 5, 6) (Syntax 1, 2, 5) (Syntax 3) (Syntax 6)
Description
This function reads out real or complex vectors of matrices, matrices and vectors or strings. Please refer to the following table for the return values:
374
Argument 2 iN iN kN
Argument 3 jN jN
Result Vector (xij 1 , , xijK ) Number xij Matrix x11k x1nk . . .. . . . . . xm1k xmnk Number vi Vector (vxs , , vxe ) Vector (vxs , , vxe ) Vector (vxs , , vxe ) Vector (vxs , , vxe ) Vector (vxs , , vxe ) Character si
Again, v denotes a vector, M a matrix, VM a vector of matrices, s a vector of characters and xs, xs1, xs2, xe, xe1, xe2 are range limiters. Example v=linspace(1,2,4) returns 1, 1.33, 1.67, 2. Then, y=v[3] See also returns 2.
375
det()
Determinant of a matrix. Syntax y=det(X) Arguments Name X Type , Rmnp , Cmnp Def. Range ], +[ Required
nn
,C
nn
Description This function calculates the determinant of a quadratical n x n matrix X. The result is either a real or a complex number. Example X=eye(2)*3 returns y=det(X) returns 9. See also eye() 3 0 0 . Then, 3
376
inverse()
Matrix inverse. Syntax Y=inverse(X) Arguments Name X Type , Rmnp , Cmnp Def. Range ], +[ Required
nn
,C
nn
Description This function inverts a quadratical n x n matrix X. The generated inverted matrix Y fullls the equation X Y = X X 1 = 1, where denotes matrix multiplication and 1 the identity matrix. The matrix X must be regular, that means that its determinant = 0. Example X=eye(2)*3 returns 3 0 0 . Then, 3 0.333 0 0 . 0.333
377
transpose()
Matrix transpose. Syntax Y=transpose(X) Arguments Name X Type , Rmnp , Cmnp Def. Range ], +[ Required
mn
,C
mn
Description This function transposes a m x n matrix X, which is equivalent to exchanging rows and columns according to Y = X T = (xij )T = (xji ) with 1 i m, 1 j n The generated matrix Y is a n x m matrix. Example X=eye(2)*3 returns 3 0 0 . Then, 3 3 0 0 . 3
378
abs()
Absolute value. Syntax y=abs(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function calculates the absolute value of a real or complex number, vector or matrix. For x R: y = For C x f or x 0 x f or x < 0 a2 + b 2
x := a + i b a, b R: y =
For x being a vector or a matrix the two equations above are applied to the components of x. Examples y=abs(-3) returns 3, y=abs(-3+4*i) returns 5. See also mag(), norm(), real(), imag(), conj(), phase(), arg()
379
angle()
Phase angle in radians of a complex number. Synonym for arg . Syntax y=angle(x) See also abs(), mag(), norm(), real(), imag(), conj(), phase(), arg()
380
arg()
Phase angle in radians of a complex number. Syntax y=arg(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function returns the phase angle in degrees of a real or complex number, vector or matrix. For x R: y = For C 0 f or x 0 f or x < 0
Denition range a > 0, b > 0 a < 0, b > 0 a < 0, b < 0 a > 0, b < 0 a = 0, b > 0 a > 0, b > 0 a = 0, b = 0
In this case the arctan() function returns values in radians. The result y of the phase function is in the range [, + ]. For x being a vector or a matrix the two equations above are applied to the components of x. Examples y=arg(-3) returns 3.14, y=arg(-3+4*i) returns 2.21.
381
382
conj()
Conjugate of a complex number. Syntax y=conj(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function returns the conjugate of a real or complex number, vector or matrix. For x R: y = x For C x := a + i b a, b R: y = a i b
For x being a vector or a matrix the two equations above are applied to the components of x. Example y=conj(-3+4*i) returns -3-4*i. See also abs(), mag(), norm(), real(), imag(), phase(), arg()
383
deg2rad()
Converts phase from degrees into radians. Syntax y=deg2rad(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function converts a real phase, a complex phase or a phase vector given in degrees into radians. For x R: y = For x C : y = x 180 Re {x} 180
For x being a vector the two equations above are applied to the components of x. Example y=deg2rad(45) returns 0.785. See also rad2deg(), phase(), arg()
384
imag()
Imaginary value of a complex number. Syntax y=imag(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function returns the imaginary value of a real or complex number, vector or matrix. For x R: y = 0 For C x := a + i b a, b R: y = b
For x being a vector or a matrix the two equations above are applied to the components of x. Example y=imag(-3+4*i) returns 4. See also abs(), mag(), norm(), real(), conj(), phase(), arg()
385
mag()
Magnitude of a complex number. Syntax y=mag(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function calculates the magnitude (absolute value) of a real or complex number, vector or matrix. For x R: y = For C x f or x 0 x f or x < 0 a2 + b 2
x := a + i b a, b R: y =
For x being a vector or a matrix the two equations above are applied to the components of x. Examples y=mag(-3) returns 3, y=mag(-3+4*i) returns 5. See also abs(), norm(), real(), imag(), conj(), phase(), arg()
386
norm()
Square of the absolute value of a vector. Syntax y=norm(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the square of the absolute value of a real or complex number, vector or matrix. For x R: y = x2 For C x := a + i b a, b R: y = a2 + b2
For x being a vector or a matrix the two equations above are applied to the components of x. Example y=norm(-3+4*i) returns 25. See also abs(), mag(), real(), imag(), conj(), phase(), arg()
387
phase()
Phase angle in degrees of a complex number. Syntax y=phase(x) Arguments Name x Type ,Cmn , Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function returns the phase angle in degrees of a real or complex number, vector or matrix. For x R: y = For C 0 f or x 0 180 f or x < 0
Denition range a > 0, b > 0 a < 0, b > 0 a < 0, b < 0 a > 0, b < 0 a = 0, b > 0 a > 0, b > 0 a = 0, b = 0
In this case the arctan() function returns values in degrees. The result y of the phase function is in the range [180, +180]. For x being a vector or a matrix the two equations above are applied to the components of x. Examples y=phase(-3) returns 180, y=phase(-3+4*i) returns 127.
388
389
polar()
Transform from polar coordinates into complex number. Syntax c=polar(a,p) Arguments Name a p Type Rn , Cn Rn , Cn Def. Range ], +[ ], +[ Required
Description This function transforms a point given in polar coordinates (amplitude a and phase p in degrees) in the complex plane into the corresponding complex number: x + i y = a eip = a cos p + i a sin p For a or p being vectors the equation above is applied to the components of a or p. Example c=polar(3,45) returns 2.12+j2.12. See also abs(), mag(), norm(), real(), imag(), conj(), phase(), arg(), exp(), cos(), sin()
390
rad2deg()
Converts phase from degrees into radians. Syntax y=rad2deg(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function converts a real phase, a complex phase or a phase vector given in radians into degrees. For x R: y = For x C : y = 180 x 180 Re {x}
For x being a vector the two equations above are applied to the components of x. Example y=deg2rad(0.785) returns 45. See also deg2rad(), phase(), arg()
391
real()
Real value of a complex number. Syntax y=real(x) Arguments Name x Type ,Cmn ,Rmnp , Cmnp Def. Range ], +[ Required
R, C, R , C , R
mn
Description This function returns the real value of a real or complex number, vector or matrix. For x R: y = x For C x := a + i b a, b R: y = a
For x being a vector or a matrix the two equations above are applied to the components of x. Example y=real(-3+4*i) returns -3. See also abs(), mag(), norm(), imag(), conj(), phase(), arg()
392
signum()
Signum function. Syntax y=signum(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the sign of a real or complex number or vector. 1 f or x > 0 0 f or x = 0 For x R: y = 1 f or x < 0 x f or x = 0 |x| 0 f or x = 0
For x C: y =
For x being a vector the two equations above are applied to the components of x. Examples y=signum(-4) returns -1, y=signum(3+4*i) returns 0.6+j0.8. See also abs(), sign()
393
sign()
Sign function. Syntax y=sign(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the sign of a real or complex number or vector. For x R: y = 1 f or x >= 0 1 f or x < 0 x f or x = 0 |x| 1 f or x = 0
For x C: y =
For x being a vector the two equations above are applied to the components of x. Examples y=sign(-4) returns -1, y=sign(3+4*i) returns 0.6+j0.8. See also abs(), signum()
394
sqr()
Square of a number. Syntax y=sqr(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the square root of a real or complex number or vector. y = x2 For x being a vector the two equations above are applied to the components of x. Examples y=sqr(-4) returns 16, y=sqr(3+4*i) returns -7+j24. See also sqrt()
395
sqrt()
Square root. Syntax y=sqrt(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the square root of a real or complex number or vector. For x R: y = For x C: y = x f or x 0 i x f or x < 0 |x| ei 2 with = arg (x)
For x being a vector the two equations above are applied to the components of x. Examples y=sqrt(-4) returns 0+j2, y=sqrt(3+4*i) returns 2+j1. See also sqr()
396
unwrap()
Unwraps a phase vector in radians. Syntax y=unwrap(x) y=unwrap(x, t) Arguments Name x t Type Rn , Cn R Def. Range ], +[ ], +[ Required Default
Description This function unwraps a phase vector x to avoid phase jumps. If two consecutive values of x dier by more than tolerance t, 2 (depending on the sign of the dierence) is added to the current element of x. The predened value of the optional parameter t is . Examples y=unwrap(3.15*linspace(-2,2,5)) returns -6.3, -9.43, -12.6, -15.7, -18.8, y=unwrap(2*linspace(-2,2,5),1) returns -4, -8.28, -12.6, -16.8, -21.1, y=unwrap(2*linspace(-2,2,5),3) returns -4, -2, 0, 2, 4. See also abs(), mag(), norm(), real(), imag(), conj(), phase(), arg()
397
exp()
Exponential function. Syntax y=exp(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the exponential function of a real or complex number or vector. For x R: y = ex For C x := a + i b a, b R: y = ex = ea+i b = ea (cos b + i sin b)
For x being a vector the two equations above are applied to the components of x. Examples y=exp(-4) returns 0.0183, y=exp(3+4*i) returns -13.1-j15.2. See also ln(), log10(), log2(), cos(), sin()
398
log10()
Decimal logarithm. Syntax y=log10(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ {0} Required
Description This function calculates the principal value of the decimal logarithm (base 10) of a real or complex number or vector. ln (x) f or x > 0 ln (10) For x R: y = ln (x) +i f or x < 0 ln (10) ln (10) For x C: y = ln (|x|) arg (x) +i ln (10) ln (10)
For x being a vector the two equations above are applied to the components of x. Examples y=log10(-4) returns 0.602+j1.36, y=log10(3+4*i) returns 0.699+j0.403. See also ln(), log2(), exp(), arg()
399
log2()
Binary logarithm. Syntax y=log2(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ {0} Required
Description This function calculates the principal value of the binary logarithm (base 2) of a real or complex number or vector. ln (x) f or x > 0 ln (2) For x R: y = ln (x) +i f or x < 0 ln (2) ln (2) For x C: y = ln (|x|) arg (x) +i ln (2) ln (2)
For x being a vector the two equations above are applied to the components of x. Examples y=log2(-4) returns 2+j4.53, y=log2(3+4*i) returns 2.32+j1.34. See also ln(), log10(), exp(), arg()
400
ln()
Natural logarithm (base e). Syntax y=ln(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ {0} Required
Description This function calculates the principal value of the natural logarithm (base e ) of a real or complex number or vector. For x R: y = ln (x) f or x > 0 ln (x) f or x < 0
For x C: y = ln (|x|) + i arg (x) For x being a vector the two equations above are applied to the components of x. Examples y=ln(-4) returns 1.39+j3.14, y=ln(3+4*i) returns 1.61+j0.927. See also log2(), log10(), exp(), arg()
401
Trigonometry
cos()
Cosine function. Syntax y=cos(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the cosine of a real or complex number or vector. For x R: y = cos (x) with y [1, 1] For x C: y =
1 2
For x being a vector the two equations above are applied to the components of x. Examples y=cos(-0.5) returns 0.878, y=cos(3+4*i) returns -27.0-j3.85. See also sin(), tan(), arccos()
402
cosec()
Cosecant. Syntax y=cosec(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ {k } , k Z Required
Description This function calculates the cosecant of a real or complex number or vector. y = cosec x = 1 sin x
For x being a vector the equation above is applied to the components of x. Example y=cosec(1) returns 1.19. See also sin(), sec()
403
cot()
Cotangent function. Syntax y=cot(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ {k } , k Z Required
Description This function calculates the cotangent of a real or complex number or vector. For x R: y = 1 with y [, +] tan (x) exp (i x)2 + 1 exp (i x)2 1
For x C: y = i
For x being a vector the two equations above are applied to the components of x. Examples y=cot(-0.5) returns -1.83, y=cot(3+4*i) returns -0.000188-j1. See also tan(), sin(), cos(), arctan(), arccot()
404
sec()
Secant. Syntax y=sec(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ k + 1 , kZ 2 Required
Description This function calculates the secant of a real or complex number or vector. y =sec x= 1 cos x
For x being a vector the equation above is applied to the components of x. Example y=sec(0) returns 1. See also cos(), cosec()
405
sin()
Sine function. Syntax y=sin(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the sine of a real or complex number or vector. For x R: y = sin (x) with y [1, 1] For x C: y = 1 i (exp (i x) exp (i x)) 2 For x being a vector the two equations above are applied to the components of x. Examples y=sin(-0.5) returns -0.479, y=sin(3+4*i) returns 3.85-j27. See also cos(), tan(), arcsin()
406
tan()
Tangent function. Syntax y=tan(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ \ k + 1 , kZ 2 Required
Description This function calculates the tangent of a real or complex number or vector. For x R: y = tan (x) with y [, +] For x C: y = i exp (i x)2 1 exp (i x)2 + 1
For x being a vector the two equations above are applied to the components of x. Examples y=tan(-0.5) returns -0.546, y=tan(3+4*i) returns -0.000187+j0.999. See also cot(), sin(), cos(), arctan(), arccot()
407
arccos()
Arc cosine (also known as inverse cosine). Syntax y=arccos(x) Arguments Name x Type R, C, Rn , Cn Def. Range [1, +1] Required
Description This function calculates principal value of the the arc cosine of a real or complex number or vector. For x R: y = arccos (x) with y [0, ] For x C: y = i ln x + x2 1
For x being a vector the two equations above are applied to the components of x. Examples y=arccos(-1) returns 3.14, y=arccos(3+4*i) returns 0.937-j2.31. See also cos(), arcsin(), arctan(), arccot()
408
arccot()
Arc cotangent. Syntax y=arccot(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the principal value of the arc cotangent of a real or complex number or vector. For x R: y =arccot(x) with y [0, ] For x C: y = i ln 2 xi x+i
For x being a vector the two equations above are applied to the components of x. Examples y=arccot(-1) returns 2.36, y=arccot(3+4*i) returns 0.122-j0.159. See also cot(), tan(), arccos(), arcsin(), arctan()
409
arcsin()
Arc sine (also known as inverse sine). Syntax y=arcsin(x) Arguments Name x Type R, C, Rn , Cn Def. Range [1, +1] Required
Description This function calculates the principal value of the arc sine of a real or complex number or vector. For x R: y = arcsin (x) with y , 2 For x C: y = i ln i x + 1 x2
2
For x being a vector the two equations above are applied to the components of x. Examples y=arcsin(-1) returns -1.57, y=arcsin(3+4*i) returns 0.634+j2.31. See also sin(), arccos(), arctan(), arccot()
410
arctan()
Arc tangent (also known as inverse tangent). Syntax z=arctan(x) z=arctan(y,x) Arguments Name x y Type R, C, Rn , Cn R, C, Rn , Cn Def. Range ], +[ ], +[ Required
Description For the rst syntax ( z =arctan(x ) ), this function calculates the principal value of the arc tangent of a real or complex number or vector. For x R: y = arctan (x) with y , 2 1 2i For x C: y = i ln 1 2 x+i For x being a vector the two equations above are applied to the components of x. If the second syntax ( z =arctan(y, x ) ) nds application, the expression z = arctan (y/x) (with the arctan() function dened above) is evaluated. The sign of z is determined by sign(z )= + f or Re {x} > 0 . f or Re {x} > 0
2
Note that for the second syntax the case x = y = 0 is not dened. Examples z=arctan(-1) returns -0.785,
411
z=arctan(3+4*i) returns 1.45+j0.159, z=arctan(1,1) returns 0.785. See also tan(), arccos(), arcsin(), arccot()
412
Hyperbolic Functions
cosh()
Hyperbolic cosine. Syntax y=cosh(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the hyperbolic cosine of a real or complex number or vector. y=1 (ex + ex ) 2 For x being a vector the equation above is applied to the components of x. Examples y=cosh(-1) returns 1.54, y=cosh(3+4*i) returns -6.58-j7.58. See also exp(), sinh(), tanh(), cos()
413
cosech()
Hyperbolic cosecant. Syntax y=cosech(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[\ {0} Required
Description This function calculates the hyperbolic cosecant of a real or complex number or vector. y= 1 sinh x
For x being a vector the equation above is applied to the components of x. Examples y=cosech(-1) returns -0.851, y=cosech(3+4*i) returns -0.0649+j0.0755. See also exp(), sinh(), sech(), cosec()
414
coth()
Hyperbolic cotangent. Syntax y=coth(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[\ {0} Required
Description This function calculates the hyperbolic cotangent of a real or complex number or vector. y= 1 ex + ex = x tanh x e ex
For x being a vector the equation above is applied to the components of x. Examples y=coth(-1) returns -1.31, y=coth(3+4*i) returns 0.999-j0.0049. See also exp(), cosh(), sinh(), tanh(), tan()
415
sech()
Hyperbolic secant. Syntax y=sech(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the hyperbolic secant of a real or complex number or vector. y= 1 cosh x
For x being a vector the equation above is applied to the components of x. Examples y=sech(-1) returns 0.648, y=sech(3+4*i) returns -0.0653+j0.0752. See also exp(), cosh(), cosech(), sec()
416
sinh()
Hyperbolic sine. Syntax y=sinh(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the hyperbolic sine of a real or complex number or vector. y=1 (ex ex ) 2 For x being a vector the equation above is applied to the components of x. Examples y=sinh(-1) returns -1.18, y=sinh(3+4*i) returns -6.55-j7.62. See also exp(), cosh(), tanh(), sin()
417
tanh()
Hyperbolic tangent. Syntax y=tanh(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the hyperbolic tangent of a real or complex number or vector. y= ex ex ex + ex
For x being a vector the equation above is applied to the components of x. Examples y=tanh(-1) returns -0.762, y=tanh(3+4*i) returns 1+j0.00491. See also exp(), cosh(), sinh(), coth(), tan()
418
arcosh()
Hyperbolic area cosine. Syntax y=arcosh(x) Arguments Name x Type R, C, Rn , Cn Def. Range [1, +[ Required
Description This function calculates the hyperbolic area cosine of a real or complex number or vector, which is the inverse function to the cosh function. y = arcosh x = ln x + x2 1
For x being a vector the equation above is applied to the components of x. Examples y=arcosh(1) returns 0, y=arcosh(3+4*i) returns 2.31+j0.937. See also arsinh(), artanh(), cosh(), arccos(), ln(), sqrt()
419
arcoth()
Hyperbolic area cotangent. Syntax y=arcoth(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], 1[ ]+1, +[ Required
Description This function calculates the hyperbolic area cotangent of a real or complex number or vector, which is the inverse function to the cotanh function. y = arcoth x = 1 ln 2 x+1 x1
For x being a vector the equation above is applied to the components of x. Examples y=arcoth(2) returns 0.549, y=arcoth(3+4*i) returns 0.118-j0.161. See also arsinh(), arcosh(), tanh(), arctan(), ln(), sqrt()
420
arsinh()
Hyperbolic area sine. Syntax y=arsinh(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the hyperbolic area sine of a real or complex number or vector, which is the inverse function to the sinh function. y = arsinh x = ln x + x2 + 1
For x being a vector the equation above is applied to the components of x. Examples y=arsinh(1) returns 0.881, y=arsinh(3+4*i) returns 2.3+j0.918. See also arcosh(), artanh(), sinh(), arcsin(), ln(), sqrt()
421
artanh()
Hyperbolic area tangent. Syntax y=artanh(x) Arguments Name x Type R, C, Rn , Cn Def. Range ]1, +1[ Required
Description This function calculates the hyperbolic area tangent of a real or complex number or vector, which is the inverse function to the tanh function. y = artanh x = 1 ln 2 1+x 1x
For x being a vector the equation above is applied to the components of x. Examples y=artanh(0) returns 0, y=artanh(3+4*i) returns 0.118+j1.41. See also arsinh(), arcosh(), tanh(), arctan(), ln(), sqrt()
422
Rounding
ceil()
Round to the next higher integer. Syntax y=ceil(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function rounds a real number x to the next higher integer value. If x is a complex number both real part and imaginary part are rounded. For x being a vector the operation above is applied to the components of x. Examples y=ceil(-3.5) returns -3, y=ceil(3.2+4.7*i) returns 4+j5. See also oor(), x(), round()
423
x()
Truncate decimal places from real number. Syntax y=x(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function truncates the decimal places from a real number x and returns an integer. If x is a complex number both real part and imaginary part are rounded. For x being a vector the operation above is applied to the components of x. Examples y=fix(-3.5) returns -3, y=fix(3.2+4.7*i) returns 3+j4. See also ceil(), oor(), round()
424
oor()
Round to the next lower integer. Syntax y=oor(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function rounds a real number x to the next lower integer value. If x is a complex number both real part and imaginary part are rounded. For x being a vector the operation above is applied to the components of x. Examples y=floor(-3.5) returns -4, y=floor(3.2+4.7*i) returns 3+j4. See also ceil(), x(), round()
425
round()
Round to nearest integer. Syntax y=round(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function rounds a real number x to its nearest integer value. If x is a complex number both real part and imaginary part are rounded. For x being a vector the operation above is applied to the components of x. Examples y=round(-3.5) returns -4, y=round(3.2+4.7*i) returns 3+j5. See also ceil(), oor(), x()
426
besseli0()
Modied Bessel function of order zero. Syntax i0=besseli0(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function evaluates the modied Bessel function of order zero of a real or complex number or vector.
i0 (x) = J0 (i x) =
k=0
x 2k 2
k ! (k + 1)
where J0 (x)is the Bessel function of order zero and (x)denotes the gamma function. For x being a vector the equation above is applied to the components of x. Example y=besseli0(1) returns 1.266. See also besselj(), bessely()
427
besselj()
Bessel function of n-th order. Syntax jn=besselj(n,x) Arguments Name n x Type N R, C, Rn , Cn Def. Range [0, +[ ], +[ Required
Description This function evaluates the Bessel function of n-th order of a real or complex number or vector.
Jn (x) =
k=0
(1)k x 2 , k ! (n + k + 1)
n+2k
where (x)denotes the gamma function. For x being a vector the equation above is applied to the components of x. Example y=besselj(1,1) returns 0,44. See also besseli0(), bessely()
428
bessely()
Bessel function of second kind and n-th order. Syntax yn=bessely(n,x) Arguments Name n x Type N R, C, Rn , Cn Def. Range [0, +[ ], +[ Required
Description This function evaluates the Bessel function of second kind and n-th order of a real or complex number or vector. Yn (x) = lim Jm (x) cos m Jm (x) , mn sin m
where Jm (x)denotes the Bessel function of rst kind and n-th order. For x being a vector the equation above is applied to the components of x. Example y=bessely(1,1) returns -0.781. See also besseli0(), besselj()
429
erf()
Error function. Syntax y=erf(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function evaluates the error function of a real or complex number or vector. For x R,
x
2 y=
0
et dt
If x is a complex number both real part and imaginary part are subjected to the equation above. For x being a vector the equation is applied to the components of x. Example y=erf(0.5) returns 0.520. See also erfc(), ernv(), erfcinv(), exp()
430
erfc()
Complementary error function. Syntax y=erfc(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function evaluates the complementary error function of a real or complex number or vector. For x R,
x
2 y =1
0
et dt
If x is a complex number both real part and imaginary part are subjected to the equation above. For x being a vector the equation is applied to the components of x. Example y=erfc(0.5) returns 0.480. See also erf(), ernv(), erfcinv(), exp()
431
ernv()
Inverse error function. Syntax y=ernv(x) Arguments Name x Type R, C, Rn , Cn Def. Range ]1, +1[ Required
Description This function evaluates the inverse of the error function of a real or complex number or vector. For 1 < x < 1, y = erf 1 (x) If x is a complex number both real part and imaginary part are subjected to the equation above. For x being a vector the equation is applied to the components of x. Example y=erfinv(0.8) returns 0.906. See also erf(), erfc(), erfcinv(), exp()
432
erfcinv()
Inverse complementary error function. Syntax y=erfcinv(x) Arguments Name x Type R, C, Rn , Cn Def. Range ]0, +2[ Required
Description This function evaluates the inverse of the complementary error function of a real or complex number or vector. For 0 < x < 2, y = erfc1 (x) If x is a complex number both real part and imaginary part are subjected to the equation above. For x being a vector the equation is applied to the components of x. Example y=erfcinv(0.5) returns 0.477. See also erf(), erfc(), ernv(), exp()
433
sinc()
Sinc function. Syntax y=sinc(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function evaluates the sinc function of a real or complex number or vector. sin x f or x = 0 x 1 f or x = 0
y=
For x being a vector the equation above is applied to the components of x. Examples y=sinc(-3) returns 0.047, y=sinc(3+4*i) returns -3.86-j3.86. See also sin()
434
step()
Step function. Syntax y=step(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function calculates the step function of a real or complex number or vector. For x R, 0 f or x < 0 0.5 f or x = 0 y= 1 f or x > 0 If x is a complex number both real part and imaginary part are subjected to the equation above. For x being a vector the equation is applied to the components of x. Example y=step(0.5) returns 1. See also
435
avg()
Average of vector elements. Syntax y=avg(x) Arguments Name x Type R, C, R , Cn , Range xs : xe
n
Def. Range ], +[
Required
Description This function returns the sum of the elements of a real or complex vector or range. For x Cn : y = 1 n xi , 1 i n (for vectors) or xs i xe (for ranges) n i=1
For x being a real or complex number, x itself is returned. Example y=avg(linspace(1,3,10)) returns 2. See also sum(), max(), min()
436
cumavg()
Cumulative average of vector elements. Syntax y=cumavg(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the cumulative average of the elements of a real or complex vector. For x Cn : yk = 1 k xi , 1 k n k i=1
For x being a real or complex number, x itself is returned. Example y=cumavg(linspace(1,3,3)) returns 1, 1.5, 2. See also cumsum(), cumprod(), avg(), sum(), prod(), max(), min()
437
max()
Maximum value. Syntax y=max(x) y=max(a,b) Arguments Name x a b Type R, C, R , Cn , Range xs : xe R, C R, C
n
Def. Range ], +[ ], +[ ], +[
Required
Description For the rst syntax ( y=max(x) ), this function returns the maximum value of a real or complex vector or range. For x Rn : y =max (xi ) , 1 i n (for vectors) or xs i xe (for ranges) For x Cn : y = max ( |xi |) , 1 i n (for vectors) or xs i xe (for ranges), with sign + f or |arg (xi )| else
2
For x being a real or complex number: that is the case n = 1. The second syntax ( y=max(a,b) ) nds application, if two (generally complex) numbers a and b need to be compared. In principle, the maximum of the absolute values is selected, but it must be considered whether a and b are located in the right or left complex half plane. If the latter is the case, the negative absolute value of a and b needs to be regarded (for example, which is the case for negative real numbers), otherwise the positive absolute value is taken: y = max ( |a| , |b|), with |a| sign + f or |arg (a)| else
2
438
Example y=max(linspace(1,3,10)) returns 3. y=max(1,3) returns 3. y=max(1,1+i) returns 1+j1. y=max(1,-1+i) returns 1. See also min(), abs()
439
min()
Minimum value. Syntax y=min(x) y=min(a,b) Arguments Name x a b Type R, C, R , Cn , Range xs : xe R, C R, C
n
Def. Range ], +[ ], +[ ], +[
Required
Description For the rst syntax ( y=min(x) ), this function returns the minimum value of a real or complex vector or range. For x Rn : y =min (xi ) , 1 i n (for vectors) or xs i xe (for ranges) For x Cn : y = min ( |xi |) , 1 i n (for vectors) or xs i xe (for ranges), with sign + f or |arg (xi )| else
2
For x being a real or complex number: that is the case n = 1. The second syntax ( y=min(a,b) ) nds application, if two (generally complex) numbers a and b need to be compared. In principle, the maximum of the absolute values is selected, but it must be considered whether a and b are located in the right or left complex half plane. If the latter is the case, the negative absolute value of a and b needs to be regarded (for example, which is the case for negative real numbers), otherwise the positive absolute value is taken: y = min ( |a| , |b|), with |a| sign + f or |arg (a)| else
2
440
Example y=min(linspace(1,3,10)) returns 1. y=min(1,3) returns 1. y=min(1,1+i) returns 1. y=min(1,-1+i) returns -1+j1. See also max(), abs()
441
rms()
Root Mean Square of vector elements. Syntax y=rms(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the rms (root mean square) value of the elements of a real or complex vector. By application of the trapezoidal integration rule, for x Cn : y = 1 n
n i=1
ai x i x i , 1 i n, ai =
1 for 2 i n 1 1 for i = 1 or i = n 2
For x being a real or complex number, |x| itself is returned. Example y=rms(linspace(1,2,8)) returns 1.43. See also variance(), stddev(), avg()
442
runavg()
Running average of vector elements. Syntax y=runavg(x,m) Arguments Name x m Type R, C, Rn , Cn N Def. Range ], +[ [1, +[ Required
Description This function returns the running average over m elements of a real or complex vector. For x Cn : yk = 1 k+m1 xi , 1 k n m i=k
For x being a real or complex number, x itself is returned. Example y=runavg(linspace(1,3,6),2) returns 1.2, 1.6, 2, 2.4, 2.8. See also cumavg(), cumsum(), avg(), sum()
443
stddev()
Standard deviation of vector elements. Syntax y=stddev(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the stddev of the elements of a real or complex vector x. For x Cn : y = variance(x) For x being a real or complex number, 0 is returned. Example y=stddev(linspace(1,3,10)) returns 0.673. See also stddev(), avg(), max(), min()
444
variance()
Variance of vector elements. Syntax y=variance(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the variance of the elements of a real or complex vector. For x Cn : y =
n 1 (xi x)2 , where x denotes mean (average) value of x. n 1 i=1
For x being a real or complex number, 0 is returned. Example y=variance(linspace(1,3,10)) returns 0.453. See also stddev(), avg(), max(), min()
445
Basic Operation
cumprod()
Cumulative product of vector elements. Syntax y=cumprod(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the cumulative product of the elements of a real or complex vector. For x Cn : yk =
k
xi , 1 k n
i=1
For x being a real or complex number, x itself is returned. Example y=cumprod(linspace(1,3,3)) returns 1, 2, 6. See also cumsum(), cumavg(), prod(), sum(), avg(), max(), min()
446
cumsum()
Cumulative sum of vector elements. Syntax y=cumsum(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the cumulative sum of the elements of a real or complex vector.
k
For x C : yk =
i=1
xi , 1 k n
For x being a real or complex number, x itself is returned. Example y=cumsum(linspace(1,3,3)) returns 1, 3, 6. See also cumprod(), cumavg(), sum(), prod(), avg(), max(), min()
447
interpolate()
Equidistant spline interpolation of data vector. Syntax z=interpolate(y,t,m) z=interpolate(y,t) Arguments Name y t m Type Rn , Cn Rn , Cn N Def. Range ], +[ ], +[ [3, +[ Required Default
64
Description This function uses spline interpolation to interpolate between the points of a vector y(t). If the number of samples n is not specied, a default value of n = 64 is assumed. Example z=interpolate(linspace(0,2,3)*linspace(0,2,3),linspace(0,2,3)) returns a smooth parabolic curve: Use the Cartesian diagram to display it. See also sum(), prod()
448
4 2 0 00 5 5 . . 11 la 0 0 t t n e r p o e . I 12
Figure 15.4: Interpolated curve
prod()
Product of vector elements. Syntax y=prod(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the product of the elements of a real or complex vector. For x Cn : y =
n
xi
i=1
For x being a real or complex number, x itself is returned. Example y=prod(linspace(1,3,10)) returns 583.
449
450
sum()
Sum of vector elements. Syntax y=sum(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the sum of the elements of a real or complex vector. For x Cn : y =
n
xi
i=1
For x being a real or complex number, x itself is returned. Example y=sum(linspace(1,3,10)) returns 20. See also prod(), avg(), max(), min()
451
xvalue()
Returns x-value which is associated with the y-value nearest to a specied y-value in a given vector. Syntax x=xvalue(f,yval) Arguments Name f yval Type Rn , Cn R, C Def. Range ], +[ ], +[ Required
Description This function returns the x -value which is associated with the y -value nearest to yval in the given vector f ; therefore the vector f must have a single data dependency. Example x=xvalue(f,1). See also yvalue(), interpolate()
452
yvalue()
Returns y-value of a given vector which is located nearest to the specied x-value. Syntax y=yvalue(f,xval) Arguments Name f xval Type Rn , Cn R, C Def. Range ], +[ ], +[ Required
Description This function returns the y-value of the given vector f which is located nearest to the x-value xval ; therefore the vector f must have a single data dependency. Example y=yvalue(f,1). See also xvalue(), interpolate()
453
di()
Dierentiate vector with respect to another vector. Syntax z=di(y,x,n) Arguments Name y x n Type Rk , Ck Rm , Cm N Def. Range ], +[ ], +[ Required Default
Description This function numerically dierentiates a vector y with respect to a vector x. If the optional integer parameter n is given, the n-th derivative is calculated. Dierentiation is executed for N= min(k,m) elements. For n=1, 1 2 yi = xi yi yi1 yi+1 yi + xi xi1 xi+1 xi yi+1 yi xi+1 xi yi yi1 xi xi1 for N 1 > i > 0 for i = 0 for i = N 1
If n>1, the result of the dierentiation above is assigned to y and the aforementioned dierentiation step is repeated until the number of those steps is equal to n. Example z=diff(linspace(1,3,3),linspace(2,3,3)) returns 2, 2, 2. See also integrate(), sum(), max(), min()
454
integrate()
Integrate vector. Syntax z=integrate(y,h) Arguments Name y h Type R, C, Rn , Cn R, C Def. Range ], +[ ], +[ Required
Description This function numerically integrates a vector x with respect to a dierential h. The integration method is according to the trapez rule: f (t) dt h Example
3
yn y0 + y1 + y2 + . . . + yn1 + 2 2
455
Signal Processing
dft()
Discrete Fourier Transform. Syntax y=dft(v) Arguments Name v Type Rn , Cn Def. Range ], +[ Required
Description This function computes the Discrete Fourier Transform (DFT) of a vector v. The advantage of this function compared to t() is that the number n of components of v is arbitrary, while for the latter n must be a power of 2. The drawbacks are that dft() is slower and less accurate than t(). Example This calculates the spectrum y of a DC signal: y 1 -1.59e-17+j1.59e-17 y=dft(linspace(1,1,7)) returns . . . 2.22e-16-j1.11e-16 Please note that in this example 7 points are used for the time vector v. Since 7 is not a power of 2, the same expression used together with the t() function would lead to wrong results. Note also the rounding errors where 0 would be the correct value. See also idft(), t(), it(), Freq2Time(), Time2Freq()
456
t()
Fast Fourier Transform. Syntax y=t(v) Arguments Name v Type Rn , Cn Def. Range ], +[ Required
Description This function computes the Fast Fourier Transform (FFT) of a vector v. The number n of components of v must be a power of 2. Example This calculates the spectrum y of a DC signal: y 1 y=fft(linspace(1,1,8)) returns 0 . . . 0 See also it(), dft(), idft(), Freq2Time(), Time2Freq()
457
idft()
Inverse Discrete Fourier Transform. Syntax y=idft(v) Arguments Name v Type Rn , Cn Def. Range ], +[ Required
Description This function computes the Inverse Discrete Fourier Transform (IDFT) of a vector v. The advantage of this function compared to it() is that the number n of components of v is arbitrary, while for the latter n must be a power of 2. The drawbacks are that idft() is slower and less accurate than it(). Example This calculates the time function y belonging to a white spectrum: y 7 y=idft(linspace(1,1,7)) returns -1.11e-16-j1.11e-16 . . . 1.55e-15+j7.77e-16 Please note that in this example 7 points are used for the spectrum vector v. Since 7 is not a power of 2, the same expression used together with the it() function would lead to wrong results. Note also the rounding errors where 0 would be the correct value. See also dft(), it(), t(), Freq2Time(), Time2Freq()
458
it()
Inverse Fast Fourier Transform. Syntax y=it(v) Arguments Name v Type Rn , Cn Def. Range ], +[ Required
Description This function computes the Inverse Fast Fourier Transform (IFFT) of a vector v. The number n of components of v must be a power of 2. Example This calculates the time function y belonging to a white spectrum: y 8 y=ifft(linspace(1,1,8)) returns 0 . . . 0 See also t(), dft(), idft(), Freq2Time(), Time2Freq()
459
Time2Freq()
Interpreted Discrete Fourier Transform. Syntax y=Time2Freq(v,t) Arguments Name v t Type Rn , Cn Rk , Ck Def. Range ], +[ ], +[ Required
Description This function computes the Discrete Fourier Transform (DFT) of a vector v with respect to a time vector t. Example This calculates the spectrum y(f) of a DC signal: y=Time2Freq(linspace(1,1,7),linspace(0,1,2)) returns Frequency 0 0.167 . . . 1 y 1 -1.59e-17+j1.59e-17 . . . 2.22e-16-j1.11e-16
Please note that in this example 7 points are used for the time vector v . Note also the rounding errors at t>0, where 0 would be the correct value. See also idft(), t(), it(), Freq2Time()
460
Freq2Time()
Interpreted Inverse Discrete Fourier Transform. Syntax y=Freq2Time(v,f) Arguments Name v f Type Rn , Cn Rk , Ck Def. Range ], +[ ], +[ Required
Description This function computes the Inverse Discrete Fourier Transform (IDFT) of a vector v with respect to a frequency vector f. Example This calculates the time function y(t) belonging to a white spectrum: y=Freq2Time(linspace(1,1,7),linspace(0,1,2)) returns Frequency 0 0.167 . . . 1 y 7 -1.11e-16-j1.11e-16 . . . 1.55e-15+j7.77e-16
Please note that in this example 7 points are used for the spectrum vector v . Note also the rounding errors at t>0, where 0 would be the correct value. See also dft(), it(), t(), Time2Freq()
461
kbd()
Kaiser-Bessel derived window. Syntax y=kbd(a,n) y=kbd(a) Arguments Name a n Type R N Def. Range ], +[ [1, +[ Required Default 64
I0 a yk =
i=0
n 2
1 1
4i n 4i n
1 , 1
I0 a
i=0
If the parameter n is not specied, n =64 is assumed. Example y=kbd(0.1,4) returns . See also dft(), it(), t()
462
dB()
dB value. Syntax y=dB(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function returns the dB value of a real or complex number or vector. y = 20 log |x| For x being a vector the equation above is applied to the components of x. Example y=db(10) returns 20. See also log10()
463
dbm()
Convert voltage to power in dBm. Syntax y=dBm(u,Z0) y=dBm(u) Arguments Name u Z0 Type R, C, Rn , Cn R, C, Rn , Cn Def. Range ], +[ ], +[ Required Default 50
Description This function returns the corresponding dBm power of a real or complex voltage or vector u. The impedance Z0 referred to is either specied or 50. |u|2 y = 10 log Z0 0.001W For u being a vector the equation above is applied to the components of u. Please note that u is considered as a rms value, not as an amplitude. Example y=dbm(1) returns 13. See also dbm2w(), w2dbm(), log10()
464
dbm2w()
Convert power in dBm to power in Watts. Syntax y=dBm2w(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function converts the real or complex power or power vector, given in dBm, to the corresponding power in Watts. y = 0.001 10 10 For x being a vector the equation above is applied to the components of x. Example y=dbm2w(10) returns 0.01. See also dbm(), w2dbm()
x
465
w2dbm()
Convert power in Watts to power in dBm. Syntax y=w2dBm(x) Arguments Name x Type R, C, Rn , Cn Def. Range ], +[ Required
Description This function converts the real or complex power or power vector, given in Watts, to the corresponding power in dBm. y = 10 log x 0.001W
For x being a vector the equation above is applied to the components of x. Example y=w2dbm(1) returns 30. See also dbm(), dbm2w(), log10()
466
rtoswr()
Converts reection coecient to voltage standing wave ratio (VSWR). Syntax s=rtoswr(r) Arguments Name r Type R, C, Rn , Cn Def. Range |r| 1 Required
Description For a real or complex reection coecient r, this function calculates the corresponding voltage standing wave ratio (VSWR) s according to s= 1 + |r| 1 |r |
VSWR is a real number and if usually given in the notation s : 1. For r being a vector the equation above is applied to the components of r. Examples s=rtoswr(0) returns 1. s=rtoswr(0.1+0.2*i) returns 1.58. See also ytor(), ztor(), rtoy(), rtoz()
467
rtoy()
Converts reection coecient to admittance. Syntax y=rtoy(r) y=rtoy(r, Z0) Arguments Name r Z0 Type R, C, Rn , Cn R, C Def. Range |r| 1 ], +[ Required Default 50
Description For a real or complex reection coecient r, this function calculates the corresponding admittance y according to y= 1 1r Z0 1 + r
If the reference impedance Z0 is not provided, the function assumes Z0 = 50. For r being a vector the equation above is applied to the components of r. Example y=rtoy(0.333) returns 0.01. See also ytor(), ztor(), rtoswr()
468
rtoz()
Converts reection coecient to impedance. Syntax z=rtoz(r) z=rtoz(r, Z0) Arguments Name r Z0 Type R, C, Rn , Cn R, C Def. Range |r| 1 ], +[ Required Default 50
Description For a real or complex reection coecient r, this function calculates the corresponding impedance Z according to Z = Z0 1r 1+r
If the reference impedance Z0 is not provided, the function assumes Z0 = 50. For r being a vector the equation above is applied to the components of r. Example z=rtoz(0.333) returns 99.9. See also ztor(), ytor(), rtoswr()
469
ytor()
Converts admittance to reection coecient. Syntax r=ytor(Y) r=ytor(Y, Z0) Arguments Name Y Z0 Type R, C, Rn , Cn R, C Def. Range ], +[ ], +[ Required Default 50
Description For a real or complex admittance y, this function calculates the corresponding reection coecient according to r= 1 Y Z0 1 + Y Z0
For Y being a vector the equation above is applied to the components of Y. If the reference impedance Z0 is not provided, the function assumes Z0 = 50. Often a dB measure is given for the reection coecient, the so called return loss: RL = 20 log |r| [dB] Example r=ytor(0.01) returns 0.333. See also rtoy(), rtoz(), rtoswr(), log10(), dB()
470
ztor()
Converts impedance to reection coecient. Syntax r=ztor(Z) r=ztor(Z, Z0) Arguments Name Z Z0 Type R, C, Rn , Cn R, C Def. Range ], +[ ], +[ Required Default 50
Description For a real or complex impedance Z, this function calculates the corresponding reection coecient according to r= Z Z0 Z + Z0
For Z being a vector the equation above is applied to the components of Z. If the reference impedance Z0 is not provided, the function assumes Z0 = 50. Often a dB measure is given for the reection coecient, the so called return loss: RL = 20 log |r| [dB] Example r=ztor(100) returns 0.333. See also rtoz(), rtoy(), rtoswr(), log10(), dB()
471
stos()
Converts S-parameter matrix to S-parameter matrix with dierent reference impedance(s). Syntax y=stos(S, Zref) y=stos(S, Zref, Z0) Arguments Name S Zref Z0 Type Rnn , Cnn R, C, Rn , Cn R, C, Rn , Cn Def. Range |Sij | ], +[ , 1 i, j n |Sii | 1, 1 i n ], +[ ], +[ Required 50 Default
Description This function converts a real or complex scattering parameter matrix S into a scattering matrix Y. S has a reference impedance Zref, whereas the created scattering matrix Y has a reference impedance Z0. If the reference impedance Z0 is not provided, the function assumes Z0 = 50. Both Zref and Z0 can be real or complex numbers or vectors; in the latter case the function operates on the elements of Zref and Z0. Example Conversion of 50 terminated S-parameters to 100 terminated S-parameters: S2=stos(eye(2)*0.1,50,100) returns See also twoport(), stoy(), stoz() -0.241 0 0 . -0.241
472
stoy()
Converts S-parameter matrix to Y-parameter matrix. Syntax Y=stoy(S) Y=stoy(S, Zref) Arguments Name S Zref Type Rnn , Cnn R, C, Rn , Cn Def. Range |Sij | ], +[ , 1 i, j n |Sii | 1, 1 i n ], +[ Required Default
50
Description This function converts a real or complex scattering parameter matrix S into an admittance matrix Y. S has a reference impedance Zref, which is assumed to be Zref = 50 if not provided by the user. Zref can be real or complex number or vector; in the latter case the function operates on the elements of Zref. Example Y=stoy(eye(2)*0.1,100) returns See also twoport(), stos(), stoz(), ytos() 0.00818 0 0 . 0.00818
473
stoz()
Converts S-parameter matrix to Z-parameter matrix. Syntax Z=stoz(S) Z=stoz(S, Zref) Arguments Name S Zref Type Rnn , Cnn R, C, Rn , Cn Def. Range |Sij | ], +[ , 1 i, j n |Sii | 1, 1 i n ], +[ Required Default
50
Description This function converts a real or complex scattering parameter matrix S into an impedance matrix Z. S has a reference impedance Zref, which is assumed to be Zref = 50 if not provided by the user. Zref can be real or complex number or vector; in the latter case the function operates on the elements of Zref. Example Z=stoz(eye(2)*0.1,100) returns See also twoport(), stos(), stoy(), ztos() 122 0 0 . 122
474
twoport()
Converts a two-port matrix from one representation into another. Syntax U=twoport(X, from, to) Arguments Name X from to Type R , C22 Character Character
22
Def. Range ], +[ {Y , Z , H , G, A, S, T } {Y , Z , H , G, A, S, T }
Required
Description This function converts a real or complex two-port matrix X from one representation into another. Example Transfer a two-port Y matrix Y1 into a Z matrix: Y1=eye(2)*0.1 Z1=twoport(Y1,Y,Z) returns See also stos(), ytos(), ztos(), stoz(), stoy(), ytoz(), ztoy() 10 0 0 . 10
475
ytos()
Converts Y-parameter matrix to S-parameter matrix. Syntax S=ytos(Y) S=ytos(Y, Z0) Arguments Name Y Z0 Type R , Cnn R, C, Rn , Cn
nn
Def. Range ], +[ ], +[
Required
Default 50
Description This function converts a real or complex admittance matrix Y into a scattering parameter matrix S. Y has a reference impedance Z0, which is assumed to be Z0 = 50 if not provided by the user. Z0 can be real or complex number or vector; in the latter case the function operates on the elements of Z0. Example S=ytos(eye(2)*0.1,100) returns See also twoport(), stos(), ztos(), stoy() -0.818 0 0 . -0.818
476
ytoz()
Converts Y-parameter matrix to Z-parameter matrix. Syntax Z=ytoz(Y) Arguments Name Y Type R , Cnn
nn
Def. Range ], +[
Required
Description This function converts a real or complex admittance matrix Y into an impedance matrix Z. Example Z=ytoz(eye(2)*0.1) returns See also twoport(), ztoy() 10 0 0 . 10
477
ztos()
Converts Z-parameter matrix to S-parameter matrix. Syntax S=ztos(Z) S=ztos(Z, Z0) Arguments Name Z Z0 Type R , Cnn R, C, Rn , Cn
nn
Def. Range ], +[ ], +[
Required
Default 50
Description This function converts a real or complex impedance matrix Z into a scattering parameter matrix S. Z has a reference impedance Z0, which is assumed to be Z0 = 50 if not provided by the user. Z0 can be real or complex number or vector; in the latter case the function operates on the elements of Z0. Example S=ztos(eye(2)*0.1,100) returns See also twoport(), twoport(), stos(), ytos(), stoz() -0.998 0 0 . -0.998
478
ztoy()
Converts Z-parameter matrix to Y-parameter matrix. Syntax Y=ztoy(Z) Arguments Name Z Type R , Cnn
nn
Def. Range ], +[
Required
Description This function converts a real or complex impedance matrix Z into an admittance matrix Y. Example Y=ztoy(eye(2)*0.1) returns See also twoport(), ytoz() 10 0 0 . 10
479
15.5.4 Ampliers
GaCircle()
Circle(s) with constant available power gain Ga in the source plane. Syntax y=GaCircle(X,Ga,v) y=GaCircle(X,Ga,n) y=GaCircle(X,Ga) Arguments Name X v Ga n Type R22p , C22p Rn R, Rm N Def. Range ], +[ [0, 360]o [0, +[ [2, +[ Required 64 Default
Description This function generates the points of the circle of constant available power gain GA in the complex source plane (rS ) of an amplier. The amplier is described by a two-port S-parameter matrix S. Radius r and center c of this circle are calculated as follows:
2 1 2 K gA |S12 S21 | + gA |S12 S21 |2 gA (S11 S22 ) , 1 + gA |S11 |2 ||2
r=
1 + gA |S11 | ||
and c =
where gA =
The points of the circle can be specied by the angle vector v, where the angle must be given in degrees. Another possibility is to specify the number n of angular equally distributed points around the circle. If no additional argument to X is given, 64 points are taken. The available power gain can also be specied in a vector Ga, leading to the generation of m circles, where m is the size of Ga. Please also refer to Qucs - Technical Papers, chapter 1.5.
480
481
GpCircle()
Circle(s) with constant operating power gain Gp in the load plane. Syntax y=GpCircle(X,Gp,v) y=GpCircle(X,Gp,n) y=GpCircle(X,Gp) Arguments Name X v Gp n Type , C22p Rn R, Rm N Def. Range ], +[ [0, 360]o [0, +[ [2, +[ Required 64 Default
22p
Description This function generates the points of the circle of constant operating power gain GP in the complex load plane (rL ) of an amplier. The amplier is described by a two-port S-parameter matrix S. Radius r and center c of this circle are calculated as follows:
2 1 2 K gP |S12 S21 | + gP |S12 S21 |2 S11 ) gA (S22 , 1 + gP |S22 |2 ||2
r=
1 + gP |S22 |2 ||2
and c =
where gA =
The points of the circle can be specied by the angle vector v, where the angle must be given in degrees. Another possibility is to specify the number n of angular equally distributed points around the circle. If no additional argument to X is given, 64 points are taken. The available power gain can also be specied in a vector G p, leading to the generation of m circles, where m is the size of G p. Please also refer to Qucs - Technical Papers, chapter 1.5. Example
482
483
Mu()
Mu stability factor of a two-port S-parameter matrix. Syntax y=Mu(S) Arguments Name S Type ,C ,R22 , C22
22p
22p
Def. Range ], +[
Required
Description This function returns the Mu stability factor of an amplier being described by a two-port S-parameter matrix S : = 1 |S11 |2 |S22 S11 | + |S21 S12 |
denotes determinant of S . The amplier is unconditionally stable if > 1. For S being a vector of matrices the equation above is applied to the sub-matrices of S. Example m=Mu(S) See also Mu2(), Rollet(), StabCircleS(), StabCircleL()
484
Mu2()
Mu stability factor of a two-port S-parameter matrix. Syntax y=Mu2(S) Arguments Name S Type ,C ,R22 , C22
22p
22p
Def. Range ], +[
Required
Description This function returns the Mu stability factor of an amplier being described by a twoport S-parameter matrix S : = 1 |S22 |2 |S11 S22 | + |S21 S12 |
denotes determinant of S . The amplier is unconditionally stable if > 1. For S being a vector of matrices the equation above is applied to the sub-matrices of S. Example m=Mu2(S) See also Mu2(), Rollet(), StabCircleS(), StabCircleL()
485
NoiseCircle()
Generates circle(s) with constant Noise Figure(s). Syntax y=NoiseCircle(Sopt,Fmin,Rn,F,v) y=NoiseCircle(Sopt,Fmin,Rn,F,n) y=NoiseCircle(Sopt,Fmin,Rn,F) Arguments Name Sopt Fmin Rn F v n Type Rn , Cn Rn Rn , Cn R, Rn Rn N Def. Range ], +[ [1, +[ [0, +[ [1, +[ [0, 360]o [2, +[ Required Default
64
Description This function generates the points of the circle of constant Noise Figure (NF) F in the complex source plane (rS ) of an amplier. Generally, the amplier has its minimum NF Fmin , if the source reection coecient rS = Sopt (noise matching). Note that this state with optimum source reection coecient Sopt is dierent from power matching ! Thus power gain under noise matching is lower than the maximum obtainable gain. The values of Sopt , Fmin and the normalised equivalent noise resistance Rn /Z0 can be usually taken from the data sheet of the amplier. Radius r and center c of the circle of constant NF are calculated as follows: N 2 + N 1 |Sopt |2 Sopt F Fmin and c = , with N = Z0 |1 + Sopt |2 . 1+N 1+N 4 Rn
r=
The points of the circle can be specied by the angle vector v, where the angle must be given in degrees. Another possibility is to specify the number n of angular equally distributed points around the circle. If no additional argument to X is given, 64 points are taken. Please also refer to Qucs - Technical Papers, chapter 2.2.
486
487
PlotVs()
Returns a data item based upon vector or matrix vector with dependency on a given vector. Syntax y=PlotVs(X, v) Arguments Name X v Type R , C , Rmnp , Cmnp Rn , Cn
n n
Def. Range ], +[ ], +[
Required
Description This function returns a data item based upon a vector or matrix vector X with dependency on a given vector v. Example PlotVs(Gain,frequency/1E9). See also
488
Rollet()
Rollet stability factor of a two-port S-parameter matrix. Syntax y=Rollet(S) Arguments Name S Type ,C ,R22 , C22
22p
22p
Def. Range ], +[
Required
Description This function returns the Rollet stability factor K of an amplier being described by a two-port S-parameter matrix S : K= 1 |S11 |2 |S22 |2 + ||2 2 |S21 | |S12 |
denotes determinant of S . The amplier is unconditionally stable if K > 1 and || < 1. Note that a large K may be misleading in case of a multi-stage amplier, pretending extraordinary stability. This is in conict with reality where a large gain amplier usually suers from instability due to parasitics. For S being a vector of matrices the equation above is applied to the sub-matrices of S. Example K=Rollet(S) See also Mu(), Mu2(), StabCircleS(), StabCircleL()
489
StabCircleL()
Stability circle in the load plane. Syntax y=StabCircleL(X) y=StabCircleL(X,v) y=StabCircleL(X,n) Arguments Name X v n Type , C22p Rn N Def. Range ], +[ [0, 360]o [2, +[ Required Default
22p
64
Description This function generates the stability circle points in the complex load reection coecient (rL ) plane of an amplier. The amplier is described by a two-port S-parameter matrix S. Radius r and center c of this circle are calculated as follows: r=
S11 S22 S21 S12 and c = |S22 |2 ||2 |S22 |2 ||2
denotes determinant of S . The points of the circle can be specied by the angle vector v, where the angle must be given in degrees. Another possibility is to specify the number n of angular equally distributed points around the circle. If no additional argument to X is given, 64 points are taken. If the center of the rL plane lies within this circle and |S11 | 1 then the circuit is stable for all reection coecients inside the circle. If the center of the rL plane lies outside the circle and |S11 | 1 then the circuit is stable for all reection coecients outside the circle (please also refer to Qucs - Technical Papers, chapter 1.5). Example v=StabCircleL(S)
490
491
StabCircleS()
Stability circle in the source plane. Syntax y=StabCircleS(X) y=StabCircleS(X,v) y=StabCircleS(X,n) Arguments Name X v n Type , C22p Rn N Def. Range ], +[ [0, 360]o [2, +[ Required Default
22p
64
Description This function generates the stability circle points in the complex source reection coecient (rS ) plane of an amplier. The amplier is described by a two-port S-parameter matrix S. Radius r and center c of this circle are calculated as follows: r=
S22 S11 S21 S12 and c = |S11 |2 ||2 |S11 |2 ||2
denotes determinant of S . The points of the circle can be specied by the angle vector v, where the angle must be given in degrees. Another possibility is to specify the number n of angular equally distributed points around the circle. If no additional argument to X is given, 64 points are taken. If the center of the rS plane lies within this circle and |S22 | 1 then the circuit is stable for all reection coecients inside the circle. If the center of the rS plane lies outside the circle and |S22 | 1 then the circuit is stable for all reection coecients outside the circle (please also refer to Qucs - Technical Papers, chapter 1.5). Example v=StabCircleS(S)
492
493
494
tabular and graphical forms. All circuit simulators have one other important attribute, namely that they represent individual electronic components by a model, or abstraction, in a way that can be understood and analysed by the simulation engine when undertaking a simulation task. Without component models the science of circuit simulation would not have developed to the stage it has today. From a users point of view component models are the key to simulator productivity; the greater the number of dierent models the easier it becomes to analyse mixed analogue and digital electronic systems.
Shown in Fig. 16.1 is a block diagram of the analogue component modelling and simulation facilities currently provided by the Qucs package. The diagram is structured as a ow chart which emphasises the dierent device modelling routes. When Qucs was rst released only two of these were available for users to develop new device models. The rst of these has been used extensively by the package developers to construct the built-in models that are distributed with each Qucs release. This fundamental route involves hand coding the C++ code for a new model1 , its compilation and linking with the core Qucs C++ code. Obviously, this does require a specialised knowledge of the Qucs model programming interface2 , the necessary C++ skills, including a good working knowledge of the Trolltech Qt toolkit3 . At the time of writing these notes the latest device to be added to Qucs using this approach is the exponential pulse source4 . Models based on hand written C++ code are normally restricted to basic devices that form the fundamental component core of a simulator - particularly where simulation computational eciency is important. One disadvantage of this approach, is the obvious one, in that the time to implement a new model increases disproportionately with increasing model complexity. For most Qucs users this route would not be the most natural to use when developing new models. However, for the specialist who spends a signicant amount of time researching new device models this has always in the past, been the route of choice. Unfortunately, modern semiconductor device models are becoming so complex that the model development time can stretch into months or even years and requires typically thousands of lines of C or C++ code to characterise a model5 . With the more complex models the problem of nding bugs in the model code also acts as a limit to fast model development.
For the average Qucs user their rst introduction to the software is probably through constructing circuit schematics made entirely from the standard component models built
1
The technical details of the built-in models are described in: Qucs Technical Papers, Stefan Jahn, Michael Margraf, Vincent Habchi and Raimund Jacob, http://qucs.sourceforge.net/technical.html. 2 Writing the documentation for the Qucs model programming interface is on the to do list and will be completed, when time allows, sometime in the future. 3 Qt is a registered trademark of Trolltech, Norway; http://www.trolltech.com/copyright. 4 Added by Gunther Kraut on 15 April 2007. This device has been added for compatibility with SPICE. 5 A good introduction to writing compact device models is given in How to (and how not to) write a compact model in Verilog-A, Georey J. Coram, 2004, Proc. 2004 IEEE International Behavioral Modeling and Simulation Conference (BMAS 2004), pp 97- 106.
495
SPICE netlist
SPICE preprocessor
ADMS compiler Schematic capture symbols QUCS GUI Circuit entered using schematic capture
C++ code
Qucs components
Simulate
Generate Qucs netlist code from GUI schematic, including conversion of SPICE code to Qucs format
Qucs Tools: Line Calculator Attenuator Design Matching Circuits Filter Design
QUCSATOR C++ component code compiled and linked to Qucsator core C++ code via API
Figure 16.1: Qucs analogue component modelling and simulation block diagram (not including optimisation)
496
into the package and the testing of their performance by launching the simulator from one of the Qucs simulation icons.6 The next natural stage in the Qucs modelling and simulation learning curve is the use of subcircuits where groups of built-in components are collected together to form a higher level circuit block. These blocks are often arranged with a common theme, forming a Qucs library. The process of modelling new devices/circuits is normally done by connecting existing component models and user dened subcircuits. With this type of modelling higher level functional models can only be constructed from existing fundamental components or previously constructed subcircuits. Engineers often call this approach to modelling, macromodelling. Qucs releases up to 0.0.10 relied on macromodelling for functional model development via the Qucs schematic interface. This route remains popular amongst most Qucs users because it is easy to understand, is fully interactive and allows straight forward testing of new models. One feature that is common to all components included in Qucs releases up to 0.0.10 may not be immediately obvious to readers, namely that, with the exception of sweep variables, component values could only be numbers, for example R1 = 1k, and were not allowed to be represented by algebraic expressions like R1 = Value1, where Value1 = 100.0+50 X. Its also worth pointing out at this point that during simulation, again performed by Qucs releases up to 0.0.10, component values were required to remain constant and could not be a function of the circuit variables such as voltage, current or charge.
One way to remove the component value restrictions imposed by early Qucs releases is to model devices and circuits using preprocessor extended forms of the SPICE netlist language. Circuit design equations can then be embedded in SPICE netlists and the calculation of component values completed by the SPICE preprocessor. Both the SPICE to Qucs and OP AMP tutorials7 outline in detail the steps required to merge circuit design and simulation in this way. This modelling route is a very important and powerful model development tool. So much so that ongoing tests to identify how compatible Qucs is with the industrial standard SPICE 2g6 and 3f5 syntax are currently being undertaken as part of the Qucs development schedule8 . Although perfectly viable as a model development tool the use of an extended SPICE netlist language has a number of serious disadvantages, namely that not all the Qucs built-in component models have equivalent SPICE models and secondly text netlists are the only entry medium for describing models.
The previous paragraphs give a brief statement of the dierent component modelling routes that were available up to release 0.0.11. Qucs 0.0.11 is very much a modelling water shed in
6
The Getting Started with Qucs tutorial by Stefan Jahn outlines a number of basic simulation techniques; http://qucs.sourceforge.net/docs.html. 7 Qucs simulation of SPICE netlists and Modelling Operational Ampliers, Mike Brinson, http://qucs. sourceforge.net/docs.html. 8 Qucs: Report Book; SPICE to Qucs test reports, Mike Brinson, http://qucs.sourceforge.net/docs. html.
497
that symbolic equations were introduced for the calculation of component values, previously equations were only allowed when structuring simulation output data for post simulation listing or plotting. Release 0.0.11 allows the following types of variable; 1. sweep variables, 2. equations left hand side, 3. component parameters left hand side (e.g. R1.R), 4. subcircuit parameters and 5. simulation output data. With each Qucs release the number of analysis functions, and other data processing features, included in the Qucs equation set continues to expand9 . From release 0.0.11 parameters are also allowed with subcircuits so that data can be passed to a model. This allows generalised subcircuit/macromodels to be developed for popular devices such as operational ampliers. Through the use of embedded design equations within subcircuits and parameter passing it became possible to construct powerful models that mix both circuit design procedures and the calculation of individual component values. Qucs 0.0.11 still imposed the restriction that equations could not be functions of voltage, current or charge.
With the release of Qucs 0.0.12 the voltage, current and charge restrictions imposed on equations will nally be relaxed. The introduction of a new device modelling component called the equation dened device (EDD) allows rstly device current to be formulated as a function of voltage, and secondly device charge to be calculated as a function of voltage and current. The syntax adopted for the new model borrows heavily on the compact device modelling approach taken by the Verilog-A modelling language.
Some readers will probably have noted that so far these notes make no reference to the ADMS model development route illustrated in Fig. 16.1. ADMS stands for Automated device model synthesizer10 and includes a Verilog-A to C/C++ compiler. It allows compact device models to be described in the Verilog-A language then compiled to C/C++ and the resulting code linked with the Qucs core simulation code11 . Model development using ADMS is similar to the fundamental hand coded C++ model development route except that model development is greatly simplied by the power of the high level Verilog-A language. A strong relationship exists between the ADMS and EDD modelling procedures in that
See Measurement Expressions Reference Manual, Gunther Kraut and Stefan Jahn, http://qucs. sourceforge.net/docs.html. 10 L.Lemaitre, C.C. McAndrew, and S. Hamm, ADMS - Automated Device Model Synthesizer, Proc. IEEE CICC, 2002. 11 For more details see, Qucs Description: Verilog-AMS interface, Stefan Jahn and H el` ene Parruitte, http://qucs.sourceforge.net/docs.html.
9
498
EDD can be considered a fast interactive model prototyping method whose equations can easily be expressed in Verilog-A and compiled into C/C++ code for permanent inclusion in the Qucs simulator12 .
The opening paragraphs attempt to outline the available device modelling techniques that are central to the functioning of the Qucs package. The remaining sections of this tutorial note are devoted to illustrating the power of Qucs modelling through the introduction of a number of illustrative examples. Initially these start from a simple, and hopefully familiar, point and then proceed to more complex examples which present many of the concepts lightly touched upon in the opening text.
(16.1)
Hence, by expressing Cap as a function of fc and stepping fc through a range of frequencies, the eect of capacitance changes on the voltage transfer function can be found. More
12
Appendix A gives an operator and function comparison table for Qucs and Verilog-A.
499
importantly a nomogram of Cap values against fc can be plotted giving the circuit designer a visual aid for determing the value of Cap required for given values of R1 and fc . Although the circuits shown in Figs. 16.2 and 16.3 are very basic they do demonstrate how much more powerful a circuit simulator becomes when component values are calculated using equations.
16.3.1 Low pass active lter design with embedded design equations
In this section a more advanced circuit design example is introduced to illustrate the power of embedded design equations in a Qucs simulation schematic. A second order Sallen-Key low pass lter is employed for this task because it is so well known and most readers are likely to have met its design in the past. A second order low pass lter is represented by the voltage transfer function:
A(S ) =
A0 Vout = Vin (1 + a2 S + b2 S 2 )
(16.3)
where A0 is the passband DC gain and coecients a2 , b2 are for Bessel, Butterworth, Tschebysche or similar polynomials. The following list13 gives the second order coecients for the Bessel 1.3617, 0.618; Butterworth 1.4142, 1.000; and 3dB ripple Tschebysche 1.065, 1.9305, polynomials. The second order Sallen-Key low pass lter circuit is shown in Fig. 16.4. This circuit has a voltage gain transfer function given by:
A(S ) = where
A0 = 1 +
(16.5)
This can be simplied by letting R1 = R2 = R and C1 = C2 = C ; the transfer function then becomes:
13
See OP Amps for everyone, Chapter 16: Active lter design technology, Texas Instruments, August 2002, SL0D006B, PP 16.1,16.63.
500
VCap
Parameter sweep
SW1 Sim=AC1 Type=lin Param=Cap Start=0.1u Stop=1.1u Points=11
V1 U=1 V
R1 R=1k
C1 C=Cap
ac simulation
AC1 Type=log Start=1Hz Stop=1 MHz Points=61
VCap.v
0.5
1e-6
Cap
5e-7
0 2 4 6 number 8 10
501
VCap
ac simulation
AC1 Type=log Start=1Hz Stop=1 MHz Points=61
Parameter sweep
SW1 Sim=AC1 Type=log Param=fc Start=10 Stop=1000 Points=21
V1 U=1 V
R1 R=Rvalue
C1 C=Cap
VCap.v
0.5
1e-5
Cap
1e-6
Figure 16.3: A simple RC circuit simulation employing equation determined component values
502
C2
SUB1
+
V1 U=1 V R1 R2 C1 OPA27(TI)
VEE Vout
V2 U=15 V
VCC V3 U=15 V
R3
R4
A(S ) =
A0 . 1 + [c R C (3 A0)] S + (c R C )2 S 2
(16.6)
By comparison a2 = c R C (3 A0) and b2 = (c R C )2 Fixing C and solving for R and A0, yields b2 a2 , and A0 = 3 . R= c C b2 Also once A0 is known the value for R4 can be calculated using equation A0 = 1 + R3 . R4 (16.10) (16.8) (16.7)
(16.9)
Hence by providing values for C and R3 the values for R and A0, and of course R4, can be determined for a specied cut o frequency f c. Figure 16.5 shows the nal design schematic and the simulation results for this example. A number of important observations can be made from Fig. 16.5:
503
C2 C=C SUB1
+
V1 U=1 V R2 R=R R1 R=R C1 C=C OPA27(TI)
VEE Vout
V2 U=15 V
dc simulation
DC1
VCC V3 U=15 V
ac simulation
Equation AC1 Type=log Start=1 Hz Stop=100 kHz Points=101 R3 R=R3_calc 4 R4 R=R4_calc
Eqn1 C=22e-9 a2=1.065 b2=1.9305 fc=3000 R=sqrt(b2)/(2*pi*fc*C) A0=3-a2/(sqrt(b2)) R3_calc=4700 R4_calc=(A0-1)*R3_calc gain_dB=dB(Vout.v) gain_phase=rad2deg(unwrap(angle(Vout.v)))
Vout.v
0 0 gain_phase -50 -200 1 10 100 1e3 acfrequency 1e4 1e5 1 10 100 1e3 acfrequency 1e4 1e5 gain_dB
-100
Figure 16.5: The Sallen-Key lowpass active lter schematic with embedded design equations
504
1. One or more equation blocks hold both design and post simulation data processing equations plus assignments for named items: C , f c and R3 are given numerical values, the a and b polynomial coecients are set to the values introduced in the text, and nally the design equations for R, A0 and R4 calculations are listed. 2. The order of entries in equation blocks is not important because Qucs automatically sorts out the data it requires when calculating equations. 3. The lefthand quantities in the assignment entries in the equation blocks are linked to the component values in the schematic, see for example C and R. 4. The OP27 operational amplier model is from the modied Qucs 0.0.11 OPAMP library. This model was generated using the SPICE to Qucs modelling route. 5. To design and simulate a Sallen-Key low pass lter with a dierent cut o frequency14 simply change the value of f c and rerun the Qucs simulator. 6. On completion of a simulation, pressing key F5 (Show last messages) causes the simulation log to be displayed. This includes the calculated values of the components and the netlist for the circuit, see Fig. 16.6. 7. One nal point of signicance that some readers may have noticed - all numerical values in equation blocks must be specied in scientic notation; electronic notation like 1k or 3nF is not allowed15 .
14
If the design calculations result in impractical values for the lter components then the value of C should be changed and the simulation repeated. 15 In long term it is expected that electronic notation will be allowed. The changes for this are on the to do list but at the moment the work has a low priority.
505
Output : n e t l i s t content 13 R i n s t a n c e s 5 C instances 2 VCCS i n s t a n c e s 5 CCCS i n s t a n c e s 2 VCVS i n s t a n c e s 1 CCVS i n s t a n c e s 8 Vdc i n s t a n c e s 1 Idc i n s t a n c e s 1 Vac i n s t a n c e s 4 Diode i n s t a n c e s 2 BJT i n s t a n c e s 1 DC i n s t a n c e s 1 AC i n s t a n c e s creating netlist . . . c h e c k e r n o t i c e , v a r i a b l e Vout . v in e q u a t i o n g a i n dB not y e t d e f i n e d c h e c k e r n o t i c e , v a r i a b l e Vout . v in e q u a t i o n g a i n phase not y e t d e f i n e d kB = 1 . 38065 e 23 e = 2 . 71828 p i = 3 . 14159 C = 2 . 2 e 08 a2 = 1 . 065 b2 = 1 . 9305 f c = 3000 R = 3350 . 51 A0 = 2 . 2335 R3 c a l c = 4700 R4 c a l c = 5797 . 43 kB = 1 . 38065 e 23 e = 2 . 71828 p i = 3 . 14159 kB = 1 . 38065 e 23 e = 2 . 71828 p i = 3 . 14159 kB = 1 . 38065 e 23 e = 2 . 71828 p i = 3 . 14159
Figure 16.6: Message output log for the simulation of the Sallen-key low pass circuit: for brevity only the component value section is given
506
507
V1 U=f1_amp P_sig f=f1 Phase=ph1 Equation V2 U=f2_amp f=f2 Phase=ph2 V3 U=f3_amp f=f3 Phase=ph3 V4 U=f4_amp f=f4 Phase=ph4 Eqn1 f2=2*f1 f3=3*f1 f4=4*f1
HG1
SUB1 f1=1000 f1_amp=1.0 f2_amp=0.0 ph1=0.0 ph2=0.0 f3_amp=0.0 f4_amp=0.0 ph3=0.0 ph4=0.0
Figure 16.7: Harmonic generator subcircuit schematic and symbol are used to compute the DFT of the harmonic generator waveform, convert the resulting spectra from double sided to single sided form, compute and plot the amplitude and power spectral densities.
to you. These functions provide Qucs with powerful numerical resource which signicantly extends the range of problems that Qucs can analyse.
508
Equation hg_sig Eqn1 ts=(max(time)-min(time))/length(time) fs=1/ts Adft=dft(hg_sig.Vt) LAdft=length(hg_sig.Vt) Amp2=2*Adft[1:(LAdfto2)-1] LAdfto2=LAdft/2 Amp_squared=Adft[:LAdfto2]*conj(Adft[:LAdfto2]) Amp=sqrt(Amp_squared) f_bin=linspace(1, LAdfto2, LAdfto2) f=(f_bin-1)*fs/LAdft PLAmp=PlotVs(2*Amp/LAdft,f) PLPower=PlotVs(4*Amp*Amp/(LAdft*LAdft),f)
transient simulation
TR1 Type=lin Start=0 Stop=10 ms Points=500
HG1
R1 R=50 Ohm SUB1 f1=1000 f1_amp=5.0 f2_amp=2.0 ph1=0 ph2=0 f3_amp=2 f4_amp=0 ph3=0 ph4=90
5 hg_sig.Vt
-5
1e-3
0.002
0.003
0.004
0.005 time
0.006
0.007
0.008
0.009
0.01
6 Power Spectral density (V^2) PLPower Amplitude Spectral density (V) PLAmp
30
20
10
Figure 16.8: Harmonic generator subcircuit test circuit and simulation waveforms
509
In reality the macromodel for a typical OP AMP that models DC, AC and transient domains is much more complex than the model given in Fig. 16.9. The schematic for a typical multi-domain OP AMP modular macromodel is shown in Fig. 16.11, where each section of the macromodel is represented, if needed, by its own equation block. The test schematics shown in Figures. 16.12 and 16.13 show two OP AMPs with dierent subcircuit parameters. In Fig. 16.12 the small signal characteristics of unity gain closed
21
The term AC here refers to the fact that the OP AMP model chosen for demonstration purposes is a simplied version of a multi-domain OP AMP model. It only models small signal AC parameters and device input stage bias and oset properties. 22 The schematic shown in Fig. 16.9 forms part of a modular OP AMP macromodel. A detailed description of the function of individual networks and the derivation of the component equations is given in Qucs tutorial Modelling Operational Ampliers, Mike Brinson, http://qucs.sourceforge.net/docs.html.
510
Voff1 U=voff1 Ib1 I=ib Ioff1 I=ioff1 Ib2 I=ib R1 R=r1 Cin1 C=cd R2 R=r2
P_INN1
GMSRT1 G=0.01 S
Voff2 U=voff2
GMP1 G=1 S
P_INP1
AC
+
SUB1 voff=0.7e-3 ioff=80e-3 rd=2e6 cd=1.4e-12 aoldc=200e3 gbp=1e6 ro=75 EOS1 G=1
ROS1 R=ro
P_OUT1
Output stage
Input Stage
Figure 16.9: Expanded AC OP AMP model showing circuitry and equation blocks loop ampliers clearly show the dierence in performance of the OP AMPs. Figure 16.13 is particularly interesting in that it illustrates how Qucs can be used to determine the eect of amplier oset voltage on integrator DC saturation by stepping resister rp through a series of values. The low oset voltage of the OP27 makes this device much more suitable for integrator circuits when compared to the popular UA741. These results can be conrmed by a simple calculation: the oset voltage for the UA741 is set at 0.7 mV and the amplier open loop DC gain at roughly 200, 000. The UA741 goes into saturation when rp is approximately 20 M. In saturation the OP AMP gain becomes open loop giving a DC output voltage of roughly 0.7e-3 2e5 or 14 V, which agrees with the Qucs simulation results.
511
IN AC P_INN1
ON
+
SUB1 v_off=0.7e-3 i_off=20e-9 r_d=2e6 c_d=1.4e-12 i_b=80e-9 g_bp=1e6 a_oldc=200e3 r_o=75 P_INP1
Input Stage IP OP
P_INN3
IN
ON
P_INN2
P_INP2
GMSRT1 G=0.01 S RSRT1 R=1 RADO1 R=aoldc CP1 C=cp1 P_OUT2 GMP1 G=1 S
output IN O Stage SUB9 ro=r_o PO1 ROS1 R=ro EOS1 G=1 P_OUT3
512
Voff1 U=voff1
P_INN
RSUM1 R=1
SRC1 G=1 S
Voff2 U=voff2
P_INP RDCMZ R=650M RCM1 R=1M RCM2 R=1 SRC2 G=1 S Equation ECM1 G=ecm1 CCM1 C=ccm1 GMSRT1 G=0.01 S RSCALE1 R=100 VSR1 U=p1 RSRT1 R=1 RADO R=aoldc CP1 C=cp1 Eqn4 cp1=1/(2*pi*gbp)
SRC3 G=1 S
RP2 R=1
CP2 C=cp2
GMP2 G=1 S
VLIM1 U=vlim1 Equation DVL1 Is=8e-16 A Eqn7 vlim1=vcc-vccm+1 vlim2=-vee+veem+1 P_OUT DVLM2 Is=8e-16 A
D2 Is=1e-15 A Cj0=0.0
RDCCL1 R=100M
ECL G=1
P_VEE
Figure 16.11: Modular OP AMP subcircuit schematic with embedded component calculation equations 513
R1 R=4.7k
vout_op27
V3 U=1 V
R2 R=4.7k MOD
V1 U=15 V VCC
VEE
V2 U=15 V
SUB1 voff=30e-6 ib=15e-9 ioff=12e-9 rd=4e6 cd=1.4e-12 cmrrdc=1778279.4 fcmz=2009.0 aoldc=1778279.4 gbp=8e6 fp2=17e6 pslewr=2.8e6 nslewr=2.8e6 vcc=15 vee=-15 vccm=14 veem=-14 ro=75 idcoutm=32e-3
vout_ua741
R3 R=4.7k
R4 R=4.7k MOD
VCC
VEE
Equation
dc simulation
DC1
number 1
vout_op27.V -3.87e-05
vout_ua741.V 0.001
ac simulation
AC1 Type=log Start=1 Hz Stop=100MHz Points=161
SUB2 voff=0.7e-3 ib=80e-9 ioff=10e-9 rd=2e6 cd=1.4e-12 cmrrdc=31622.77 fcmz=200.0 aoldc=199526.3 gbp=1e6 fp2=3e6 pslewr=0.5e6 nslewr=0.5e6 vcc=15 vee=-15 vccm=14 veem=-14 ro=75 idcoutm=34e-3
vout_ua741.v vout_op27.v
0.5
gain_ua741 gain_op27
-20
-40
200
phase_ua741 phase_op27
100
Figure 16.12: Unity gain OP AMP test circuit and waveforms 514
R3 R=rp
vout_ua741
R4 R=rp
vout_op27
C2 C=1 uF V3 U=15 V
R1 R=1k MOD
VCC
MOD
VCC
V2 U=15 V VEE
V4 U=15 V VEE
SUB1 voff=0.7e-3 ib=80e-9 ioff=10e-9 rd=2e6 cd=1.4e-12 cmrrdc=31622.77 fcmz=200.0 aoldc=199526.3 gbp=1e6 fp2=3e6 pslewr=0.5e6 nslewr=0.5e6 vcc=15 vee=-15 vccm=14 veem=-14 ro=75 idcoutm=34e-3
Parameter sweep
SW1 Sim=DC1 Type=log Param=rp Start=1e3 Stop=1e9 Points=31
dc simulation
DC1
SUB2 voff=30e-6 ib=15e-9 ioff=12e-9 rd=4e6 cd=1.4e-12 cmrrdc=1778279.4 fcmz=2009.0 aoldc=1778279.4 gbp=8e6 fp2=17e6 pslewr=2.8e6 nslewr=2.8e6 vcc=15 vee=-15 vccm=14 veem=-14 ro=75 idcoutm=32e-3
15
vout_op27.V vout_ua741.V
10
515
Sp1 = tsweep
Parameter sweep
SW1 Sim=DC1 Type=lin Param=tsweep Start=10 Stop=110 Points=100
0.6
Sp2=Sp1
tscan=Sp2
P1
R2 R=10k Temp=26.85
516
# Qucs 0 . 0 . 12 / media / hda2 /Qucs e q u a t i o n m o d e l l i n g p r j / r d i v t e s t tsweep 3 l . s c h . Def : r d i v sub1 temp n e t 1 n e t 0 t s c a n=27 =10 k Temp= t s c a n Tc1=0 . 01 Tc2=0 . 015 Tnom=26 . 85 R : R2 gnd n e t 0 R R : R1 n e t 1 n e t 0 R =10 k Temp=26 . 85 Tc1=0 . 0 Tc2=0 . 0 Tnom=26 . 85 . Def : End . Def : r d i v t e s t 6 temp n e t 1 n e t 0 sp2=27 Sub : SUB1 n e t 1 n e t 0 Type= r d i v sub1 temp t s c a n=sp2 . Def : End . Def : r d i v sub3 temp n e t 0 n e t 1 sp1=27 Sub : SUB1 n e t 0 n e t 1 Type= r d i v t e s t 6 temp sp2=sp1 . Def : End Vdc : V1 n e t 0 gnd U =1 V . DC : DC1 Temp=26 . 85 r e l t o l =0 . 001 a b s t o l=1 pA v n t o l=1 uV saveOPs=no MaxIter=150 s a v e A l l=no c o n v H e l p e r=none S o l v e r=CroutLU .SW: SW1 Sim=DC1 Type= l i n Param=tsweep Start=10 Stop=110 P o i n t s=100 Sub : SUB1 n e t 0 vp01 Type= r d i v sub3 temp sp1=tsweep
Figure 16.15: Qucs netlist for nested subcircuit showing parameter passing sequence
Probably the most well known non-linear controlled generators are the SPICE 2g6 and 3f5 forms, see A. Vladimirescu, Kaihe Zhang, A.R. Newton, D.O. Pederson and A. Sangiovanni-Vincentelli, SPICE Version 2G Users Guide, 1981, Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, Ca. 94720, section 11, Appendix B: Nonlinear dependent sources., and B. Johnson, T. Quarles, A.R. Newton, D.O. Pederson and A. Sangiovanni-Vincentelli, SPICE3 Version f Users Manual, 1992, Department of Electrical Engineering and Computer Sciences, University of California, Berkeley, Ca. 94720, section 3.2.2.4, Non-linear dependent sources.
517
form of EDD is implemented24 . EDD is an advanced component that allows Qucs users to construct their own device models from a set of equations derived from the physical properties that characterise a device. The explicit form of EDD can only be used to develop models for devices where their dening equations can be transformed into the explicit analysis form required by Qucs25 . A range of functions similar to those dened in the Verilog-A compact device modelling language are provided by Qucs, making the equation modelling language easy to use and powerful. The ternary ? : form of the C language if statement has also been implemented to allow selection of model equations that change with diering device voltage, current and charge conditions. Before introducing the EDD symbol and its properties consider the following circuit simulation modelling problem: a model for a device is required where the output voltage is a function of two input voltages V IN1 and V IN2 , such that Vout (V IN1 , V IN2 ) = V IN1 V IN2 , where V IN1 and V IN2 can be arbitrary varying voltages. This type of model is dicult to simulate at functional level26 using the pre-version 0.0.12 built-in devices. A linear voltage controlled voltage source can be used to multiply a voltage by a constant. Multiplying by a second voltage is not possible with the linear controlled sources. Qucs AM modulated and PM modulated sources are the nearest that Qucs has to the source dened above. These sources however, only allow sinusoidal carrier signals. Illustrated in Fig. 16.16 is a four quadrant multiplier EDD which allows multiplication of two varying signals27 . The EDD device generates current I 1 = V 2 V 3. This in turn is transformed to the output voltage by a unity gain current controlled voltage source SRC1. An EDD device can consist of up to 8 branches. The branches have currents, I1 to I8, voltages V1 to V8 and internal charges Q1 to Q8 respectively. Overall the total device current depends how these branches are connected. A similar comment applies to the total device charge. In Fig. 16.16 currents I2 and I3 are set to zero, charges Q2 and Q3 are also zero, and voltages V 2 = V IN1 and V 3 = V IN2 . Hence current I1 becomes the multiplication of V IN1 and V IN2 . The fact that currents I2 and I3 are set to zero implies that the terminals connected to the external input voltages have high impedance and act as voltage probes. The test circuit in Fig. 16.16 is shown with signal inputs generated by sinusoidal oscillators; V1 acts as a modulating signal and V2 as a carrier signal. The bottom right hand corner of Fig. 16.16 includes a second graph which illustrates the eect
24
(16.11)
See Qucs Technical Papers, Section 10.7: Equation dened models, Stefan Jahn, Michael Margraf, Vincent Habchi and Raimund Jacob, http://qucs.sourceforge.net/technical.html. 25 The Y parameters of the device being modelled must also exist for the explicit form of the EDD to be valid. 26 It is, of course, possible to model the multiplier operation at discrete component level e.g. using a Gilbert cell mixer circuit. 27 This model is based on an idea suggested by Stefan Jahn, during the EDD development phase.
518
SRC1 G=1
2
1 vmul_2_tb:Out.Vt
In1 Num=2
3
In2 Num=3
Figure 16.16: Qucs EDD four quadrent multiplier model and test circuit
Each branch can be a function of one or more of these circuit variables but not necessarily all three at the same time.
519
The total terminal current is the sum of the individual branch currents. Equations for the three branch currents are given by the following equations: I = I 1 + IC + IL, where I 1 = f (V ), IC = C (V, I ) Also V 1 = i2, V 2 = IL, i2 = L(I ) Giving IL = and VL=V2=V1= Hence I = f (V ) + C (V, I ) 1 L(I ) V 2 dt d dt V 1 dt (16.15) dV 1 dQ1 = dt dt (16.12)
(16.13)
dV 2 dIL , V 1 = L(I ) dt dt
(16.14)
(16.16)
dV 1 1 + dt L(I )
(16.17)
The EDD is characterised by eight parallel branches each comprising a current component In and a charge component Qn, where n ranges from 1 to 8. The currents may be constants or dened by equations that are functions of the EDD branch voltages (these are designated V 1 to V 8). This form of the EDD component is known as the explicit EDD model. Please note, EDD currents cannot be functions of current. However, with release 0.0.12 implementation of the explicit EDD the device charge can be a function of either voltage or current29 . The current in the resistive branch being a function of EDD voltage allows a range of two terminal30 devices to be modelled, allowing, for example, nonlinear resistors and diode models to be easily developed. Similarly, the fact that the EDD charge can be a function of voltage or current extends the range of allowed Qucs capacitor types opening new areas of application. The same comments apply to the nonlinear inductors where components that have inductance values which are functions of current allow modelling of nonlinear transformer and coupled inductor eects. This was not possible with earlier Qucs releases. The EDD current and charge values may be dened by symbolic equations that include the operators and functions listed in the Short description of mathematical functions entry in the Qucs help index31 .
29
This allows modelling of semiconductor capacitive eects where the amount of stored charge is either a function of voltage (depletion layer capacitance), or a function of current (diusion capacitance). 30 The number of device terminals can be increased to model transistors and other devices. 31 The Qucs operators and functions are a superset of those dened in the Verilog-A language manual. However, in some cases the name of the operator or function diers slightly. For example Verilog-A uses pow(x, y ) for the power function whilst Qucs uses to denote xy . An example of diering function names are the inverse trigonometric functions. A list of the available functions is given in Appendix A.
520
I IC Q C1 C=f(V,I)
I1 R1 R=f(V)
IL L1 L=f(I)
V1
V1
D2 I1=0 Q1=L(I)*V2
1
V2
Gyrator
Figure 16.17: A non-linear two terminal branch with parallel resistive, capacitive and inductive components
521
Which in terms of an if then else type statement is equivalent to: I1 = V1/( if (V1 < 1.0) then 1000 else if (V1 < 2.0) then 1000 + 4000*(V1-1) else if (V1 < 5.0) then 5000 else if ((V1 >= 5.0) && (V1 < 6.0)) then 5000 - 4500*(V1-5.0) else 500 )
32
One eect of such a discontinuity is the introduction of rapidly changing circuit conditions which can cause the simulator diculties in converging to a correct solution. Sometimes, if this happens, simulation run times may be dramatically increased or simulation fails altogether.
522
Parameter sweep
Equation Eqn1 R=Vs/Pr1.I
dc simulation
DC1
Vs
V1 U=Vs
Pr1
D1 I1=V1/((V1<1.0) ? 1000 : (V1<2.0) ? 1000+4000*(V1-1) : (V1<5.0) ? 5000 : ((V1 >=5.0) && (V1<6.0)) ? 5000-4500*(V1-5.0) : 500)
1
0.1 5e3
0.01 4e3
Pr1.I
1e-4
1e-5
1e-6
523
33
The details of these polynomial functions are presented in Test Reports 4 and 5 of the SPICE to Qucs testing Series, Mike Brinson, http://qucs.sourceforge.net/docs.html. 34 SPICE 2g6 allows up to twenty coecients. Simply add more higher order terms to the Qucs polynomial if required.
524
V2 U=1 V V1 U=Vb
Vout
R1 R=1k
dc simulation
DC1
Vb 1 2 3 4 5 6 7 8 9 10
Vout.V 1 2 3 4 5 6 7 8 9 10
ac simulation
AC1 Type=log Start=1 Hz Stop=10kHz Points=201
Parameter sweep
SW1 Sim=AC1 Type=lin Param=Vb Start=1 Stop=10 Points=10
PIN1
Vout.v
0.5
200
Ph_Vout
150
525
P_inp1
1
P_inn1
IND=L+L2*I(L)+L3*I(L)^2+L4*I(L)^3
Pr1
transient simulation
TR1 Type=lin Start=0 Stop=4 us
Parameter sweep
SW1 Sim=TR1 Type=lin Param=vin Start=0 Stop=100 Points=3
dc simulation
DC1
Pr2
L1 L=1e-6
100
in.Vt
-100 0 5e-7 1e-6 1.5e-6 2e-6 time 2.5e-6 3e-6 3.5e-6 4e-6
Pr1.It
Pr2.It
20
526
(16.18)
Id = Is + Vd GM IN,
(16.19)
Id = IBV,
(Vd = BV )
(16.20)
(Vd < BV ).
(16.21)
The SPICE 2g6 and 3f5 device parameters are a subset of those commonly provided with current generation of circuit simulators, including Qucs. 36 A second three terminal MESFET transistor example is available for downloading from the Qucs Web site. 37 These equations are for the SPICE 2g6 diode model, see Giuseppe Massobrio, Chapter 1, Pn-junction diode and Schottky diode, Semiconductor device modeling with SPICE, Edited by Paolo Antognetti, Giuseppe Massobrio, 1988, McGraw-Hill,Inc, ISBN 0-07-002107-4.
527
GM IN = a small conductance in parallel with the diode38 V t = kB T /q , where T is the diode temperature in Kelvin, kB is Boltzmanns constant and q the charge on the electron. BV = reverse breakdown voltage (positive number) IBV = reverse breakdown current (positive number). Figure 16.21 gives the EDD model for the experimental semiconductor diode. The ternary operator ?: is used to select the correct equation for each diode operating region. The diode current Id : content.tex, v 1.22007/06/0316 : 58 : 59elaExp is the sum of EDD branch currents I 1 to I 4, where I 1 represents the diode forward bias region, I 2 the reverse bias region and I 3 plus I 4 the diode reverse bias breakdown region. When calculating diode current a special form of the exponential function exp(), called limexp(), is employed to assist Qucs to converge to a solution during DC and transient large signal analysis. The function limexp() linearises the exponential function at large argument values minimising the possibility of oating point overow and generation of software exceptions. The Id Vd characteristic curves shown in Fig. 16.21 are for the forward bias region with series resistance rs set to 0.01. For completeness the simulation data for the Qucs built-in diode are also given. Clearly the two sets of results are very similar. The DC simulation results for the diode reverse breakdown region of operation are shown in Fig. 16.22. Again for comparison an Id Vd plot for the Qucs built-in diode is also provided. In this region of operation some slight dierences are apparent: although for both devices the reverse breakdown is very close to 100V the slope of the Id V d curve at negative voltages beyond -BV is dierent, emphasising that the SPICE diode model does not model breakdown or zener eects well39 . The next stage in the development of the diode model is to add capacitance eects: depletion layer capacitance for the reverse bias region and diusion capacitance for the forward bias region. Diode capacitance is given by: Depletion layer capacitance Cdep = Vd dQdep = Area Cj 0 1 dVd Vj
m
(16.22)
(16.23)
GMIN is added to help Qucs DC convergence. The SPICE default value is 1e-12S. See Steven M. Sandler, SPICE subcircuit accurately models zener characteristics, Personal Engineering, November 1998, pp 45-48 for more information on this subject.
528
PANODE1
RS1 R=rs
D2 I1=(V1>-5.0*n*Vt) ? Is*(limexp(V1/(n*Vt))-1.0)+V1*GMIN : 0 Q1=0 I2=(-BV<V1) ? (V1<-5.0*n*Vt) ? -Is+V1*GMIN : 0 : 0 Q2=0 I3=(V1==-BV) ? -IBV : 0 Q3=0 I4=(V1<-BV) ? -Is*(limexp(-(BV+V1)/Vt)-1.0+BV/Vt) : 0 Q4=0
Vs U=Vd
dc simulation
DC1
PCATHODE1
Pr2 Pr1 SUB1 n=1.0 rs=0.01 Is=1e-14 BV=100.0 IBV=1e-3 Vj=1.0 D1 Is=1e-14 A N=1 Vj=1.0 Rs=0.01 Bv=100.00 Ibv=1e-3
Parameter sweep
SW1 Sim=DC1 Type=lin Param=Vd Start=0 Stop=1 Points=190
10
Id (A)
-20
10
ID_Q (A)
-20
Figure 16.21: Compact diode model DC test circuit and simulation results: SUB1 is the EDD diode model and D1 the Qucs diode model with the same parameters as SUB1. 529
-5
Id (A)
-50
Figure 16.22: Compact diode model DC simulation results for the reverse breakdown region of operation Where the total stored charge Qd = Qdep + Qdif f . Using the same notation as the SPICE diode model:
Qdif f = tt Id
Vd
Qdep = Area Cj 0
0
Vd Vj
dV,
1 (ax + b)1+n and simplifying yields: Using integration formula (ax + b) dx = a 1+n
n
Qdep
Area Cj 0 Vj Vd = 1 1 1m Vj
1m
(16.26)
Qdep
F3 +
F C Vj
m Vd Vj
dV,
On integrating
Qdep = Area Cj 0 F 1 +
1 F2
F 3 (Vd F C Vj ) +
m 2 Vj
Vd2 + (F C Vj )2 (16.28)
Where
530
F1 =
Vj 1 (1 F C )1m , F 2 = (1 F C )1+m , F 3 = 1 F C (1 + m) 1m
(16.29)
In these equations: F C = Coecient for forward-bias depletion capacitance. m = Grading coecient. tt = Transit time. Area = Device area. Cj 0 = Zero-bias junction capacitance. Figure 16.23 shows the extended diode model. The Cdep and Cdif f components of the device capacitance have been included in the EDD model as stored charge Q1 and Q2. Again the ternary operator ?: is employed to select the correct equation for each section of the diode DC operating range. An equation block is used to simplify the charge equations through the use of factors F1, F2 and F3.40 . An area factor has also been added to the EDD model in Fig. 16.23. This is introduced to allow simulation of two or more equivalent parallel devices. The diode variables scaled by area are:
Is (A) = Is Area,
Cj 0(A) = Cj 0 Area,
and
rs (A) = rs/Area.
(16.30)
The test circuit shown in Fig. 16.23 illustrates how device capacitance and resistance can be determined as a function of diode bias voltage. Firstly, the diode S parameters are determined at a given bias voltage, secondly these are converted to Y parameters and the diode capacitance (Cap) and resistance (RD) extracted from Y [1, 1], and nally the variation of Cap and RD with diode voltage Vd plotted using the Qucs plotting function PlotVs. Notice that the value of Cap at Vd = 0V agrees with the value of Cj 0. To complete the demonstration EDD diode model all that remains to do is to add temperature dependence to the current and capacitance equations. Circuit simulators normally use two temperatures to determine device temperature dependence; the rst called Tnom represents the temperature that the device parameters were measured, and the second called Temp represents the current device temperature. A high percentage of the diode parameters are temperature dependent. However, to simplify the demonstration diode model only the temperature dependence of parameters Is , V j and Cj 0 will be included
40
In complex current and charge expressions precalculating subexpressions in equation blocks ensures that they are only calculated once at the beginning of a simulation, ensuring minimum run times for an EDD model.
531
Equation
PCATHODE1
Eqn2 GMIN=1e-12 F1=(Vj/(1-m))*(1-(1-FC)^(1-m)) F2=(1-FC)^(1+m) F3=1-FC*(1+m) Vt=vt(300) X1 Vs1 U=Vs P1 Num=1 Z=50 Ohm
D1 I1=(V1>-5.0*n*Vt) ? Is*(limexp(V1/(n*Vt))-1.0)+V1*GMIN : 0 Q1=(V1 < FC*Vj) ? tt*I1+Area*(Cj0*Vj/(1-m))*(1-(1-V1/Vj)^(1-m)) : 0 I2=(-BV<V1) ? (V1<-5.0*n*Vt) ? -Is+V1*GMIN : 0 : 0 Q2=(V1 >= FC*Vj) ? tt*I1+Area*Cj0*(F1+(1/F2)*(F3*(V1-FC*Vj)+(m/(2*Vj))*(V1*V1-FC*FC*Vj*Vj))) : 0 I3=(V1==-BV) ? -IBV : 0 Q3=0 I4=(V1<-BV) ? -Is*(limexp(-(BV+V1)/Vt)-1.0+BV/Vt) : 0 Q4=0
S parameter simulation
SP1 Type=const Values=[100 kHz] Equation 1e12 Rd ( ) 5e11 0 -4 -3 -2
Cap (F)
LN_RD
dc simulation
DC1
Vd (V)
Vd
Pr1 SUB1 n=1.0 rs=0.01 Is=1e-14 BV=100.0 IBV=1e-3 Vj=1.0 Cj0=1e-12 FC=0.5 tt=1e-12 Area=1 m=0.5
Parameter sweep
SW1 Sim=SP1 Type=lin Param=Vs Start=-4 Stop=0.8 Points=200
1e-11
5e-12
0 -4 -3 -2 Vd (V) -1 0 1
20
0 -1 0 1 -4 -3 -2 -1 VD (V) 0 1
532
in the model. Adding extra temperature dependence to the diode model is left to readers as an exercise41 . One of the great advantages of the EDD style of modelling is that it is interactive allowing easy experimentation with models to any given level. The following equations list the temperature dependence of Is , V j and Cj 0. Let T1 = Tnom and T2 = Temp, then Is (T 2) = Is (T 1) T2 T1
XT I n
exp
q Eg (300) kB T 2
T2 T1
(16.31)
T2 2 kB T 2 V j (T 2) = V j (T 1) ln T1 q
T2 T1
1.5
T2 Eg (T 1) Eg (T 2) T1
(16.32)
V j (T 2) V j (T 1) V j (T 1)
(16.33)
In these equations: XT I = Saturation current temperature exponent. 7.02e 4 T 2 , the energy gap. Eg (T ) = EG(0) 1108 + T Figure 16.24 shows the extended EDD for the experimental diode model. Again the limexp() function is used in preference to the standard exp() function in the temperature calculations listed in equations block Eqn2. The test circuit in Fig. 16.24 sweeps the device temperature from 20 to 80 degrees Centigrade. The graph inlay illustrates the experimental diode current Id plotted as a function of temperature. The temperature of the built-in Qucs diode is held constant, at room temperature, and its current Id Q plotted as an overlay. The two curves cross at room temperature, indicating identical currents at this temperature.
41
533
Pr2
dc simulation
DC1
Vs U=0.6
Pr1 SUB1 n=1.0 rs=0.01 Is=1e-14 BV=100.0 IBV=1e-3 Vj=1.0 Cj0=1e-12 m=0.5 Area=1 FC=0.5 tt=1e-12 XTI=3.0 Tnom=26.85 Temp=Temp_sw Eg=1.16
D1 Is=1e-14 A N=1 Cj0=1e-12 Vj=1.0 Rs=0.01 Bv=100.00 Ibv=1e-3 Temp=26.85 Xti=3.0 Eg=1.11 Tnom=26.85 Area=1
Parameter sweep
SW2 Sim=DC1 Type=lin Param=Temp_sw Start=-20 Stop=80 Points=100
1e-8 -20
20 40 Temp (Centigrade)
60
80
D2 I1=(V1>-5.0*n*Vt) ? Area*Is_T2*(limexp(V1/(n*Vt))-1.0)+V1*GMIN : 0 Q1=(V1 < FC*Vj) ? tt*I1+Area*(Cj0_T2*Vj_T2/(1-m))*(1-(1-V1/Vj_T2)^(1-m)) : 0 I2=(-BV<V1) ? (V1<-5.0*n*Vt) ? -Area*Is_T2+V1*GMIN : 0 : 0 Q2=(V1 >= FC*Vj) ? tt*I1+Area*Cj0_T2*(F1+(1/F2)*(F3*(V1-FC*Vj_T2)+(m/(2*Vj_T2))*(V1*V1-FC*FC*Vj_T2*Vj_T2))) : 0 I3=(V1==-BV) ? -IBV : 0 Q3=0 I4=(V1<-BV) ? -Area*Is_T2*(limexp(-(BV+V1)/Vt)-1.0+BV/Vt) : 0 Q4=0
PCATHODE1 Equation Equation Eqn2 Cj0_T2=Cj0*(1+m*(400e-6*(T2-T1)-(Vj_T2-Vj)/Vj)) rs_AREA=rs/AREA GMIN=1e-12 A=7.02e-4 B=1108 T1=Tnom+273.15 Vj_T2=(T2/T1)*Vj-(2*kB*T2/q)*ln((T2/T1)^1.5)-((T2/T1)*Eg_T1-Eg_T2) Is_T2=Is*(T2/T1)^(XTI/n)*limexp((-(q*Eg)/(kB*T2))*(1-T2/T1)) Eg_T1=Eg-A*T1*T1/(B+T1) Eg_T2=Eg-A*T2*T2/(B+T2) T2=Temp+273.15
534
535
Operators
536
Functions 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. ln(x) natural logarithm log10(x) decimal logarithm [log(x)] exp(x) exponential function base e sqrt(x) square root min(x,y) minimum max(x,y) maximum abs(x) absolute value sin(x) sine cos(x) cosine tan(x) tangent arcsin(x) inverse sine [asin(x)] arccos(x) inverse cosine [acos(x)] arctan(x[,y]) inverse tangent [atan2(x,y)] sinh(x) hyperbolic sine cosh(x) hyperbolic cosine tanh(x) hyperbolic tangent arsinh(x) inverse hyperbolic sine [asinh(x)] arcosh(x) inverse hyperbolic cosine [acosh(x)] artanh(x0 inverse hyperbolic tangent [atanh(x)] limexp(x) argument limited exponential function hypot(x,y) Euclidean distance function
537
16.15.1 Enter the series resonance circuit and add input and output pins
538
539
540
16.15.4 Add the names of the subcircuit parameters to the LCR symbol
Right click on the SUB / File=name caption and enter names of subcircuit parameters with their default values.
Figure 16.29: Stage 4: entering subcircuit parameter names and default values
Figure 16.30: Stage 4: resulting subcircuit and parameter list with default values
541
LCR
O
Vout
dc simulation
DC1
ac simulation
AC1 Type=log Start=100 Hz Stop=100kHz Points=100
Parameter sweep
SW1 Sim=AC1 Type=lin Param=R_SW Start=1 Stop=10 Points=10
Vout.v
0.5
100
gain
542