1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
13 <h1 id=
"gedagafswitcapsymbolsandnetlister">gEDA/gaf Switcap Symbols and Netlister
</h1>
21 This document is released under GFDL
30 <h2 id=
"overview">Overview
</h2>
34 This document describes the symbol library and gnetlist backend which supports driving SWITCAP simulations from the gEDA/gaf system. SWITCAP is a switched capacitor circuit simulator available from Columbia University. It is used in many classroom and research environments. One drawback to SWITCAP is the lack of a freely available schematic capture frontend. The gEDA/gaf SWITCAP symbol library and gnetlist backend tries to fill that gap.
<br/>
36 The basic steps involved with using gEDA as the frontend for SWITCAP simulations are:
39 <li class=
"level1"><div class=
"li"> Create schematics of the circuit.
</div>
41 <li class=
"level1"><div class=
"li"> Create an analysis file.
</div>
43 <li class=
"level1"><div class=
"li"> Extract the netlist.
</div>
45 <li class=
"level1"><div class=
"li"> Run the SWITCAP simulation.
</div>
47 <li class=
"level1"><div class=
"li"> Run
<strong>sw2asc
</strong> to extract the results.
</div>
49 <li class=
"level1"><div class=
"li"> View the results with
<strong>gwave
</strong>.
</div>
55 <h2 id=
"requirements">Requirements
</h2>
59 You will need the following programs to be installed:
62 <li class=
"level1"><div class=
"li"> A recent version of gEDA/gaf. To see if your version is recent enough, see if the directory
<strong><code>$prefix/share/gEDA/sym/switcap
</code></strong> exists.
<strong><code>$prefix
</code></strong> is the installation prefix for gEDA on your system.
</div>
64 <li class=
"level1"><div class=
"li"> SWITCAP. The executable is usually called
<strong><code>sw
</code></strong>. If you do not have SWITCAP available on your system, you will need to contact Columbia University to obtain a copy. The gEDA/gaf SWITCAP support was tested with SWITCAP Version A
.5R Release
21-Sep-
87.
</div>
66 <li class=
"level1 node"><div class=
"li"> Although it is optional, you may wish to install a tool which can be used for plotting the output data. SWITCAP produces both ASCII data listings as well as ugly ASCII plots (note the release date of the version of SWITCAP used). Suitable tools are:
</div>
68 <li class=
"level2"><div class=
"li"> Gwave. Gwave is an analog waveform viewer. It is fairly basic, but easy to use, includes cursors, and has zoom/pan features. See
<strong>http:
<em>www.geda-project.org
<strong>
69 - Scilab. Similar to matlab. Powerful, but no cursors or panning. See
</strong>http:
</em>www-rocq.inria.fr/scilab
</strong></div>
71 <li class=
"level2"><div class=
"li"> Octave. Similar to matlab. See
<strong>http:
<em>www.octave.org
<strong>
72 - Grace. See
</strong>http:
</em>plasma-gate.weizmann.ac.il/Grace/
</strong></div>
80 <h2 id=
"creatingschematics">Creating Schematics
</h2>
85 <h3 id=
"requiredsymbols">Required Symbols
</h3>
89 This section assumes you are familiar with using gschem to create and edit schematics. SWITCAP netlisting is only supported for the components contained in the SWITCAP symbol library as well as the ground symbol found in the
'power
' library which comes with gEDA. All allowed SWITCAP elements except for subcircuits are supported. You
<em>must
</em> include the following elements
93 <li class=
"level1"><div class=
"li"> One instance of the switcap-timing symbol. This symbol will set the master clock period for your simulations.
</div>
95 <li class=
"level1"><div class=
"li"> One or more instances of the switcap-clock symbol. This symbol defines a clock with a particular phase and period. The reference designator of the clock symbol is used by the switches to set what phase they switch on.
</div>
97 <li class=
"level1"><div class=
"li"> One or more instances of the switcap-analysis symbol. This symbol defines an analysis by specifying a file to include in the SWITCAP netlist. By including multiple instances of this symbol, multiple analysis files may be included.
</div>
103 <h3 id=
"optionalsymbols">Optional Symbols
</h3>
107 You can also optionally add the following SWITCAP special symbols to your schematic:
110 <li class=
"level1"><div class=
"li"> Zero or one instance of the switcap-title symbol. This will add a TITLE: line to the SWITCAP netlist and will appear in the output file.
</div>
112 <li class=
"level1"><div class=
"li"> Zero or one instance of the switcap-options symbol. By editing the OPTIONS attribute on this symbol you can set the various options which can be passed to SWITCAP.
</div>
118 <h3 id=
"netnames">Net Names
</h3>
122 When creating schematics to drive SWITCAP, you should name all nets that you wish to plot. To avoid possible conflicts with unnamed nets, you should avoid using purely numerical names for nets because all unnamed nets will be assigned (somewhat randomly) numbers without checking for possible conflicts with explicitly named nets. SWITCAP limits the length of node names to
7 characters.
127 <h3 id=
"switches">Switches
</h3>
131 When placing switches on your schematic, you will need to define which clock they are controlled with. This is done by setting the clock attribute on the switch to the reference designator of the clock which should control it.
136 <h2 id=
"extractingtheswitcapnetlist">Extracting the SWITCAP Netlist
</h2>
140 To extract the SWITCAP netlist, run:
142 <pre class=
"code">gnetlist -g switcap -o test.scn file1.sch [file2.sch ...]
</pre>
145 For the example file contained in this archive, you can run:
147 <pre class=
"code">gnetlist -g switcap -o example.scn ckt.sch clocks.sch analysis.sch
</pre>
150 The netlist will be left in
<strong>example.scn
</strong>.
155 <h2 id=
"runningswitcap">Running SWITCAP
</h2>
159 I typically use something like:
161 <pre class=
"code">printf
"example.scn\nexample.out\n
" | sw
</pre>
164 so I can use command history to rerun SWITCAP without having to manually type the file names each time.
<br/>
166 Refer to the SWITCAP manual for more details.
171 <h2 id=
"appendixa--symbolsinthelibrary">Appendix A -- Symbols in the Library
</h2>
176 <h3 id=
"capacitorsswitcap-capacitor">Capacitors (switcap-capacitor)
</h3>
180 Ideal capacitor. Attributes:
183 <li class=
"level1"><div class=
"li"> <strong>C
</strong>=capacitance. Required. Specifies filename to be included.
</div>
185 <li class=
"level1"><div class=
"li"> <strong>refdes
</strong>=reference designator. Required. Must start with
"C
" and be unique.
</div>
191 <h3 id=
"switchesswitcap-switch">Switches (switcap-switch)
</h3>
195 Ideal switch. Attributes:
198 <li class=
"level1"><div class=
"li"> <strong>clock
</strong>=Controlling clock. Required. Specifies which clock controls this switch.
</div>
200 <li class=
"level1"><div class=
"li"> <strong>refdes
</strong>=reference designator. Required. Must start with
"S
" and be unique.
</div>
206 <h3 id=
"independentvoltagesourcesswitcap-vsrc">Independent Voltage Sources (switcap-vsrc)
</h3>
213 <li class=
"level1"><div class=
"li"> <strong>refdes
</strong>=reference designator. Required. Must start with
"V
" and be unique.
</div>
219 <h3 id=
"dependentvoltagesourcesswitcap-vcvs">Dependent Voltage Sources (switcap-vcvs)
</h3>
226 <li class=
"level1"><div class=
"li"> <strong>gain
</strong>=gain. Required. Specifies the gain of the controlled source.
</div>
228 <li class=
"level1"><div class=
"li"> <strong>refdes
</strong>=reference designator. Required. Must start with
"E
" and be unique.
</div>
234 <h3 id=
"clockspecificationswitcap-clock">Clock Specification (switcap-clock)
</h3>
241 <li class=
"level1"><div class=
"li"> <strong>PSTART
</strong>=starting clock phase. Required. Specifies on what phase of the master clock this clock turns on.
</div>
243 <li class=
"level1"><div class=
"li"> <strong>PSTOP
</strong>=ending clock phase. Required. Specifies on what phase of the master clock this clock turns off.
</div>
245 <li class=
"level1"><div class=
"li"> <strong>PERIOD
</strong>=clock period. Required. Specifies the period of the clock in terms of master clock cycles.
</div>
247 <li class=
"level1"><div class=
"li"> <strong>refdes
</strong>=reference designator. Required. The switches that are controlled by this clock will refer to it by the reference designator. As such, avoid running any reference designator renumbering tools.
</div>
253 <h3 id=
"mastertimingspecificationswitcap-timing">Master Timing Specification (switcap-timing)
</h3>
260 <li class=
"level1"><div class=
"li"> PERIOD=clock period. Required. Specifies the period of the master clock in seconds.
</div>
265 Only a single instance of this symbol is allowed.
270 <h3 id=
"analysisfileincludeswitcap-analysis">Analysis File Include (switcap-analysis)
</h3>
274 This symbol will cause a specified file containing SWITCAP analysis commands to be included in the output netlist. Attributes:
277 <li class=
"level1"><div class=
"li"> <strong>file
</strong>=filename. Required. Specifies filename to be included.
</div>
283 <h3 id=
"simulationtitlespecificationswitcap-title">Simulation Title Specification (switcap-title)
</h3>
290 <li class=
"level1"><div class=
"li"> <strong>TITLE
</strong>=switcap title. Required. Specifies the TITLE line for the SWITCAP netlist.
</div>
295 Only a single instance of this symbol is allowed.
300 <h3 id=
"simulationoptionsspecificationswitcap-options">Simulation Options Specification (switcap-options)
</h3>
307 <li class=
"level1"><div class=
"li"> <strong>OPTIONS
</strong>=switcap options. Required. Specifies the OPTIONS line for the SWITCAP netlist. See the SWITCAP manual for allowed values.
</div>
312 Only a single instance of this symbol is allowed.
317 <h2 id=
"example">Example
</h2>
321 This appendix provides a simple example of the entire process of generating a schematic, producing a SWITCAP netlist, running a simulation, and plotting the results.
323 <div class=
"table sectionedit1"><table class=
"inline">
325 <td class=
"col0"> <a href=
"media/geda/switcap_figure1.jpg" class=
"media" target=
"_blank" title=
"geda:switcap_figure1.jpg">geda:switcap_figure1.jpg
</a> </td>
328 <td class=
"col0"> <a href=
"media/geda/switcap_figure2.jpg" class=
"media" target=
"_blank" title=
"geda:switcap_figure2.jpg">geda:switcap_figure2.jpg
</a> </td>
331 <td class=
"col0"> <a href=
"media/geda/switcap_figure3.jpg" class=
"media" target=
"_blank" title=
"geda:switcap_figure3.jpg">geda:switcap_figure3.jpg
</a> </td>
334 <td class=
"col0"> <a href=
"media/geda/switcap_figure4.jpg" class=
"media" target=
"_blank" title=
"geda:switcap_figure4.jpg">geda:switcap_figure4.jpg
</a> </td>
337 <!-- EDIT1 TABLE [7420-7555] -->
339 Figure
5/
6: Simulation Results - Transient MISSING
344 <h3 id=
"exampleschematics">Example Schematics
</h3>
348 <strong>Figure
1</strong> shows the schematic of a simple switched capacitor circuit. Note that some switches, S1 and S3 for example, are controlled by CLK1 while others, S2 and S4 for example, are controlled by the complement of CLK1 (#CLK1).
<br/>
350 <strong>Figure
2</strong> shows the definition of a clock and the master clock. Here we define a master clock period (mcp) of
1.0 μs in the timing block. In the clock definition symbol, we define a clock called CLK1 that has a period equal to
1 master clock period (mcp). The phase of CLK1 turning on switches is
0 and the phase of CLK1 turning off switches is
3/
8 mcp. Additional clock phases can be defined by creating more instances of the clock definition symbol.
<br/>
352 <strong>Figure
3</strong> shows an instantiation of the title block symbol which will cause
"my title
" to be used in the TITLE line in the SWITCAP netlist. Figure
3 also shows an instantiation of an analysis block which directs the netlister to include the contents of the file test.ana in the output netlist.
<strong>Figure
4</strong> shows the contents of the test.ana file.
357 <h3 id=
"netlistthedesign">Netlist the Design
</h3>
361 To netlist the design, run:
363 <pre class=
"code">gnetlist -g switcap -o example.scn ckt.sch clocks.sch analysis.sch
</pre>
367 <h3 id=
"runthesimulation">Run the Simulation
</h3>
371 Run the simulation with:
373 <pre class=
"code">printf
"example.scn\nexample.out\n
" | sw
</pre>
377 <h3 id=
"processtheresults">Process the Results
</h3>
381 Convert the SWITCAP output file to something gwave can read by running:
383 <pre class=
"code">sw2asc example.out
</pre>
387 <h3 id=
"plottheresults">Plot the Results
</h3>
391 Start up the gwave program and load the first sinusoidal steady state result by running:
393 <pre class=
"code">gwave example.out.SSS
.1.asc
</pre>
396 Drag the two waveforms onto the two waveform panels and change the x-axis to a log scale. Figure
5 shows the output. Start up the gwave program and load the transient result by running:
398 <pre class=
"code">gwave example.out.TRAN
.1.asc
</pre>
402 <h2 id=
"documentrevisionhistory">Document Revision History
</h2>
404 <div class=
"table sectionedit2"><table class=
"inline">
406 <td class=
"col0"> April
13th,
2003 </td><td class=
"col1"> Created switcap.tex
</td>
409 <!-- EDIT2 TABLE [9488-9530] -->