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.
The basic steps involved with using gEDA as the frontend for SWITCAP simulations are:
You will need the following programs to be installed:
$prefix/share/gEDA/sym/switcap
exists. $prefix
is the installation prefix for gEDA on your system.sw
. 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.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 must include the following elements on your schematic:
You can also optionally add the following SWITCAP special symbols to your schematic:
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.
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.
To extract the SWITCAP netlist, run:
gnetlist -g switcap -o test.scn file1.sch [file2.sch ...]
For the example file contained in this archive, you can run:
gnetlist -g switcap -o example.scn ckt.sch clocks.sch analysis.sch
The netlist will be left in example.scn.
I typically use something like:
printf "example.scn\nexample.out\n" | sw
so I can use command history to rerun SWITCAP without having to manually type the file names each time.
Refer to the SWITCAP manual for more details.
Ideal capacitor. Attributes:
Ideal switch. Attributes:
Attributes:
Attributes:
Attributes:
Attributes:
Only a single instance of this symbol is allowed.
This symbol will cause a specified file containing SWITCAP analysis commands to be included in the output netlist. Attributes:
Attributes:
Only a single instance of this symbol is allowed.
Attributes:
Only a single instance of this symbol is allowed.
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.
Figure 5/6: Simulation Results - Transient MISSING
Figure 1 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).
Figure 2 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.
Figure 3 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. Figure 4 shows the contents of the test.ana file.
To netlist the design, run:
gnetlist -g switcap -o example.scn ckt.sch clocks.sch analysis.sch
Run the simulation with:
printf "example.scn\nexample.out\n" | sw
Convert the SWITCAP output file to something gwave can read by running:
sw2asc example.out
Start up the gwave program and load the first sinusoidal steady state result by running:
gwave example.out.SSS.1.asc
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:
gwave example.out.TRAN.1.asc
April 13th, 2003 | Created switcap.tex |