Repository: hausen/circuit-simulator Branch: master Commit: 293216aaee13 Files: 381 Total size: 548.9 KB Directory structure: gitextract_yobno83y/ ├── .gitignore ├── README.md └── src/ ├── ACRailElm.java ├── ACVoltageElm.java ├── ADCElm.java ├── AnalogSwitch2Elm.java ├── AnalogSwitchElm.java ├── AndGateElm.java ├── AntennaElm.java ├── BoxElm.java ├── CC2Elm.java ├── CapacitorElm.java ├── ChipElm.java ├── CirSim.java ├── Circuit.java ├── CircuitCanvas.java ├── CircuitElm.java ├── CircuitLayout.java ├── CircuitNode.java ├── CircuitNodeLink.java ├── ClockElm.java ├── CounterElm.java ├── CurrentElm.java ├── DACElm.java ├── DCVoltageElm.java ├── DFlipFlopElm.java ├── DecadeElm.java ├── DiacElm.java ├── Diode.java ├── DiodeElm.java ├── EditDialog.java ├── EditDialogLayout.java ├── EditInfo.java ├── EditOptions.java ├── GateElm.java ├── GraphicElm.java ├── GroundElm.java ├── ImportExportAppletDialog.java ├── ImportExportClipboardDialog.java ├── ImportExportDialog.java ├── ImportExportDialogFactory.java ├── ImportExportDialogLayout.java ├── ImportExportFileDialog.java ├── Inductor.java ├── InductorElm.java ├── InverterElm.java ├── JKFlipFlopElm.java ├── JfetElm.java ├── LEDElm.java ├── LampElm.java ├── LatchElm.java ├── LogicInputElm.java ├── LogicOutputElm.java ├── Makefile ├── Manifest.txt ├── MemristorElm.java ├── MosfetElm.java ├── NJfetElm.java ├── NMosfetElm.java ├── NTransistorElm.java ├── NandGateElm.java ├── NorGateElm.java ├── OpAmpElm.java ├── OpAmpSwapElm.java ├── OrGateElm.java ├── OutputElm.java ├── PMosfetElm.java ├── PTransistorElm.java ├── PhaseCompElm.java ├── PhotoResistorElm.java ├── PotElm.java ├── ProbeElm.java ├── PushSwitchElm.java ├── RailElm.java ├── RelayElm.java ├── ResistorElm.java ├── RowInfo.java ├── SCRElm.java ├── Scope.java ├── SevenSegElm.java ├── SparkGapElm.java ├── SquareRailElm.java ├── SweepElm.java ├── Switch2Elm.java ├── SwitchElm.java ├── TappedTransformerElm.java ├── TextElm.java ├── ThermistorElm.java ├── TimerElm.java ├── TransLineElm.java ├── TransformerElm.java ├── TransistorElm.java ├── TriacElm.java ├── TriodeElm.java ├── TunnelDiodeElm.java ├── VCOElm.java ├── VarRailElm.java ├── VoltageElm.java ├── WireElm.java ├── XorGateElm.java ├── ZenerElm.java ├── circuits/ │ ├── 3-cgand.txt │ ├── 3-cgor.txt │ ├── 3-f211.txt │ ├── 3-f220.txt │ ├── 3-f221.txt │ ├── 3-invert.txt │ ├── 3way.txt │ ├── 4way.txt │ ├── 555int.txt │ ├── 555lowduty.txt │ ├── 555missing.txt │ ├── 555monostable.txt │ ├── 555pulsemod.txt │ ├── 555saw.txt │ ├── 555schmitt.txt │ ├── 555sequencer.txt │ ├── 555square.txt │ ├── 7segdecoder.txt │ ├── allpass1.txt │ ├── allpass2.txt │ ├── amdetect.txt │ ├── amp-dfdx.txt │ ├── amp-diff.txt │ ├── amp-follower.txt │ ├── amp-fullrect.txt │ ├── amp-integ.txt │ ├── amp-invert.txt │ ├── amp-noninvert.txt │ ├── amp-rect.txt │ ├── amp-schmitt.txt │ ├── amp-sum.txt │ ├── bandpass.txt │ ├── besselbutter.txt │ ├── blank.txt │ ├── butter10lo.txt │ ├── cap.txt │ ├── capac.txt │ ├── capmult.txt │ ├── capmultcaps.txt │ ├── capmultfreq.txt │ ├── cappar.txt │ ├── capseries.txt │ ├── cc2.txt │ ├── cc2imp.txt │ ├── cc2impn.txt │ ├── cc2n.txt │ ├── ccdiff.txt │ ├── cciamp.txt │ ├── ccinductor.txt │ ├── ccint.txt │ ├── ccitov.txt │ ├── ccvccs.txt │ ├── ceamp.txt │ ├── classd.txt │ ├── clockedsrff.txt │ ├── cmosff.txt │ ├── cmosinverter.txt │ ├── cmosinvertercap.txt │ ├── cmosinverterslow.txt │ ├── cmosmsff.txt │ ├── cmosnand.txt │ ├── cmosnor.txt │ ├── cmostransgate.txt │ ├── cmosxor.txt │ ├── colpitts.txt │ ├── counter.txt │ ├── counter8.txt │ ├── coupled1.txt │ ├── coupled2.txt │ ├── coupled3.txt │ ├── crossover.txt │ ├── cube.txt │ ├── currentsrc.txt │ ├── currentsrcelm.txt │ ├── currentsrcramp.txt │ ├── dac.txt │ ├── darlington.txt │ ├── dcrestoration.txt │ ├── deccounter.txt │ ├── decoder.txt │ ├── delayrc.txt │ ├── deltasigma.txt │ ├── diff.txt │ ├── digcompare.txt │ ├── digsine.txt │ ├── diodeclip.txt │ ├── diodecurve.txt │ ├── diodelimit.txt │ ├── diodevar.txt │ ├── divideby2.txt │ ├── divideby3.txt │ ├── dram.txt │ ├── dtlinverter.txt │ ├── dtlnand.txt │ ├── dtlnor.txt │ ├── eclnor.txt │ ├── eclosc.txt │ ├── edgedff.txt │ ├── filt-hipass-l.txt │ ├── filt-hipass.txt │ ├── filt-lopass-l.txt │ ├── filt-lopass.txt │ ├── filt-vcvs-hipass.txt │ ├── filt-vcvs-lopass.txt │ ├── flashadc.txt │ ├── follower.txt │ ├── freqdouble.txt │ ├── fulladd.txt │ ├── fullrect.txt │ ├── fullrectf.txt │ ├── graycode.txt │ ├── grid.txt │ ├── grid2.txt │ ├── gyrator.txt │ ├── halfadd.txt │ ├── hartley.txt │ ├── hfadc.txt │ ├── howland.txt │ ├── impedance.txt │ ├── indmultfreq.txt │ ├── indmultind.txt │ ├── indpar.txt │ ├── indseries.txt │ ├── induct.txt │ ├── inductac.txt │ ├── inductkick-block.txt │ ├── inductkick-snub.txt │ ├── inductkick.txt │ ├── inv-osc.txt │ ├── invertamp.txt │ ├── itov.txt │ ├── jfetamp.txt │ ├── jfetcurrentsrc.txt │ ├── jfetfollower-nooff.txt │ ├── jfetfollower.txt │ ├── jkff.txt │ ├── johnsonctr.txt │ ├── ladder.txt │ ├── leadingedge.txt │ ├── ledflasher.txt │ ├── lissa.txt │ ├── logconvert.txt │ ├── longdist.txt │ ├── lrc-critical.txt │ ├── lrc.txt │ ├── majority.txt │ ├── masterslaveff.txt │ ├── mirror.txt │ ├── moscurrentramp.txt │ ├── moscurrentsrc.txt │ ├── mosfetamp.txt │ ├── mosfollower.txt │ ├── mosmirror.txt │ ├── mosswitch.txt │ ├── mr-crossbar.txt │ ├── mr-sine.txt │ ├── mr-sine2.txt │ ├── mr-sine3.txt │ ├── mr-square.txt │ ├── mr-triangle.txt │ ├── mr.txt │ ├── multivib-a.txt │ ├── multivib-bi.txt │ ├── multivib-mono.txt │ ├── mux.txt │ ├── mux3state.txt │ ├── nandff.txt │ ├── nic-r.txt │ ├── nmosfet.txt │ ├── nmosinverter.txt │ ├── nmosinverter2.txt │ ├── nmosnand.txt │ ├── norton.txt │ ├── notch.txt │ ├── npn.txt │ ├── ohms.txt │ ├── opamp-regulator.txt │ ├── opamp.txt │ ├── opampfeedback.txt │ ├── opint-current.txt │ ├── opint-invert-amp.txt │ ├── opint-slew.txt │ ├── opint.txt │ ├── peak-detect.txt │ ├── phasecomp.txt │ ├── phasecompint.txt │ ├── phaseseq.txt │ ├── phaseshiftosc.txt │ ├── phasesplit.txt │ ├── pll.txt │ ├── pll2.txt │ ├── pll2a.txt │ ├── pmosfet.txt │ ├── pnp.txt │ ├── pot.txt │ ├── potdivide.txt │ ├── powerfactor1.txt │ ├── powerfactor2.txt │ ├── pushpull.txt │ ├── pushpullxover.txt │ ├── r2rladder.txt │ ├── rectify.txt │ ├── relaxosc.txt │ ├── relay.txt │ ├── relayand.txt │ ├── relayctr.txt │ ├── relayff.txt │ ├── relaymux.txt │ ├── relayor.txt │ ├── relaytff.txt │ ├── relayxor.txt │ ├── res-par.txt │ ├── res-series.txt │ ├── resistors.txt │ ├── ringing.txt │ ├── ringmod.txt │ ├── rossler.txt │ ├── rtlinverter.txt │ ├── rtlnand.txt │ ├── rtlnor.txt │ ├── samplenhold.txt │ ├── sawtooth.txt │ ├── schmitt.txt │ ├── scr.txt │ ├── scractrig.txt │ ├── sine.txt │ ├── sinediode.txt │ ├── spark-marx.txt │ ├── spark-sawtooth.txt │ ├── spikegen.txt │ ├── switchedcap.txt │ ├── switchfilter.txt │ ├── swtreedac.txt │ ├── synccounter.txt │ ├── tdiode.txt │ ├── tdosc.txt │ ├── tdrelax.txt │ ├── tesla.txt │ ├── thevenin.txt │ ├── tl.txt │ ├── tlfreq.txt │ ├── tllight.txt │ ├── tllopass.txt │ ├── tlmatch1.txt │ ├── tlmatch2.txt │ ├── tlmis1.txt │ ├── tlmismatch.txt │ ├── tlstand.txt │ ├── tlterm.txt │ ├── traffic.txt │ ├── trans-diffamp-common.txt │ ├── trans-diffamp-cursrc.txt │ ├── trans-diffamp.txt │ ├── transformer.txt │ ├── transformerdc.txt │ ├── transformerdown.txt │ ├── transformerup.txt │ ├── transswitch.txt │ ├── triangle.txt │ ├── triode.txt │ ├── triodeamp.txt │ ├── ttlinverter.txt │ ├── ttlnand.txt │ ├── ttlnor.txt │ ├── twint.txt │ ├── vco.txt │ ├── voltdivide.txt │ ├── voltdouble.txt │ ├── voltdouble2.txt │ ├── voltinvert.txt │ ├── voltquad.txt │ ├── volttriple.txt │ ├── volume.txt │ ├── wheatstone.txt │ ├── xor.txt │ ├── xorphasedet.txt │ ├── zeneriv.txt │ ├── zenerref.txt │ └── zenerreffollow.txt └── setuplist.txt ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ src/*.class ================================================ FILE: README.md ================================================ circuit-simulator ================= This is a version of Paul Falstad's circuit simulator (original available at ) with the following improvements: * fixed import/export when running as an applet * it is now possible to save/load to/from a file when running as an application * the circuits that appear in the "Circuit" menu may now be bundled with the jar file. * many interface improvements: double click to edit, Delete key to delete a component, cursor changes to crosshairs when in place mode, Esc goes back to move/interact mode, ... * separated keyboard shortcuts from dump types (this makes it easier to configure shortcuts without changing the file format) * WireElm is now a subclass of ResistorElm (without this change, whenever you use two switches in parallel, you get the error "voltage source/wire loop with no resistance") * some cosmetic improvements (like starting with a white background as default) compiling and building ---------------------- If you have make installed, just `cd` to the *src* directory and run `make`, followed by a `make jar` If not, compile with `javac *.java` and build the jar file with `jar cfm circuit.jar Manifest.txt *.class *.txt circuits/` running ------- As an application: `java -jar circuit.jar` If you want to use the circuit simulator as an applet, create an html file and load the applet with: Sorry, you need a Java-enabled browser to see the simulation. If you want to enable import/export of circuit files, you must define two javascript helper functions in the same page: * `exportCircuit(dump)`, whose first parameter is a string describing the circuit in the same format used for the circuit file. * `importCircuit()`, which must return a string describing the circuit in the same format used for the circuit file. The definition of those functions is up to you (for instance, you may copy the string to/from a textarea). terms and conditions -------------------- The terms and conditions for the original code still apply. Check before redistributing or modifying the code. You must always consult the original licensing information but, in case the link is unavailable, here is a copy of the original license (as of 2013-05-08): You have permission to use these applets in a classroom setting or take screenshots as long as the applets are unmodified. Modification or redistribution for non-commercial purposes is allowed, as long as you credit me (Paul Falstad) and provide a link to my page (the page you found the applet(s) on, or http://www.falstad.com/mathphysics.html). Contact me for any other uses. The source code for each applet is generally available on that applet's web page, but some of the applets use third-party source code that has restrictions. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. Rodrigo Hausen's changes are in the public domain (but it would be nice if you credited me alongside Paul if you use this version). ================================================ FILE: src/ACRailElm.java ================================================ class ACRailElm extends RailElm { public ACRailElm(int xx, int yy) { super(xx, yy, WF_AC); } Class getDumpClass() { return RailElm.class; } int getShortcut() { return 0; } } ================================================ FILE: src/ACVoltageElm.java ================================================ class ACVoltageElm extends VoltageElm { public ACVoltageElm(int xx, int yy) { super(xx, yy, WF_AC); } Class getDumpClass() { return VoltageElm.class; } } ================================================ FILE: src/ADCElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class ADCElm extends ChipElm { public ADCElm(int xx, int yy) { super(xx, yy); } public ADCElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "ADC"; } boolean needsBits() { return true; } void setupPins() { sizeX = 2; sizeY = bits > 2 ? bits : 2; pins = new Pin[getPostCount()]; int i; for (i = 0; i != bits; i++) { pins[i] = new Pin(bits-1-i, SIDE_E, "D" + i); pins[i].output = true; } pins[bits] = new Pin(0, SIDE_W, "In"); pins[bits+1] = new Pin(sizeY-1, SIDE_W, "V+"); allocNodes(); } void execute() { int imax = (1< 0) r_on = ei.value; if (n == 2 && ei.value > 0) r_off = ei.value; } } ================================================ FILE: src/AndGateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class AndGateElm extends GateElm { public AndGateElm(int xx, int yy) { super(xx, yy); } public AndGateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } void setPoints() { super.setPoints(); // 0=topleft, 1-10 = top curve, 11 = right, 12-21=bottom curve, // 22 = bottom left Point triPoints[] = newPointArray(23); interpPoint2(lead1, lead2, triPoints[0], triPoints[22], 0, hs2); int i; for (i = 0; i != 10; i++) { double a = i*.1; double b = Math.sqrt(1-a*a); interpPoint2(lead1, lead2, triPoints[i+1], triPoints[21-i], .5+a/2, b*hs2); } triPoints[11] = new Point(lead2); if (isInverting()) { pcircle = interpPoint(point1, point2, .5+(ww+4)/dn); lead2 = interpPoint(point1, point2, .5+(ww+8)/dn); } gatePoly = createPolygon(triPoints); } String getGateName() { return "AND gate"; } boolean calcFunction() { int i; boolean f = true; for (i = 0; i != inputCount; i++) f &= getInput(i); return f; } int getDumpType() { return 150; } int getShortcut() { return '2'; } } ================================================ FILE: src/AntennaElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class AntennaElm extends RailElm { public AntennaElm(int xx, int yy) { super(xx, yy, WF_DC); } public AntennaElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); waveform = WF_DC; } double fmphase; void stamp() { sim.stampVoltageSource(0, nodes[0], voltSource); } void doStep() { sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage()); } double getVoltage() { fmphase += 2*pi*(2200+Math.sin(2*pi*sim.t*13)*100)*sim.timeStep; double fm = 3*Math.sin(fmphase); return Math.sin(2*pi*sim.t*3000)*(1.3+Math.sin(2*pi*sim.t*12))*3 + Math.sin(2*pi*sim.t*2710)*(1.3+Math.sin(2*pi*sim.t*13))*3 + Math.sin(2*pi*sim.t*2433)*(1.3+Math.sin(2*pi*sim.t*14))*3 + fm; } int getDumpType() { return 'A'; } int getShortcut() { return 0; } } ================================================ FILE: src/BoxElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; import java.util.Vector; class BoxElm extends GraphicElm { public BoxElm(int xx, int yy) { super(xx, yy); x2 = xx + 16; y2 = yy + 16; setBbox(x, y, x2, y2); } public BoxElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); x2 = xb; y2 = yb; /* if ( st.hasMoreTokens() ) x = new Integer(st.nextToken()).intValue(); if ( st.hasMoreTokens() ) y = new Integer(st.nextToken()).intValue(); if ( st.hasMoreTokens() ) x2 = new Integer(st.nextToken()).intValue(); if ( st.hasMoreTokens() ) y2 = new Integer(st.nextToken()).intValue();*/ setBbox(x, y, x2, y2); } String dump() { return super.dump(); } int getDumpType() { return 'b'; } void drag(int xx, int yy) { x = xx; y = yy; } void draw(Graphics g) { //g.setColor(needsHighlight() ? selectColor : lightGrayColor); g.setColor(needsHighlight() ? selectColor : Color.GRAY); setBbox(x, y, x2, y2); if ( x < x2 && y < y2 ) g.fillRect(x,y, x2-x, y2-y); else if ( x > x2 && y < y2 ) g.fillRect(x2,y, x-x2, y2-y); else if ( x < x2 && y > y2 ) g.fillRect(x, y2, x2-x, y-y2); else g.fillRect(x2, y2, x-x2, y-y2); } public EditInfo getEditInfo(int n) { return null; } public void setEditValue(int n, EditInfo ei) { } void getInfo(String arr[]) { } @Override int getShortcut() { return 0; } } ================================================ FILE: src/CC2Elm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class CC2Elm extends ChipElm { double gain; public CC2Elm(int xx, int yy) { super(xx, yy); gain = 1; } public CC2Elm(int xx, int yy, int g) { super(xx, yy); gain = g; } public CC2Elm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); gain = new Double(st.nextToken()).doubleValue(); } String dump() { return super.dump() + " " + gain; } String getChipName() { return "CC2"; } void setupPins() { sizeX = 2; sizeY = 3; pins = new Pin[3]; pins[0] = new Pin(0, SIDE_W, "X"); pins[0].output = true; pins[1] = new Pin(2, SIDE_W, "Y"); pins[2] = new Pin(1, SIDE_E, "Z"); } void getInfo(String arr[]) { arr[0] = (gain == 1) ? "CCII+" : "CCII-"; arr[1] = "X,Y = " + getVoltageText(volts[0]); arr[2] = "Z = " + getVoltageText(volts[2]); arr[3] = "I = " + getCurrentText(pins[0].current); } //boolean nonLinear() { return true; } void stamp() { // X voltage = Y voltage sim.stampVoltageSource(0, nodes[0], pins[0].voltSource); sim.stampVCVS(0, nodes[1], 1, pins[0].voltSource); // Z current = gain * X current sim.stampCCCS(0, nodes[2], pins[0].voltSource, gain); } void draw(Graphics g) { pins[2].current = pins[0].current * gain; drawChip(g); } int getPostCount() { return 3; } int getVoltageSourceCount() { return 1; } int getDumpType() { return 179; } } class CC2NegElm extends CC2Elm { public CC2NegElm(int xx, int yy) { super(xx, yy, -1); } Class getDumpClass() { return CC2Elm.class; } } ================================================ FILE: src/CapacitorElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class CapacitorElm extends CircuitElm { double capacitance; double compResistance, voltdiff; Point plate1[], plate2[]; public static final int FLAG_BACK_EULER = 2; public CapacitorElm(int xx, int yy) { super(xx, yy); capacitance = 1e-5; } public CapacitorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); capacitance = new Double(st.nextToken()).doubleValue(); voltdiff = new Double(st.nextToken()).doubleValue(); } boolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; } void setNodeVoltage(int n, double c) { super.setNodeVoltage(n, c); voltdiff = volts[0]-volts[1]; } void reset() { current = curcount = 0; // put small charge on caps when reset to start oscillators voltdiff = 1e-3; } int getDumpType() { return 'c'; } String dump() { return super.dump() + " " + capacitance + " " + voltdiff; } void setPoints() { super.setPoints(); double f = (dn/2-4)/dn; // calc leads lead1 = interpPoint(point1, point2, f); lead2 = interpPoint(point1, point2, 1-f); // calc plates plate1 = newPointArray(2); plate2 = newPointArray(2); interpPoint2(point1, point2, plate1[0], plate1[1], f, 12); interpPoint2(point1, point2, plate2[0], plate2[1], 1-f, 12); } void draw(Graphics g) { int hs = 12; setBbox(point1, point2, hs); // draw first lead and plate setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); setPowerColor(g, false); drawThickLine(g, plate1[0], plate1[1]); if (sim.powerCheckItem.getState()) g.setColor(Color.gray); // draw second lead and plate setVoltageColor(g, volts[1]); drawThickLine(g, point2, lead2); setPowerColor(g, false); drawThickLine(g, plate2[0], plate2[1]); updateDotCount(); if (sim.dragElm != this) { drawDots(g, point1, lead1, curcount); drawDots(g, point2, lead2, -curcount); } drawPosts(g); if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(capacitance, "F"); drawValues(g, s, hs); } } void stamp() { // capacitor companion model using trapezoidal approximation // (Norton equivalent) consists of a current source in // parallel with a resistor. Trapezoidal is more accurate // than backward euler but can cause oscillatory behavior // if RC is small relative to the timestep. if (isTrapezoidal()) compResistance = sim.timeStep/(2*capacitance); else compResistance = sim.timeStep/capacitance; sim.stampResistor(nodes[0], nodes[1], compResistance); sim.stampRightSide(nodes[0]); sim.stampRightSide(nodes[1]); } void startIteration() { if (isTrapezoidal()) curSourceValue = -voltdiff/compResistance-current; else curSourceValue = -voltdiff/compResistance; //System.out.println("cap " + compResistance + " " + curSourceValue + " " + current + " " + voltdiff); } void calculateCurrent() { double voltdiff = volts[0] - volts[1]; // we check compResistance because this might get called // before stamp(), which sets compResistance, causing // infinite current if (compResistance > 0) current = voltdiff/compResistance + curSourceValue; } double curSourceValue; void doStep() { sim.stampCurrentSource(nodes[0], nodes[1], curSourceValue); } void getInfo(String arr[]) { arr[0] = "capacitor"; getBasicInfo(arr); arr[3] = "C = " + getUnitText(capacitance, "F"); arr[4] = "P = " + getUnitText(getPower(), "W"); //double v = getVoltageDiff(); //arr[4] = "U = " + getUnitText(.5*capacitance*v*v, "J"); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Capacitance (F)", capacitance, 0, 0); if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Trapezoidal Approximation", isTrapezoidal()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) capacitance = ei.value; if (n == 1) { if (ei.checkbox.getState()) flags &= ~FLAG_BACK_EULER; else flags |= FLAG_BACK_EULER; } } int getShortcut() { return 'c'; } } ================================================ FILE: src/ChipElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; abstract class ChipElm extends CircuitElm { int csize, cspc, cspc2; int bits; final int FLAG_SMALL = 1; final int FLAG_FLIP_X = 1024; final int FLAG_FLIP_Y = 2048; public ChipElm(int xx, int yy) { super(xx, yy); if (needsBits()) bits = (this instanceof DecadeElm) ? 10 : 4; noDiagonal = true; setupPins(); setSize(sim.smallGridCheckItem.getState() ? 1 : 2); } public ChipElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); if (needsBits()) bits = new Integer(st.nextToken()).intValue(); noDiagonal = true; setupPins(); setSize((f & FLAG_SMALL) != 0 ? 1 : 2); int i; for (i = 0; i != getPostCount(); i++) { if (pins[i].state) { volts[i] = new Double(st.nextToken()).doubleValue(); pins[i].value = volts[i] > 2.5; } } } boolean needsBits() { return false; } void setSize(int s) { csize = s; cspc = 8*s; cspc2 = cspc*2; flags &= ~FLAG_SMALL; flags |= (s == 1) ? FLAG_SMALL : 0; } abstract void setupPins(); void draw(Graphics g) { drawChip(g); } void drawChip(Graphics g) { int i; Font f = new Font("SansSerif", 0, 10*csize); g.setFont(f); FontMetrics fm = g.getFontMetrics(); for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; setVoltageColor(g, volts[i]); Point a = p.post; Point b = p.stub; drawThickLine(g, a, b); p.curcount = updateDotCount(p.current, p.curcount); drawDots(g, b, a, p.curcount); if (p.bubble) { g.setColor(sim.printableCheckItem.getState() ? Color.white : Color.black); drawThickCircle(g, p.bubbleX, p.bubbleY, 1); g.setColor(lightGrayColor); drawThickCircle(g, p.bubbleX, p.bubbleY, 3); } g.setColor(whiteColor); int sw = fm.stringWidth(p.text); g.drawString(p.text, p.textloc.x-sw/2, p.textloc.y+fm.getAscent()/2); if (p.lineOver) { int ya = p.textloc.y-fm.getAscent()/2; g.drawLine(p.textloc.x-sw/2, ya, p.textloc.x+sw/2, ya); } } g.setColor(needsHighlight() ? selectColor : lightGrayColor); drawThickPolygon(g, rectPointsX, rectPointsY, 4); if (clockPointsX != null) g.drawPolyline(clockPointsX, clockPointsY, 3); for (i = 0; i != getPostCount(); i++) drawPost(g, pins[i].post.x, pins[i].post.y, nodes[i]); } int rectPointsX[], rectPointsY[]; int clockPointsX[], clockPointsY[]; Pin pins[]; int sizeX, sizeY; boolean lastClock; void drag(int xx, int yy) { yy = sim.snapGrid(yy); if (xx < x) { xx = x; yy = y; } else { y = y2 = yy; x2 = sim.snapGrid(xx); } setPoints(); } void setPoints() { if (x2-x > sizeX*cspc2 && this == sim.dragElm) setSize(2); int hs = cspc; int x0 = x+cspc2; int y0 = y; int xr = x0-cspc; int yr = y0-cspc; int xs = sizeX*cspc2; int ys = sizeY*cspc2; rectPointsX = new int[] { xr, xr+xs, xr+xs, xr }; rectPointsY = new int[] { yr, yr, yr+ys, yr+ys }; setBbox(xr, yr, rectPointsX[2], rectPointsY[2]); int i; for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; switch (p.side) { case SIDE_N: p.setPoint(x0, y0, 1, 0, 0, -1, 0, 0); break; case SIDE_S: p.setPoint(x0, y0, 1, 0, 0, 1, 0, ys-cspc2);break; case SIDE_W: p.setPoint(x0, y0, 0, 1, -1, 0, 0, 0); break; case SIDE_E: p.setPoint(x0, y0, 0, 1, 1, 0, xs-cspc2, 0);break; } } } Point getPost(int n) { return pins[n].post; } abstract int getVoltageSourceCount(); // output count void setVoltageSource(int j, int vs) { int i; for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; if (p.output && j-- == 0) { p.voltSource = vs; return; } } System.out.println("setVoltageSource failed for " + this); } void stamp() { int i; for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; if (p.output) sim.stampVoltageSource(0, nodes[i], p.voltSource); } } void execute() {} void doStep() { int i; for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; if (!p.output) p.value = volts[i] > 2.5; } execute(); for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; if (p.output) sim.updateVoltageSource(0, nodes[i], p.voltSource, p.value ? 5 : 0); } } void reset() { int i; for (i = 0; i != getPostCount(); i++) { pins[i].value = false; pins[i].curcount = 0; volts[i] = 0; } lastClock = false; } String dump() { int t = getDumpType(); String s = super.dump(); if (needsBits()) s += " " + bits; int i; for (i = 0; i != getPostCount(); i++) { if (pins[i].state) s += " " + volts[i]; } return s; } void getInfo(String arr[]) { arr[0] = getChipName(); int i, a = 1; for (i = 0; i != getPostCount(); i++) { Pin p = pins[i]; if (arr[a] != null) arr[a] += "; "; else arr[a] = ""; String t = p.text; if (p.lineOver) t += '\''; if (p.clock) t = "Clk"; arr[a] += t + " = " + getVoltageText(volts[i]); if (i % 2 == 1) a++; } } void setCurrent(int x, double c) { int i; for (i = 0; i != getPostCount(); i++) if (pins[i].output && pins[i].voltSource == x) pins[i].current = c; } String getChipName() { return "chip"; } boolean getConnection(int n1, int n2) { return false; } boolean hasGroundConnection(int n1) { return pins[n1].output; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Flip X", (flags & FLAG_FLIP_X) != 0); return ei; } if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Flip Y", (flags & FLAG_FLIP_Y) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { if (ei.checkbox.getState()) flags |= FLAG_FLIP_X; else flags &= ~FLAG_FLIP_X; setPoints(); } if (n == 1) { if (ei.checkbox.getState()) flags |= FLAG_FLIP_Y; else flags &= ~FLAG_FLIP_Y; setPoints(); } } final int SIDE_N = 0; final int SIDE_S = 1; final int SIDE_W = 2; final int SIDE_E = 3; class Pin { Pin(int p, int s, String t) { pos = p; side = s; text = t; } Point post, stub; Point textloc; int pos, side, voltSource, bubbleX, bubbleY; String text; boolean lineOver, bubble, clock, output, value, state; double curcount, current; void setPoint(int px, int py, int dx, int dy, int dax, int day, int sx, int sy) { if ((flags & FLAG_FLIP_X) != 0) { dx = -dx; dax = -dax; px += cspc2*(sizeX-1); sx = -sx; } if ((flags & FLAG_FLIP_Y) != 0) { dy = -dy; day = -day; py += cspc2*(sizeY-1); sy = -sy; } int xa = px+cspc2*dx*pos+sx; int ya = py+cspc2*dy*pos+sy; post = new Point(xa+dax*cspc2, ya+day*cspc2); stub = new Point(xa+dax*cspc , ya+day*cspc ); textloc = new Point(xa , ya ); if (bubble) { bubbleX = xa+dax*10*csize; bubbleY = ya+day*10*csize; } if (clock) { clockPointsX = new int[3]; clockPointsY = new int[3]; clockPointsX[0] = xa+dax*cspc-dx*cspc/2; clockPointsY[0] = ya+day*cspc-dy*cspc/2; clockPointsX[1] = xa; clockPointsY[1] = ya; clockPointsX[2] = xa+dax*cspc+dx*cspc/2; clockPointsY[2] = ya+day*cspc+dy*cspc/2; } } } } ================================================ FILE: src/CirSim.java ================================================ // CirSim.java (c) 2010 by Paul Falstad // For information about the theory behind this, see Electronic Circuit & System Simulation Methods by Pillage import java.io.InputStream; import java.awt.*; import java.awt.image.*; import java.applet.Applet; import java.util.Vector; import java.io.File; import java.util.Random; import java.util.Arrays; import java.lang.Math; import java.net.URL; import java.awt.event.*; import java.io.FilterInputStream; import java.io.ByteArrayOutputStream; import java.util.StringTokenizer; import java.text.DecimalFormat; import java.text.NumberFormat; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URLDecoder; import java.net.URLEncoder; public class CirSim extends Frame implements ComponentListener, ActionListener, AdjustmentListener, MouseMotionListener, MouseListener, ItemListener, KeyListener { Thread engine = null; Dimension winSize; Image dbimage; Random random; public static final int sourceRadius = 7; public static final double freqMult = 3.14159265*2*4; public String getAppletInfo() { return "Circuit by Paul Falstad"; } static Container main; Label titleLabel; Button resetButton; Button dumpMatrixButton; MenuItem exportItem, exportLinkItem, importItem, exitItem, undoItem, redoItem, cutItem, copyItem, pasteItem, selectAllItem, optionsItem; Menu optionsMenu; Checkbox stoppedCheck; CheckboxMenuItem dotsCheckItem; CheckboxMenuItem voltsCheckItem; CheckboxMenuItem powerCheckItem; CheckboxMenuItem smallGridCheckItem; CheckboxMenuItem showValuesCheckItem; CheckboxMenuItem conductanceCheckItem; CheckboxMenuItem euroResistorCheckItem; CheckboxMenuItem printableCheckItem; CheckboxMenuItem conventionCheckItem; CheckboxMenuItem idealWireCheckItem; Scrollbar speedBar; Scrollbar currentBar; Label powerLabel; Scrollbar powerBar; PopupMenu elmMenu; MenuItem elmEditMenuItem; MenuItem elmCutMenuItem; MenuItem elmCopyMenuItem; MenuItem elmDeleteMenuItem; MenuItem elmScopeMenuItem; PopupMenu scopeMenu; PopupMenu transScopeMenu; PopupMenu mainMenu; CheckboxMenuItem scopeVMenuItem; CheckboxMenuItem scopeIMenuItem; CheckboxMenuItem scopeMaxMenuItem; CheckboxMenuItem scopeMinMenuItem; CheckboxMenuItem scopeFreqMenuItem; CheckboxMenuItem scopePowerMenuItem; CheckboxMenuItem scopeIbMenuItem; CheckboxMenuItem scopeIcMenuItem; CheckboxMenuItem scopeIeMenuItem; CheckboxMenuItem scopeVbeMenuItem; CheckboxMenuItem scopeVbcMenuItem; CheckboxMenuItem scopeVceMenuItem; CheckboxMenuItem scopeVIMenuItem; CheckboxMenuItem scopeXYMenuItem; CheckboxMenuItem scopeResistMenuItem; CheckboxMenuItem scopeVceIcMenuItem; MenuItem scopeSelectYMenuItem; Class addingClass; int mouseMode = MODE_SELECT; int tempMouseMode = MODE_SELECT; String mouseModeStr = "Select"; static final double pi = 3.14159265358979323846; static final int MODE_ADD_ELM = 0; static final int MODE_DRAG_ALL = 1; static final int MODE_DRAG_ROW = 2; static final int MODE_DRAG_COLUMN = 3; static final int MODE_DRAG_SELECTED = 4; static final int MODE_DRAG_POST = 5; static final int MODE_SELECT = 6; static final int infoWidth = 120; int dragX, dragY, initDragX, initDragY; int selectedSource; Rectangle selectedArea; int gridSize, gridMask, gridRound; boolean dragging; boolean analyzeFlag; boolean dumpMatrix; boolean useBufferedImage; boolean isMac; String ctrlMetaKey; double t; int pause = 10; int scopeSelected = -1; int menuScope = -1; int hintType = -1, hintItem1, hintItem2; String stopMessage; double timeStep; static final int HINT_LC = 1; static final int HINT_RC = 2; static final int HINT_3DB_C = 3; static final int HINT_TWINT = 4; static final int HINT_3DB_L = 5; Vector elmList; // Vector setupList; CircuitElm dragElm, menuElm, mouseElm, stopElm; boolean didSwitch = false; int mousePost = -1; CircuitElm plotXElm, plotYElm; int draggingPost; SwitchElm heldSwitchElm; double circuitMatrix[][], circuitRightSide[], origRightSide[], origMatrix[][]; RowInfo circuitRowInfo[]; int circuitPermute[]; boolean circuitNonLinear; int voltageSourceCount; int circuitMatrixSize, circuitMatrixFullSize; boolean circuitNeedsMap; public boolean useFrame; int scopeCount; Scope scopes[]; int scopeColCount[]; static EditDialog editDialog; static ImportExportDialog impDialog, expDialog; Class dumpTypes[], shortcuts[]; static String muString = "u"; static String ohmString = "ohm"; String clipboard; Rectangle circuitArea; int circuitBottom; Vector undoStack, redoStack; int getrand(int x) { int q = random.nextInt(); if (q < 0) q = -q; return q % x; } CircuitCanvas cv; Circuit applet; CirSim(Circuit a) { super("Circuit Simulator v1.6.1a"); applet = a; useFrame = false; } String startCircuit = null; String startLabel = null; String startCircuitText = null; String baseURL = "http://www.falstad.com/circuit/"; public void init() { String euroResistor = null; String useFrameStr = null; boolean printable = true; // hausen: changed from false to true boolean convention = true; CircuitElm.initClass(this); try { baseURL = applet.getDocumentBase().getFile(); // look for circuit embedded in URL String doc = applet.getDocumentBase().toString(); int in = doc.indexOf('#'); if (in > 0) { String x = null; try { x = doc.substring(in+1); x = URLDecoder.decode(x); startCircuitText = x; } catch (Exception e) { System.out.println("can't decode " + x); e.printStackTrace(); } } in = doc.lastIndexOf('/'); if (in > 0) baseURL = doc.substring(0, in+1); String param = applet.getParameter("PAUSE"); if (param != null) pause = Integer.parseInt(param); startCircuit = applet.getParameter("startCircuit"); startLabel = applet.getParameter("startLabel"); euroResistor = applet.getParameter("euroResistors"); useFrameStr = applet.getParameter("useFrame"); String x = applet.getParameter("whiteBackground"); if (x != null && x.equalsIgnoreCase("true")) printable = true; x = applet.getParameter("conventionalCurrent"); if (x != null && x.equalsIgnoreCase("true")) convention = false; } catch (Exception e) { } boolean euro = (euroResistor != null && euroResistor.equalsIgnoreCase("true")); useFrame = (useFrameStr == null || !useFrameStr.equalsIgnoreCase("false")); if (useFrame) main = this; else main = applet; String os = System.getProperty("os.name"); isMac = (os.indexOf("Mac ") == 0); ctrlMetaKey = (isMac) ? "\u2318" : "Ctrl"; String jv = System.getProperty("java.class.version"); double jvf = new Double(jv).doubleValue(); if (jvf >= 48) { muString = "\u03bc"; ohmString = "\u03a9"; useBufferedImage = true; } dumpTypes = new Class[300]; shortcuts = new Class[127]; // these characters are reserved dumpTypes[(int)'o'] = Scope.class; dumpTypes[(int)'h'] = Scope.class; dumpTypes[(int)'$'] = Scope.class; dumpTypes[(int)'%'] = Scope.class; dumpTypes[(int)'?'] = Scope.class; dumpTypes[(int)'B'] = Scope.class; main.setLayout(new CircuitLayout()); cv = new CircuitCanvas(this); cv.addComponentListener(this); cv.addMouseMotionListener(this); cv.addMouseListener(this); cv.addKeyListener(this); main.add(cv); mainMenu = new PopupMenu(); MenuBar mb = null; if (useFrame) mb = new MenuBar(); Menu m = new Menu("File"); if (useFrame) mb.add(m); else mainMenu.add(m); m.add(importItem = getMenuItem("Import")); m.add(exportItem = getMenuItem("Export")); // m.add(exportLinkItem = getMenuItem("Export Link")); m.addSeparator(); m.add(exitItem = getMenuItem("Exit")); m = new Menu("Edit"); m.add(undoItem = getMenuItem("Undo")); undoItem.setShortcut(new MenuShortcut(KeyEvent.VK_Z)); m.add(redoItem = getMenuItem("Redo")); redoItem.setShortcut(new MenuShortcut(KeyEvent.VK_Z, true)); m.addSeparator(); m.add(cutItem = getMenuItem("Cut")); cutItem.setShortcut(new MenuShortcut(KeyEvent.VK_X)); m.add(copyItem = getMenuItem("Copy")); copyItem.setShortcut(new MenuShortcut(KeyEvent.VK_C)); m.add(pasteItem = getMenuItem("Paste")); pasteItem.setShortcut(new MenuShortcut(KeyEvent.VK_V)); pasteItem.setEnabled(false); m.add(selectAllItem = getMenuItem("Select All")); selectAllItem.setShortcut(new MenuShortcut(KeyEvent.VK_A)); if (useFrame) mb.add(m); else mainMenu.add(m); m = new Menu("Scope"); if (useFrame) mb.add(m); else mainMenu.add(m); m.add(getMenuItem("Stack All", "stackAll")); m.add(getMenuItem("Unstack All", "unstackAll")); optionsMenu = m = new Menu("Options"); if (useFrame) mb.add(m); else mainMenu.add(m); m.add(dotsCheckItem = getCheckItem("Show Current")); dotsCheckItem.setState(false); // hausen: changed from true to false m.add(voltsCheckItem = getCheckItem("Show Voltage")); voltsCheckItem.setState(true); m.add(powerCheckItem = getCheckItem("Show Power")); m.add(showValuesCheckItem = getCheckItem("Show Values")); showValuesCheckItem.setState(true); //m.add(conductanceCheckItem = getCheckItem("Show Conductance")); m.add(smallGridCheckItem = getCheckItem("Small Grid")); m.add(euroResistorCheckItem = getCheckItem("European Resistors")); euroResistorCheckItem.setState(euro); m.add(printableCheckItem = getCheckItem("White Background")); printableCheckItem.setState(printable); m.add(conventionCheckItem = getCheckItem("Conventional Current Motion")); conventionCheckItem.setState(convention); m.add(idealWireCheckItem = getCheckItem("Ideal Wires")); idealWireCheckItem.setState(WireElm.ideal); idealWireCheckItem.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { WireElm.ideal = true; } else { WireElm.ideal = false; } System.err.println("ideal wires: " + WireElm.ideal); } } ); m.add(optionsItem = getMenuItem("Other Options...")); Menu circuitsMenu = new Menu("Circuits"); if (useFrame) mb.add(circuitsMenu); else mainMenu.add(circuitsMenu); mainMenu.add(getClassCheckItem("Add Wire", "WireElm")); mainMenu.add(getClassCheckItem("Add Resistor", "ResistorElm")); Menu passMenu = new Menu("Passive Components"); mainMenu.add(passMenu); passMenu.add(getClassCheckItem("Add Capacitor", "CapacitorElm")); passMenu.add(getClassCheckItem("Add Inductor", "InductorElm")); passMenu.add(getClassCheckItem("Add Switch", "SwitchElm")); passMenu.add(getClassCheckItem("Add Push Switch", "PushSwitchElm")); passMenu.add(getClassCheckItem("Add SPDT Switch", "Switch2Elm")); passMenu.add(getClassCheckItem("Add Potentiometer", "PotElm")); passMenu.add(getClassCheckItem("Add Transformer", "TransformerElm")); passMenu.add(getClassCheckItem("Add Tapped Transformer", "TappedTransformerElm")); passMenu.add(getClassCheckItem("Add Transmission Line", "TransLineElm")); passMenu.add(getClassCheckItem("Add Relay", "RelayElm")); passMenu.add(getClassCheckItem("Add Memristor", "MemristorElm")); passMenu.add(getClassCheckItem("Add Spark Gap", "SparkGapElm")); Menu inputMenu = new Menu("Inputs/Outputs"); mainMenu.add(inputMenu); inputMenu.add(getClassCheckItem("Add Ground", "GroundElm")); inputMenu.add(getClassCheckItem("Add Voltage Source (2-terminal)", "DCVoltageElm")); inputMenu.add(getClassCheckItem("Add A/C Source (2-terminal)", "ACVoltageElm")); inputMenu.add(getClassCheckItem("Add Voltage Source (1-terminal)", "RailElm")); inputMenu.add(getClassCheckItem("Add A/C Source (1-terminal)", "ACRailElm")); inputMenu.add(getClassCheckItem("Add Square Wave (1-terminal)", "SquareRailElm")); inputMenu.add(getClassCheckItem("Add Analog Output", "OutputElm")); inputMenu.add(getClassCheckItem("Add Logic Input", "LogicInputElm")); inputMenu.add(getClassCheckItem("Add Logic Output", "LogicOutputElm")); inputMenu.add(getClassCheckItem("Add Clock", "ClockElm")); inputMenu.add(getClassCheckItem("Add A/C Sweep", "SweepElm")); inputMenu.add(getClassCheckItem("Add Var. Voltage", "VarRailElm")); inputMenu.add(getClassCheckItem("Add Antenna", "AntennaElm")); inputMenu.add(getClassCheckItem("Add Current Source", "CurrentElm")); inputMenu.add(getClassCheckItem("Add LED", "LEDElm")); inputMenu.add(getClassCheckItem("Add Lamp (beta)", "LampElm")); Menu activeMenu = new Menu("Active Components"); mainMenu.add(activeMenu); activeMenu.add(getClassCheckItem("Add Diode", "DiodeElm")); activeMenu.add(getClassCheckItem("Add Zener Diode", "ZenerElm")); activeMenu.add(getClassCheckItem("Add Transistor (bipolar, NPN)", "NTransistorElm")); activeMenu.add(getClassCheckItem("Add Transistor (bipolar, PNP)", "PTransistorElm")); activeMenu.add(getClassCheckItem("Add Op Amp (- on top)", "OpAmpElm")); activeMenu.add(getClassCheckItem("Add Op Amp (+ on top)", "OpAmpSwapElm")); activeMenu.add(getClassCheckItem("Add MOSFET (n-channel)", "NMosfetElm")); activeMenu.add(getClassCheckItem("Add MOSFET (p-channel)", "PMosfetElm")); activeMenu.add(getClassCheckItem("Add JFET (n-channel)", "NJfetElm")); activeMenu.add(getClassCheckItem("Add JFET (p-channel)", "PJfetElm")); activeMenu.add(getClassCheckItem("Add Analog Switch (SPST)", "AnalogSwitchElm")); activeMenu.add(getClassCheckItem("Add Analog Switch (SPDT)", "AnalogSwitch2Elm")); activeMenu.add(getClassCheckItem("Add SCR", "SCRElm")); //activeMenu.add(getClassCheckItem("Add Varactor/Varicap", "VaractorElm")); activeMenu.add(getClassCheckItem("Add Tunnel Diode", "TunnelDiodeElm")); activeMenu.add(getClassCheckItem("Add Triode", "TriodeElm")); //activeMenu.add(getClassCheckItem("Add Diac", "DiacElm")); //activeMenu.add(getClassCheckItem("Add Triac", "TriacElm")); //activeMenu.add(getClassCheckItem("Add Photoresistor", "PhotoResistorElm")); //activeMenu.add(getClassCheckItem("Add Thermistor", "ThermistorElm")); activeMenu.add(getClassCheckItem("Add CCII+", "CC2Elm")); activeMenu.add(getClassCheckItem("Add CCII-", "CC2NegElm")); Menu gateMenu = new Menu("Logic Gates"); mainMenu.add(gateMenu); gateMenu.add(getClassCheckItem("Add Inverter", "InverterElm")); gateMenu.add(getClassCheckItem("Add NAND Gate", "NandGateElm")); gateMenu.add(getClassCheckItem("Add NOR Gate", "NorGateElm")); gateMenu.add(getClassCheckItem("Add AND Gate", "AndGateElm")); gateMenu.add(getClassCheckItem("Add OR Gate", "OrGateElm")); gateMenu.add(getClassCheckItem("Add XOR Gate", "XorGateElm")); Menu chipMenu = new Menu("Chips"); mainMenu.add(chipMenu); chipMenu.add(getClassCheckItem("Add D Flip-Flop", "DFlipFlopElm")); chipMenu.add(getClassCheckItem("Add JK Flip-Flop", "JKFlipFlopElm")); chipMenu.add(getClassCheckItem("Add 7 Segment LED", "SevenSegElm")); chipMenu.add(getClassCheckItem("Add VCO", "VCOElm")); chipMenu.add(getClassCheckItem("Add Phase Comparator", "PhaseCompElm")); chipMenu.add(getClassCheckItem("Add Counter", "CounterElm")); chipMenu.add(getClassCheckItem("Add Decade Counter", "DecadeElm")); chipMenu.add(getClassCheckItem("Add 555 Timer", "TimerElm")); chipMenu.add(getClassCheckItem("Add DAC", "DACElm")); chipMenu.add(getClassCheckItem("Add ADC", "ADCElm")); chipMenu.add(getClassCheckItem("Add Latch", "LatchElm")); Menu otherMenu = new Menu("Other"); mainMenu.add(otherMenu); otherMenu.add(getClassCheckItem("Add Text", "TextElm")); otherMenu.add(getClassCheckItem("Add Box", "BoxElm")); otherMenu.add(getClassCheckItem("Add Scope Probe", "ProbeElm")); otherMenu.add(getCheckItem("Drag All (Alt-drag)", "DragAll")); otherMenu.add(getCheckItem( isMac ? "Drag Row (Alt-S-drag, S-right)" : "Drag Row (S-right)", "DragRow")); otherMenu.add(getCheckItem( isMac ? "Drag Column (Alt-\u2318-drag, \u2318-right)" : "Drag Column (C-right)", "DragColumn")); otherMenu.add(getCheckItem("Drag Selected", "DragSelected")); otherMenu.add(getCheckItem("Drag Post (" + ctrlMetaKey + "-drag)", "DragPost")); mainMenu.add(getCheckItem("Select/Drag Selected (space or Shift-drag)", "Select")); main.add(mainMenu); main.add(resetButton = new Button("Reset")); resetButton.addActionListener(this); dumpMatrixButton = new Button("Dump Matrix"); //main.add(dumpMatrixButton); dumpMatrixButton.addActionListener(this); stoppedCheck = new Checkbox("Stopped"); stoppedCheck.addItemListener(this); main.add(stoppedCheck); main.add(new Label("Simulation Speed", Label.CENTER)); // was max of 140 main.add(speedBar = new Scrollbar(Scrollbar.HORIZONTAL, 3, 1, 0, 260)); speedBar.addAdjustmentListener(this); main.add(new Label("Current Speed", Label.CENTER)); currentBar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 100); currentBar.addAdjustmentListener(this); main.add(currentBar); main.add(powerLabel = new Label("Power Brightness", Label.CENTER)); main.add(powerBar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 1, 1, 100)); powerBar.addAdjustmentListener(this); powerBar.disable(); powerLabel.disable(); main.add(new Label("www.falstad.com")); if (useFrame) main.add(new Label("")); Font f = new Font("SansSerif", 0, 10); Label l; l = new Label("Current Circuit:"); l.setFont(f); titleLabel = new Label("Label"); titleLabel.setFont(f); if (useFrame) { main.add(l); main.add(titleLabel); } setGrid(); elmList = new Vector(); // setupList = new Vector(); undoStack = new Vector(); redoStack = new Vector(); scopes = new Scope[20]; scopeColCount = new int[20]; scopeCount = 0; random = new Random(); cv.setBackground(Color.black); cv.setForeground(Color.lightGray); elmMenu = new PopupMenu(); elmMenu.add(elmEditMenuItem = getMenuItem("Edit")); elmMenu.add(elmScopeMenuItem = getMenuItem("View in Scope")); elmMenu.add(elmCutMenuItem = getMenuItem("Cut")); elmMenu.add(elmCopyMenuItem = getMenuItem("Copy")); elmMenu.add(elmDeleteMenuItem = getMenuItem("Delete")); main.add(elmMenu); scopeMenu = buildScopeMenu(false); transScopeMenu = buildScopeMenu(true); getSetupList(circuitsMenu, false); if (useFrame) setMenuBar(mb); if (startCircuitText != null) readSetup(startCircuitText); else if (stopMessage == null && startCircuit != null) readSetupFile(startCircuit, startLabel); else readSetup(null, 0, false); if (useFrame) { Dimension screen = getToolkit().getScreenSize(); resize(860, 640); handleResize(); Dimension x = getSize(); setLocation((screen.width - x.width)/2, (screen.height - x.height)/2); show(); } else { if (!powerCheckItem.getState()) { main.remove(powerBar); main.remove(powerLabel); main.validate(); } hide(); handleResize(); applet.validate(); } requestFocus(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { destroyFrame(); } } ); } boolean shown = false; public void triggerShow() { if (!shown) show(); shown = true; } public void requestFocus() { super.requestFocus(); cv.requestFocus(); } PopupMenu buildScopeMenu(boolean t) { PopupMenu m = new PopupMenu(); m.add(getMenuItem("Remove", "remove")); m.add(getMenuItem("Speed 2x", "speed2")); m.add(getMenuItem("Speed 1/2x", "speed1/2")); m.add(getMenuItem("Scale 2x", "scale")); m.add(getMenuItem("Max Scale", "maxscale")); m.add(getMenuItem("Stack", "stack")); m.add(getMenuItem("Unstack", "unstack")); m.add(getMenuItem("Reset", "reset")); if (t) { m.add(scopeIbMenuItem = getCheckItem("Show Ib")); m.add(scopeIcMenuItem = getCheckItem("Show Ic")); m.add(scopeIeMenuItem = getCheckItem("Show Ie")); m.add(scopeVbeMenuItem = getCheckItem("Show Vbe")); m.add(scopeVbcMenuItem = getCheckItem("Show Vbc")); m.add(scopeVceMenuItem = getCheckItem("Show Vce")); m.add(scopeVceIcMenuItem = getCheckItem("Show Vce vs Ic")); } else { m.add(scopeVMenuItem = getCheckItem("Show Voltage")); m.add(scopeIMenuItem = getCheckItem("Show Current")); m.add(scopePowerMenuItem = getCheckItem("Show Power Consumed")); m.add(scopeMaxMenuItem = getCheckItem("Show Peak Value")); m.add(scopeMinMenuItem = getCheckItem("Show Negative Peak Value")); m.add(scopeFreqMenuItem = getCheckItem("Show Frequency")); m.add(scopeVIMenuItem = getCheckItem("Show V vs I")); m.add(scopeXYMenuItem = getCheckItem("Plot X/Y")); m.add(scopeSelectYMenuItem = getMenuItem("Select Y", "selecty")); m.add(scopeResistMenuItem = getCheckItem("Show Resistance")); } main.add(m); return m; } MenuItem getMenuItem(String s) { MenuItem mi = new MenuItem(s); mi.addActionListener(this); return mi; } MenuItem getMenuItem(String s, String ac) { MenuItem mi = new MenuItem(s); mi.setActionCommand(ac); mi.addActionListener(this); return mi; } CheckboxMenuItem getCheckItem(String s) { CheckboxMenuItem mi = new CheckboxMenuItem(s); mi.addItemListener(this); mi.setActionCommand(""); return mi; } CheckboxMenuItem getClassCheckItem(String s, String t) { try { Class c = Class.forName(t); CircuitElm elm = constructElement(c, 0, 0); register(c, elm); if ( elm.needsShortcut() ) { s += " (" + (char)elm.getShortcut() + ")"; } elm.delete(); } catch (Exception ee) { ee.printStackTrace(); } return getCheckItem(s, t); } CheckboxMenuItem getCheckItem(String s, String t) { CheckboxMenuItem mi = new CheckboxMenuItem(s); mi.addItemListener(this); mi.setActionCommand(t); return mi; } void register(Class c, CircuitElm elm) { int t = elm.getDumpType(); if (t == 0) { System.out.println("no dump type: " + c); return; } int s = elm.getShortcut(); if ( elm.needsShortcut() && s == 0 ) { if ( s == 0 ) { System.err.println("no shortcut " + c + " for " + c); return; } else if ( s <= ' ' || s >= 127 ) { System.err.println("invalid shortcut " + c + " for " + c); return; } } Class dclass = elm.getDumpClass(); if ( dumpTypes[t] != null && dumpTypes[t] != dclass ) { System.out.println("dump type conflict: " + c + " " + dumpTypes[t]); return; } dumpTypes[t] = dclass; Class sclass = elm.getClass(); if ( elm.needsShortcut() && shortcuts[s] != null && shortcuts[s] != sclass ) { System.err.println("shortcut conflict: " + c + " (previously assigned to " + shortcuts[s] + ")"); } else { shortcuts[s] = sclass; } } void handleResize() { winSize = cv.getSize(); if (winSize.width == 0) return; dbimage = main.createImage(winSize.width, winSize.height); int h = winSize.height / 5; /*if (h < 128 && winSize.height > 300) h = 128;*/ circuitArea = new Rectangle(0, 0, winSize.width, winSize.height-h); int i; int minx = 1000, maxx = 0, miny = 1000, maxy = 0; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); // centered text causes problems when trying to center the circuit, // so we special-case it here if (!ce.isCenteredText()) { minx = min(ce.x, min(ce.x2, minx)); maxx = max(ce.x, max(ce.x2, maxx)); } miny = min(ce.y, min(ce.y2, miny)); maxy = max(ce.y, max(ce.y2, maxy)); } // center circuit; we don't use snapGrid() because that rounds int dx = gridMask & ((circuitArea.width -(maxx-minx))/2-minx); int dy = gridMask & ((circuitArea.height-(maxy-miny))/2-miny); if (dx+minx < 0) dx = gridMask & (-minx); if (dy+miny < 0) dy = gridMask & (-miny); for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.move(dx, dy); } // after moving elements, need this to avoid singular matrix probs needAnalyze(); circuitBottom = 0; } void destroyFrame() { if (applet == null) { dispose(); System.exit(0); } else { applet.destroyFrame(); } } public boolean handleEvent(Event ev) { if (ev.id == Event.WINDOW_DESTROY) { destroyFrame(); return true; } return super.handleEvent(ev); } public void paint(Graphics g) { cv.repaint(); } static final int resct = 6; long lastTime = 0, lastFrameTime, lastIterTime, secTime = 0; int frames = 0; int steps = 0; int framerate = 0, steprate = 0; public void updateCircuit(Graphics realg) { CircuitElm realMouseElm; if (winSize == null || winSize.width == 0) return; if (analyzeFlag) { analyzeCircuit(); analyzeFlag = false; } if (editDialog != null && editDialog.elm instanceof CircuitElm) mouseElm = (CircuitElm) (editDialog.elm); realMouseElm = mouseElm; if (mouseElm == null) mouseElm = stopElm; setupScopes(); Graphics2D g = null; // hausen: changed to Graphics2D g = (Graphics2D)dbimage.getGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); CircuitElm.selectColor = Color.cyan; if (printableCheckItem.getState()) { CircuitElm.whiteColor = Color.black; CircuitElm.lightGrayColor = Color.black; g.setColor(Color.white); } else { CircuitElm.whiteColor = Color.white; CircuitElm.lightGrayColor = Color.lightGray; g.setColor(Color.black); } g.fillRect(0, 0, winSize.width, winSize.height); if (!stoppedCheck.getState()) { try { runCircuit(); } catch (Exception e) { e.printStackTrace(); analyzeFlag = true; cv.repaint(); return; } } if (!stoppedCheck.getState()) { long sysTime = System.currentTimeMillis(); if (lastTime != 0) { int inc = (int) (sysTime-lastTime); double c = currentBar.getValue(); c = java.lang.Math.exp(c/3.5-14.2); CircuitElm.currentMult = 1.7 * inc * c; if (!conventionCheckItem.getState()) CircuitElm.currentMult = -CircuitElm.currentMult; } if (sysTime-secTime >= 1000) { framerate = frames; steprate = steps; frames = 0; steps = 0; secTime = sysTime; } lastTime = sysTime; } else lastTime = 0; CircuitElm.powerMult = Math.exp(powerBar.getValue()/4.762-7); int i; Font oldfont = g.getFont(); for (i = 0; i != elmList.size(); i++) { if (powerCheckItem.getState()) g.setColor(Color.gray); /*else if (conductanceCheckItem.getState()) g.setColor(Color.white);*/ getElm(i).draw(g); } if (tempMouseMode == MODE_DRAG_ROW || tempMouseMode == MODE_DRAG_COLUMN || tempMouseMode == MODE_DRAG_POST || tempMouseMode == MODE_DRAG_SELECTED) for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.drawPost(g, ce.x , ce.y ); ce.drawPost(g, ce.x2, ce.y2); } int badnodes = 0; // find bad connections, nodes not connected to other elements which // intersect other elements' bounding boxes // debugged by hausen: nullPointerException if ( nodeList != null ) for (i = 0; i != nodeList.size(); i++) { CircuitNode cn = getCircuitNode(i); if (!cn.internal && cn.links.size() == 1) { int bb = 0, j; CircuitNodeLink cnl = cn.links.elementAt(0); for (j = 0; j != elmList.size(); j++) { // TODO: (hausen) see if this change does not break stuff CircuitElm ce = getElm(j); if ( ce instanceof GraphicElm ) continue; if (cnl.elm != ce && getElm(j).boundingBox.contains(cn.x, cn.y)) bb++; } if (bb > 0) { g.setColor(Color.red); g.fillOval(cn.x-3, cn.y-3, 7, 7); badnodes++; } } } /*if (mouseElm != null) { g.setFont(oldfont); g.drawString("+", mouseElm.x+10, mouseElm.y); }*/ if (dragElm != null && (dragElm.x != dragElm.x2 || dragElm.y != dragElm.y2)) dragElm.draw(g); g.setFont(oldfont); int ct = scopeCount; if (stopMessage != null) ct = 0; for (i = 0; i != ct; i++) scopes[i].draw(g); g.setColor(CircuitElm.whiteColor); if (stopMessage != null) { g.drawString(stopMessage, 10, circuitArea.height); } else { if (circuitBottom == 0) calcCircuitBottom(); String info[] = new String[10]; if (mouseElm != null) { if (mousePost == -1) mouseElm.getInfo(info); else info[0] = "V = " + CircuitElm.getUnitText(mouseElm.getPostVoltage(mousePost), "V"); /* //shownodes for (i = 0; i != mouseElm.getPostCount(); i++) info[0] += " " + mouseElm.nodes[i]; if (mouseElm.getVoltageSourceCount() > 0) info[0] += ";" + (mouseElm.getVoltageSource()+nodeList.size()); */ } else { CircuitElm.showFormat.setMinimumFractionDigits(2); info[0] = "t = " + CircuitElm.getUnitText(t, "s"); CircuitElm.showFormat.setMinimumFractionDigits(0); } if (hintType != -1) { for (i = 0; info[i] != null; i++) ; String s = getHint(); if (s == null) hintType = -1; else info[i] = s; } int x = 0; if (ct != 0) x = scopes[ct-1].rightEdge() + 20; x = max(x, winSize.width*2/3); // count lines of data for (i = 0; info[i] != null; i++) ; if (badnodes > 0) info[i++] = badnodes + ((badnodes == 1) ? " bad connection" : " bad connections"); // find where to show data; below circuit, not too high unless we need it int ybase = winSize.height-15*i-5; ybase = min(ybase, circuitArea.height); ybase = max(ybase, circuitBottom); for (i = 0; info[i] != null; i++) g.drawString(info[i], x, ybase+15*(i+1)); } if (selectedArea != null) { g.setColor(CircuitElm.selectColor); g.drawRect(selectedArea.x, selectedArea.y, selectedArea.width, selectedArea.height); } mouseElm = realMouseElm; frames++; /* g.setColor(Color.white); g.drawString("Framerate: " + framerate, 10, 10); g.drawString("Steprate: " + steprate, 10, 30); g.drawString("Steprate/iter: " + (steprate/getIterCount()), 10, 50); g.drawString("iterc: " + (getIterCount()), 10, 70); */ realg.drawImage(dbimage, 0, 0, this); if (!stoppedCheck.getState() && circuitMatrix != null) { // Limit to 50 fps (thanks to Jurgen Klotzer for this) long delay = 1000/50 - (System.currentTimeMillis() - lastFrameTime); //realg.drawString("delay: " + delay, 10, 90); if (delay > 0) { try { Thread.sleep(delay); } catch (InterruptedException e) { } } cv.repaint(0); } lastFrameTime = lastTime; } void setupScopes() { int i; // check scopes to make sure the elements still exist, and remove // unused scopes/columns int pos = -1; for (i = 0; i < scopeCount; i++) { if (locateElm(scopes[i].elm) < 0) scopes[i].setElm(null); if (scopes[i].elm == null) { int j; for (j = i; j != scopeCount; j++) scopes[j] = scopes[j+1]; scopeCount--; i--; continue; } if (scopes[i].position > pos+1) scopes[i].position = pos+1; pos = scopes[i].position; } while (scopeCount > 0 && scopes[scopeCount-1].elm == null) scopeCount--; int h = winSize.height - circuitArea.height; pos = 0; for (i = 0; i != scopeCount; i++) scopeColCount[i] = 0; for (i = 0; i != scopeCount; i++) { pos = max(scopes[i].position, pos); scopeColCount[scopes[i].position]++; } int colct = pos+1; int iw = infoWidth; if (colct <= 2) iw = iw*3/2; int w = (winSize.width-iw) / colct; int marg = 10; if (w < marg*2) w = marg*2; pos = -1; int colh = 0; int row = 0; int speed = 0; for (i = 0; i != scopeCount; i++) { Scope s = scopes[i]; if (s.position > pos) { pos = s.position; colh = h / scopeColCount[pos]; row = 0; speed = s.speed; } if (s.speed != speed) { s.speed = speed; s.resetGraph(); } Rectangle r = new Rectangle(pos*w, winSize.height-h+colh*row, w-marg, colh); row++; if (!r.equals(s.rect)) s.setRect(r); } } String getHint() { CircuitElm c1 = getElm(hintItem1); CircuitElm c2 = getElm(hintItem2); if (c1 == null || c2 == null) return null; if (hintType == HINT_LC) { if (!(c1 instanceof InductorElm)) return null; if (!(c2 instanceof CapacitorElm)) return null; InductorElm ie = (InductorElm) c1; CapacitorElm ce = (CapacitorElm) c2; return "res.f = " + CircuitElm.getUnitText(1/(2*pi*Math.sqrt(ie.inductance* ce.capacitance)), "Hz"); } if (hintType == HINT_RC) { if (!(c1 instanceof ResistorElm)) return null; if (!(c2 instanceof CapacitorElm)) return null; ResistorElm re = (ResistorElm) c1; CapacitorElm ce = (CapacitorElm) c2; return "RC = " + CircuitElm.getUnitText(re.resistance*ce.capacitance, "s"); } if (hintType == HINT_3DB_C) { if (!(c1 instanceof ResistorElm)) return null; if (!(c2 instanceof CapacitorElm)) return null; ResistorElm re = (ResistorElm) c1; CapacitorElm ce = (CapacitorElm) c2; return "f.3db = " + CircuitElm.getUnitText(1/(2*pi*re.resistance*ce.capacitance), "Hz"); } if (hintType == HINT_3DB_L) { if (!(c1 instanceof ResistorElm)) return null; if (!(c2 instanceof InductorElm)) return null; ResistorElm re = (ResistorElm) c1; InductorElm ie = (InductorElm) c2; return "f.3db = " + CircuitElm.getUnitText(re.resistance/(2*pi*ie.inductance), "Hz"); } if (hintType == HINT_TWINT) { if (!(c1 instanceof ResistorElm)) return null; if (!(c2 instanceof CapacitorElm)) return null; ResistorElm re = (ResistorElm) c1; CapacitorElm ce = (CapacitorElm) c2; return "fc = " + CircuitElm.getUnitText(1/(2*pi*re.resistance*ce.capacitance), "Hz"); } return null; } public void toggleSwitch(int n) { int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce instanceof SwitchElm) { n--; if (n == 0) { ((SwitchElm) ce).toggle(); analyzeFlag = true; cv.repaint(); return; } } } } void needAnalyze() { analyzeFlag = true; cv.repaint(); } Vector nodeList; CircuitElm voltageSources[]; public CircuitNode getCircuitNode(int n) { if (n >= nodeList.size()) return null; return nodeList.elementAt(n); } public CircuitElm getElm(int n) { if (n >= elmList.size()) return null; return elmList.elementAt(n); } void analyzeCircuit() { calcCircuitBottom(); if (elmList.isEmpty()) return; stopMessage = null; stopElm = null; int i, j; int vscount = 0; nodeList = new Vector(); boolean gotGround = false; boolean gotRail = false; CircuitElm volt = null; //System.out.println("ac1"); // look for voltage or ground element for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce instanceof GroundElm) { gotGround = true; break; } if (ce instanceof RailElm) gotRail = true; if (volt == null && ce instanceof VoltageElm) volt = ce; } // if no ground, and no rails, then the voltage elm's first terminal // is ground if (!gotGround && volt != null && !gotRail) { CircuitNode cn = new CircuitNode(); Point pt = volt.getPost(0); cn.x = pt.x; cn.y = pt.y; nodeList.addElement(cn); } else { // otherwise allocate extra node for ground CircuitNode cn = new CircuitNode(); cn.x = cn.y = -1; nodeList.addElement(cn); } //System.out.println("ac2"); // allocate nodes and voltage sources for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); int inodes = ce.getInternalNodeCount(); int ivs = ce.getVoltageSourceCount(); int posts = ce.getPostCount(); // allocate a node for each post and match posts to nodes for (j = 0; j != posts; j++) { Point pt = ce.getPost(j); int k; for (k = 0; k != nodeList.size(); k++) { CircuitNode cn = getCircuitNode(k); if (pt.x == cn.x && pt.y == cn.y) break; } if (k == nodeList.size()) { CircuitNode cn = new CircuitNode(); cn.x = pt.x; cn.y = pt.y; CircuitNodeLink cnl = new CircuitNodeLink(); cnl.num = j; cnl.elm = ce; cn.links.addElement(cnl); ce.setNode(j, nodeList.size()); nodeList.addElement(cn); } else { CircuitNodeLink cnl = new CircuitNodeLink(); cnl.num = j; cnl.elm = ce; getCircuitNode(k).links.addElement(cnl); ce.setNode(j, k); // if it's the ground node, make sure the node voltage is 0, // cause it may not get set later if (k == 0) ce.setNodeVoltage(j, 0); } } for (j = 0; j != inodes; j++) { CircuitNode cn = new CircuitNode(); cn.x = cn.y = -1; cn.internal = true; CircuitNodeLink cnl = new CircuitNodeLink(); cnl.num = j+posts; cnl.elm = ce; cn.links.addElement(cnl); ce.setNode(cnl.num, nodeList.size()); nodeList.addElement(cn); } vscount += ivs; } voltageSources = new CircuitElm[vscount]; vscount = 0; circuitNonLinear = false; //System.out.println("ac3"); // determine if circuit is nonlinear for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.nonLinear()) circuitNonLinear = true; int ivs = ce.getVoltageSourceCount(); for (j = 0; j != ivs; j++) { voltageSources[vscount] = ce; ce.setVoltageSource(j, vscount++); } } voltageSourceCount = vscount; int matrixSize = nodeList.size()-1 + vscount; circuitMatrix = new double[matrixSize][matrixSize]; circuitRightSide = new double[matrixSize]; origMatrix = new double[matrixSize][matrixSize]; origRightSide = new double[matrixSize]; circuitMatrixSize = circuitMatrixFullSize = matrixSize; circuitRowInfo = new RowInfo[matrixSize]; circuitPermute = new int[matrixSize]; int vs = 0; for (i = 0; i != matrixSize; i++) circuitRowInfo[i] = new RowInfo(); circuitNeedsMap = false; // stamp linear circuit elements for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.stamp(); } //System.out.println("ac4"); // determine nodes that are unconnected boolean closure[] = new boolean[nodeList.size()]; boolean tempclosure[] = new boolean[nodeList.size()]; boolean changed = true; closure[0] = true; while (changed) { changed = false; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); // loop through all ce's nodes to see if they are connected // to other nodes not in closure for (j = 0; j < ce.getPostCount(); j++) { if (!closure[ce.getNode(j)]) { if (ce.hasGroundConnection(j)) closure[ce.getNode(j)] = changed = true; continue; } int k; for (k = 0; k != ce.getPostCount(); k++) { if (j == k) continue; int kn = ce.getNode(k); if (ce.getConnection(j, k) && !closure[kn]) { closure[kn] = true; changed = true; } } } } if (changed) continue; // connect unconnected nodes for (i = 0; i != nodeList.size(); i++) if (!closure[i] && !getCircuitNode(i).internal) { System.out.println("node " + i + " unconnected"); stampResistor(0, i, 1e8); closure[i] = true; changed = true; break; } } //System.out.println("ac5"); for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); // look for inductors with no current path if (ce instanceof InductorElm) { FindPathInfo fpi = new FindPathInfo(FindPathInfo.INDUCT, ce, ce.getNode(1)); // first try findPath with maximum depth of 5, to avoid slowdowns if (!fpi.findPath(ce.getNode(0), 5) && !fpi.findPath(ce.getNode(0))) { System.out.println(ce + " no path"); ce.reset(); } } // look for current sources with no current path if (ce instanceof CurrentElm) { FindPathInfo fpi = new FindPathInfo(FindPathInfo.INDUCT, ce, ce.getNode(1)); if (!fpi.findPath(ce.getNode(0))) { stop("No path for current source!", ce); return; } } // look for voltage source loops if ((ce instanceof VoltageElm && ce.getPostCount() == 2) || ce instanceof WireElm) { FindPathInfo fpi = new FindPathInfo(FindPathInfo.VOLTAGE, ce, ce.getNode(1)); if (fpi.findPath(ce.getNode(0))) { stop("Voltage source/wire loop with no resistance!", ce); return; } } // look for shorted caps, or caps w/ voltage but no R if (ce instanceof CapacitorElm) { FindPathInfo fpi = new FindPathInfo(FindPathInfo.SHORT, ce, ce.getNode(1)); if (fpi.findPath(ce.getNode(0))) { System.out.println(ce + " shorted"); ce.reset(); } else { fpi = new FindPathInfo(FindPathInfo.CAP_V, ce, ce.getNode(1)); if (fpi.findPath(ce.getNode(0))) { stop("Capacitor loop with no resistance!", ce); return; } } } } //System.out.println("ac6"); // simplify the matrix; this speeds things up quite a bit for (i = 0; i != matrixSize; i++) { int qm = -1, qp = -1; double qv = 0; RowInfo re = circuitRowInfo[i]; /*System.out.println("row " + i + " " + re.lsChanges + " " + re.rsChanges + " " + re.dropRow);*/ if (re.lsChanges || re.dropRow || re.rsChanges) continue; double rsadd = 0; // look for rows that can be removed for (j = 0; j != matrixSize; j++) { double q = circuitMatrix[i][j]; if (circuitRowInfo[j].type == RowInfo.ROW_CONST) { // keep a running total of const values that have been // removed already rsadd -= circuitRowInfo[j].value*q; continue; } if (q == 0) continue; if (qp == -1) { qp = j; qv = q; continue; } if (qm == -1 && q == -qv) { qm = j; continue; } break; } //System.out.println("line " + i + " " + qp + " " + qm + " " + j); /*if (qp != -1 && circuitRowInfo[qp].lsChanges) { System.out.println("lschanges"); continue; } if (qm != -1 && circuitRowInfo[qm].lsChanges) { System.out.println("lschanges"); continue; }*/ if (j == matrixSize) { if (qp == -1) { stop("Matrix error", null); return; } RowInfo elt = circuitRowInfo[qp]; if (qm == -1) { // we found a row with only one nonzero entry; that value // is a constant int k; for (k = 0; elt.type == RowInfo.ROW_EQUAL && k < 100; k++) { // follow the chain /*System.out.println("following equal chain from " + i + " " + qp + " to " + elt.nodeEq);*/ qp = elt.nodeEq; elt = circuitRowInfo[qp]; } if (elt.type == RowInfo.ROW_EQUAL) { // break equal chains //System.out.println("Break equal chain"); elt.type = RowInfo.ROW_NORMAL; continue; } if (elt.type != RowInfo.ROW_NORMAL) { System.out.println("type already " + elt.type + " for " + qp + "!"); continue; } elt.type = RowInfo.ROW_CONST; elt.value = (circuitRightSide[i]+rsadd)/qv; circuitRowInfo[i].dropRow = true; //System.out.println(qp + " * " + qv + " = const " + elt.value); i = -1; // start over from scratch } else if (circuitRightSide[i]+rsadd == 0) { // we found a row with only two nonzero entries, and one // is the negative of the other; the values are equal if (elt.type != RowInfo.ROW_NORMAL) { //System.out.println("swapping"); int qq = qm; qm = qp; qp = qq; elt = circuitRowInfo[qp]; if (elt.type != RowInfo.ROW_NORMAL) { // we should follow the chain here, but this // hardly ever happens so it's not worth worrying // about System.out.println("swap failed"); continue; } } elt.type = RowInfo.ROW_EQUAL; elt.nodeEq = qm; circuitRowInfo[i].dropRow = true; //System.out.println(qp + " = " + qm); } } } //System.out.println("ac7"); // find size of new matrix int nn = 0; for (i = 0; i != matrixSize; i++) { RowInfo elt = circuitRowInfo[i]; if (elt.type == RowInfo.ROW_NORMAL) { elt.mapCol = nn++; //System.out.println("col " + i + " maps to " + elt.mapCol); continue; } if (elt.type == RowInfo.ROW_EQUAL) { RowInfo e2 = null; // resolve chains of equality; 100 max steps to avoid loops for (j = 0; j != 100; j++) { e2 = circuitRowInfo[elt.nodeEq]; if (e2.type != RowInfo.ROW_EQUAL) break; if (i == e2.nodeEq) break; elt.nodeEq = e2.nodeEq; } } if (elt.type == RowInfo.ROW_CONST) elt.mapCol = -1; } for (i = 0; i != matrixSize; i++) { RowInfo elt = circuitRowInfo[i]; if (elt.type == RowInfo.ROW_EQUAL) { RowInfo e2 = circuitRowInfo[elt.nodeEq]; if (e2.type == RowInfo.ROW_CONST) { // if something is equal to a const, it's a const elt.type = e2.type; elt.value = e2.value; elt.mapCol = -1; //System.out.println(i + " = [late]const " + elt.value); } else { elt.mapCol = e2.mapCol; //System.out.println(i + " maps to: " + e2.mapCol); } } } //System.out.println("ac8"); /*System.out.println("matrixSize = " + matrixSize); for (j = 0; j != circuitMatrixSize; j++) { System.out.println(j + ": "); for (i = 0; i != circuitMatrixSize; i++) System.out.print(circuitMatrix[j][i] + " "); System.out.print(" " + circuitRightSide[j] + "\n"); } System.out.print("\n");*/ // make the new, simplified matrix int newsize = nn; double newmatx[][] = new double[newsize][newsize]; double newrs [] = new double[newsize]; int ii = 0; for (i = 0; i != matrixSize; i++) { RowInfo rri = circuitRowInfo[i]; if (rri.dropRow) { rri.mapRow = -1; continue; } newrs[ii] = circuitRightSide[i]; rri.mapRow = ii; //System.out.println("Row " + i + " maps to " + ii); for (j = 0; j != matrixSize; j++) { RowInfo ri = circuitRowInfo[j]; if (ri.type == RowInfo.ROW_CONST) newrs[ii] -= ri.value*circuitMatrix[i][j]; else newmatx[ii][ri.mapCol] += circuitMatrix[i][j]; } ii++; } circuitMatrix = newmatx; circuitRightSide = newrs; matrixSize = circuitMatrixSize = newsize; for (i = 0; i != matrixSize; i++) origRightSide[i] = circuitRightSide[i]; for (i = 0; i != matrixSize; i++) for (j = 0; j != matrixSize; j++) origMatrix[i][j] = circuitMatrix[i][j]; circuitNeedsMap = true; /* System.out.println("matrixSize = " + matrixSize + " " + circuitNonLinear); for (j = 0; j != circuitMatrixSize; j++) { for (i = 0; i != circuitMatrixSize; i++) System.out.print(circuitMatrix[j][i] + " "); System.out.print(" " + circuitRightSide[j] + "\n"); } System.out.print("\n");*/ // if a matrix is linear, we can do the lu_factor here instead of // needing to do it every frame if (!circuitNonLinear) { if (!lu_factor(circuitMatrix, circuitMatrixSize, circuitPermute)) { stop("Singular matrix!", null); return; } } } void calcCircuitBottom() { int i; circuitBottom = 0; for (i = 0; i != elmList.size(); i++) { Rectangle rect = getElm(i).boundingBox; int bottom = rect.height + rect.y; if (bottom > circuitBottom) circuitBottom = bottom; } } class FindPathInfo { static final int INDUCT = 1; static final int VOLTAGE = 2; static final int SHORT = 3; static final int CAP_V = 4; boolean used[]; int dest; CircuitElm firstElm; int type; FindPathInfo(int t, CircuitElm e, int d) { dest = d; type = t; firstElm = e; used = new boolean[nodeList.size()]; } boolean findPath(int n1) { return findPath(n1, -1); } boolean findPath(int n1, int depth) { if (n1 == dest) return true; if (depth-- == 0) return false; if (used[n1]) { //System.out.println("used " + n1); return false; } used[n1] = true; int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce == firstElm) continue; if (type == INDUCT) { if (ce instanceof CurrentElm) continue; } if (type == VOLTAGE) { if (!(ce.isWire() || ce instanceof VoltageElm)) continue; } if (type == SHORT && !ce.isWire()) continue; if (type == CAP_V) { if (!(ce.isWire() || ce instanceof CapacitorElm || ce instanceof VoltageElm)) continue; } if (n1 == 0) { // look for posts which have a ground connection; // our path can go through ground int j; for (j = 0; j != ce.getPostCount(); j++) if (ce.hasGroundConnection(j) && findPath(ce.getNode(j), depth)) { used[n1] = false; return true; } } int j; for (j = 0; j != ce.getPostCount(); j++) { //System.out.println(ce + " " + ce.getNode(j)); if (ce.getNode(j) == n1) break; } if (j == ce.getPostCount()) continue; if (ce.hasGroundConnection(j) && findPath(0, depth)) { //System.out.println(ce + " has ground"); used[n1] = false; return true; } if (type == INDUCT && ce instanceof InductorElm) { double c = ce.getCurrent(); if (j == 0) c = -c; //System.out.println("matching " + c + " to " + firstElm.getCurrent()); //System.out.println(ce + " " + firstElm); if (Math.abs(c-firstElm.getCurrent()) > 1e-10) continue; } int k; for (k = 0; k != ce.getPostCount(); k++) { if (j == k) continue; //System.out.println(ce + " " + ce.getNode(j) + "-" + ce.getNode(k)); if (ce.getConnection(j, k) && findPath(ce.getNode(k), depth)) { //System.out.println("got findpath " + n1); used[n1] = false; return true; } //System.out.println("back on findpath " + n1); } } used[n1] = false; //System.out.println(n1 + " failed"); return false; } } void stop(String s, CircuitElm ce) { stopMessage = s; circuitMatrix = null; stopElm = ce; stoppedCheck.setState(true); analyzeFlag = false; cv.repaint(); } // control voltage source vs with voltage from n1 to n2 (must // also call stampVoltageSource()) void stampVCVS(int n1, int n2, double coef, int vs) { int vn = nodeList.size()+vs; stampMatrix(vn, n1, coef); stampMatrix(vn, n2, -coef); } // stamp independent voltage source #vs, from n1 to n2, amount v void stampVoltageSource(int n1, int n2, int vs, double v) { int vn = nodeList.size()+vs; stampMatrix(vn, n1, -1); stampMatrix(vn, n2, 1); stampRightSide(vn, v); stampMatrix(n1, vn, 1); stampMatrix(n2, vn, -1); } // use this if the amount of voltage is going to be updated in doStep() void stampVoltageSource(int n1, int n2, int vs) { int vn = nodeList.size()+vs; stampMatrix(vn, n1, -1); stampMatrix(vn, n2, 1); stampRightSide(vn); stampMatrix(n1, vn, 1); stampMatrix(n2, vn, -1); } void updateVoltageSource(int n1, int n2, int vs, double v) { int vn = nodeList.size()+vs; stampRightSide(vn, v); } void stampResistor(int n1, int n2, double r) { double r0 = 1/r; if (Double.isNaN(r0) || Double.isInfinite(r0)) { System.out.print("bad resistance " + r + " " + r0 + "\n"); int a = 0; a /= a; } stampMatrix(n1, n1, r0); stampMatrix(n2, n2, r0); stampMatrix(n1, n2, -r0); stampMatrix(n2, n1, -r0); } void stampConductance(int n1, int n2, double r0) { stampMatrix(n1, n1, r0); stampMatrix(n2, n2, r0); stampMatrix(n1, n2, -r0); stampMatrix(n2, n1, -r0); } // current from cn1 to cn2 is equal to voltage from vn1 to 2, divided by g void stampVCCurrentSource(int cn1, int cn2, int vn1, int vn2, double g) { stampMatrix(cn1, vn1, g); stampMatrix(cn2, vn2, g); stampMatrix(cn1, vn2, -g); stampMatrix(cn2, vn1, -g); } void stampCurrentSource(int n1, int n2, double i) { stampRightSide(n1, -i); stampRightSide(n2, i); } // stamp a current source from n1 to n2 depending on current through vs void stampCCCS(int n1, int n2, int vs, double gain) { int vn = nodeList.size()+vs; stampMatrix(n1, vn, gain); stampMatrix(n2, vn, -gain); } // stamp value x in row i, column j, meaning that a voltage change // of dv in node j will increase the current into node i by x dv. // (Unless i or j is a voltage source node.) void stampMatrix(int i, int j, double x) { if (i > 0 && j > 0) { if (circuitNeedsMap) { i = circuitRowInfo[i-1].mapRow; RowInfo ri = circuitRowInfo[j-1]; if (ri.type == RowInfo.ROW_CONST) { //System.out.println("Stamping constant " + i + " " + j + " " + x); circuitRightSide[i] -= x*ri.value; return; } j = ri.mapCol; //System.out.println("stamping " + i + " " + j + " " + x); } else { i--; j--; } circuitMatrix[i][j] += x; } } // stamp value x on the right side of row i, representing an // independent current source flowing into node i void stampRightSide(int i, double x) { if (i > 0) { if (circuitNeedsMap) { i = circuitRowInfo[i-1].mapRow; //System.out.println("stamping " + i + " " + x); } else i--; circuitRightSide[i] += x; } } // indicate that the value on the right side of row i changes in doStep() void stampRightSide(int i) { //System.out.println("rschanges true " + (i-1)); if (i > 0) circuitRowInfo[i-1].rsChanges = true; } // indicate that the values on the left side of row i change in doStep() void stampNonLinear(int i) { if (i > 0) circuitRowInfo[i-1].lsChanges = true; } double getIterCount() { if (speedBar.getValue() == 0) return 0; //return (Math.exp((speedBar.getValue()-1)/24.) + .5); return .1*Math.exp((speedBar.getValue()-61)/24.); } boolean converged; int subIterations; void runCircuit() { if (circuitMatrix == null || elmList.size() == 0) { circuitMatrix = null; return; } int iter; //int maxIter = getIterCount(); boolean debugprint = dumpMatrix; dumpMatrix = false; long steprate = (long) (160*getIterCount()); long tm = System.currentTimeMillis(); long lit = lastIterTime; if (1000 >= steprate*(tm-lastIterTime)) return; for (iter = 1; ; iter++) { int i, j, k, subiter; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.startIteration(); } steps++; final int subiterCount = 5000; for (subiter = 0; subiter != subiterCount; subiter++) { converged = true; subIterations = subiter; for (i = 0; i != circuitMatrixSize; i++) circuitRightSide[i] = origRightSide[i]; if (circuitNonLinear) { for (i = 0; i != circuitMatrixSize; i++) for (j = 0; j != circuitMatrixSize; j++) circuitMatrix[i][j] = origMatrix[i][j]; } for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.doStep(); } if (stopMessage != null) return; boolean printit = debugprint; debugprint = false; for (j = 0; j != circuitMatrixSize; j++) { for (i = 0; i != circuitMatrixSize; i++) { double x = circuitMatrix[i][j]; if (Double.isNaN(x) || Double.isInfinite(x)) { stop("nan/infinite matrix!", null); return; } } } if (printit) { for (j = 0; j != circuitMatrixSize; j++) { for (i = 0; i != circuitMatrixSize; i++) System.out.print(circuitMatrix[j][i] + ","); System.out.print(" " + circuitRightSide[j] + "\n"); } System.out.print("\n"); } if (circuitNonLinear) { if (converged && subiter > 0) break; if (!lu_factor(circuitMatrix, circuitMatrixSize, circuitPermute)) { stop("Singular matrix!", null); return; } } lu_solve(circuitMatrix, circuitMatrixSize, circuitPermute, circuitRightSide); for (j = 0; j != circuitMatrixFullSize; j++) { RowInfo ri = circuitRowInfo[j]; double res = 0; if (ri.type == RowInfo.ROW_CONST) res = ri.value; else res = circuitRightSide[ri.mapCol]; /*System.out.println(j + " " + res + " " + ri.type + " " + ri.mapCol);*/ if (Double.isNaN(res)) { converged = false; //debugprint = true; break; } if (j < nodeList.size()-1) { CircuitNode cn = getCircuitNode(j+1); for (k = 0; k != cn.links.size(); k++) { CircuitNodeLink cnl = (CircuitNodeLink) cn.links.elementAt(k); cnl.elm.setNodeVoltage(cnl.num, res); } } else { int ji = j-(nodeList.size()-1); //System.out.println("setting vsrc " + ji + " to " + res); voltageSources[ji].setCurrent(ji, res); } } if (!circuitNonLinear) break; } if (subiter > 5) System.out.print("converged after " + subiter + " iterations\n"); if (subiter == subiterCount) { stop("Convergence failed!", null); break; } t += timeStep; for (i = 0; i != scopeCount; i++) scopes[i].timeStep(); tm = System.currentTimeMillis(); lit = tm; if (iter*1000 >= steprate*(tm-lastIterTime) || (tm-lastFrameTime > 500)) break; } lastIterTime = lit; //System.out.println((System.currentTimeMillis()-lastFrameTime)/(double) iter); } int min(int a, int b) { return (a < b) ? a : b; } int max(int a, int b) { return (a > b) ? a : b; } void editFuncPoint(int x, int y) { // XXX cv.repaint(pause); } public void componentHidden(ComponentEvent e){} public void componentMoved(ComponentEvent e){} public void componentShown(ComponentEvent e) { cv.repaint(); } public void componentResized(ComponentEvent e) { handleResize(); cv.repaint(100); } public void actionPerformed(ActionEvent e) { String ac = e.getActionCommand(); if (e.getSource() == resetButton) { int i; // on IE, drawImage() stops working inexplicably every once in // a while. Recreating it fixes the problem, so we do that here. dbimage = main.createImage(winSize.width, winSize.height); for (i = 0; i != elmList.size(); i++) getElm(i).reset(); for (i = 0; i != scopeCount; i++) scopes[i].resetGraph(); analyzeFlag = true; t = 0; stoppedCheck.setState(false); cv.repaint(); } if (e.getSource() == dumpMatrixButton) dumpMatrix = true; if (e.getSource() == exportItem) doExport(false); if (e.getSource() == optionsItem) doEdit(new EditOptions(this)); if (e.getSource() == importItem) doImport(); if (e.getSource() == exportLinkItem) doExport(true); if (e.getSource() == undoItem) doUndo(); if (e.getSource() == redoItem) doRedo(); if (ac.compareTo("Cut") == 0) { if (e.getSource() != elmCutMenuItem) menuElm = null; doCut(); } if (ac.compareTo("Copy") == 0) { if (e.getSource() != elmCopyMenuItem) menuElm = null; doCopy(); } if (ac.compareTo("Paste") == 0) doPaste(); if (e.getSource() == selectAllItem) doSelectAll(); if (e.getSource() == exitItem) { destroyFrame(); return; } if (ac.compareTo("stackAll") == 0) stackAll(); if (ac.compareTo("unstackAll") == 0) unstackAll(); if (e.getSource() == elmEditMenuItem) doEdit(menuElm); if (ac.compareTo("Delete") == 0) { if (e.getSource() != elmDeleteMenuItem) menuElm = null; doDelete(); } if (e.getSource() == elmScopeMenuItem && menuElm != null) { int i; for (i = 0; i != scopeCount; i++) if (scopes[i].elm == null) break; if (i == scopeCount) { if (scopeCount == scopes.length) return; scopeCount++; scopes[i] = new Scope(this); scopes[i].position = i; handleResize(); } scopes[i].setElm(menuElm); } if (menuScope != -1) { if (ac.compareTo("remove") == 0) scopes[menuScope].setElm(null); if (ac.compareTo("speed2") == 0) scopes[menuScope].speedUp(); if (ac.compareTo("speed1/2") == 0) scopes[menuScope].slowDown(); if (ac.compareTo("scale") == 0) scopes[menuScope].adjustScale(.5); if (ac.compareTo("maxscale") == 0) scopes[menuScope].adjustScale(1e-50); if (ac.compareTo("stack") == 0) stackScope(menuScope); if (ac.compareTo("unstack") == 0) unstackScope(menuScope); if (ac.compareTo("selecty") == 0) scopes[menuScope].selectY(); if (ac.compareTo("reset") == 0) scopes[menuScope].resetGraph(); cv.repaint(); } if (ac.indexOf("setup ") == 0) { pushUndo(); readSetupFile(ac.substring(6), ((MenuItem) e.getSource()).getLabel()); } } void stackScope(int s) { if (s == 0) { if (scopeCount < 2) return; s = 1; } if (scopes[s].position == scopes[s-1].position) return; scopes[s].position = scopes[s-1].position; for (s++; s < scopeCount; s++) scopes[s].position--; } void unstackScope(int s) { if (s == 0) { if (scopeCount < 2) return; s = 1; } if (scopes[s].position != scopes[s-1].position) return; for (; s < scopeCount; s++) scopes[s].position++; } void stackAll() { int i; for (i = 0; i != scopeCount; i++) { scopes[i].position = 0; scopes[i].showMax = scopes[i].showMin = false; } } void unstackAll() { int i; for (i = 0; i != scopeCount; i++) { scopes[i].position = i; scopes[i].showMax = true; } } void doEdit(Editable eable) { clearSelection(); pushUndo(); if (editDialog != null) { requestFocus(); editDialog.setVisible(false); editDialog = null; } editDialog = new EditDialog(eable, this); editDialog.show(); } void doImport() { if (impDialog == null) impDialog = ImportExportDialogFactory.Create(this, ImportExportDialog.Action.IMPORT); // impDialog = new ImportExportClipboardDialog(this, // ImportExportDialog.Action.IMPORT); pushUndo(); impDialog.execute(); } void doExport(boolean url) { String dump = dumpCircuit(); if (url) dump = baseURL + "#" + URLEncoder.encode(dump); if (expDialog == null) { expDialog = ImportExportDialogFactory.Create(this, ImportExportDialog.Action.EXPORT); // expDialog = new ImportExportClipboardDialog(this, // ImportExportDialog.Action.EXPORT); } expDialog.setDump(dump); expDialog.execute(); } String dumpCircuit() { int i; int f = (dotsCheckItem.getState()) ? 1 : 0; f |= (smallGridCheckItem.getState()) ? 2 : 0; f |= (voltsCheckItem.getState()) ? 0 : 4; f |= (powerCheckItem.getState()) ? 8 : 0; f |= (showValuesCheckItem.getState()) ? 0 : 16; // 32 = linear scale in afilter String dump = "$ " + f + " " + timeStep + " " + getIterCount() + " " + currentBar.getValue() + " " + CircuitElm.voltageRange + " " + powerBar.getValue() + "\n"; for (i = 0; i != elmList.size(); i++) dump += getElm(i).dump() + "\n"; for (i = 0; i != scopeCount; i++) { String d = scopes[i].dump(); if (d != null) dump += d + "\n"; } if (hintType != -1) dump += "h " + hintType + " " + hintItem1 + " " + hintItem2 + "\n"; return dump; } public void adjustmentValueChanged(AdjustmentEvent e) { System.out.print(((Scrollbar) e.getSource()).getValue() + "\n"); } ByteArrayOutputStream readUrlData(URL url) throws java.io.IOException { Object o = url.getContent(); FilterInputStream fis = (FilterInputStream) o; ByteArrayOutputStream ba = new ByteArrayOutputStream(fis.available()); int blen = 1024; byte b[] = new byte[blen]; while (true) { int len = fis.read(b); if (len <= 0) break; ba.write(b, 0, len); } return ba; } URL getCodeBase() { try { if (applet != null) return applet.getCodeBase(); File f = new File("."); return new URL("file:" + f.getCanonicalPath() + "/"); } catch (Exception e) { e.printStackTrace(); return null; } } void getSetupList(Menu menu, boolean retry) { Menu stack[] = new Menu[6]; int stackptr = 0; stack[stackptr++] = menu; try { // hausen: if setuplist.txt does not exist in the same // directory, try reading from the jar file ByteArrayOutputStream ba = null; try { URL url = new URL(getCodeBase() + "setuplist.txt"); ba = readUrlData(url); } catch (Exception e) { URL url = getClass().getClassLoader().getResource("setuplist.txt"); ba = readUrlData(url); } // /hausen byte b[] = ba.toByteArray(); int len = ba.size(); int p; if (len == 0 || b[0] != '#') { // got a redirect, try again getSetupList(menu, true); return; } for (p = 0; p < len; ) { int l; for (l = 0; l != len-p; l++) if (b[l+p] == '\n') { l++; break; } String line = new String(b, p, l-1); if (line.charAt(0) == '#') ; else if (line.charAt(0) == '+') { Menu n = new Menu(line.substring(1)); menu.add(n); menu = stack[stackptr++] = n; } else if (line.charAt(0) == '-') { menu = stack[--stackptr-1]; } else { int i = line.indexOf(' '); if (i > 0) { String title = line.substring(i+1); boolean first = false; if (line.charAt(0) == '>') first = true; String file = line.substring(first ? 1 : 0, i); menu.add(getMenuItem(title, "setup " + file)); if (first && startCircuit == null) { startCircuit = file; startLabel = title; } } } p += l; } } catch (Exception e) { e.printStackTrace(); stop("Can't read setuplist.txt!", null); } } void readSetup(String text) { readSetup(text, false); } void readSetup(String text, boolean retain) { readSetup(text.getBytes(), text.length(), retain); titleLabel.setText("untitled"); } void readSetupFile(String str, String title) { t = 0; System.out.println(str); try { URL url = new URL(getCodeBase() + "circuits/" + str); ByteArrayOutputStream ba = readUrlData(url); readSetup(ba.toByteArray(), ba.size(), false); } catch (Exception e1) { try { URL url = getClass().getClassLoader().getResource("circuits/" + str); ByteArrayOutputStream ba = readUrlData(url); readSetup(ba.toByteArray(), ba.size(), false); } catch (Exception e) { e.printStackTrace(); stop("Unable to read " + str + "!", null); } } titleLabel.setText(title); } void readSetup(byte b[], int len, boolean retain) { int i; if (!retain) { for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.delete(); } elmList.removeAllElements(); hintType = -1; timeStep = 5e-6; dotsCheckItem.setState(false); // hausen: changed from true to false smallGridCheckItem.setState(false); powerCheckItem.setState(false); voltsCheckItem.setState(true); showValuesCheckItem.setState(true); setGrid(); speedBar.setValue(117); // 57 currentBar.setValue(50); powerBar.setValue(50); CircuitElm.voltageRange = 5; scopeCount = 0; } cv.repaint(); int p; for (p = 0; p < len; ) { int l; int linelen = 0; for (l = 0; l != len-p; l++) if (b[l+p] == '\n' || b[l+p] == '\r') { linelen = l++; if (l+p < b.length && b[l+p] == '\n') l++; break; } String line = new String(b, p, linelen); StringTokenizer st = new StringTokenizer(line); while (st.hasMoreTokens()) { String type = st.nextToken(); int tint = type.charAt(0); try { if (tint == 'o') { Scope sc = new Scope(this); sc.position = scopeCount; sc.undump(st); scopes[scopeCount++] = sc; break; } if (tint == 'h') { readHint(st); break; } if (tint == '$') { readOptions(st); break; } if (tint == '%' || tint == '?' || tint == 'B') { // ignore afilter-specific stuff break; } if (tint >= '0' && tint <= '9') tint = new Integer(type).intValue(); int x1 = new Integer(st.nextToken()).intValue(); int y1 = new Integer(st.nextToken()).intValue(); int x2 = new Integer(st.nextToken()).intValue(); int y2 = new Integer(st.nextToken()).intValue(); int f = new Integer(st.nextToken()).intValue(); CircuitElm ce = null; Class cls = dumpTypes[tint]; if (cls == null) { System.out.println("unrecognized dump type: " + type); break; } // find element class Class carr[] = new Class[6]; //carr[0] = getClass(); carr[0] = carr[1] = carr[2] = carr[3] = carr[4] = int.class; carr[5] = StringTokenizer.class; Constructor cstr = null; cstr = cls.getConstructor(carr); // invoke constructor with starting coordinates Object oarr[] = new Object[6]; //oarr[0] = this; oarr[0] = new Integer(x1); oarr[1] = new Integer(y1); oarr[2] = new Integer(x2); oarr[3] = new Integer(y2); oarr[4] = new Integer(f ); oarr[5] = st; ce = (CircuitElm) cstr.newInstance(oarr); ce.setPoints(); elmList.addElement(ce); } catch (java.lang.reflect.InvocationTargetException ee) { ee.getTargetException().printStackTrace(); break; } catch (Exception ee) { ee.printStackTrace(); break; } break; } p += l; } enableItems(); if (!retain) handleResize(); // for scopes needAnalyze(); } void readHint(StringTokenizer st) { hintType = new Integer(st.nextToken()).intValue(); hintItem1 = new Integer(st.nextToken()).intValue(); hintItem2 = new Integer(st.nextToken()).intValue(); } void readOptions(StringTokenizer st) { int flags = new Integer(st.nextToken()).intValue(); dotsCheckItem.setState((flags & 1) != 0); smallGridCheckItem.setState((flags & 2) != 0); voltsCheckItem.setState((flags & 4) == 0); powerCheckItem.setState((flags & 8) == 8); showValuesCheckItem.setState((flags & 16) == 0); timeStep = new Double (st.nextToken()).doubleValue(); double sp = new Double(st.nextToken()).doubleValue(); int sp2 = (int) (Math.log(10*sp)*24+61.5); //int sp2 = (int) (Math.log(sp)*24+1.5); speedBar.setValue(sp2); currentBar.setValue(new Integer(st.nextToken()).intValue()); CircuitElm.voltageRange = new Double (st.nextToken()).doubleValue(); try { powerBar.setValue(new Integer(st.nextToken()).intValue()); } catch (Exception e) { } setGrid(); } int snapGrid(int x) { return (x+gridRound) & gridMask; } boolean doSwitch(int x, int y) { if (mouseElm == null || !(mouseElm instanceof SwitchElm)) return false; SwitchElm se = (SwitchElm) mouseElm; se.toggle(); if (se.momentary) heldSwitchElm = se; needAnalyze(); return true; } int locateElm(CircuitElm elm) { int i; for (i = 0; i != elmList.size(); i++) if (elm == elmList.elementAt(i)) return i; return -1; } public void mouseDragged(MouseEvent e) { // ignore right mouse button with no modifiers (needed on PC) if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) { int ex = e.getModifiersEx(); if ((ex & (MouseEvent.META_DOWN_MASK| MouseEvent.SHIFT_DOWN_MASK| MouseEvent.CTRL_DOWN_MASK| MouseEvent.ALT_DOWN_MASK)) == 0) return; } if (!circuitArea.contains(e.getX(), e.getY())) return; if (dragElm != null) dragElm.drag(e.getX(), e.getY()); boolean success = true; switch (tempMouseMode) { case MODE_DRAG_ALL: dragAll(snapGrid(e.getX()), snapGrid(e.getY())); break; case MODE_DRAG_ROW: dragRow(snapGrid(e.getX()), snapGrid(e.getY())); break; case MODE_DRAG_COLUMN: dragColumn(snapGrid(e.getX()), snapGrid(e.getY())); break; case MODE_DRAG_POST: if (mouseElm != null) dragPost(snapGrid(e.getX()), snapGrid(e.getY())); break; case MODE_SELECT: if (mouseElm == null) selectArea(e.getX(), e.getY()); else { tempMouseMode = MODE_DRAG_SELECTED; success = dragSelected(e.getX(), e.getY()); } break; case MODE_DRAG_SELECTED: success = dragSelected(e.getX(), e.getY()); break; } dragging = true; if (success) { if (tempMouseMode == MODE_DRAG_SELECTED && mouseElm instanceof GraphicElm ) { dragX = e.getX(); dragY = e.getY(); } else { dragX = snapGrid(e.getX()); dragY = snapGrid(e.getY()); } } cv.repaint(pause); } void dragAll(int x, int y) { int dx = x-dragX; int dy = y-dragY; if (dx == 0 && dy == 0) return; int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.move(dx, dy); } removeZeroLengthElements(); } void dragRow(int x, int y) { int dy = y-dragY; if (dy == 0) return; int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.y == dragY) ce.movePoint(0, 0, dy); if (ce.y2 == dragY) ce.movePoint(1, 0, dy); } removeZeroLengthElements(); } void dragColumn(int x, int y) { int dx = x-dragX; if (dx == 0) return; int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.x == dragX) ce.movePoint(0, dx, 0); if (ce.x2 == dragX) ce.movePoint(1, dx, 0); } removeZeroLengthElements(); } boolean dragSelected(int x, int y) { boolean me = false; if (mouseElm != null && !mouseElm.isSelected()) mouseElm.setSelected(me = true); // snap grid, unless we're only dragging text elements int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if ( ce.isSelected() && !(ce instanceof GraphicElm) ) break; } if (i != elmList.size()) { x = snapGrid(x); y = snapGrid(y); } int dx = x-dragX; int dy = y-dragY; if (dx == 0 && dy == 0) { // don't leave mouseElm selected if we selected it above if (me) mouseElm.setSelected(false); return false; } boolean allowed = true; // check if moves are allowed for (i = 0; allowed && i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.isSelected() && !ce.allowMove(dx, dy)) allowed = false; } if (allowed) { for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.isSelected()) ce.move(dx, dy); } needAnalyze(); } // don't leave mouseElm selected if we selected it above if (me) mouseElm.setSelected(false); return allowed; } void dragPost(int x, int y) { if (draggingPost == -1) { draggingPost = (distanceSq(mouseElm.x , mouseElm.y , x, y) > distanceSq(mouseElm.x2, mouseElm.y2, x, y)) ? 1 : 0; } int dx = x-dragX; int dy = y-dragY; if (dx == 0 && dy == 0) return; mouseElm.movePoint(draggingPost, dx, dy); needAnalyze(); } void selectArea(int x, int y) { int x1 = min(x, initDragX); int x2 = max(x, initDragX); int y1 = min(y, initDragY); int y2 = max(y, initDragY); selectedArea = new Rectangle(x1, y1, x2-x1, y2-y1); int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.selectRect(selectedArea); } } void setSelectedElm(CircuitElm cs) { int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.setSelected(ce == cs); } mouseElm = cs; } void removeZeroLengthElements() { int i; boolean changed = false; for (i = elmList.size()-1; i >= 0; i--) { CircuitElm ce = getElm(i); if (ce.x == ce.x2 && ce.y == ce.y2) { elmList.removeElementAt(i); ce.delete(); changed = true; } } needAnalyze(); } public void mouseMoved(MouseEvent e) { if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) return; int x = e.getX(); int y = e.getY(); dragX = snapGrid(x); dragY = snapGrid(y); draggingPost = -1; int i; CircuitElm origMouse = mouseElm; mouseElm = null; mousePost = -1; plotXElm = plotYElm = null; int bestDist = 100000; int bestArea = 100000; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); if (ce.boundingBox.contains(x, y)) { int j; int area = ce.boundingBox.width * ce.boundingBox.height; int jn = ce.getPostCount(); if (jn > 2) jn = 2; for (j = 0; j != jn; j++) { Point pt = ce.getPost(j); int dist = distanceSq(x, y, pt.x, pt.y); // if multiple elements have overlapping bounding boxes, // we prefer selecting elements that have posts close // to the mouse pointer and that have a small bounding // box area. if (dist <= bestDist && area <= bestArea) { bestDist = dist; bestArea = area; mouseElm = ce; } } if (ce.getPostCount() == 0) mouseElm = ce; } } scopeSelected = -1; if (mouseElm == null) { for (i = 0; i != scopeCount; i++) { Scope s = scopes[i]; if (s.rect.contains(x, y)) { s.select(); scopeSelected = i; } } // the mouse pointer was not in any of the bounding boxes, but we // might still be close to a post for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); int j; int jn = ce.getPostCount(); for (j = 0; j != jn; j++) { Point pt = ce.getPost(j); int dist = distanceSq(x, y, pt.x, pt.y); if (distanceSq(pt.x, pt.y, x, y) < 26) { mouseElm = ce; mousePost = j; break; } } } } else { mousePost = -1; // look for post close to the mouse pointer for (i = 0; i != mouseElm.getPostCount(); i++) { Point pt = mouseElm.getPost(i); if (distanceSq(pt.x, pt.y, x, y) < 26) mousePost = i; } } if (mouseElm != origMouse) cv.repaint(); } int distanceSq(int x1, int y1, int x2, int y2) { x2 -= x1; y2 -= y1; return x2*x2+y2*y2; } public void mouseClicked(MouseEvent e) { if ( e.getClickCount() == 2 && !didSwitch ) doEditMenu(e); if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { if (mouseMode == MODE_SELECT || mouseMode == MODE_DRAG_SELECTED) clearSelection(); } } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { scopeSelected = -1; mouseElm = plotXElm = plotYElm = null; cv.repaint(); } public void mousePressed(MouseEvent e) { didSwitch = false; System.out.println(e.getModifiers()); int ex = e.getModifiersEx(); if ((ex & (MouseEvent.META_DOWN_MASK| MouseEvent.SHIFT_DOWN_MASK)) == 0 && e.isPopupTrigger()) { doPopupMenu(e); return; } if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { // left mouse tempMouseMode = mouseMode; if ((ex & MouseEvent.ALT_DOWN_MASK) != 0 && (ex & MouseEvent.META_DOWN_MASK) != 0) tempMouseMode = MODE_DRAG_COLUMN; else if ((ex & MouseEvent.ALT_DOWN_MASK) != 0 && (ex & MouseEvent.SHIFT_DOWN_MASK) != 0) tempMouseMode = MODE_DRAG_ROW; else if ((ex & MouseEvent.SHIFT_DOWN_MASK) != 0) tempMouseMode = MODE_SELECT; else if ((ex & MouseEvent.ALT_DOWN_MASK) != 0) tempMouseMode = MODE_DRAG_ALL; else if ((ex & (MouseEvent.CTRL_DOWN_MASK| MouseEvent.META_DOWN_MASK)) != 0) tempMouseMode = MODE_DRAG_POST; } else if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) { // right mouse if ((ex & MouseEvent.SHIFT_DOWN_MASK) != 0) tempMouseMode = MODE_DRAG_ROW; else if ((ex & (MouseEvent.CTRL_DOWN_MASK| MouseEvent.META_DOWN_MASK)) != 0) tempMouseMode = MODE_DRAG_COLUMN; else return; } if (tempMouseMode != MODE_SELECT && tempMouseMode != MODE_DRAG_SELECTED) clearSelection(); if (mouseMode == MODE_SELECT && doSwitch(e.getX(), e.getY())) { didSwitch = true; return; } pushUndo(); initDragX = e.getX(); initDragY = e.getY(); dragging = true; if (tempMouseMode != MODE_ADD_ELM || addingClass == null) return; int x0 = snapGrid(e.getX()); int y0 = snapGrid(e.getY()); if (!circuitArea.contains(x0, y0)) return; dragElm = constructElement(addingClass, x0, y0); } CircuitElm constructElement(Class c, int x0, int y0) { // find element class Class carr[] = new Class[2]; //carr[0] = getClass(); carr[0] = carr[1] = int.class; Constructor cstr = null; try { cstr = c.getConstructor(carr); } catch (NoSuchMethodException ee) { System.out.println("caught NoSuchMethodException " + c); return null; } catch (Exception ee) { ee.printStackTrace(); return null; } // invoke constructor with starting coordinates Object oarr[] = new Object[2]; oarr[0] = new Integer(x0); oarr[1] = new Integer(y0); try { return (CircuitElm) cstr.newInstance(oarr); } catch (Exception ee) { ee.printStackTrace(); } return null; } // hausen: add doEditMenu void doEditMenu(MouseEvent e) { if( mouseElm != null ) doEdit(mouseElm); } void doPopupMenu(MouseEvent e) { menuElm = mouseElm; menuScope = -1; if (scopeSelected != -1) { PopupMenu m = scopes[scopeSelected].getMenu(); menuScope = scopeSelected; if (m != null) m.show(e.getComponent(), e.getX(), e.getY()); } else if (mouseElm != null) { elmEditMenuItem .setEnabled(mouseElm.getEditInfo(0) != null); elmScopeMenuItem.setEnabled(mouseElm.canViewInScope()); elmMenu.show(e.getComponent(), e.getX(), e.getY()); } else { doMainMenuChecks(mainMenu); mainMenu.show(e.getComponent(), e.getX(), e.getY()); } } void doMainMenuChecks(Menu m) { int i; if (m == optionsMenu) return; for (i = 0; i != m.getItemCount(); i++) { MenuItem mc = m.getItem(i); if (mc instanceof Menu) doMainMenuChecks((Menu) mc); if (mc instanceof CheckboxMenuItem) { CheckboxMenuItem cmi = (CheckboxMenuItem) mc; cmi.setState( mouseModeStr.compareTo(cmi.getActionCommand()) == 0); } } } public void mouseReleased(MouseEvent e) { int ex = e.getModifiersEx(); if ((ex & (MouseEvent.SHIFT_DOWN_MASK|MouseEvent.CTRL_DOWN_MASK| MouseEvent.META_DOWN_MASK)) == 0 && e.isPopupTrigger()) { doPopupMenu(e); return; } tempMouseMode = mouseMode; selectedArea = null; dragging = false; boolean circuitChanged = false; if (heldSwitchElm != null) { heldSwitchElm.mouseUp(); heldSwitchElm = null; circuitChanged = true; } if (dragElm != null) { // if the element is zero size then don't create it if (dragElm.x == dragElm.x2 && dragElm.y == dragElm.y2) dragElm.delete(); else { elmList.addElement(dragElm); circuitChanged = true; } dragElm = null; } if (circuitChanged) needAnalyze(); if (dragElm != null) dragElm.delete(); dragElm = null; cv.repaint(); } void enableItems() { if (powerCheckItem.getState()) { powerBar.enable(); powerLabel.enable(); } else { powerBar.disable(); powerLabel.disable(); } enableUndoRedo(); } public void itemStateChanged(ItemEvent e) { cv.repaint(pause); Object mi = e.getItemSelectable(); if (mi == stoppedCheck) return; if (mi == smallGridCheckItem) setGrid(); if (mi == powerCheckItem) { if (powerCheckItem.getState()) voltsCheckItem.setState(false); else voltsCheckItem.setState(true); } if (mi == voltsCheckItem && voltsCheckItem.getState()) powerCheckItem.setState(false); enableItems(); if (menuScope != -1) { Scope sc = scopes[menuScope]; sc.handleMenu(e, mi); } if (mi instanceof CheckboxMenuItem) { MenuItem mmi = (MenuItem) mi; int prevMouseMode = mouseMode; setMouseMode(MODE_ADD_ELM); String s = mmi.getActionCommand(); if (s.length() > 0) mouseModeStr = s; if (s.compareTo("DragAll") == 0) setMouseMode(MODE_DRAG_ALL); else if (s.compareTo("DragRow") == 0) setMouseMode(MODE_DRAG_ROW); else if (s.compareTo("DragColumn") == 0) setMouseMode(MODE_DRAG_COLUMN); else if (s.compareTo("DragSelected") == 0) setMouseMode(MODE_DRAG_SELECTED); else if (s.compareTo("DragPost") == 0) setMouseMode(MODE_DRAG_POST); else if (s.compareTo("Select") == 0) setMouseMode(MODE_SELECT); else if (s.length() > 0) { try { addingClass = Class.forName(s); } catch (Exception ee) { ee.printStackTrace(); } } else setMouseMode(prevMouseMode); tempMouseMode = mouseMode; } } void setGrid() { gridSize = (smallGridCheckItem.getState()) ? 8 : 16; gridMask = ~(gridSize-1); gridRound = gridSize/2-1; } void pushUndo() { redoStack.removeAllElements(); String s = dumpCircuit(); if (undoStack.size() > 0 && s.compareTo(undoStack.lastElement()) == 0) return; undoStack.add(s); enableUndoRedo(); } void doUndo() { if (undoStack.size() == 0) return; redoStack.add(dumpCircuit()); String s = undoStack.remove(undoStack.size()-1); readSetup(s); enableUndoRedo(); } void doRedo() { if (redoStack.size() == 0) return; undoStack.add(dumpCircuit()); String s = redoStack.remove(redoStack.size()-1); readSetup(s); enableUndoRedo(); } void enableUndoRedo() { redoItem.setEnabled(redoStack.size() > 0); undoItem.setEnabled(undoStack.size() > 0); } void setMouseMode(int mode) { mouseMode = mode; if ( mode == MODE_ADD_ELM ) cv.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); else cv.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } void setMenuSelection() { if (menuElm != null) { if (menuElm.selected) return; clearSelection(); menuElm.setSelected(true); } } void doCut() { int i; pushUndo(); setMenuSelection(); clipboard = ""; for (i = elmList.size()-1; i >= 0; i--) { CircuitElm ce = getElm(i); if (ce.isSelected()) { clipboard += ce.dump() + "\n"; ce.delete(); elmList.removeElementAt(i); } } enablePaste(); needAnalyze(); } void doDelete() { int i; pushUndo(); setMenuSelection(); boolean hasDeleted = false; for (i = elmList.size()-1; i >= 0; i--) { CircuitElm ce = getElm(i); if (ce.isSelected()) { ce.delete(); elmList.removeElementAt(i); hasDeleted = true; } } if ( !hasDeleted ) { for (i = elmList.size()-1; i >= 0; i--) { CircuitElm ce = getElm(i); if (ce == mouseElm) { ce.delete(); elmList.removeElementAt(i); hasDeleted = true; mouseElm = null; break; } } } if ( hasDeleted ) needAnalyze(); } void doCopy() { int i; clipboard = ""; setMenuSelection(); for (i = elmList.size()-1; i >= 0; i--) { CircuitElm ce = getElm(i); if (ce.isSelected()) clipboard += ce.dump() + "\n"; } enablePaste(); } void enablePaste() { pasteItem.setEnabled(clipboard.length() > 0); } void doPaste() { pushUndo(); clearSelection(); int i; Rectangle oldbb = null; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); Rectangle bb = ce.getBoundingBox(); if (oldbb != null) oldbb = oldbb.union(bb); else oldbb = bb; } int oldsz = elmList.size(); readSetup(clipboard, true); // select new items Rectangle newbb = null; for (i = oldsz; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.setSelected(true); Rectangle bb = ce.getBoundingBox(); if (newbb != null) newbb = newbb.union(bb); else newbb = bb; } if (oldbb != null && newbb != null && oldbb.intersects(newbb)) { // find a place for new items int dx = 0, dy = 0; int spacew = circuitArea.width - oldbb.width - newbb.width; int spaceh = circuitArea.height - oldbb.height - newbb.height; if (spacew > spaceh) dx = snapGrid(oldbb.x + oldbb.width - newbb.x + gridSize); else dy = snapGrid(oldbb.y + oldbb.height - newbb.y + gridSize); for (i = oldsz; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.move(dx, dy); } // center circuit handleResize(); } needAnalyze(); } void clearSelection() { int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.setSelected(false); } } void doSelectAll() { int i; for (i = 0; i != elmList.size(); i++) { CircuitElm ce = getElm(i); ce.setSelected(true); } } public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyTyped(KeyEvent e) { if (e.getKeyChar() == 127) { doDelete(); return; } if (e.getKeyChar() > ' ' && e.getKeyChar() < 127) { Class c = shortcuts[e.getKeyChar()]; if (c == null) return; CircuitElm elm = null; elm = constructElement(c, 0, 0); if (elm == null) return; setMouseMode(MODE_ADD_ELM); mouseModeStr = c.getName(); addingClass = c; } if (e.getKeyChar() == ' ' || e.getKeyChar() == KeyEvent.VK_ESCAPE) { setMouseMode(MODE_SELECT); mouseModeStr = "Select"; } tempMouseMode = mouseMode; } // factors a matrix into upper and lower triangular matrices by // gaussian elimination. On entry, a[0..n-1][0..n-1] is the // matrix to be factored. ipvt[] returns an integer vector of pivot // indices, used in the lu_solve() routine. boolean lu_factor(double a[][], int n, int ipvt[]) { double scaleFactors[]; int i,j,k; scaleFactors = new double[n]; // divide each row by its largest element, keeping track of the // scaling factors for (i = 0; i != n; i++) { double largest = 0; for (j = 0; j != n; j++) { double x = Math.abs(a[i][j]); if (x > largest) largest = x; } // if all zeros, it's a singular matrix if (largest == 0) return false; scaleFactors[i] = 1.0/largest; } // use Crout's method; loop through the columns for (j = 0; j != n; j++) { // calculate upper triangular elements for this column for (i = 0; i != j; i++) { double q = a[i][j]; for (k = 0; k != i; k++) q -= a[i][k]*a[k][j]; a[i][j] = q; } // calculate lower triangular elements for this column double largest = 0; int largestRow = -1; for (i = j; i != n; i++) { double q = a[i][j]; for (k = 0; k != j; k++) q -= a[i][k]*a[k][j]; a[i][j] = q; double x = Math.abs(q); if (x >= largest) { largest = x; largestRow = i; } } // pivoting if (j != largestRow) { double x; for (k = 0; k != n; k++) { x = a[largestRow][k]; a[largestRow][k] = a[j][k]; a[j][k] = x; } scaleFactors[largestRow] = scaleFactors[j]; } // keep track of row interchanges ipvt[j] = largestRow; // avoid zeros if (a[j][j] == 0.0) { System.out.println("avoided zero"); a[j][j]=1e-18; } if (j != n-1) { double mult = 1.0/a[j][j]; for (i = j+1; i != n; i++) a[i][j] *= mult; } } return true; } // Solves the set of n linear equations using a LU factorization // previously performed by lu_factor. On input, b[0..n-1] is the right // hand side of the equations, and on output, contains the solution. void lu_solve(double a[][], int n, int ipvt[], double b[]) { int i; // find first nonzero b element for (i = 0; i != n; i++) { int row = ipvt[i]; double swap = b[row]; b[row] = b[i]; b[i] = swap; if (swap != 0) break; } int bi = i++; for (; i < n; i++) { int row = ipvt[i]; int j; double tot = b[row]; b[row] = b[i]; // forward substitution using the lower triangular matrix for (j = bi; j < i; j++) tot -= a[i][j]*b[j]; b[i] = tot; } for (i = n-1; i >= 0; i--) { double tot = b[i]; // back-substitution using the upper triangular matrix int j; for (j = i+1; j != n; j++) tot -= a[i][j]*b[j]; b[i] = tot/a[i][i]; } } } ================================================ FILE: src/Circuit.java ================================================ // Circuit.java (c) 2005,2008 by Paul Falstad, www.falstad.com import java.io.InputStream; import java.awt.*; import java.awt.image.*; import java.applet.Applet; import java.util.Vector; import java.io.File; import java.util.Random; import java.util.Arrays; import java.lang.Math; import java.net.URL; import java.awt.event.*; import java.io.FilterInputStream; import java.io.ByteArrayOutputStream; import java.util.StringTokenizer; import java.text.DecimalFormat; import java.text.NumberFormat; import java.lang.reflect.Constructor; import java.lang.reflect.Method; public class Circuit extends Applet implements ComponentListener { static CirSim ogf; boolean finished = false; void destroyFrame() { if (ogf != null) ogf.dispose(); ogf = null; repaint(); finished = true; } boolean started = false; public void init() { addComponentListener(this); } public static void main(String args[]) { ogf = new CirSim(null); ogf.init(); } public void showFrame() { if ( finished ) { repaint(); return; } if (ogf == null) { started = true; ogf = new CirSim(this); ogf.init(); } ogf.setVisible(true); repaint(); } public void hideFrame() { if ( finished ) return; ogf.setVisible(false); repaint(); } public void toggleSwitch(int x) { ogf.toggleSwitch(x); } public void paint(Graphics g) { String s = "Applet is open in a separate window."; if ( ogf != null && !ogf.isVisible() ) s = "Applet window is hidden."; if (!started) s = "Applet is starting."; else if (ogf == null || finished) s = "Applet is finished."; else if (ogf != null && ogf.useFrame) ogf.triggerShow(); g.drawString(s, 10, 30); } public void componentHidden(ComponentEvent e){} public void componentMoved(ComponentEvent e){} public void componentShown(ComponentEvent e) { showFrame(); } public void componentResized(ComponentEvent e) { if (ogf != null) ogf.componentResized(e); } public void destroy() { if (ogf != null) ogf.dispose(); ogf = null; repaint(); } }; ================================================ FILE: src/CircuitCanvas.java ================================================ import java.awt.*; class CircuitCanvas extends Canvas { CirSim pg; CircuitCanvas(CirSim p) { pg = p; } public Dimension getPreferredSize() { return new Dimension(300,400); } public void update(Graphics g) { pg.updateCircuit(g); } public void paint(Graphics g) { pg.updateCircuit(g); } }; ================================================ FILE: src/CircuitElm.java ================================================ import java.awt.*; import java.text.DecimalFormat; import java.text.NumberFormat; public abstract class CircuitElm implements Editable { static double voltageRange = 5; static int colorScaleCount = 32; static Color colorScale[]; static double currentMult, powerMult; static Point ps1, ps2; static CirSim sim; static Color whiteColor, selectColor, lightGrayColor; static Font unitsFont; public static NumberFormat showFormat, shortFormat, noCommaFormat; static final double pi = 3.14159265358979323846; int x, y, x2, y2, flags, nodes[], voltSource; int dx, dy, dsign; double dn, dpx1, dpy1; Point point1, point2, lead1, lead2; double volts[]; double current, curcount; Rectangle boundingBox; boolean noDiagonal; public boolean selected; int getDumpType() { return 0; } Class getDumpClass() { return getClass(); } int getDefaultFlags() { return 0; } static void initClass(CirSim s) { unitsFont = new Font("SansSerif", 0, 10); sim = s; colorScale = new Color[colorScaleCount]; int i; for (i = 0; i != colorScaleCount; i++) { double v = i*2./colorScaleCount - 1; if (v < 0) { int n1 = (int) (128*-v)+127; int n2 = (int) (127*(1+v)); colorScale[i] = new Color(n1, n2, n2); } else { int n1 = (int) (128*v)+127; int n2 = (int) (127*(1-v)); colorScale[i] = new Color(n2, n1, n2); } } ps1 = new Point(); ps2 = new Point(); showFormat = DecimalFormat.getInstance(); showFormat.setMaximumFractionDigits(2); shortFormat = DecimalFormat.getInstance(); shortFormat.setMaximumFractionDigits(1); noCommaFormat = DecimalFormat.getInstance(); noCommaFormat.setMaximumFractionDigits(10); noCommaFormat.setGroupingUsed(false); } CircuitElm(int xx, int yy) { x = x2 = xx; y = y2 = yy; flags = getDefaultFlags(); allocNodes(); initBoundingBox(); } CircuitElm(int xa, int ya, int xb, int yb, int f) { x = xa; y = ya; x2 = xb; y2 = yb; flags = f; allocNodes(); initBoundingBox(); } void initBoundingBox() { boundingBox = new Rectangle(); boundingBox.setBounds(min(x, x2), min(y, y2), abs(x2-x)+1, abs(y2-y)+1); } void allocNodes() { nodes = new int[getPostCount()+getInternalNodeCount()]; volts = new double[getPostCount()+getInternalNodeCount()]; } String dump() { int t = getDumpType(); return (t < 127 ? ((char)t)+" " : t+" ") + x + " " + y + " " + x2 + " " + y2 + " " + flags; } void reset() { int i; for (i = 0; i != getPostCount()+getInternalNodeCount(); i++) volts[i] = 0; curcount = 0; } void draw(Graphics g) {} void setCurrent(int x, double c) { current = c; } double getCurrent() { return current; } void doStep() {} void delete() {} void startIteration() {} double getPostVoltage(int x) { return volts[x]; } void setNodeVoltage(int n, double c) { volts[n] = c; calculateCurrent(); } void calculateCurrent() {} void setPoints() { dx = x2-x; dy = y2-y; dn = Math.sqrt(dx*dx+dy*dy); dpx1 = dy/dn; dpy1 = -dx/dn; dsign = (dy == 0) ? sign(dx) : sign(dy); point1 = new Point(x , y ); point2 = new Point(x2, y2); } void calcLeads(int len) { if (dn < len || len == 0) { lead1 = point1; lead2 = point2; return; } lead1 = interpPoint(point1, point2, (dn-len)/(2*dn)); lead2 = interpPoint(point1, point2, (dn+len)/(2*dn)); } Point interpPoint(Point a, Point b, double f) { Point p = new Point(); interpPoint(a, b, p, f); return p; } void interpPoint(Point a, Point b, Point c, double f) { int xpd = b.x-a.x; int ypd = b.y-a.y; /*double q = (a.x*(1-f)+b.x*f+.48); System.out.println(q + " " + (int) q);*/ c.x = (int) Math.floor(a.x*(1-f)+b.x*f+.48); c.y = (int) Math.floor(a.y*(1-f)+b.y*f+.48); } void interpPoint(Point a, Point b, Point c, double f, double g) { int xpd = b.x-a.x; int ypd = b.y-a.y; int gx = b.y-a.y; int gy = a.x-b.x; g /= Math.sqrt(gx*gx+gy*gy); c.x = (int) Math.floor(a.x*(1-f)+b.x*f+g*gx+.48); c.y = (int) Math.floor(a.y*(1-f)+b.y*f+g*gy+.48); } Point interpPoint(Point a, Point b, double f, double g) { Point p = new Point(); interpPoint(a, b, p, f, g); return p; } void interpPoint2(Point a, Point b, Point c, Point d, double f, double g) { int xpd = b.x-a.x; int ypd = b.y-a.y; int gx = b.y-a.y; int gy = a.x-b.x; g /= Math.sqrt(gx*gx+gy*gy); c.x = (int) Math.floor(a.x*(1-f)+b.x*f+g*gx+.48); c.y = (int) Math.floor(a.y*(1-f)+b.y*f+g*gy+.48); d.x = (int) Math.floor(a.x*(1-f)+b.x*f-g*gx+.48); d.y = (int) Math.floor(a.y*(1-f)+b.y*f-g*gy+.48); } void draw2Leads(Graphics g) { // draw first lead setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); // draw second lead setVoltageColor(g, volts[1]); drawThickLine(g, lead2, point2); } Point [] newPointArray(int n) { Point a[] = new Point[n]; while (n > 0) a[--n] = new Point(); return a; } void drawDots(Graphics g, Point pa, Point pb, double pos) { if (sim.stoppedCheck.getState() || pos == 0 || !sim.dotsCheckItem.getState()) return; int dx = pb.x-pa.x; int dy = pb.y-pa.y; double dn = Math.sqrt(dx*dx+dy*dy); g.setColor(Color.yellow); int ds = 16; pos %= ds; if (pos < 0) pos += ds; double di = 0; for (di = pos; di < dn; di += ds) { int x0 = (int) (pa.x+di*dx/dn); int y0 = (int) (pa.y+di*dy/dn); g.fillRect(x0-1, y0-1, 4, 4); } } Polygon calcArrow(Point a, Point b, double al, double aw) { Polygon poly = new Polygon(); Point p1 = new Point(); Point p2 = new Point(); int adx = b.x-a.x; int ady = b.y-a.y; double l = Math.sqrt(adx*adx+ady*ady); poly.addPoint(b.x, b.y); interpPoint2(a, b, p1, p2, 1-al/l, aw); poly.addPoint(p1.x, p1.y); poly.addPoint(p2.x, p2.y); return poly; } Polygon calcArrowReverse(Point a, Point b, double al, double aw) { Polygon poly = new Polygon(); Point p1 = new Point(); Point p2 = new Point(); double adx = b.x-a.x; double ady = b.y-a.y; double l = Math.sqrt(adx*adx+ady*ady); if (l > 0) { adx /= l; ady /= l; double bdx = -ady; // orthogonal unit vector double bdy = adx; // poly.addPoint((int)Math.round(b.x+1 - adx*al), (int)Math.round(b.y+1 - ady*al)); poly.addPoint((int)Math.round(b.x+1 - bdx*al), (int)Math.round(b.y+1 - bdy*aw)); poly.addPoint((int)Math.round(b.x+1 + bdx*al), (int)Math.round(b.y+1 + bdy*aw)); } return poly; } Polygon createPolygon(Point a, Point b, Point c) { Polygon p = new Polygon(); p.addPoint(a.x, a.y); p.addPoint(b.x, b.y); p.addPoint(c.x, c.y); return p; } Polygon createPolygon(Point a, Point b, Point c, Point d) { Polygon p = new Polygon(); p.addPoint(a.x, a.y); p.addPoint(b.x, b.y); p.addPoint(c.x, c.y); p.addPoint(d.x, d.y); return p; } Polygon createPolygon(Point a[]) { Polygon p = new Polygon(); int i; for (i = 0; i != a.length; i++) p.addPoint(a[i].x, a[i].y); return p; } void drag(int xx, int yy) { xx = sim.snapGrid(xx); yy = sim.snapGrid(yy); if (noDiagonal) { if (Math.abs(x-xx) < Math.abs(y-yy)) { xx = x; } else { yy = y; } } x2 = xx; y2 = yy; setPoints(); } void move(int dx, int dy) { x += dx; y += dy; x2 += dx; y2 += dy; boundingBox.move(dx, dy); setPoints(); } // determine if moving this element by (dx,dy) will put it on top of another element boolean allowMove(int dx, int dy) { int nx = x+dx; int ny = y+dy; int nx2 = x2+dx; int ny2 = y2+dy; int i; for (i = 0; i != sim.elmList.size(); i++) { CircuitElm ce = sim.getElm(i); if (ce.x == nx && ce.y == ny && ce.x2 == nx2 && ce.y2 == ny2) return false; if (ce.x == nx2 && ce.y == ny2 && ce.x2 == nx && ce.y2 == ny) return false; } return true; } void movePoint(int n, int dx, int dy) { if (n == 0) { x += dx; y += dy; } else { x2 += dx; y2 += dy; } setPoints(); } void drawPosts(Graphics g) { int i; for (i = 0; i != getPostCount(); i++) { Point p = getPost(i); drawPost(g, p.x, p.y, nodes[i]); } } void stamp() {} int getVoltageSourceCount() { return 0; } int getInternalNodeCount() { return 0; } void setNode(int p, int n) { nodes[p] = n; } void setVoltageSource(int n, int v) { voltSource = v; } int getVoltageSource() { return voltSource; } double getVoltageDiff() { return volts[0] - volts[1]; } boolean nonLinear() { return false; } int getPostCount() { return 2; } int getNode(int n) { return nodes[n]; } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? point2 : null; } void drawPost(Graphics g, int x0, int y0, int n) { if (sim.dragElm == null && !needsHighlight() && sim.getCircuitNode(n).links.size() == 2) return; if (sim.mouseMode == CirSim.MODE_DRAG_ROW || sim.mouseMode == CirSim.MODE_DRAG_COLUMN) return; drawPost(g, x0, y0); } void drawPost(Graphics g, int x0, int y0) { g.setColor(whiteColor); g.fillOval(x0-3, y0-3, 7, 7); } void setBbox(int x1, int y1, int x2, int y2) { if (x1 > x2) { int q = x1; x1 = x2; x2 = q; } if (y1 > y2) { int q = y1; y1 = y2; y2 = q; } boundingBox.setBounds(x1, y1, x2-x1+1, y2-y1+1); } void setBbox(Point p1, Point p2, double w) { setBbox(p1.x, p1.y, p2.x, p2.y); int gx = p2.y-p1.y; int gy = p1.x-p2.x; int dpx = (int) (dpx1*w); int dpy = (int) (dpy1*w); adjustBbox(p1.x+dpx, p1.y+dpy, p1.x-dpx, p1.y-dpy); } void adjustBbox(int x1, int y1, int x2, int y2) { if (x1 > x2) { int q = x1; x1 = x2; x2 = q; } if (y1 > y2) { int q = y1; y1 = y2; y2 = q; } x1 = min(boundingBox.x, x1); y1 = min(boundingBox.y, y1); x2 = max(boundingBox.x+boundingBox.width-1, x2); y2 = max(boundingBox.y+boundingBox.height-1, y2); boundingBox.setBounds(x1, y1, x2-x1, y2-y1); } void adjustBbox(Point p1, Point p2) { adjustBbox(p1.x, p1.y, p2.x, p2.y); } boolean isCenteredText() { return false; } void drawCenteredText(Graphics g, String s, int x, int y, boolean cx) { FontMetrics fm = g.getFontMetrics(); int w = fm.stringWidth(s); if (cx) x -= w/2; g.drawString(s, x, y+fm.getAscent()/2); adjustBbox(x, y-fm.getAscent()/2, x+w, y+fm.getAscent()/2+fm.getDescent()); } void drawValues(Graphics g, String s, double hs) { if (s == null) return; g.setFont(unitsFont); FontMetrics fm = g.getFontMetrics(); int w = fm.stringWidth(s); g.setColor(whiteColor); int ya = fm.getAscent()/2; int xc, yc; if (this instanceof RailElm || this instanceof SweepElm) { xc = x2; yc = y2; } else { xc = (x2+x)/2; yc = (y2+y)/2; } int dpx = (int) (dpx1*hs); int dpy = (int) (dpy1*hs); if (dpx == 0) { g.drawString(s, xc-w/2, yc-abs(dpy)-2); } else { int xx = xc+abs(dpx)+2; if (this instanceof VoltageElm || (x < x2 && y > y2)) xx = xc-(w+abs(dpx)+2); g.drawString(s, xx, yc+dpy+ya); } } void drawCoil(Graphics g, int hs, Point p1, Point p2, double v1, double v2) { double len = distance(p1, p2); int segments = 30; // 10*(int) (len/10); int i; double segf = 1./segments; ps1.setLocation(p1); for (i = 0; i != segments; i++) { double cx = (((i+1)*6.*segf) % 2)-1; double hsx = Math.sqrt(1-cx*cx); if (hsx < 0) hsx = -hsx; interpPoint(p1, p2, ps2, i*segf, hsx*hs); double v = v1+(v2-v1)*i/segments; setVoltageColor(g, v); drawThickLine(g, ps1, ps2); ps1.setLocation(ps2); } } static void drawThickLine(Graphics g, int x, int y, int x2, int y2) { g.drawLine(x, y, x2, y2); g.drawLine(x+1, y, x2+1, y2); g.drawLine(x, y+1, x2, y2+1); g.drawLine(x+1, y+1, x2+1, y2+1); } static void drawThickLine(Graphics g, Point pa, Point pb) { g.drawLine(pa.x, pa.y, pb.x, pb.y); g.drawLine(pa.x+1, pa.y, pb.x+1, pb.y); g.drawLine(pa.x, pa.y+1, pb.x, pb.y+1); g.drawLine(pa.x+1, pa.y+1, pb.x+1, pb.y+1); } static void drawThickPolygon(Graphics g, int xs[], int ys[], int c) { int i; for (i = 0; i != c-1; i++) drawThickLine(g, xs[i], ys[i], xs[i+1], ys[i+1]); drawThickLine(g, xs[i], ys[i], xs[0], ys[0]); } static void drawThickPolygon(Graphics g, Polygon p) { drawThickPolygon(g, p.xpoints, p.ypoints, p.npoints); } static void drawThickCircle(Graphics g, int cx, int cy, int ri) { int a; double m = pi/180; double r = ri*.98; for (a = 0; a != 360; a += 20) { double ax = Math.cos(a*m)*r + cx; double ay = Math.sin(a*m)*r + cy; double bx = Math.cos((a+20)*m)*r + cx; double by = Math.sin((a+20)*m)*r + cy; drawThickLine(g, (int) ax, (int) ay, (int) bx, (int) by); } } static String getVoltageDText(double v) { return getUnitText(Math.abs(v), "V"); } static String getVoltageText(double v) { return getUnitText(v, "V"); } static String getUnitText(double v, String u) { double va = Math.abs(v); if (va < 1e-14) return "0 " + u; if (va < 1e-9) return showFormat.format(v*1e12) + " p" + u; if (va < 1e-6) return showFormat.format(v*1e9) + " n" + u; if (va < 1e-3) return showFormat.format(v*1e6) + " " + CirSim.muString + u; if (va < 1) return showFormat.format(v*1e3) + " m" + u; if (va < 1e3) return showFormat.format(v) + " " + u; if (va < 1e6) return showFormat.format(v*1e-3) + " k" + u; if (va < 1e9) return showFormat.format(v*1e-6) + " M" + u; return showFormat.format(v*1e-9) + " G" + u; } static String getShortUnitText(double v, String u) { double va = Math.abs(v); if (va < 1e-13) return null; if (va < 1e-9) return shortFormat.format(v*1e12) + "p" + u; if (va < 1e-6) return shortFormat.format(v*1e9) + "n" + u; if (va < 1e-3) return shortFormat.format(v*1e6) + CirSim.muString + u; if (va < 1) return shortFormat.format(v*1e3) + "m" + u; if (va < 1e3) return shortFormat.format(v) + u; if (va < 1e6) return shortFormat.format(v*1e-3) + "k" + u; if (va < 1e9) return shortFormat.format(v*1e-6) + "M" + u; return shortFormat.format(v*1e-9) + "G" + u; } static String getCurrentText(double i) { return getUnitText(i, "A"); } static String getCurrentDText(double i) { return getUnitText(Math.abs(i), "A"); } void updateDotCount() { curcount = updateDotCount(current, curcount); } double updateDotCount(double cur, double cc) { if (sim.stoppedCheck.getState()) return cc; double cadd = cur*currentMult; /*if (cur != 0 && cadd <= .05 && cadd >= -.05) cadd = (cadd < 0) ? -.05 : .05;*/ cadd %= 8; /*if (cadd > 8) cadd = 8; if (cadd < -8) cadd = -8;*/ return cc + cadd; } void doDots(Graphics g) { updateDotCount(); if (sim.dragElm != this) drawDots(g, point1, point2, curcount); } void doAdjust() {} void setupAdjust() {} void getInfo(String arr[]) { } int getBasicInfo(String arr[]) { arr[1] = "I = " + getCurrentDText(getCurrent()); arr[2] = "Vd = " + getVoltageDText(getVoltageDiff()); return 3; } void setVoltageColor(Graphics g, double volts) { if (needsHighlight()) { g.setColor(selectColor); return; } if (!sim.voltsCheckItem.getState()) { if (!sim.powerCheckItem.getState()) // && !conductanceCheckItem.getState()) g.setColor(whiteColor); return; } int c = (int) ((volts+voltageRange)*(colorScaleCount-1)/ (voltageRange*2)); if (c < 0) c = 0; if (c >= colorScaleCount) c = colorScaleCount-1; g.setColor(colorScale[c]); } void setPowerColor(Graphics g, boolean yellow) { /*if (conductanceCheckItem.getState()) { setConductanceColor(g, current/getVoltageDiff()); return; }*/ if (!sim.powerCheckItem.getState()) return; setPowerColor(g, getPower()); } void setPowerColor(Graphics g, double w0) { w0 *= powerMult; //System.out.println(w); double w = (w0 < 0) ? -w0 : w0; if (w > 1) w = 1; int rg = 128+(int) (w*127); int b = (int) (128*(1-w)); /*if (yellow) g.setColor(new Color(rg, rg, b)); else */ if (w0 > 0) g.setColor(new Color(rg, b, b)); else g.setColor(new Color(b, rg, b)); } void setConductanceColor(Graphics g, double w0) { w0 *= powerMult; //System.out.println(w); double w = (w0 < 0) ? -w0 : w0; if (w > 1) w = 1; int rg = (int) (w*255); g.setColor(new Color(rg, rg, rg)); } double getPower() { return getVoltageDiff()*current; } double getScopeValue(int x) { return (x == 1) ? getPower() : getVoltageDiff(); } String getScopeUnits(int x) { return (x == 1) ? "W" : "V"; } public EditInfo getEditInfo(int n) { return null; } public void setEditValue(int n, EditInfo ei) {} boolean getConnection(int n1, int n2) { return true; } boolean hasGroundConnection(int n1) { return false; } boolean isWire() { return false; } boolean canViewInScope() { return getPostCount() <= 2; } boolean comparePair(int x1, int x2, int y1, int y2) { return ((x1 == y1 && x2 == y2) || (x1 == y2 && x2 == y1)); } boolean needsHighlight() { return sim.mouseElm == this || selected; } boolean isSelected() { return selected; } void setSelected(boolean x) { selected = x; } void selectRect(Rectangle r) { selected = r.intersects(boundingBox); } static int abs(int x) { return x < 0 ? -x : x; } static int sign(int x) { return (x < 0) ? -1 : (x == 0) ? 0 : 1; } static int min(int a, int b) { return (a < b) ? a : b; } static int max(int a, int b) { return (a > b) ? a : b; } static double distance(Point p1, Point p2) { double x = p1.x-p2.x; double y = p1.y-p2.y; return Math.sqrt(x*x+y*y); } Rectangle getBoundingBox() { return boundingBox; } boolean needsShortcut() { return getShortcut() > 0; } int getShortcut() { return 0; } boolean isGraphicElmt() { return false; } } ================================================ FILE: src/CircuitLayout.java ================================================ import java.awt.*; class CircuitLayout implements LayoutManager { public CircuitLayout() {} public void addLayoutComponent(String name, Component c) {} public void removeLayoutComponent(Component c) {} public Dimension preferredLayoutSize(Container target) { return new Dimension(500, 500); } public Dimension minimumLayoutSize(Container target) { return new Dimension(100,100); } public void layoutContainer(Container target) { Insets insets = target.insets(); int targetw = target.size().width - insets.left - insets.right; int cw = targetw* 8/10; int targeth = target.size().height - (insets.top+insets.bottom); target.getComponent(0).move(insets.left, insets.top); target.getComponent(0).resize(cw, targeth); int barwidth = targetw - cw; cw += insets.left; int i; int h = insets.top; for (i = 1; i < target.getComponentCount(); i++) { Component m = target.getComponent(i); if (m.isVisible()) { Dimension d = m.getPreferredSize(); if (m instanceof Scrollbar) d.width = barwidth; if (m instanceof Choice && d.width > barwidth) d.width = barwidth; if (m instanceof Label) { h += d.height/5; d.width = barwidth; } m.move(cw, h); m.resize(d.width, d.height); h += d.height; } } } }; ================================================ FILE: src/CircuitNode.java ================================================ import java.util.Vector; class CircuitNode { int x, y; Vector links; boolean internal; CircuitNode() { links = new Vector(); } } ================================================ FILE: src/CircuitNodeLink.java ================================================ class CircuitNodeLink { int num; CircuitElm elm; } ================================================ FILE: src/ClockElm.java ================================================ class ClockElm extends RailElm { public ClockElm(int xx, int yy) { super(xx, yy, WF_SQUARE); maxVoltage = 2.5; bias = 2.5; frequency = 100; flags |= FLAG_CLOCK; } Class getDumpClass() { return RailElm.class; } int getShortcut() { return 0; } } ================================================ FILE: src/CounterElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class CounterElm extends ChipElm { final int FLAG_ENABLE = 2; public CounterElm(int xx, int yy) { super(xx, yy); } public CounterElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } boolean needsBits() { return true; } String getChipName() { return "Counter"; } void setupPins() { sizeX = 2; sizeY = bits > 2 ? bits : 2; pins = new Pin[getPostCount()]; pins[0] = new Pin(0, SIDE_W, ""); pins[0].clock = true; pins[1] = new Pin(sizeY-1, SIDE_W, "R"); pins[1].bubble = true; int i; for (i = 0; i != bits; i++) { int ii = i+2; pins[ii] = new Pin(i, SIDE_E, "Q" + (bits-i-1)); pins[ii].output = pins[ii].state = true; } if (hasEnable()) pins[bits+2] = new Pin(sizeY-2, SIDE_W, "En"); allocNodes(); } int getPostCount() { if (hasEnable()) return bits+3; return bits+2; } boolean hasEnable() { return (flags & FLAG_ENABLE) != 0; } int getVoltageSourceCount() { return bits; } void execute() { boolean en = true; if (hasEnable()) en = pins[bits+2].value; if (pins[0].value && !lastClock && en) { int i; for (i = bits-1; i >= 0; i--) { int ii = i+2; if (!pins[ii].value) { pins[ii].value = true; break; } pins[ii].value = false; } } if (!pins[1].value) { int i; for (i = 0; i != bits; i++) pins[i+2].value = false; } lastClock = pins[0].value; } int getDumpType() { return 164; } } ================================================ FILE: src/CurrentElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class CurrentElm extends CircuitElm { double currentValue; public CurrentElm(int xx, int yy) { super(xx, yy); currentValue = .01; } public CurrentElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); try { currentValue = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { currentValue = .01; } } String dump() { return super.dump() + " " + currentValue; } int getDumpType() { return 'i'; } Polygon arrow; Point ashaft1, ashaft2, center; void setPoints() { super.setPoints(); calcLeads(26); ashaft1 = interpPoint(lead1, lead2, .25); ashaft2 = interpPoint(lead1, lead2, .6); center = interpPoint(lead1, lead2, .5); Point p2 = interpPoint(lead1, lead2, .75); arrow = calcArrow(center, p2, 4, 4); } void draw(Graphics g) { int cr = 12; draw2Leads(g); setVoltageColor(g, (volts[0]+volts[1])/2); setPowerColor(g, false); drawThickCircle(g, center.x, center.y, cr); drawThickLine(g, ashaft1, ashaft2); g.fillPolygon(arrow); setBbox(point1, point2, cr); doDots(g); if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(currentValue, "A"); if (dx == 0 || dy == 0) drawValues(g, s, cr); } drawPosts(g); } void stamp() { current = currentValue; sim.stampCurrentSource(nodes[0], nodes[1], current); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Current (A)", currentValue, 0, .1); return null; } public void setEditValue(int n, EditInfo ei) { currentValue = ei.value; } void getInfo(String arr[]) { arr[0] = "current source"; getBasicInfo(arr); } double getVoltageDiff() { return volts[1] - volts[0]; } } ================================================ FILE: src/DACElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class DACElm extends ChipElm { public DACElm(int xx, int yy) { super(xx, yy); } public DACElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "DAC"; } boolean needsBits() { return true; } void setupPins() { sizeX = 2; sizeY = bits > 2 ? bits : 2; pins = new Pin[getPostCount()]; int i; for (i = 0; i != bits; i++) pins[i] = new Pin(bits-1-i, SIDE_W, "D" + i); pins[bits] = new Pin(0, SIDE_E, "O"); pins[bits].output = true; pins[bits+1] = new Pin(sizeY-1, SIDE_E, "V+"); allocNodes(); } void doStep() { int ival = 0; int i; for (i = 0; i != bits; i++) if (volts[i] > 2.5) ival |= 1< 4 && pins[4].value) { pins[1].value = false; pins[2].value = true; } lastClock = pins[3].value; } int getDumpType() { return 155; } public EditInfo getEditInfo(int n) { if (n == 2) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Reset Pin", hasReset()); return ei; } return super.getEditInfo(n); } public void setEditValue(int n, EditInfo ei) { if (n == 2) { if (ei.checkbox.getState()) flags |= FLAG_RESET; else flags &= ~FLAG_RESET; setupPins(); allocNodes(); setPoints(); } super.setEditValue(n, ei); } } ================================================ FILE: src/DecadeElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class DecadeElm extends ChipElm { public DecadeElm(int xx, int yy) { super(xx, yy); } public DecadeElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "decade counter"; } boolean needsBits() { return true; } void setupPins() { sizeX = bits > 2 ? bits : 2; sizeY = 2; pins = new Pin[getPostCount()]; pins[0] = new Pin(1, SIDE_W, ""); pins[0].clock = true; pins[1] = new Pin(sizeX-1, SIDE_S, "R"); pins[1].bubble = true; int i; for (i = 0; i != bits; i++) { int ii = i+2; pins[ii] = new Pin(i, SIDE_N, "Q" + i); pins[ii].output = pins[ii].state = true; } allocNodes(); } int getPostCount() { return bits+2; } int getVoltageSourceCount() { return bits; } void execute() { int i; if (pins[0].value && !lastClock) { for (i = 0; i != bits; i++) if (pins[i+2].value) break; if (i < bits) pins[i++ +2].value = false; i %= bits; pins[i+2].value = true; } if (!pins[1].value) { for (i = 1; i != bits; i++) pins[i+2].value = false; pins[2].value = true; } lastClock = pins[0].value; } int getDumpType() { return 163; } } ================================================ FILE: src/DiacElm.java ================================================ // stub implementation of DiacElm, based on SparkGapElm // FIXME need to add DiacElm.java to srclist // FIXME need to uncomment DiacElm line from CirSim.java import java.awt.*; import java.util.StringTokenizer; class DiacElm extends CircuitElm { double onresistance, offresistance, breakdown, holdcurrent; boolean state; public DiacElm(int xx, int yy) { super(xx, yy); // FIXME need to adjust defaults to make sense for diac offresistance = 1e9; onresistance = 1e3; breakdown = 1e3; holdcurrent = 0.001; state = false; } public DiacElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); onresistance = new Double(st.nextToken()).doubleValue(); offresistance = new Double(st.nextToken()).doubleValue(); breakdown = new Double(st.nextToken()).doubleValue(); holdcurrent = new Double(st.nextToken()).doubleValue(); } boolean nonLinear() {return true;} int getDumpType() { return 185; } String dump() { return super.dump() + " " + onresistance + " " + offresistance + " " + breakdown + " " + holdcurrent; } Point ps3, ps4; void setPoints() { super.setPoints(); calcLeads(32); ps3 = new Point(); ps4 = new Point(); } void draw(Graphics g) { // FIXME need to draw Diac int i; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, 6); draw2Leads(g); setPowerColor(g, true); doDots(g); drawPosts(g); } void calculateCurrent() { double vd = volts[0] - volts[1]; if(state) current = vd/onresistance; else current = vd/offresistance; } void startIteration() { double vd = volts[0] - volts[1]; if(Math.abs(current) < holdcurrent) state = false; if(Math.abs(vd) > breakdown) state = true; //System.out.print(this + " res current set to " + current + "\n"); } void doStep() { if(state) sim.stampResistor(nodes[0], nodes[1], onresistance); else sim.stampResistor(nodes[0], nodes[1], offresistance); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void getInfo(String arr[]) { // FIXME arr[0] = "spark gap"; getBasicInfo(arr); arr[3] = state ? "on" : "off"; arr[4] = "Ron = " + getUnitText(onresistance, sim.ohmString); arr[5] = "Roff = " + getUnitText(offresistance, sim.ohmString); arr[6] = "Vbrkdn = " + getUnitText(breakdown, "V"); arr[7] = "Ihold = " + getUnitText(holdcurrent, "A"); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("On resistance (ohms)", onresistance, 0, 0); if (n == 1) return new EditInfo("Off resistance (ohms)", offresistance, 0, 0); if (n == 2) return new EditInfo("Breakdown voltage (volts)", breakdown, 0, 0); if (n == 3) return new EditInfo("Hold current (amps)", holdcurrent, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (ei.value > 0 && n == 0) onresistance = ei.value; if (ei.value > 0 && n == 1) offresistance = ei.value; if (ei.value > 0 && n == 2) breakdown = ei.value; if (ei.value > 0 && n == 3) holdcurrent = ei.value; } } ================================================ FILE: src/Diode.java ================================================ class Diode { int nodes[]; CirSim sim; Diode(CirSim s) { sim = s; nodes = new int[2]; } void setup(double fw, double zv) { fwdrop = fw; zvoltage = zv; vdcoef = Math.log(1/leakage + 1)/fwdrop; vt = 1/vdcoef; // critical voltage for limiting; current is vt/sqrt(2) at // this voltage vcrit = vt * Math.log(vt/(Math.sqrt(2)*leakage)); if (zvoltage == 0) zoffset = 0; else { // calculate offset which will give us 5mA at zvoltage double i = -.005; zoffset = zvoltage-Math.log(-(1+i/leakage))/vdcoef; } } void reset() { lastvoltdiff = 0; } public double leakage = 1e-14; // was 1e-9; double vt, vdcoef, fwdrop, zvoltage, zoffset; double lastvoltdiff; double vcrit; double limitStep(double vnew, double vold) { double arg; double oo = vnew; // check new voltage; has current changed by factor of e^2? if (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) { if(vold > 0) { arg = 1 + (vnew - vold) / vt; if(arg > 0) { // adjust vnew so that the current is the same // as in linearized model from previous iteration. // current at vnew = old current * arg vnew = vold + vt * Math.log(arg); // current at v0 = 1uA double v0 = Math.log(1e-6/leakage)*vt; vnew = Math.max(v0, vnew); } else { vnew = vcrit; } } else { // adjust vnew so that the current is the same // as in linearized model from previous iteration. // (1/vt = slope of load line) vnew = vt *Math.log(vnew/vt); } sim.converged = false; //System.out.println(vnew + " " + oo + " " + vold); } else if (vnew < 0 && zoffset != 0) { // for Zener breakdown, use the same logic but translate the values vnew = -vnew - zoffset; vold = -vold - zoffset; if (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) { if(vold > 0) { arg = 1 + (vnew - vold) / vt; if(arg > 0) { vnew = vold + vt * Math.log(arg); double v0 = Math.log(1e-6/leakage)*vt; vnew = Math.max(v0, vnew); //System.out.println(oo + " " + vnew); } else { vnew = vcrit; } } else { vnew = vt *Math.log(vnew/vt); } sim.converged = false; } vnew = -(vnew+zoffset); } return vnew; } void stamp(int n0, int n1) { nodes[0] = n0; nodes[1] = n1; sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void doStep(double voltdiff) { // used to have .1 here, but needed .01 for peak detector if (Math.abs(voltdiff-lastvoltdiff) > .01) sim.converged = false; voltdiff = limitStep(voltdiff, lastvoltdiff); lastvoltdiff = voltdiff; if (voltdiff >= 0 || zvoltage == 0) { // regular diode or forward-biased zener double eval = Math.exp(voltdiff*vdcoef); // make diode linear with negative voltages; aids convergence if (voltdiff < 0) eval = 1; double geq = vdcoef*leakage*eval; double nc = (eval-1)*leakage - geq*voltdiff; sim.stampConductance(nodes[0], nodes[1], geq); sim.stampCurrentSource(nodes[0], nodes[1], nc); } else { // Zener diode /* * I(Vd) = Is * (exp[Vd*C] - exp[(-Vd-Vz)*C] - 1 ) * * geq is I'(Vd) * nc is I(Vd) + I'(Vd)*(-Vd) */ double geq = leakage*vdcoef* ( Math.exp(voltdiff*vdcoef) + Math.exp((-voltdiff-zoffset)*vdcoef) ); double nc = leakage* ( Math.exp(voltdiff*vdcoef) - Math.exp((-voltdiff-zoffset)*vdcoef) - 1 ) + geq*(-voltdiff); sim.stampConductance(nodes[0], nodes[1], geq); sim.stampCurrentSource(nodes[0], nodes[1], nc); } } double calculateCurrent(double voltdiff) { if (voltdiff >= 0 || zvoltage == 0) return leakage*(Math.exp(voltdiff*vdcoef)-1); return leakage* ( Math.exp(voltdiff*vdcoef) - Math.exp((-voltdiff-zoffset)*vdcoef) - 1 ); } } ================================================ FILE: src/DiodeElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class DiodeElm extends CircuitElm { Diode diode; static final int FLAG_FWDROP = 1; final double defaultdrop = .805904783; double fwdrop, zvoltage; public DiodeElm(int xx, int yy) { super(xx, yy); diode = new Diode(sim); fwdrop = defaultdrop; zvoltage = 0; setup(); } public DiodeElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); diode = new Diode(sim); fwdrop = defaultdrop; zvoltage = 0; if ((f & FLAG_FWDROP) > 0) { try { fwdrop = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } } setup(); } boolean nonLinear() { return true; } void setup() { diode.setup(fwdrop, zvoltage); } int getDumpType() { return 'd'; } String dump() { flags |= FLAG_FWDROP; return super.dump() + " " + fwdrop; } final int hs = 8; Polygon poly; Point cathode[]; void setPoints() { super.setPoints(); calcLeads(16); cathode = newPointArray(2); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); poly = createPolygon(pa[0], pa[1], lead2); } void draw(Graphics g) { drawDiode(g); doDots(g); drawPosts(g); } void reset() { diode.reset(); volts[0] = volts[1] = curcount = 0; } void drawDiode(Graphics g) { setBbox(point1, point2, hs); double v1 = volts[0]; double v2 = volts[1]; draw2Leads(g); // draw arrow thingy setPowerColor(g, true); setVoltageColor(g, v1); g.fillPolygon(poly); // draw thing arrow is pointing to setVoltageColor(g, v2); drawThickLine(g, cathode[0], cathode[1]); } void stamp() { diode.stamp(nodes[0], nodes[1]); } void doStep() { diode.doStep(volts[0]-volts[1]); } void calculateCurrent() { current = diode.calculateCurrent(volts[0]-volts[1]); } void getInfo(String arr[]) { arr[0] = "diode"; arr[1] = "I = " + getCurrentText(getCurrent()); arr[2] = "Vd = " + getVoltageText(getVoltageDiff()); arr[3] = "P = " + getUnitText(getPower(), "W"); arr[4] = "Vf = " + getVoltageText(fwdrop); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Fwd Voltage @ 1A", fwdrop, 10, 1000); return null; } public void setEditValue(int n, EditInfo ei) { fwdrop = ei.value; setup(); } int getShortcut() { return 'd'; } } ================================================ FILE: src/EditDialog.java ================================================ import java.awt.*; import java.awt.event.*; import java.text.NumberFormat; import java.text.DecimalFormat; interface Editable { EditInfo getEditInfo(int n); void setEditValue(int n, EditInfo ei); } class EditDialog extends Dialog implements AdjustmentListener, ActionListener, ItemListener { Editable elm; CirSim cframe; Button applyButton, okButton; EditInfo einfos[]; int einfocount; final int barmax = 1000; NumberFormat noCommaFormat; EditDialog(Editable ce, CirSim f) { super(f, "Edit Component", false); cframe = f; elm = ce; setLayout(new EditDialogLayout()); einfos = new EditInfo[10]; noCommaFormat = DecimalFormat.getInstance(); noCommaFormat.setMaximumFractionDigits(10); noCommaFormat.setGroupingUsed(false); int i; for (i = 0; ; i++) { einfos[i] = elm.getEditInfo(i); if (einfos[i] == null) break; EditInfo ei = einfos[i]; add(new Label(ei.name)); if (ei.choice != null) { add(ei.choice); ei.choice.addItemListener(this); } else if (ei.checkbox != null) { add(ei.checkbox); ei.checkbox.addItemListener(this); } else { add(ei.textf = new TextField(unitString(ei), 10)); if (ei.text != null) ei.textf.setText(ei.text); ei.textf.addActionListener(this); if (ei.text == null) { add(ei.bar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 10, 0, barmax+2)); setBar(ei); ei.bar.addAdjustmentListener(this); } } } einfocount = i; add(applyButton = new Button("Apply")); applyButton.addActionListener(this); add(okButton = new Button("OK")); okButton.addActionListener(this); Point x = cframe.main.getLocationOnScreen(); Dimension d = getSize(); setLocation(x.x + (cframe.winSize.width-d.width)/2, x.y + (cframe.winSize.height-d.height)/2); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { closeDialog(); } } ); } String unitString(EditInfo ei) { double v = ei.value; double va = Math.abs(v); if (ei.dimensionless) return noCommaFormat.format(v); if (v == 0) return "0"; if (va < 1e-9) return noCommaFormat.format(v*1e12) + "p"; if (va < 1e-6) return noCommaFormat.format(v*1e9) + "n"; if (va < 1e-3) return noCommaFormat.format(v*1e6) + "u"; if (va < 1 && !ei.forceLargeM) return noCommaFormat.format(v*1e3) + "m"; if (va < 1e3) return noCommaFormat.format(v); if (va < 1e6) return noCommaFormat.format(v*1e-3) + "k"; if (va < 1e9) return noCommaFormat.format(v*1e-6) + "M"; return noCommaFormat.format(v*1e-9) + "G"; } double parseUnits(EditInfo ei) throws java.text.ParseException { String s = ei.textf.getText(); s = s.trim(); int len = s.length(); char uc = s.charAt(len-1); double mult = 1; switch (uc) { case 'p': case 'P': mult = 1e-12; break; case 'n': case 'N': mult = 1e-9; break; case 'u': case 'U': mult = 1e-6; break; // for ohm values, we assume mega for lowercase m, otherwise milli case 'm': mult = (ei.forceLargeM) ? 1e6 : 1e-3; break; case 'k': case 'K': mult = 1e3; break; case 'M': mult = 1e6; break; case 'G': case 'g': mult = 1e9; break; } if (mult != 1) s = s.substring(0, len-1).trim(); return noCommaFormat.parse(s).doubleValue() * mult; } void apply() { int i; for (i = 0; i != einfocount; i++) { EditInfo ei = einfos[i]; if (ei.textf == null) continue; if (ei.text == null) { try { double d = parseUnits(ei); ei.value = d; } catch (Exception ex) { /* ignored */ } } elm.setEditValue(i, ei); if (ei.text == null) setBar(ei); } cframe.needAnalyze(); } public void actionPerformed(ActionEvent e) { int i; Object src = e.getSource(); for (i = 0; i != einfocount; i++) { EditInfo ei = einfos[i]; if (src == ei.textf) { if (ei.text == null) { try { double d = parseUnits(ei); ei.value = d; } catch (Exception ex) { /* ignored */ } } elm.setEditValue(i, ei); if (ei.text == null) setBar(ei); cframe.needAnalyze(); } } if (e.getSource() == okButton) { apply(); closeDialog(); } if (e.getSource() == applyButton) apply(); } public void adjustmentValueChanged(AdjustmentEvent e) { Object src = e.getSource(); int i; for (i = 0; i != einfocount; i++) { EditInfo ei = einfos[i]; if (ei.bar == src) { double v = ei.bar.getValue() / 1000.; if (v < 0) v = 0; if (v > 1) v = 1; ei.value = (ei.maxval-ei.minval)*v + ei.minval; /*if (ei.maxval-ei.minval > 100) ei.value = Math.round(ei.value); else ei.value = Math.round(ei.value*100)/100.;*/ ei.value = Math.round(ei.value/ei.minval)*ei.minval; elm.setEditValue(i, ei); ei.textf.setText(unitString(ei)); cframe.needAnalyze(); } } } public void itemStateChanged(ItemEvent e) { Object src = e.getItemSelectable(); int i; boolean changed = false; for (i = 0; i != einfocount; i++) { EditInfo ei = einfos[i]; if (ei.choice == src || ei.checkbox == src) { elm.setEditValue(i, ei); if (ei.newDialog) changed = true; cframe.needAnalyze(); } } if (changed) { setVisible(false); cframe.editDialog = new EditDialog(elm, cframe); cframe.editDialog.show(); } } public boolean handleEvent(Event ev) { if (ev.id == Event.WINDOW_DESTROY) { closeDialog(); return true; } return super.handleEvent(ev); } void setBar(EditInfo ei) { int x = (int) (barmax*(ei.value-ei.minval)/(ei.maxval-ei.minval)); ei.bar.setValue(x); } protected void closeDialog() { cframe.main.requestFocus(); setVisible(false); cframe.editDialog = null; } } ================================================ FILE: src/EditDialogLayout.java ================================================ import java.awt.*; import java.awt.event.*; class EditDialogLayout implements LayoutManager { public EditDialogLayout() {} public void addLayoutComponent(String name, Component c) {} public void removeLayoutComponent(Component c) {} public Dimension preferredLayoutSize(Container target) { return new Dimension(500, 500); } public Dimension minimumLayoutSize(Container target) { return new Dimension(100,100); } public void layoutContainer(Container target) { Insets insets = target.insets(); int targetw = target.size().width - insets.left - insets.right; int targeth = target.size().height - (insets.top+insets.bottom); int i; int h = insets.top; int pw = 300; int x = 0; for (i = 0; i < target.getComponentCount(); i++) { Component m = target.getComponent(i); boolean newline = true; if (m.isVisible()) { Dimension d = m.getPreferredSize(); if (pw < d.width) pw = d.width; if (m instanceof Scrollbar) { h += 10; d.width = targetw-x; } if (m instanceof Choice && d.width > targetw) d.width = targetw-x; if (m instanceof Label) { Dimension d2 = target.getComponent(i+1).getPreferredSize(); if (d.height < d2.height) d.height = d2.height; h += d.height/5; newline = false; } if (m instanceof Button) { if (x == 0) h += 20; if (i != target.getComponentCount()-1) newline = false; } m.move(insets.left+x, h); m.resize(d.width, d.height); if (newline) { h += d.height; x = 0; } else x += d.width; } } if (target.size().height < h) target.resize(pw + insets.right, h + insets.bottom); } }; ================================================ FILE: src/EditInfo.java ================================================ import java.awt.*; class EditInfo { EditInfo(String n, double val, double mn, double mx) { name = n; value = val; if (mn == 0 && mx == 0 && val > 0) { minval = 1e10; while (minval > val/100) minval /= 10.; maxval = minval * 1000; } else { minval = mn; maxval = mx; } forceLargeM = name.indexOf("(ohms)") > 0 || name.indexOf("(Hz)") > 0; dimensionless = false; } EditInfo setDimensionless() { dimensionless = true; return this; } String name, text; double value, minval, maxval; TextField textf; Scrollbar bar; Choice choice; Checkbox checkbox; boolean newDialog; boolean forceLargeM; boolean dimensionless; } ================================================ FILE: src/EditOptions.java ================================================ class EditOptions implements Editable { CirSim sim; public EditOptions(CirSim s) { sim = s; } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Time step size (s)", sim.timeStep, 0, 0); if (n == 1) return new EditInfo("Range for voltage color (V)", CircuitElm.voltageRange, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) sim.timeStep = ei.value; if (n == 1 && ei.value > 0) CircuitElm.voltageRange = ei.value; } }; ================================================ FILE: src/GateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; abstract class GateElm extends CircuitElm { final int FLAG_SMALL = 1; int inputCount = 2; boolean lastOutput; public GateElm(int xx, int yy) { super(xx, yy); noDiagonal = true; inputCount = 2; setSize(sim.smallGridCheckItem.getState() ? 1 : 2); } public GateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); inputCount = new Integer(st.nextToken()).intValue(); lastOutput = new Double (st.nextToken()).doubleValue() > 2.5; noDiagonal = true; setSize((f & FLAG_SMALL) != 0 ? 1 : 2); } boolean isInverting() { return false; } int gsize, gwidth, gwidth2, gheight, hs2; void setSize(int s) { gsize = s; gwidth = 7*s; gwidth2 = 14*s; gheight = 8*s; flags = (s == 1) ? FLAG_SMALL : 0; } String dump() { return super.dump() + " " + inputCount + " " + volts[inputCount]; } Point inPosts[], inGates[]; int ww; void setPoints() { super.setPoints(); if (dn > 150 && this == sim.dragElm) setSize(2); int hs = gheight; int i; ww = gwidth2; // was 24 if (ww > dn/2) ww = (int) (dn/2); if (isInverting() && ww+8 > dn/2) ww = (int) (dn/2-8); calcLeads(ww*2); inPosts = new Point[inputCount]; inGates = new Point[inputCount]; allocNodes(); int i0 = -inputCount/2; for (i = 0; i != inputCount; i++, i0++) { if (i0 == 0 && (inputCount & 1) == 0) i0++; inPosts[i] = interpPoint(point1, point2, 0, hs*i0); inGates[i] = interpPoint(lead1, lead2, 0, hs*i0); volts[i] = (lastOutput ^ isInverting()) ? 5 : 0; } hs2 = gwidth*(inputCount/2+1); setBbox(point1, point2, hs2); } void draw(Graphics g) { int i; for (i = 0; i != inputCount; i++) { setVoltageColor(g, volts[i]); drawThickLine(g, inPosts[i], inGates[i]); } setVoltageColor(g, volts[inputCount]); drawThickLine(g, lead2, point2); g.setColor(needsHighlight() ? selectColor : lightGrayColor); drawThickPolygon(g, gatePoly); if (linePoints != null) for (i = 0; i != linePoints.length-1; i++) drawThickLine(g, linePoints[i], linePoints[i+1]); if (isInverting()) drawThickCircle(g, pcircle.x, pcircle.y, 3); curcount = updateDotCount(current, curcount); drawDots(g, lead2, point2, curcount); drawPosts(g); } Polygon gatePoly; Point pcircle, linePoints[]; int getPostCount() { return inputCount+1; } Point getPost(int n) { if (n == inputCount) return point2; return inPosts[n]; } int getVoltageSourceCount() { return 1; } abstract String getGateName(); void getInfo(String arr[]) { arr[0] = getGateName(); arr[1] = "Vout = " + getVoltageText(volts[inputCount]); arr[2] = "Iout = " + getCurrentText(getCurrent()); } void stamp() { sim.stampVoltageSource(0, nodes[inputCount], voltSource); } boolean getInput(int x) { return volts[x] > 2.5; } abstract boolean calcFunction(); void doStep() { int i; boolean f = calcFunction(); if (isInverting()) f = !f; lastOutput = f; double res = f ? 5 : 0; sim.updateVoltageSource(0, nodes[inputCount], voltSource, res); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("# of Inputs", inputCount, 1, 8). setDimensionless(); return null; } public void setEditValue(int n, EditInfo ei) { inputCount = (int) ei.value; setPoints(); } // there is no current path through the gate inputs, but there // is an indirect path through the output to ground. boolean getConnection(int n1, int n2) { return false; } boolean hasGroundConnection(int n1) { return (n1 == inputCount); } } ================================================ FILE: src/GraphicElm.java ================================================ class GraphicElm extends CircuitElm { public GraphicElm(int xx, int yy) { super(xx,yy); } public GraphicElm(int xa, int ya, int xb, int yb, int flags) { super(xa, ya, xb, yb, flags); } int getPostCount() { return 0; } } ================================================ FILE: src/GroundElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class GroundElm extends CircuitElm { public GroundElm(int xx, int yy) { super(xx, yy); } public GroundElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); } int getDumpType() { return 'g'; } int getPostCount() { return 1; } void draw(Graphics g) { setVoltageColor(g, 0); drawThickLine(g, point1, point2); int i; for (i = 0; i != 3; i++) { int a = 10-i*4; int b = i*5; // -10; interpPoint2(point1, point2, ps1, ps2, 1+b/dn, a); drawThickLine(g, ps1, ps2); } doDots(g); interpPoint(point1, point2, ps2, 1+11./dn); setBbox(point1, ps2, 11); drawPost(g, x, y, nodes[0]); } void setCurrent(int x, double c) { current = -c; } void stamp() { sim.stampVoltageSource(0, nodes[0], voltSource, 0); } double getVoltageDiff() { return 0; } int getVoltageSourceCount() { return 1; } void getInfo(String arr[]) { arr[0] = "ground"; arr[1] = "I = " + getCurrentText(getCurrent()); } boolean hasGroundConnection(int n1) { return true; } int getShortcut() { return 'g'; } } ================================================ FILE: src/ImportExportAppletDialog.java ================================================ import java.awt.Dialog; import java.applet.Applet; import java.awt.Frame; import netscape.javascript.*; // add plugin.jar to classpath during compilation class ImportExportAppletDialog extends Dialog implements ImportExportDialog { Action type; CirSim cframe; String circuitDump; ImportExportAppletDialog(CirSim f, Action type) throws Exception { super(f, (type == Action.EXPORT) ? "Export" : "Import", false); this.type = type; cframe = f; if ( cframe.applet == null ) throw new Exception("Not running as an applet!"); } public void setDump(String dump) { circuitDump = dump; } public void execute() { try { JSObject window = JSObject.getWindow(cframe.applet); if ( type == Action.EXPORT ) { //cframe.setVisible(false); window.call("exportCircuit", new Object[] { circuitDump }); } else { //cframe.setVisible(false); circuitDump = (String)window.eval("importCircuit()"); cframe.readSetup( circuitDump ); } } catch (Exception e) { e.printStackTrace(); } } } ================================================ FILE: src/ImportExportClipboardDialog.java ================================================ import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; class ImportExportClipboardDialog extends Dialog implements ImportExportDialog,ActionListener { CirSim cframe; Button importButton, closeButton; TextArea text; Action type; Clipboard clipboard = null; ImportExportClipboardDialog(CirSim f, Action type) { super(f, (type == Action.EXPORT) ? "Export" : "Import", false); cframe = f; setLayout(new ImportExportDialogLayout()); add(text = new TextArea("", 10, 60, TextArea.SCROLLBARS_BOTH)); if (type == Action.EXPORT) importButton = new Button("Copy to clipboard"); else importButton = new Button("Import"); this.type = type; add(importButton); importButton.addActionListener(this); add(closeButton = new Button("Close")); closeButton.addActionListener(this); Point x = cframe.main.getLocationOnScreen(); resize(400, 300); Dimension d = getSize(); setLocation(x.x + (cframe.winSize.width-d.width)/2, x.y + (cframe.winSize.height-d.height)/2); } public void setDump(String dump) { text.setText(dump); } public void execute() { if ( type == Action.EXPORT ) text.selectAll(); setVisible(true); } public void actionPerformed(ActionEvent e) { int i; Object src = e.getSource(); if (src == importButton) { if (clipboard == null) clipboard = getToolkit().getSystemClipboard(); if ( type == Action.EXPORT ) { StringSelection data = new StringSelection(text.getText()); clipboard.setContents(data, data); } else { cframe.readSetup(text.getText()); } } if (src == closeButton) setVisible(false); } public boolean handleEvent(Event ev) { if (ev.id == Event.WINDOW_DESTROY) { CirSim.main.requestFocus(); setVisible(false); cframe.impDialog = null; return true; } return super.handleEvent(ev); } } ================================================ FILE: src/ImportExportDialog.java ================================================ import java.awt.*; import java.awt.event.*; public interface ImportExportDialog { public enum Action { IMPORT, EXPORT }; public void setDump(String dump); public void execute(); } ================================================ FILE: src/ImportExportDialogFactory.java ================================================ public class ImportExportDialogFactory { public static ImportExportDialog Create(CirSim f, ImportExportDialog.Action type) { if (f.applet != null) { try { return new ImportExportAppletDialog(f, type); } catch (Exception e) { return new ImportExportClipboardDialog(f, type); } } else { return new ImportExportFileDialog(f, type); } } } ================================================ FILE: src/ImportExportDialogLayout.java ================================================ import java.awt.*; class ImportExportDialogLayout implements LayoutManager { public ImportExportDialogLayout() {} public void addLayoutComponent(String name, Component c) {} public void removeLayoutComponent(Component c) {} public Dimension preferredLayoutSize(Container target) { return new Dimension(500, 500); } public Dimension minimumLayoutSize(Container target) { return new Dimension(100,100); } public void layoutContainer(Container target) { Insets insets = target.insets(); int targetw = target.size().width - insets.left - insets.right; int targeth = target.size().height - (insets.top+insets.bottom); int i; int pw = 300; if (target.getComponentCount() == 0) return; Component cl = target.getComponent(target.getComponentCount()-1); Dimension dl = cl.getPreferredSize(); target.getComponent(0).move(insets.left, insets.top); int cw = target.size().width - insets.left - insets.right; int ch = target.size().height - insets.top - insets.bottom - dl.height; target.getComponent(0).resize(cw, ch); int h = ch + insets.top; int x = 0; for (i = 1; i < target.getComponentCount(); i++) { Component m = target.getComponent(i); if (m.isVisible()) { Dimension d = m.getPreferredSize(); m.move(insets.left+x, h); m.resize(d.width, d.height); x += d.width; } } } }; ================================================ FILE: src/ImportExportFileDialog.java ================================================ import java.awt.*; import java.awt.event.*; import java.io.*; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; class ImportExportFileDialog implements ImportExportDialog { CirSim cframe; private static String circuitDump; Action type; private static String directory = "."; ImportExportFileDialog(CirSim f, Action type) { if ( directory.equals(".") ) { File file = new File("circuits"); if ( file.isDirectory() ) directory = "circuits"; } this.type = type; cframe = f; } public void setDump(String dump) { circuitDump = dump; } public String getDump() { return circuitDump; } public void execute() { FileDialog fd = new FileDialog(new Frame(), (type == Action.EXPORT) ? "Save File" : "Open File", (type == Action.EXPORT) ? FileDialog.SAVE : FileDialog.LOAD ); fd.setDirectory(directory); fd.setVisible(true); String file = fd.getFile(); String dir = fd.getDirectory(); if ( dir != null ) directory = dir; if ( file == null ) return; System.err.println(dir + File.separator + file); if ( type == Action.EXPORT ) { try { writeFile(dir + file); } catch (Exception e) { e.printStackTrace(); } } else { try { String dump = readFile(dir + file); circuitDump = dump; cframe.readSetup(circuitDump); } catch (Exception e) { e.printStackTrace(); } } } private static String readFile(String path) throws IOException, FileNotFoundException { FileInputStream stream = null; try { stream = new FileInputStream(new File(path)); FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); return Charset.forName("UTF-8").decode(bb).toString(); } finally { stream.close(); } } private static void writeFile(String path) throws IOException, FileNotFoundException { FileOutputStream stream = null; try { stream = new FileOutputStream(new File(path)); FileChannel fc = stream.getChannel(); ByteBuffer bb = Charset.forName("UTF-8").encode(circuitDump); fc.write(bb); } finally { stream.close(); } } } ================================================ FILE: src/Inductor.java ================================================ class Inductor { public static final int FLAG_BACK_EULER = 2; int nodes[]; int flags; CirSim sim; double inductance; double compResistance, current; double curSourceValue; Inductor(CirSim s) { sim = s; nodes = new int[2]; } void setup(double ic, double cr, int f) { inductance = ic; current = cr; flags = f; } boolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; } void reset() { current = 0; } void stamp(int n0, int n1) { // inductor companion model using trapezoidal or backward euler // approximations (Norton equivalent) consists of a current // source in parallel with a resistor. Trapezoidal is more // accurate than backward euler but can cause oscillatory behavior. // The oscillation is a real problem in circuits with switches. nodes[0] = n0; nodes[1] = n1; if (isTrapezoidal()) compResistance = 2*inductance/sim.timeStep; else // backward euler compResistance = inductance/sim.timeStep; sim.stampResistor(nodes[0], nodes[1], compResistance); sim.stampRightSide(nodes[0]); sim.stampRightSide(nodes[1]); } boolean nonLinear() { return false; } void startIteration(double voltdiff) { if (isTrapezoidal()) curSourceValue = voltdiff/compResistance+current; else // backward euler curSourceValue = current; } double calculateCurrent(double voltdiff) { // we check compResistance because this might get called // before stamp(), which sets compResistance, causing // infinite current if (compResistance > 0) current = voltdiff/compResistance + curSourceValue; return current; } void doStep(double voltdiff) { sim.stampCurrentSource(nodes[0], nodes[1], curSourceValue); } } ================================================ FILE: src/InductorElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class InductorElm extends CircuitElm { Inductor ind; double inductance; public InductorElm(int xx, int yy) { super(xx, yy); ind = new Inductor(sim); inductance = 1; ind.setup(inductance, current, flags); } public InductorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); ind = new Inductor(sim); inductance = new Double(st.nextToken()).doubleValue(); current = new Double(st.nextToken()).doubleValue(); ind.setup(inductance, current, flags); } int getDumpType() { return 'l'; } String dump() { return super.dump() + " " + inductance + " " + current; } void setPoints() { super.setPoints(); calcLeads(32); } void draw(Graphics g) { double v1 = volts[0]; double v2 = volts[1]; int i; int hs = 8; setBbox(point1, point2, hs); draw2Leads(g); setPowerColor(g, false); drawCoil(g, 8, lead1, lead2, v1, v2); if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(inductance, "H"); drawValues(g, s, hs); } doDots(g); drawPosts(g); } void reset() { current = volts[0] = volts[1] = curcount = 0; ind.reset(); } void stamp() { ind.stamp(nodes[0], nodes[1]); } void startIteration() { ind.startIteration(volts[0]-volts[1]); } boolean nonLinear() { return ind.nonLinear(); } void calculateCurrent() { double voltdiff = volts[0]-volts[1]; current = ind.calculateCurrent(voltdiff); } void doStep() { double voltdiff = volts[0]-volts[1]; ind.doStep(voltdiff); } void getInfo(String arr[]) { arr[0] = "inductor"; getBasicInfo(arr); arr[3] = "L = " + getUnitText(inductance, "H"); arr[4] = "P = " + getUnitText(getPower(), "W"); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Inductance (H)", inductance, 0, 0); if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Trapezoidal Approximation", ind.isTrapezoidal()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) inductance = ei.value; if (n == 1) { if (ei.checkbox.getState()) flags &= ~Inductor.FLAG_BACK_EULER; else flags |= Inductor.FLAG_BACK_EULER; } ind.setup(inductance, current, flags); } } ================================================ FILE: src/InverterElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class InverterElm extends CircuitElm { double slewRate; // V/ns public InverterElm(int xx, int yy) { super(xx, yy); noDiagonal = true; slewRate = .5; } public InverterElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); noDiagonal = true; try { slewRate = new Double (st.nextToken()).doubleValue(); } catch (Exception e) { slewRate = .5; } } String dump() { return super.dump() + " " + slewRate; } int getDumpType() { return 'I'; } void draw(Graphics g) { drawPosts(g); draw2Leads(g); g.setColor(needsHighlight() ? selectColor : lightGrayColor); drawThickPolygon(g, gatePoly); drawThickCircle(g, pcircle.x, pcircle.y, 3); curcount = updateDotCount(current, curcount); drawDots(g, lead2, point2, curcount); } Polygon gatePoly; Point pcircle; void setPoints() { super.setPoints(); int hs = 16; int ww = 16; if (ww > dn/2) ww = (int) (dn/2); lead1 = interpPoint(point1, point2, .5-ww/dn); lead2 = interpPoint(point1, point2, .5+(ww+2)/dn); pcircle = interpPoint(point1, point2, .5+(ww-2)/dn); Point triPoints[] = newPointArray(3); interpPoint2(lead1, lead2, triPoints[0], triPoints[1], 0, hs); triPoints[2] = interpPoint(point1, point2, .5+(ww-5)/dn); gatePoly = createPolygon(triPoints); setBbox(point1, point2, hs); } int getVoltageSourceCount() { return 1; } void stamp() { sim.stampVoltageSource(0, nodes[1], voltSource); } void doStep() { double v0 = volts[1]; double out = volts[0] > 2.5 ? 0 : 5; double maxStep = slewRate * sim.timeStep * 1e9; out = Math.max(Math.min(v0+maxStep, out), v0-maxStep); sim.updateVoltageSource(0, nodes[1], voltSource, out); } double getVoltageDiff() { return volts[0]; } void getInfo(String arr[]) { arr[0] = "inverter"; arr[1] = "Vi = " + getVoltageText(volts[0]); arr[2] = "Vo = " + getVoltageText(volts[1]); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Slew Rate (V/ns)", slewRate, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { slewRate = ei.value; } // there is no current path through the inverter input, but there // is an indirect path through the output to ground. boolean getConnection(int n1, int n2) { return false; } boolean hasGroundConnection(int n1) { return (n1 == 1); } int getShortcut() { return '1'; } } ================================================ FILE: src/JKFlipFlopElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class JKFlipFlopElm extends ChipElm { public JKFlipFlopElm(int xx, int yy) { super(xx, yy); } public JKFlipFlopElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); pins[4].value = !pins[3].value; } String getChipName() { return "JK flip-flop"; } void setupPins() { sizeX = 2; sizeY = 3; pins = new Pin[5]; pins[0] = new Pin(0, SIDE_W, "J"); pins[1] = new Pin(1, SIDE_W, ""); pins[1].clock = true; pins[1].bubble = true; pins[2] = new Pin(2, SIDE_W, "K"); pins[3] = new Pin(0, SIDE_E, "Q"); pins[3].output = pins[3].state = true; pins[4] = new Pin(2, SIDE_E, "Q"); pins[4].output = true; pins[4].lineOver = true; } int getPostCount() { return 5; } int getVoltageSourceCount() { return 2; } void execute() { if (!pins[1].value && lastClock) { boolean q = pins[3].value; if (pins[0].value) { if (pins[2].value) q = !q; else q = true; } else if (pins[2].value) q = false; pins[3].value = q; pins[4].value = !q; } lastClock = pins[1].value; } int getDumpType() { return 156; } } ================================================ FILE: src/JfetElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class JfetElm extends MosfetElm { JfetElm(int xx, int yy, boolean pnpflag) { super(xx, yy, pnpflag); noDiagonal = true; } public JfetElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); noDiagonal = true; } Polygon gatePoly; Polygon arrowPoly; Point gatePt; void draw(Graphics g) { setBbox(point1, point2, hs); setVoltageColor(g, volts[1]); drawThickLine(g, src[0], src[1]); drawThickLine(g, src[1], src[2]); setVoltageColor(g, volts[2]); drawThickLine(g, drn[0], drn[1]); drawThickLine(g, drn[1], drn[2]); setVoltageColor(g, volts[0]); drawThickLine(g, point1, gatePt); g.fillPolygon(arrowPoly); setPowerColor(g, true); g.fillPolygon(gatePoly); curcount = updateDotCount(-ids, curcount); if (curcount != 0) { drawDots(g, src[0], src[1], curcount); drawDots(g, src[1], src[2], curcount+8); drawDots(g, drn[0], drn[1], -curcount); drawDots(g, drn[1], drn[2], -(curcount+8)); } drawPosts(g); } void setPoints() { super.setPoints(); // find the coordinates of the various points we need to draw // the JFET. int hs2 = hs*dsign; src = newPointArray(3); drn = newPointArray(3); interpPoint2(point1, point2, src[0], drn[0], 1, hs2); interpPoint2(point1, point2, src[1], drn[1], 1, hs2/2); interpPoint2(point1, point2, src[2], drn[2], 1-10/dn, hs2/2); gatePt = interpPoint(point1, point2, 1-14/dn); Point ra[] = newPointArray(4); interpPoint2(point1, point2, ra[0], ra[1], 1-13/dn, hs); interpPoint2(point1, point2, ra[2], ra[3], 1-10/dn, hs); gatePoly = createPolygon(ra[0], ra[1], ra[3], ra[2]); if (pnp == -1) { Point x = interpPoint(gatePt, point1, 18/dn); arrowPoly = calcArrow(gatePt, x, 8, 3); } else arrowPoly = calcArrow(point1, gatePt, 8, 3); } int getDumpType() { return 'j'; } // these values are taken from Hayes+Horowitz p155 double getDefaultThreshold() { return -4; } double getBeta() { return .00125; } void getInfo(String arr[]) { getFetInfo(arr, "JFET"); } } ================================================ FILE: src/LEDElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class LEDElm extends DiodeElm { double colorR, colorG, colorB; public LEDElm(int xx, int yy) { super(xx, yy); fwdrop = 2.1024259; setup(); colorR = 1; colorG = colorB = 0; } public LEDElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); if ((f & FLAG_FWDROP) == 0) fwdrop = 2.1024259; setup(); colorR = new Double(st.nextToken()).doubleValue(); colorG = new Double(st.nextToken()).doubleValue(); colorB = new Double(st.nextToken()).doubleValue(); } int getDumpType() { return 162; } String dump() { return super.dump() + " " + colorR + " " + colorG + " " + colorB; } Point ledLead1, ledLead2, ledCenter; void setPoints() { super.setPoints(); int cr = 12; ledLead1 = interpPoint(point1, point2, .5-cr/dn); ledLead2 = interpPoint(point1, point2, .5+cr/dn); ledCenter = interpPoint(point1, point2, .5); } void draw(Graphics g) { if (needsHighlight() || this == sim.dragElm) { super.draw(g); return; } setVoltageColor(g, volts[0]); drawThickLine(g, point1, ledLead1); setVoltageColor(g, volts[1]); drawThickLine(g, ledLead2, point2); g.setColor(Color.gray); int cr = 12; drawThickCircle(g, ledCenter.x, ledCenter.y, cr); cr -= 4; double w = 255*current/.01; if (w > 255) w = 255; Color cc = new Color((int) (colorR*w), (int) (colorG*w), (int) (colorB*w)); g.setColor(cc); g.fillOval(ledCenter.x-cr, ledCenter.y-cr, cr*2, cr*2); setBbox(point1, point2, cr); updateDotCount(); drawDots(g, point1, ledLead1, curcount); drawDots(g, point2, ledLead2, -curcount); drawPosts(g); } void getInfo(String arr[]) { super.getInfo(arr); arr[0] = "LED"; } public EditInfo getEditInfo(int n) { if (n == 0) return super.getEditInfo(n); if (n == 1) return new EditInfo("Red Value (0-1)", colorR, 0, 1). setDimensionless(); if (n == 2) return new EditInfo("Green Value (0-1)", colorG, 0, 1). setDimensionless(); if (n == 3) return new EditInfo("Blue Value (0-1)", colorB, 0, 1). setDimensionless(); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) super.setEditValue(0, ei); if (n == 1) colorR = ei.value; if (n == 2) colorG = ei.value; if (n == 3) colorB = ei.value; } int getShortcut() { return 'l'; } } ================================================ FILE: src/LampElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class LampElm extends CircuitElm { double resistance; final double roomTemp = 300; double temp, nom_pow, nom_v, warmTime, coolTime; public LampElm(int xx, int yy) { super(xx, yy); temp = roomTemp; nom_pow = 100; nom_v = 120; warmTime = .4; coolTime = .4; } public LampElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); temp = new Double(st.nextToken()).doubleValue(); nom_pow = new Double(st.nextToken()).doubleValue(); nom_v = new Double(st.nextToken()).doubleValue(); warmTime = new Double(st.nextToken()).doubleValue(); coolTime = new Double(st.nextToken()).doubleValue(); } String dump() { return super.dump() + " " + temp + " " + nom_pow + " " + nom_v + " " + warmTime + " " + coolTime; } int getDumpType() { return 181; } Point bulbLead[], filament[], bulb; int bulbR; void reset() { super.reset(); temp = roomTemp; } final int filament_len = 24; void setPoints() { super.setPoints(); int llen = 16; calcLeads(llen); bulbLead = newPointArray(2); filament = newPointArray(2); bulbR = 20; filament[0] = interpPoint(lead1, lead2, 0, filament_len); filament[1] = interpPoint(lead1, lead2, 1, filament_len); double br = filament_len-Math.sqrt(bulbR*bulbR-llen*llen); bulbLead[0] = interpPoint(lead1, lead2, 0, br); bulbLead[1] = interpPoint(lead1, lead2, 1, br); bulb = interpPoint(filament[0], filament[1], .5); } Color getTempColor() { if (temp < 1200) { int x = (int) (255*(temp-800)/400); if (x < 0) x = 0; return new Color(x, 0, 0); } if (temp < 1700) { int x = (int) (255*(temp-1200)/500); if (x < 0) x = 0; return new Color(255, x, 0); } if (temp < 2400) { int x = (int) (255*(temp-1700)/700); if (x < 0) x = 0; return new Color(255, 255, x); } return Color.white; } void draw(Graphics g) { double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, 4); adjustBbox(bulb.x-bulbR, bulb.y-bulbR, bulb.x+bulbR, bulb.y+bulbR); // adjustbbox draw2Leads(g); setPowerColor(g, true); g.setColor(getTempColor()); g.fillOval(bulb.x-bulbR, bulb.y-bulbR, bulbR*2, bulbR*2); g.setColor(Color.white); drawThickCircle(g, bulb.x, bulb.y, bulbR); setVoltageColor(g, v1); drawThickLine(g, lead1, filament[0]); setVoltageColor(g, v2); drawThickLine(g, lead2, filament[1]); setVoltageColor(g, (v1+v2)*.5); drawThickLine(g, filament[0], filament[1]); updateDotCount(); if (sim.dragElm != this) { drawDots(g, point1, lead1, curcount); double cc = curcount+(dn-16)/2; drawDots(g, lead1, filament[0], cc); cc += filament_len; drawDots(g, filament[0], filament[1], cc); cc += 16; drawDots(g, filament[1], lead2, cc); cc += filament_len; drawDots(g, lead2, point2, curcount); } drawPosts(g); } void calculateCurrent() { current = (volts[0]-volts[1])/resistance; //System.out.print(this + " res current set to " + current + "\n"); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } boolean nonLinear() { return true; } void startIteration() { // based on http://www.intusoft.com/nlpdf/nl11.pdf double nom_r = nom_v*nom_v/nom_pow; // this formula doesn't work for values over 5390 double tp = (temp > 5390) ? 5390 : temp; resistance = nom_r*(1.26104 - 4.90662*Math.sqrt(17.1839/tp - 0.00318794) - 7.8569/(tp - 187.56)); double cap = 1.57e-4*nom_pow; double capw = cap * warmTime/.4; double capc = cap * coolTime/.4; //System.out.println(nom_r + " " + (resistance/nom_r)); temp += getPower()*sim.timeStep/capw; double cr = 2600/nom_pow; temp -= sim.timeStep*(temp-roomTemp)/(capc*cr); //System.out.println(capw + " " + capc + " " + temp + " " +resistance); } void doStep() { sim.stampResistor(nodes[0], nodes[1], resistance); } void getInfo(String arr[]) { arr[0] = "lamp"; getBasicInfo(arr); arr[3] = "R = " + getUnitText(resistance, sim.ohmString); arr[4] = "P = " + getUnitText(getPower(), "W"); arr[5] = "T = " + ((int) temp) + " K"; } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Nominal Power", nom_pow, 0, 0); if (n == 1) return new EditInfo("Nominal Voltage", nom_v, 0, 0); if (n == 2) return new EditInfo("Warmup Time (s)", warmTime, 0, 0); if (n == 3) return new EditInfo("Cooldown Time (s)", coolTime, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) nom_pow = ei.value; if (n == 1 && ei.value > 0) nom_v = ei.value; if (n == 2 && ei.value > 0) warmTime = ei.value; if (n == 3 && ei.value > 0) coolTime = ei.value; } } ================================================ FILE: src/LatchElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class LatchElm extends ChipElm { public LatchElm(int xx, int yy) { super(xx, yy); } public LatchElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "Latch"; } boolean needsBits() { return true; } int loadPin; void setupPins() { sizeX = 2; sizeY = bits+1; pins = new Pin[getPostCount()]; int i; for (i = 0; i != bits; i++) pins[i] = new Pin(bits-1-i, SIDE_W, "I" + i); for (i = 0; i != bits; i++) { pins[i+bits] = new Pin(bits-1-i, SIDE_E, "O"); pins[i+bits].output = true; } pins[loadPin = bits*2] = new Pin(bits, SIDE_W, "Ld"); allocNodes(); } boolean lastLoad = false; void execute() { int i; if (pins[loadPin].value && !lastLoad) for (i = 0; i != bits; i++) pins[i+bits].value = pins[i].value; lastLoad = pins[loadPin].value; } int getVoltageSourceCount() { return bits; } int getPostCount() { return bits*2+1; } int getDumpType() { return 168; } } ================================================ FILE: src/LogicInputElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class LogicInputElm extends SwitchElm { final int FLAG_TERNARY = 1; final int FLAG_NUMERIC = 2; double hiV, loV; Polygon arrowPoly; public LogicInputElm(int xx, int yy) { super(xx, yy, false); hiV = 5; loV = 0; flags = 2; // hausen: default to numeric } public LogicInputElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); try { hiV = new Double(st.nextToken()).doubleValue(); loV = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { hiV = 5; loV = 0; } if (isTernary()) posCount = 3; } boolean isTernary() { return (flags & FLAG_TERNARY) != 0; } boolean isNumeric() { return (flags & (FLAG_TERNARY|FLAG_NUMERIC)) != 0; } int getDumpType() { return 'L'; } String dump() { return super.dump() + " " + hiV + " " + loV; } int getPostCount() { return 1; } void setPoints() { super.setPoints(); lead1 = interpPoint(point1, point2, 1-12/dn); arrowPoly = calcArrowReverse(point1, lead1, 8, 8); } void draw(Graphics g) { Font f = new Font("SansSerif", Font.BOLD, 20); g.setFont(f); g.setColor(needsHighlight() ? selectColor : whiteColor); String s = position == 0 ? "L" : "H"; if (isNumeric()) s = "" + position; setBbox(point1, lead1, 0); drawCenteredText(g, s, x2, y2, true); setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); g.fillPolygon(arrowPoly); updateDotCount(); drawDots(g, point1, lead1, curcount); drawPosts(g); } void setCurrent(int vs, double c) { current = -c; } void stamp() { double v = (position == 0) ? loV : hiV; if (isTernary()) v = position * 2.5; sim.stampVoltageSource(0, nodes[0], voltSource, v); } int getVoltageSourceCount() { return 1; } double getVoltageDiff() { return volts[0]; } void getInfo(String arr[]) { arr[0] = "logic input"; arr[1] = (position == 0) ? "low" : "high"; if (isNumeric()) arr[1] = "" + position; arr[1] += " (" + getVoltageText(volts[0]) + ")"; arr[2] = "I = " + getCurrentText(getCurrent()); } boolean hasGroundConnection(int n1) { return true; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, 0, 0); ei.checkbox = new Checkbox("Momentary Switch", momentary); return ei; } if (n == 1) return new EditInfo("High Voltage", hiV, 10, -10); if (n == 2) return new EditInfo("Low Voltage", loV, 10, -10); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) momentary = ei.checkbox.getState(); if (n == 1) hiV = ei.value; if (n == 2) loV = ei.value; } int getShortcut() { return 'i'; } } ================================================ FILE: src/LogicOutputElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class LogicOutputElm extends CircuitElm { final int FLAG_TERNARY = 1; final int FLAG_NUMERIC = 2; final int FLAG_PULLDOWN = 4; double threshold; String value; Polygon arrowPoly; public LogicOutputElm(int xx, int yy) { super(xx, yy); threshold = 3; // hausen: default to 3 flags = 6; // hausen: default to numeric and pulldown } public LogicOutputElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); try { threshold = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { threshold = 3; } } String dump() { return super.dump() + " " + threshold; } int getDumpType() { return 'M'; } int getPostCount() { return 1; } boolean isTernary() { return (flags & FLAG_TERNARY) != 0; } //boolean isNumeric() { return (flags & (FLAG_TERNARY|FLAG_NUMERIC)) != 0; } boolean isNumeric() { return true; } // hausen: always numeric boolean needsPullDown() { return (flags & FLAG_PULLDOWN) != 0; } void setPoints() { super.setPoints(); lead1 = interpPoint(point1, point2, 1-12/dn); arrowPoly = calcArrow(point1, lead1, 8, 8); } void draw(Graphics g) { Font f = new Font("SansSerif", Font.BOLD, 20); g.setFont(f); //g.setColor(needsHighlight() ? selectColor : lightGrayColor); g.setColor(lightGrayColor); String s = (volts[0] < threshold) ? "L" : "H"; if (isTernary()) { if (volts[0] > 3.75) s = "2"; else if (volts[0] > 1.25) s = "1"; else s = "0"; } else if (isNumeric()) s = (volts[0] < threshold) ? "0" : "1"; value = s; setBbox(point1, lead1, 0); drawCenteredText(g, s, x2, y2, true); setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); g.fillPolygon(arrowPoly); drawPosts(g); } void stamp() { if (needsPullDown()) sim.stampResistor(nodes[0], 0, 1e6); } double getVoltageDiff() { return volts[0]; } void getInfo(String arr[]) { arr[0] = "logic output"; arr[1] = (volts[0] < threshold) ? "low" : "high"; if (isNumeric()) arr[1] = value; arr[2] = "V = " + getVoltageText(volts[0]); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Threshold", threshold, 10, -10); if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Current Required", needsPullDown()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) threshold = ei.value; if (n == 1) { if (ei.checkbox.getState()) flags = FLAG_PULLDOWN; else flags &= ~FLAG_PULLDOWN; } } int getShortcut() { return 'o'; } } ================================================ FILE: src/Makefile ================================================ PLUGINJAR=/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/plugin.jar #PLUGINJAR=/usr/share/icedtea-web/plugin.jar all: javac -classpath $(PLUGINJAR):. *.java jar: circuit.jar src: cd .. && zip -r circuit-src.zip src/Makefile src/*.java src/*.txt src/circuits/ run: all java Circuit circuit.jar: all jar cfm circuit.jar Manifest.txt *.class *.txt circuits/ clean: rm -f *.class circuit.jar ================================================ FILE: src/Manifest.txt ================================================ Main-Class: Circuit ================================================ FILE: src/MemristorElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class MemristorElm extends CircuitElm { double r_on, r_off, dopeWidth, totalWidth, mobility, resistance; public MemristorElm(int xx, int yy) { super(xx, yy); r_on = 100; r_off = 160*r_on; dopeWidth = 0; totalWidth = 10e-9; // meters mobility = 1e-10; // m^2/sV resistance = 100; } public MemristorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); r_on = new Double(st.nextToken()).doubleValue(); r_off = new Double(st.nextToken()).doubleValue(); dopeWidth = new Double(st.nextToken()).doubleValue(); totalWidth = new Double(st.nextToken()).doubleValue(); mobility = new Double(st.nextToken()).doubleValue(); resistance = 100; } int getDumpType() { return 'm'; } String dump() { return super.dump() + " " + r_on + " " + r_off + " " + dopeWidth + " " + totalWidth + " " + mobility; } Point ps3, ps4; void setPoints() { super.setPoints(); calcLeads(32); ps3 = new Point(); ps4 = new Point(); } void draw(Graphics g) { int segments = 6; int i; int ox = 0; double v1 = volts[0]; double v2 = volts[1]; int hs = 2+(int) (8*(1-dopeWidth/totalWidth)); setBbox(point1, point2, hs); draw2Leads(g); setPowerColor(g, true); double segf = 1./segments; // draw zigzag for (i = 0; i <= segments; i++) { int nx = (i & 1) == 0 ? 1 : -1; if (i == segments) nx = 0; double v = v1+(v2-v1)*i/segments; setVoltageColor(g, v); interpPoint(lead1, lead2, ps1, i*segf, hs*ox); interpPoint(lead1, lead2, ps2, i*segf, hs*nx); drawThickLine(g, ps1, ps2); if (i == segments) break; interpPoint(lead1, lead2, ps1, (i+1)*segf, hs*nx); drawThickLine(g, ps1, ps2); ox = nx; } doDots(g); drawPosts(g); } boolean nonLinear() { return true; } void calculateCurrent() { current = (volts[0]-volts[1])/resistance; } void reset() { dopeWidth = 0; } void startIteration() { double wd = dopeWidth/totalWidth; dopeWidth += sim.timeStep*mobility*r_on*current/totalWidth; if (dopeWidth < 0) dopeWidth = 0; if (dopeWidth > totalWidth) dopeWidth = totalWidth; resistance = r_on * wd + r_off * (1-wd); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void doStep() { sim.stampResistor(nodes[0], nodes[1], resistance); } void getInfo(String arr[]) { arr[0] = "memristor"; getBasicInfo(arr); arr[3] = "R = " + getUnitText(resistance, sim.ohmString); arr[4] = "P = " + getUnitText(getPower(), "W"); } double getScopeValue(int x) { return (x == 2) ? resistance : (x == 1) ? getPower() : getVoltageDiff(); } String getScopeUnits(int x) { return (x == 2) ? sim.ohmString : (x == 1) ? "W" : "V"; } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Max Resistance (ohms)", r_on, 0, 0); if (n == 1) return new EditInfo("Min Resistance (ohms)", r_off, 0, 0); if (n == 2) return new EditInfo("Width of Doped Region (nm)", dopeWidth*1e9, 0, 0); if (n == 3) return new EditInfo("Total Width (nm)", totalWidth*1e9, 0, 0); if (n == 4) return new EditInfo("Mobility (um^2/(s*V))", mobility*1e12, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) r_on = ei.value; if (n == 1) r_off = ei.value; if (n == 2) dopeWidth = ei.value*1e-9; if (n == 3) totalWidth = ei.value*1e-9; if (n == 4) mobility = ei.value*1e-12; } } ================================================ FILE: src/MosfetElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class MosfetElm extends CircuitElm { int pnp; int FLAG_PNP = 1; int FLAG_SHOWVT = 2; int FLAG_DIGITAL = 4; double vt; MosfetElm(int xx, int yy, boolean pnpflag) { super(xx, yy); pnp = (pnpflag) ? -1 : 1; flags = (pnpflag) ? FLAG_PNP : 0; noDiagonal = true; vt = getDefaultThreshold(); } public MosfetElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); pnp = ((f & FLAG_PNP) != 0) ? -1 : 1; noDiagonal = true; vt = getDefaultThreshold(); try { vt = new Double(st.nextToken()).doubleValue(); } catch (Exception e) {} } double getDefaultThreshold() { return 1.5; } double getBeta() { return .02; } boolean nonLinear() { return true; } boolean drawDigital() { return (flags & FLAG_DIGITAL) != 0; } void reset() { lastv1 = lastv2 = volts[0] = volts[1] = volts[2] = curcount = 0; } String dump() { return super.dump() + " " + vt; } int getDumpType() { return 'f'; } final int hs = 16; void draw(Graphics g) { setBbox(point1, point2, hs); setVoltageColor(g, volts[1]); drawThickLine(g, src[0], src[1]); setVoltageColor(g, volts[2]); drawThickLine(g, drn[0], drn[1]); int segments = 6; int i; setPowerColor(g, true); double segf = 1./segments; for (i = 0; i != segments; i++) { double v = volts[1]+(volts[2]-volts[1])*i/segments; setVoltageColor(g, v); interpPoint(src[1], drn[1], ps1, i*segf); interpPoint(src[1], drn[1], ps2, (i+1)*segf); drawThickLine(g, ps1, ps2); } setVoltageColor(g, volts[1]); drawThickLine(g, src[1], src[2]); setVoltageColor(g, volts[2]); drawThickLine(g, drn[1], drn[2]); if (!drawDigital()) { setVoltageColor(g, pnp == 1 ? volts[1] : volts[2]); g.fillPolygon(arrowPoly); } if (sim.powerCheckItem.getState()) g.setColor(Color.gray); setVoltageColor(g, volts[0]); drawThickLine(g, point1, gate[1]); drawThickLine(g, gate[0], gate[2]); if (drawDigital() && pnp == -1) drawThickCircle(g, pcircle.x, pcircle.y, pcircler); if ((flags & FLAG_SHOWVT) != 0) { String s = "" + (vt*pnp); g.setColor(whiteColor); g.setFont(unitsFont); drawCenteredText(g, s, x2+2, y2, false); } if ((needsHighlight() || sim.dragElm == this) && dy == 0) { g.setColor(Color.white); g.setFont(unitsFont); int ds = sign(dx); g.drawString("G", gate[1].x-10*ds, gate[1].y-5); g.drawString(pnp == -1 ? "D" : "S", src[0].x-3+9*ds, src[0].y+4); // x+6 if ds=1, -12 if -1 g.drawString(pnp == -1 ? "S" : "D", drn[0].x-3+9*ds, drn[0].y+4); } curcount = updateDotCount(-ids, curcount); drawDots(g, src[0], src[1], curcount); drawDots(g, src[1], drn[1], curcount); drawDots(g, drn[1], drn[0], curcount); drawPosts(g); } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? src[0] : drn[0]; } double getCurrent() { return ids; } double getPower() { return ids*(volts[2]-volts[1]); } int getPostCount() { return 3; } int pcircler; Point src[], drn[], gate[], pcircle; Polygon arrowPoly; void setPoints() { super.setPoints(); // find the coordinates of the various points we need to draw // the MOSFET. int hs2 = hs*dsign; src = newPointArray(3); drn = newPointArray(3); interpPoint2(point1, point2, src[0], drn[0], 1, -hs2); interpPoint2(point1, point2, src[1], drn[1], 1-22/dn, -hs2); interpPoint2(point1, point2, src[2], drn[2], 1-22/dn, -hs2*4/3); gate = newPointArray(3); interpPoint2(point1, point2, gate[0], gate[2], 1-28/dn, hs2/2); // was 1-20/dn interpPoint(gate[0], gate[2], gate[1], .5); if (!drawDigital()) { if (pnp == 1) arrowPoly = calcArrow(src[1], src[0], 10, 4); else arrowPoly = calcArrow(drn[0], drn[1], 12, 5); } else if (pnp == -1) { interpPoint(point1, point2, gate[1], 1-36/dn); int dist = (dsign < 0) ? 32 : 31; pcircle = interpPoint(point1, point2, 1-dist/dn); pcircler = 3; } } double lastv1, lastv2; double ids; int mode = 0; double gm = 0; void stamp() { sim.stampNonLinear(nodes[1]); sim.stampNonLinear(nodes[2]); } void doStep() { double vs[] = new double[3]; vs[0] = volts[0]; vs[1] = volts[1]; vs[2] = volts[2]; if (vs[1] > lastv1 + .5) vs[1] = lastv1 + .5; if (vs[1] < lastv1 - .5) vs[1] = lastv1 - .5; if (vs[2] > lastv2 + .5) vs[2] = lastv2 + .5; if (vs[2] < lastv2 - .5) vs[2] = lastv2 - .5; int source = 1; int drain = 2; if (pnp*vs[1] > pnp*vs[2]) { source = 2; drain = 1; } int gate = 0; double vgs = vs[gate ]-vs[source]; double vds = vs[drain]-vs[source]; if (Math.abs(lastv1-vs[1]) > .01 || Math.abs(lastv2-vs[2]) > .01) sim.converged = false; lastv1 = vs[1]; lastv2 = vs[2]; double realvgs = vgs; double realvds = vds; vgs *= pnp; vds *= pnp; ids = 0; gm = 0; double Gds = 0; double beta = getBeta(); if (vgs > .5 && this instanceof JfetElm) { sim.stop("JFET is reverse biased!", this); return; } if (vgs < vt) { // should be all zero, but that causes a singular matrix, // so instead we treat it as a large resistor Gds = 1e-8; ids = vds*Gds; mode = 0; } else if (vds < vgs-vt) { // linear ids = beta*((vgs-vt)*vds - vds*vds*.5); gm = beta*vds; Gds = beta*(vgs-vds-vt); mode = 1; } else { // saturation; Gds = 0 gm = beta*(vgs-vt); // use very small Gds to avoid nonconvergence Gds = 1e-8; ids = .5*beta*(vgs-vt)*(vgs-vt) + (vds-(vgs-vt))*Gds; mode = 2; } double rs = -pnp*ids + Gds*realvds + gm*realvgs; //System.out.println("M " + vds + " " + vgs + " " + ids + " " + gm + " "+ Gds + " " + volts[0] + " " + volts[1] + " " + volts[2] + " " + source + " " + rs + " " + this); sim.stampMatrix(nodes[drain], nodes[drain], Gds); sim.stampMatrix(nodes[drain], nodes[source], -Gds-gm); sim.stampMatrix(nodes[drain], nodes[gate], gm); sim.stampMatrix(nodes[source], nodes[drain], -Gds); sim.stampMatrix(nodes[source], nodes[source], Gds+gm); sim.stampMatrix(nodes[source], nodes[gate], -gm); sim.stampRightSide(nodes[drain], rs); sim.stampRightSide(nodes[source], -rs); if (source == 2 && pnp == 1 || source == 1 && pnp == -1) ids = -ids; } void getFetInfo(String arr[], String n) { arr[0] = ((pnp == -1) ? "p-" : "n-") + n; arr[0] += " (Vt = " + getVoltageText(pnp*vt) + ")"; arr[1] = ((pnp == 1) ? "Ids = " : "Isd = ") + getCurrentText(ids); arr[2] = "Vgs = " + getVoltageText(volts[0]-volts[pnp == -1 ? 2 : 1]); arr[3] = ((pnp == 1) ? "Vds = " : "Vsd = ") + getVoltageText(volts[2]-volts[1]); arr[4] = (mode == 0) ? "off" : (mode == 1) ? "linear" : "saturation"; arr[5] = "gm = " + getUnitText(gm, "A/V"); } void getInfo(String arr[]) { getFetInfo(arr, "MOSFET"); } boolean canViewInScope() { return true; } double getVoltageDiff() { return volts[2] - volts[1]; } boolean getConnection(int n1, int n2) { return !(n1 == 0 || n2 == 0); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Threshold Voltage", pnp*vt, .01, 5); if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Digital Symbol", drawDigital()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) vt = pnp*ei.value; if (n == 1) { flags = (ei.checkbox.getState()) ? (flags | FLAG_DIGITAL) : (flags & ~FLAG_DIGITAL); setPoints(); } } } ================================================ FILE: src/NJfetElm.java ================================================ class NJfetElm extends JfetElm { public NJfetElm(int xx, int yy) { super(xx, yy, false); } Class getDumpClass() { return JfetElm.class; } } class PJfetElm extends JfetElm { public PJfetElm(int xx, int yy) { super(xx, yy, true); } Class getDumpClass() { return JfetElm.class; } } ================================================ FILE: src/NMosfetElm.java ================================================ class NMosfetElm extends MosfetElm { public NMosfetElm(int xx, int yy) { super(xx, yy, false); } Class getDumpClass() { return MosfetElm.class; } } ================================================ FILE: src/NTransistorElm.java ================================================ class NTransistorElm extends TransistorElm { public NTransistorElm(int xx, int yy) { super(xx, yy, false); } Class getDumpClass() { return TransistorElm.class; } } ================================================ FILE: src/NandGateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class NandGateElm extends AndGateElm { public NandGateElm(int xx, int yy) { super(xx, yy); } public NandGateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } boolean isInverting() { return true; } String getGateName() { return "NAND gate"; } int getDumpType() { return 151; } int getShortcut() { return '@'; } } ================================================ FILE: src/NorGateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class NorGateElm extends OrGateElm { public NorGateElm(int xx, int yy) { super(xx, yy); } public NorGateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getGateName() { return "NOR gate"; } boolean isInverting() { return true; } int getDumpType() { return 153; } int getShortcut() { return '#'; } } ================================================ FILE: src/OpAmpElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class OpAmpElm extends CircuitElm { int opsize, opheight, opwidth, opaddtext; double maxOut, minOut, gain, gbw; boolean reset; final int FLAG_SWAP = 1; final int FLAG_SMALL = 2; final int FLAG_LOWGAIN = 4; public OpAmpElm(int xx, int yy) { super(xx, yy); noDiagonal = true; maxOut = 15; minOut = -15; gbw = 1e6; setSize(sim.smallGridCheckItem.getState() ? 1 : 2); setGain(); } public OpAmpElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); maxOut = 15; minOut = -15; // GBW has no effect in this version of the simulator, but we // retain it to keep the file format the same gbw = 1e6; try { maxOut = new Double(st.nextToken()).doubleValue(); minOut = new Double(st.nextToken()).doubleValue(); gbw = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } noDiagonal = true; setSize((f & FLAG_SMALL) != 0 ? 1 : 2); setGain(); } void setGain() { // gain of 100000 breaks e-amp-dfdx.txt // gain was 1000, but it broke amp-schmitt.txt gain = ((flags & FLAG_LOWGAIN) != 0) ? 1000 : 100000; } String dump() { return super.dump() + " " + maxOut + " " + minOut + " " + gbw; } boolean nonLinear() { return true; } void draw(Graphics g) { setBbox(point1, point2, opheight*2); setVoltageColor(g, volts[0]); drawThickLine(g, in1p[0], in1p[1]); setVoltageColor(g, volts[1]); drawThickLine(g, in2p[0], in2p[1]); g.setColor(needsHighlight() ? selectColor : lightGrayColor); setPowerColor(g, true); drawThickPolygon(g, triangle); g.setFont(plusFont); drawCenteredText(g, "-", textp[0].x, textp[0].y-2, true); drawCenteredText(g, "+", textp[1].x, textp[1].y , true); setVoltageColor(g, volts[2]); drawThickLine(g, lead2, point2); curcount = updateDotCount(current, curcount); drawDots(g, point2, lead2, curcount); drawPosts(g); } double getPower() { return volts[2]*current; } Point in1p[], in2p[], textp[]; Polygon triangle; Font plusFont; void setSize(int s) { opsize = s; opheight = 8*s; opwidth = 13*s; flags = (flags & ~FLAG_SMALL) | ((s == 1) ? FLAG_SMALL : 0); } void setPoints() { super.setPoints(); if (dn > 150 && this == sim.dragElm) setSize(2); int ww = opwidth; if (ww > dn/2) ww = (int) (dn/2); calcLeads(ww*2); int hs = opheight*dsign; if ((flags & FLAG_SWAP) != 0) hs = -hs; in1p = newPointArray(2); in2p = newPointArray(2); textp = newPointArray(2); interpPoint2(point1, point2, in1p[0], in2p[0], 0, hs); interpPoint2(lead1 , lead2, in1p[1], in2p[1], 0, hs); interpPoint2(lead1 , lead2, textp[0], textp[1], .2, hs); Point tris[] = newPointArray(2); interpPoint2(lead1, lead2, tris[0], tris[1], 0, hs*2); triangle = createPolygon(tris[0], tris[1], lead2); plusFont = new Font("SansSerif", 0, opsize == 2 ? 14 : 10); } int getPostCount() { return 3; } Point getPost(int n) { return (n == 0) ? in1p[0] : (n == 1) ? in2p[0] : point2; } int getVoltageSourceCount() { return 1; } void getInfo(String arr[]) { arr[0] = "op-amp"; arr[1] = "V+ = " + getVoltageText(volts[1]); arr[2] = "V- = " + getVoltageText(volts[0]); // sometimes the voltage goes slightly outside range, to make // convergence easier. so we hide that here. double vo = Math.max(Math.min(volts[2], maxOut), minOut); arr[3] = "Vout = " + getVoltageText(vo); arr[4] = "Iout = " + getCurrentText(getCurrent()); arr[5] = "range = " + getVoltageText(minOut) + " to " + getVoltageText(maxOut); } double lastvd; void stamp() { int vn = sim.nodeList.size()+voltSource; sim.stampNonLinear(vn); sim.stampMatrix(nodes[2], vn, 1); } void doStep() { double vd = volts[1] - volts[0]; if (Math.abs(lastvd-vd) > .1) sim.converged = false; else if (volts[2] > maxOut+.1 || volts[2] < minOut-.1) sim.converged = false; double x = 0; int vn = sim.nodeList.size()+voltSource; double dx = 0; if (vd >= maxOut/gain && (lastvd >= 0 || sim.getrand(4) == 1)) { dx = 1e-4; x = maxOut - dx*maxOut/gain; } else if (vd <= minOut/gain && (lastvd <= 0 || sim.getrand(4) == 1)) { dx = 1e-4; x = minOut - dx*minOut/gain; } else dx = gain; //System.out.println("opamp " + vd + " " + volts[2] + " " + dx + " " + x + " " + lastvd + " " + sim.converged); // newton-raphson sim.stampMatrix(vn, nodes[0], dx); sim.stampMatrix(vn, nodes[1], -dx); sim.stampMatrix(vn, nodes[2], 1); sim.stampRightSide(vn, x); lastvd = vd; /*if (sim.converged) System.out.println((volts[1]-volts[0]) + " " + volts[2] + " " + initvd);*/ } // there is no current path through the op-amp inputs, but there // is an indirect path through the output to ground. boolean getConnection(int n1, int n2) { return false; } boolean hasGroundConnection(int n1) { return (n1 == 2); } double getVoltageDiff() { return volts[2] - volts[1]; } int getDumpType() { return 'a'; } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Max Output (V)", maxOut, 1, 20); if (n == 1) return new EditInfo("Min Output (V)", minOut, -20, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) maxOut = ei.value; if (n == 1) minOut = ei.value; } } ================================================ FILE: src/OpAmpSwapElm.java ================================================ class OpAmpSwapElm extends OpAmpElm { public OpAmpSwapElm(int xx, int yy) { super(xx, yy); flags |= FLAG_SWAP; } Class getDumpClass() { return OpAmpElm.class; } } ================================================ FILE: src/OrGateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class OrGateElm extends GateElm { public OrGateElm(int xx, int yy) { super(xx, yy); } public OrGateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getGateName() { return "OR gate"; } void setPoints() { super.setPoints(); // 0-15 = top curve, 16 = right, 17-32=bottom curve, // 33-37 = left curve Point triPoints[] = newPointArray(38); if (this instanceof XorGateElm) linePoints = new Point[5]; int i; for (i = 0; i != 16; i++) { double a = i/16.; double b = 1-a*a; interpPoint2(lead1, lead2, triPoints[i], triPoints[32-i], .5+a/2, b*hs2); } double ww2 = (ww == 0) ? dn*2 : ww*2; for (i = 0; i != 5; i++) { double a = (i-2)/2.; double b = 4*(1-a*a)-2; interpPoint(lead1, lead2, triPoints[33+i], b/(ww2), a*hs2); if (this instanceof XorGateElm) linePoints[i] = interpPoint(lead1, lead2, (b-5)/(ww2), a*hs2); } triPoints[16] = new Point(lead2); if (isInverting()) { pcircle = interpPoint(point1, point2, .5+(ww+4)/dn); lead2 = interpPoint(point1, point2, .5+(ww+8)/dn); } gatePoly = createPolygon(triPoints); } boolean calcFunction() { int i; boolean f = false; for (i = 0; i != inputCount; i++) f |= getInput(i); return f; } int getDumpType() { return 152; } int getShortcut() { return '3'; } } ================================================ FILE: src/OutputElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class OutputElm extends CircuitElm { final int FLAG_VALUE = 1; public OutputElm(int xx, int yy) { super(xx, yy); } public OutputElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); } int getDumpType() { return 'O'; } int getPostCount() { return 1; } void setPoints() { super.setPoints(); lead1 = new Point(); } void draw(Graphics g) { boolean selected = (needsHighlight() || sim.plotYElm == this); Font f = new Font("SansSerif", selected ? Font.BOLD : 0, 14); g.setFont(f); g.setColor(selected ? selectColor : whiteColor); String s = (flags & FLAG_VALUE) != 0 ? getVoltageText(volts[0]) : "out"; FontMetrics fm = g.getFontMetrics(); if (this == sim.plotXElm) s = "X"; if (this == sim.plotYElm) s = "Y"; interpPoint(point1, point2, lead1, 1-(fm.stringWidth(s)/2+8)/dn); setBbox(point1, lead1, 0); drawCenteredText(g, s, x2, y2, true); setVoltageColor(g, volts[0]); if (selected) g.setColor(selectColor); drawThickLine(g, point1, lead1); drawPosts(g); } double getVoltageDiff() { return volts[0]; } void getInfo(String arr[]) { arr[0] = "output"; arr[1] = "V = " + getVoltageText(volts[0]); } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Show Voltage", (flags & FLAG_VALUE) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) flags = (ei.checkbox.getState()) ? (flags | FLAG_VALUE) : (flags & ~FLAG_VALUE); } } ================================================ FILE: src/PMosfetElm.java ================================================ class PMosfetElm extends MosfetElm { public PMosfetElm(int xx, int yy) { super(xx, yy, true); } Class getDumpClass() { return MosfetElm.class; } } ================================================ FILE: src/PTransistorElm.java ================================================ class PTransistorElm extends TransistorElm { public PTransistorElm(int xx, int yy) { super(xx, yy, true); } Class getDumpClass() { return TransistorElm.class; } } ================================================ FILE: src/PhaseCompElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class PhaseCompElm extends ChipElm { public PhaseCompElm(int xx, int yy) { super(xx, yy); } public PhaseCompElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "phase comparator"; } void setupPins() { sizeX = 2; sizeY = 2; pins = new Pin[3]; pins[0] = new Pin(0, SIDE_W, "I1"); pins[1] = new Pin(1, SIDE_W, "I2"); pins[2] = new Pin(0, SIDE_E, "O"); pins[2].output = true; } boolean nonLinear() { return true; } void stamp() { int vn = sim.nodeList.size()+pins[2].voltSource; sim.stampNonLinear(vn); sim.stampNonLinear(0); sim.stampNonLinear(nodes[2]); } boolean ff1, ff2; void doStep() { boolean v1 = volts[0] > 2.5; boolean v2 = volts[1] > 2.5; if (v1 && !pins[0].value) ff1 = true; if (v2 && !pins[1].value) ff2 = true; if (ff1 && ff2) ff1 = ff2 = false; double out = (ff1) ? 5 : (ff2) ? 0 : -1; //System.out.println(out + " " + v1 + " " + v2); if (out != -1) sim.stampVoltageSource(0, nodes[2], pins[2].voltSource, out); else { // tie current through output pin to 0 int vn = sim.nodeList.size()+pins[2].voltSource; sim.stampMatrix(vn, vn, 1); } pins[0].value = v1; pins[1].value = v2; } int getPostCount() { return 3; } int getVoltageSourceCount() { return 1; } int getDumpType() { return 161; } } ================================================ FILE: src/PhotoResistorElm.java ================================================ // stub PhotoResistorElm based on SparkGapElm // FIXME need to uncomment PhotoResistorElm line from CirSim.java // FIXME need to add PhotoResistorElm.java to srclist import java.awt.*; import java.util.StringTokenizer; class PhotoResistorElm extends CircuitElm { double minresistance, maxresistance; double resistance; Scrollbar slider; Label label; public PhotoResistorElm(int xx, int yy) { super(xx, yy); maxresistance = 1e9; minresistance = 1e3; createSlider(); } public PhotoResistorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); minresistance = new Double(st.nextToken()).doubleValue(); maxresistance = new Double(st.nextToken()).doubleValue(); createSlider(); } boolean nonLinear() {return true;} int getDumpType() { return 186; } String dump() { return super.dump() + " " + minresistance + " " + maxresistance; } Point ps3, ps4; void createSlider() { sim.main.add(label = new Label("Light Level", Label.CENTER)); int value = 50; sim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101)); sim.main.validate(); } void setPoints() { super.setPoints(); calcLeads(32); ps3 = new Point(); ps4 = new Point(); } void delete() { sim.main.remove(label); sim.main.remove(slider); } void draw(Graphics g) { int i; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, 6); draw2Leads(g); // FIXME need to draw properly, see ResistorElm.java setPowerColor(g, true); doDots(g); drawPosts(g); } void calculateCurrent() { double vd = volts[0] - volts[1]; current = vd/resistance; } void startIteration() { double vd = volts[0] - volts[1]; // FIXME set resistance as appropriate, using slider.getValue() resistance = minresistance; //System.out.print(this + " res current set to " + current + "\n"); } void doStep() { sim.stampResistor(nodes[0], nodes[1], resistance); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void getInfo(String arr[]) { // FIXME arr[0] = "spark gap"; getBasicInfo(arr); arr[3] = "R = " + getUnitText(resistance, sim.ohmString); arr[4] = "Ron = " + getUnitText(minresistance, sim.ohmString); arr[5] = "Roff = " + getUnitText(maxresistance, sim.ohmString); } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Min resistance (ohms)", minresistance, 0, 0); if (n == 1) return new EditInfo("Max resistance (ohms)", maxresistance, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (ei.value > 0 && n == 0) minresistance = ei.value; if (ei.value > 0 && n == 1) maxresistance = ei.value; } } ================================================ FILE: src/PotElm.java ================================================ import java.awt.*; import java.awt.event.*; import java.util.StringTokenizer; class PotElm extends CircuitElm implements AdjustmentListener { double position, maxResistance, resistance1, resistance2; double current1, current2, current3; double curcount1, curcount2, curcount3; Scrollbar slider; Label label; String sliderText; public PotElm(int xx, int yy) { super(xx, yy); setup(); maxResistance = 1000; position = .5; sliderText = "Resistance"; createSlider(); } public PotElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); maxResistance = new Double(st.nextToken()).doubleValue(); position = new Double(st.nextToken()).doubleValue(); sliderText = st.nextToken(); while (st.hasMoreTokens()) sliderText += ' ' + st.nextToken(); createSlider(); } void setup() { } int getPostCount() { return 3; } int getDumpType() { return 174; } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? point2 : post3; } String dump() { return super.dump() + " " + maxResistance + " " + position + " " + sliderText; } void createSlider() { sim.main.add(label = new Label(sliderText, Label.CENTER)); int value = (int) (position*100); sim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101)); sim.main.validate(); slider.addAdjustmentListener(this); } public void adjustmentValueChanged(AdjustmentEvent e) { sim.analyzeFlag = true; setPoints(); } void delete() { sim.main.remove(label); sim.main.remove(slider); } Point post3, corner2, arrowPoint, midpoint, arrow1, arrow2; Point ps3, ps4; int bodyLen; void setPoints() { super.setPoints(); int offset = 0; if (abs(dx) > abs(dy)) { dx = sim.snapGrid(dx/2)*2; point2.x = x2 = point1.x + dx; offset = (dx < 0) ? dy : -dy; point2.y = point1.y; } else { dy = sim.snapGrid(dy/2)*2; point2.y = y2 = point1.y + dy; offset = (dy > 0) ? dx : -dx; point2.x = point1.x; } if (offset == 0) offset = sim.gridSize; dn = distance(point1, point2); int bodyLen = 32; calcLeads(bodyLen); position = slider.getValue()*.0099+.005; int soff = (int) ((position-.5)*bodyLen); //int offset2 = offset - sign(offset)*4; post3 = interpPoint(point1, point2, .5, offset); corner2 = interpPoint(point1, point2, soff/dn+.5, offset); arrowPoint = interpPoint(point1, point2, soff/dn+.5, 8*sign(offset)); midpoint = interpPoint(point1, point2, soff/dn+.5); arrow1 = new Point(); arrow2 = new Point(); double clen = abs(offset)-8; interpPoint2(corner2, arrowPoint, arrow1, arrow2, (clen-8)/clen, 8); ps3 = new Point(); ps4 = new Point(); } void draw(Graphics g) { int segments = 16; int i; int ox = 0; int hs = sim.euroResistorCheckItem.getState() ? 6 : 8; double v1 = volts[0]; double v2 = volts[1]; double v3 = volts[2]; setBbox(point1, point2, hs); draw2Leads(g); setPowerColor(g, true); double segf = 1./segments; int divide = (int) (segments*position); if (!sim.euroResistorCheckItem.getState()) { // draw zigzag for (i = 0; i != segments; i++) { int nx = 0; switch (i & 3) { case 0: nx = 1; break; case 2: nx = -1; break; default: nx = 0; break; } double v = v1+(v3-v1)*i/divide; if (i >= divide) v = v3+(v2-v3)*(i-divide)/(segments-divide); setVoltageColor(g, v); interpPoint(lead1, lead2, ps1, i*segf, hs*ox); interpPoint(lead1, lead2, ps2, (i+1)*segf, hs*nx); drawThickLine(g, ps1, ps2); ox = nx; } } else { // draw rectangle setVoltageColor(g, v1); interpPoint2(lead1, lead2, ps1, ps2, 0, hs); drawThickLine(g, ps1, ps2); for (i = 0; i != segments; i++) { double v = v1+(v3-v1)*i/divide; if (i >= divide) v = v3+(v2-v3)*(i-divide)/(segments-divide); setVoltageColor(g, v); interpPoint2(lead1, lead2, ps1, ps2, i*segf, hs); interpPoint2(lead1, lead2, ps3, ps4, (i+1)*segf, hs); drawThickLine(g, ps1, ps3); drawThickLine(g, ps2, ps4); } interpPoint2(lead1, lead2, ps1, ps2, 1, hs); drawThickLine(g, ps1, ps2); } setVoltageColor(g, v3); drawThickLine(g, post3, corner2); drawThickLine(g, corner2, arrowPoint); drawThickLine(g, arrow1, arrowPoint); drawThickLine(g, arrow2, arrowPoint); curcount1 = updateDotCount(current1, curcount1); curcount2 = updateDotCount(current2, curcount2); curcount3 = updateDotCount(current3, curcount3); if (sim.dragElm != this) { drawDots(g, point1, midpoint, curcount1); drawDots(g, point2, midpoint, curcount2); drawDots(g, post3, corner2, curcount3); drawDots(g, corner2, midpoint, curcount3+distance(post3, corner2)); } drawPosts(g); } void calculateCurrent() { current1 = (volts[0]-volts[2])/resistance1; current2 = (volts[1]-volts[2])/resistance2; current3 = -current1-current2; } void stamp() { resistance1 = maxResistance*position; resistance2 = maxResistance*(1-position); sim.stampResistor(nodes[0], nodes[2], resistance1); sim.stampResistor(nodes[2], nodes[1], resistance2); } void getInfo(String arr[]) { arr[0] = "potentiometer"; arr[1] = "Vd = " + getVoltageDText(getVoltageDiff()); arr[2] = "R1 = " + getUnitText(resistance1, sim.ohmString); arr[3] = "R2 = " + getUnitText(resistance2, sim.ohmString); arr[4] = "I1 = " + getCurrentDText(current1); arr[5] = "I2 = " + getCurrentDText(current2); } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Resistance (ohms)", maxResistance, 0, 0); if (n == 1) { EditInfo ei = new EditInfo("Slider Text", 0, -1, -1); ei.text = sliderText; return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) maxResistance = ei.value; if (n == 1) { sliderText = ei.textf.getText(); label.setText(sliderText); } } } ================================================ FILE: src/ProbeElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class ProbeElm extends CircuitElm { static final int FLAG_SHOWVOLTAGE = 1; public ProbeElm(int xx, int yy) { super(xx, yy); } public ProbeElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); } int getDumpType() { return 'p'; } Point center; void setPoints() { super.setPoints(); // swap points so that we subtract higher from lower if (point2.y < point1.y) { Point x = point1; point1 = point2; point2 = x; } center = interpPoint(point1, point2, .5); } void draw(Graphics g) { int hs = 8; setBbox(point1, point2, hs); boolean selected = (needsHighlight() || sim.plotYElm == this); double len = (selected || sim.dragElm == this) ? 16 : dn-32; calcLeads((int) len); setVoltageColor(g, volts[0]); if (selected) g.setColor(selectColor); drawThickLine(g, point1, lead1); setVoltageColor(g, volts[1]); if (selected) g.setColor(selectColor); drawThickLine(g, lead2, point2); Font f = new Font("SansSerif", Font.BOLD, 14); g.setFont(f); if (this == sim.plotXElm) drawCenteredText(g, "X", center.x, center.y, true); if (this == sim.plotYElm) drawCenteredText(g, "Y", center.x, center.y, true); if (mustShowVoltage()) { String s = getShortUnitText(volts[0], "V"); drawValues(g, s, 4); } drawPosts(g); } boolean mustShowVoltage() { return (flags & FLAG_SHOWVOLTAGE) != 0; } void getInfo(String arr[]) { arr[0] = "scope probe"; arr[1] = "Vd = " + getVoltageText(getVoltageDiff()); } boolean getConnection(int n1, int n2) { return false; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Show Voltage", mustShowVoltage()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { if (ei.checkbox.getState()) flags = FLAG_SHOWVOLTAGE; else flags &= ~FLAG_SHOWVOLTAGE; } } } ================================================ FILE: src/PushSwitchElm.java ================================================ class PushSwitchElm extends SwitchElm { public PushSwitchElm(int xx, int yy) { super(xx, yy, true); } Class getDumpClass() { return SwitchElm.class; } int getShortcut() { return 0; } } ================================================ FILE: src/RailElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class RailElm extends VoltageElm { public RailElm(int xx, int yy) { super(xx, yy, WF_DC); } RailElm(int xx, int yy, int wf) { super(xx, yy, wf); } public RailElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } final int FLAG_CLOCK = 1; int getDumpType() { return 'R'; } int getPostCount() { return 1; } void setPoints() { super.setPoints(); lead1 = interpPoint(point1, point2, 1-circleSize/dn); } void draw(Graphics g) { setBbox(point1, point2, circleSize); setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); boolean clock = waveform == WF_SQUARE && (flags & FLAG_CLOCK) != 0; if (waveform == WF_DC || waveform == WF_VAR || clock) { Font f = new Font("SansSerif", 0, 12); g.setFont(f); g.setColor(needsHighlight() ? selectColor : whiteColor); setPowerColor(g, false); double v = getVoltage(); String s = getShortUnitText(v, "V"); if (Math.abs(v) < 1) s = showFormat.format(v) + "V"; if (getVoltage() > 0) s = "+" + s; if (this instanceof AntennaElm) s = "Ant"; if (clock) s = "CLK"; drawCenteredText(g, s, x2, y2, true); } else { drawWaveform(g, point2); } drawPosts(g); curcount = updateDotCount(-current, curcount); if (sim.dragElm != this) drawDots(g, point1, lead1, curcount); } double getVoltageDiff() { return volts[0]; } void stamp() { if (waveform == WF_DC) sim.stampVoltageSource(0, nodes[0], voltSource, getVoltage()); else sim.stampVoltageSource(0, nodes[0], voltSource); } void doStep() { if (waveform != WF_DC) sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage()); } boolean hasGroundConnection(int n1) { return true; } int getShortcut() { return 'V'; } } ================================================ FILE: src/RelayElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; // 0 = switch // 1 = switch end 1 // 2 = switch end 2 // ... // 3n = coil // 3n+1 = coil // 3n+2 = end of coil resistor class RelayElm extends CircuitElm { double inductance; Inductor ind; double r_on, r_off, onCurrent; Point coilPosts[], coilLeads[], swposts[][], swpoles[][], ptSwitch[]; Point lines[]; double coilCurrent, switchCurrent[], coilCurCount, switchCurCount[]; double d_position, coilR; int i_position; int poleCount; int openhs; final int nSwitch0 = 0; final int nSwitch1 = 1; final int nSwitch2 = 2; int nCoil1, nCoil2, nCoil3; final int FLAG_SWAP_COIL = 1; public RelayElm(int xx, int yy) { super(xx, yy); ind = new Inductor(sim); inductance = .2; ind.setup(inductance, 0, Inductor.FLAG_BACK_EULER); noDiagonal = true; onCurrent = .02; r_on = .05; r_off = 1e6; coilR = 20; coilCurrent = coilCurCount = 0; poleCount = 1; setupPoles(); } public RelayElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); poleCount = new Integer(st.nextToken()).intValue(); inductance = new Double(st.nextToken()).doubleValue(); coilCurrent = new Double(st.nextToken()).doubleValue(); r_on = new Double(st.nextToken()).doubleValue(); r_off = new Double(st.nextToken()).doubleValue(); onCurrent = new Double(st.nextToken()).doubleValue(); coilR = new Double(st.nextToken()).doubleValue(); noDiagonal = true; ind = new Inductor(sim); ind.setup(inductance, coilCurrent, Inductor.FLAG_BACK_EULER); setupPoles(); } void setupPoles() { nCoil1 = 3*poleCount; nCoil2 = nCoil1+1; nCoil3 = nCoil1+2; if (switchCurrent == null || switchCurrent.length != poleCount) { switchCurrent = new double[poleCount]; switchCurCount = new double[poleCount]; } } int getDumpType() { return 178; } String dump() { return super.dump() + " " + poleCount + " " + inductance + " " + coilCurrent + " " + r_on + " " + r_off + " " + onCurrent + " " + coilR; } void draw(Graphics g) { int i, p; for (i = 0; i != 2; i++) { setVoltageColor(g, volts[nCoil1+i]); drawThickLine(g, coilLeads[i], coilPosts[i]); } int x = ((flags & FLAG_SWAP_COIL) != 0) ? 1 : 0; drawCoil(g, dsign*6, coilLeads[x], coilLeads[1-x], volts[nCoil1+x], volts[nCoil2-x]); // draw lines g.setColor(Color.darkGray); for (i = 0; i != poleCount; i++) { if (i == 0) interpPoint(point1, point2, lines[i*2 ], .5, openhs*2+5*dsign-i*openhs*3); else interpPoint(point1, point2, lines[i*2], .5, (int) (openhs*(-i*3+3-.5+d_position))+5*dsign); interpPoint(point1, point2, lines[i*2+1], .5, (int) (openhs*(-i*3-.5+d_position))-5*dsign); g.drawLine(lines[i*2].x, lines[i*2].y, lines[i*2+1].x, lines[i*2+1].y); } for (p = 0; p != poleCount; p++) { int po = p*3; for (i = 0; i != 3; i++) { // draw lead setVoltageColor(g, volts[nSwitch0+po+i]); drawThickLine(g, swposts[p][i], swpoles[p][i]); } interpPoint(swpoles[p][1], swpoles[p][2], ptSwitch[p], d_position); //setVoltageColor(g, volts[nSwitch0]); g.setColor(Color.lightGray); drawThickLine(g, swpoles[p][0], ptSwitch[p]); switchCurCount[p] = updateDotCount(switchCurrent[p], switchCurCount[p]); drawDots(g, swposts[p][0], swpoles[p][0], switchCurCount[p]); if (i_position != 2) drawDots(g, swpoles[p][i_position+1], swposts[p][i_position+1], switchCurCount[p]); } coilCurCount = updateDotCount(coilCurrent, coilCurCount); drawDots(g, coilPosts[0], coilLeads[0], coilCurCount); drawDots(g, coilLeads[0], coilLeads[1], coilCurCount); drawDots(g, coilLeads[1], coilPosts[1], coilCurCount); drawPosts(g); setBbox(coilPosts[0], coilLeads[1], 0); adjustBbox(swpoles[poleCount-1][0], swposts[poleCount-1][1]); // XXX } void setPoints() { super.setPoints(); setupPoles(); allocNodes(); openhs = -dsign*16; // switch calcLeads(32); swposts = new Point[poleCount][3]; swpoles = new Point[poleCount][3]; int i, j; for (i = 0; i != poleCount; i++) { for (j = 0; j != 3; j++) { swposts[i][j] = new Point(); swpoles[i][j] = new Point(); } interpPoint(lead1, lead2, swpoles[i][0], 0, -openhs*3*i); interpPoint(lead1, lead2, swpoles[i][1], 1, -openhs*3*i-openhs); interpPoint(lead1, lead2, swpoles[i][2], 1, -openhs*3*i+openhs); interpPoint(point1, point2, swposts[i][0], 0, -openhs*3*i); interpPoint(point1, point2, swposts[i][1], 1, -openhs*3*i-openhs); interpPoint(point1, point2, swposts[i][2], 1, -openhs*3*i+openhs); } // coil coilPosts = newPointArray(2); coilLeads = newPointArray(2); ptSwitch = newPointArray(poleCount); int x = ((flags & FLAG_SWAP_COIL) != 0) ? 1 : 0; interpPoint(point1, point2, coilPosts[0], x, openhs*2); interpPoint(point1, point2, coilPosts[1], x, openhs*3); interpPoint(point1, point2, coilLeads[0], .5, openhs*2); interpPoint(point1, point2, coilLeads[1], .5, openhs*3); // lines lines = newPointArray(poleCount*2); } Point getPost(int n) { if (n < 3*poleCount) return swposts[n / 3][n % 3]; return coilPosts[n-3*poleCount]; } int getPostCount() { return 2+poleCount*3; } int getInternalNodeCount() { return 1; } void reset() { super.reset(); ind.reset(); coilCurrent = coilCurCount = 0; int i; for (i = 0; i != poleCount; i++) switchCurrent[i] = switchCurCount[i] = 0; } double a1, a2, a3, a4; void stamp() { // inductor from coil post 1 to internal node ind.stamp(nodes[nCoil1], nodes[nCoil3]); // resistor from internal node to coil post 2 sim.stampResistor(nodes[nCoil3], nodes[nCoil2], coilR); int i; for (i = 0; i != poleCount*3; i++) sim.stampNonLinear(nodes[nSwitch0+i]); } void startIteration() { ind.startIteration(volts[nCoil1]-volts[nCoil3]); // magic value to balance operate speed with reset speed semi-realistically double magic = 1.3; double pmult = Math.sqrt(magic+1); double p = coilCurrent*pmult/onCurrent; d_position = Math.abs(p*p) - 1.3; if (d_position < 0) d_position = 0; if (d_position > 1) d_position = 1; if (d_position < .1) i_position = 0; else if (d_position > .9) i_position = 1; else i_position = 2; //System.out.println("ind " + this + " " + current + " " + voltdiff); } // we need this to be able to change the matrix for each step boolean nonLinear() { return true; } void doStep() { double voltdiff = volts[nCoil1]-volts[nCoil3]; ind.doStep(voltdiff); int p; for (p = 0; p != poleCount*3; p += 3) { sim.stampResistor(nodes[nSwitch0+p], nodes[nSwitch1+p], i_position == 0 ? r_on : r_off); sim.stampResistor(nodes[nSwitch0+p], nodes[nSwitch2+p], i_position == 1 ? r_on : r_off); } } void calculateCurrent() { double voltdiff = volts[nCoil1]-volts[nCoil3]; coilCurrent = ind.calculateCurrent(voltdiff); // actually this isn't correct, since there is a small amount // of current through the switch when off int p; for (p = 0; p != poleCount; p++) { if (i_position == 2) switchCurrent[p] = 0; else switchCurrent[p] = (volts[nSwitch0+p*3]-volts[nSwitch1+p*3+i_position])/r_on; } } void getInfo(String arr[]) { arr[0] = i_position == 0 ? "relay (off)" : i_position == 1 ? "relay (on)" : "relay"; int i; int ln = 1; for (i = 0; i != poleCount; i++) arr[ln++] = "I" + (i+1) + " = " + getCurrentDText(switchCurrent[i]); arr[ln++] = "coil I = " + getCurrentDText(coilCurrent); arr[ln++] = "coil Vd = " + getVoltageDText(volts[nCoil1] - volts[nCoil2]); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Inductance (H)", inductance, 0, 0); if (n == 1) return new EditInfo("On Resistance (ohms)", r_on, 0, 0); if (n == 2) return new EditInfo("Off Resistance (ohms)", r_off, 0, 0); if (n == 3) return new EditInfo("On Current (A)", onCurrent, 0, 0); if (n == 4) return new EditInfo("Number of Poles", poleCount, 1, 4). setDimensionless(); if (n == 5) return new EditInfo("Coil Resistance (ohms)", coilR, 0, 0); if (n == 6) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Swap Coil Direction", (flags & FLAG_SWAP_COIL) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) { inductance = ei.value; ind.setup(inductance, coilCurrent, Inductor.FLAG_BACK_EULER); } if (n == 1 && ei.value > 0) r_on = ei.value; if (n == 2 && ei.value > 0) r_off = ei.value; if (n == 3 && ei.value > 0) onCurrent = ei.value; if (n == 4 && ei.value >= 1) { poleCount = (int) ei.value; setPoints(); } if (n == 5 && ei.value > 0) coilR = ei.value; if (n == 6) { if (ei.checkbox.getState()) flags |= FLAG_SWAP_COIL; else flags &= ~FLAG_SWAP_COIL; setPoints(); } } boolean getConnection(int n1, int n2) { return (n1 / 3 == n2 / 3); } int getShortcut() { return 'R'; } } ================================================ FILE: src/ResistorElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class ResistorElm extends CircuitElm { double resistance; public ResistorElm(int xx, int yy) { super(xx, yy); resistance = 100; } public ResistorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); resistance = new Double(st.nextToken()).doubleValue(); } int getDumpType() { return 'r'; } String dump() { return super.dump() + " " + resistance; } Point ps3, ps4; void setPoints() { super.setPoints(); calcLeads(32); ps3 = new Point(); ps4 = new Point(); } void draw(Graphics g) { int segments = 16; int i; int ox = 0; int hs = sim.euroResistorCheckItem.getState() ? 6 : 8; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, hs); draw2Leads(g); setPowerColor(g, true); double segf = 1./segments; if (!sim.euroResistorCheckItem.getState()) { // draw zigzag for (i = 0; i != segments; i++) { int nx = 0; switch (i & 3) { case 0: nx = 1; break; case 2: nx = -1; break; default: nx = 0; break; } double v = v1+(v2-v1)*i/segments; setVoltageColor(g, v); interpPoint(lead1, lead2, ps1, i*segf, hs*ox); interpPoint(lead1, lead2, ps2, (i+1)*segf, hs*nx); drawThickLine(g, ps1, ps2); ox = nx; } } else { // draw rectangle setVoltageColor(g, v1); interpPoint2(lead1, lead2, ps1, ps2, 0, hs); drawThickLine(g, ps1, ps2); for (i = 0; i != segments; i++) { double v = v1+(v2-v1)*i/segments; setVoltageColor(g, v); interpPoint2(lead1, lead2, ps1, ps2, i*segf, hs); interpPoint2(lead1, lead2, ps3, ps4, (i+1)*segf, hs); drawThickLine(g, ps1, ps3); drawThickLine(g, ps2, ps4); } interpPoint2(lead1, lead2, ps1, ps2, 1, hs); drawThickLine(g, ps1, ps2); } if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(resistance, ""); drawValues(g, s, hs); } doDots(g); drawPosts(g); } void calculateCurrent() { current = (volts[0]-volts[1])/resistance; //System.out.print(this + " res current set to " + current + "\n"); } void stamp() { sim.stampResistor(nodes[0], nodes[1], resistance); } void getInfo(String arr[]) { arr[0] = "resistor"; getBasicInfo(arr); arr[3] = "R = " + getUnitText(resistance, sim.ohmString); arr[4] = "P = " + getUnitText(getPower(), "W"); } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Resistance (ohms)", resistance, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (ei.value > 0) resistance = ei.value; } int getShortcut() { return 'r'; } } ================================================ FILE: src/RowInfo.java ================================================ // info about each row/column of the matrix for simplification purposes class RowInfo { static final int ROW_NORMAL = 0; // ordinary value static final int ROW_CONST = 1; // value is constant static final int ROW_EQUAL = 2; // value is equal to another value int nodeEq, type, mapCol, mapRow; double value; boolean rsChanges; // row's right side changes boolean lsChanges; // row's left side changes boolean dropRow; // row is not needed in matrix RowInfo() { type = ROW_NORMAL; } } ================================================ FILE: src/SCRElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; // Silicon-Controlled Rectifier // 3 nodes, 1 internal node // 0 = anode, 1 = cathode, 2 = gate // 0, 3 = variable resistor // 3, 2 = diode // 2, 1 = 50 ohm resistor class SCRElm extends CircuitElm { final int anode = 0; final int cnode = 1; final int gnode = 2; final int inode = 3; Diode diode; public SCRElm(int xx, int yy) { super(xx, yy); setDefaults(); setup(); } public SCRElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); setDefaults(); try { lastvac = new Double(st.nextToken()).doubleValue(); lastvag = new Double(st.nextToken()).doubleValue(); volts[anode] = 0; volts[cnode] = -lastvac; volts[gnode] = -lastvag; triggerI = new Double(st.nextToken()).doubleValue(); holdingI = new Double(st.nextToken()).doubleValue(); cresistance = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } setup(); } void setDefaults() { cresistance = 50; holdingI = .0082; triggerI = .01; } void setup() { diode = new Diode(sim); diode.setup(.8, 0); } boolean nonLinear() { return true; } void reset() { volts[anode] = volts[cnode] = volts[gnode] = 0; diode.reset(); lastvag = lastvac = curcount_a = curcount_c = curcount_g = 0; } int getDumpType() { return 177; } String dump() { return super.dump() + " " + (volts[anode]-volts[cnode]) + " " + (volts[anode]-volts[gnode]) + " " + triggerI + " "+ holdingI + " " + cresistance; } double ia, ic, ig, curcount_a, curcount_c, curcount_g; double lastvac, lastvag; double cresistance, triggerI, holdingI; final int hs = 8; Polygon poly; Point cathode[], gate[]; void setPoints() { super.setPoints(); int dir = 0; if (abs(dx) > abs(dy)) { dir = -sign(dx)*sign(dy); point2.y = point1.y; } else { dir = sign(dy)*sign(dx); point2.x = point1.x; } if (dir == 0) dir = 1; calcLeads(16); cathode = newPointArray(2); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); poly = createPolygon(pa[0], pa[1], lead2); gate = newPointArray(2); double leadlen = (dn-16)/2; int gatelen = sim.gridSize; gatelen += leadlen % sim.gridSize; if (leadlen < gatelen) { x2 = x; y2 = y; return; } interpPoint(lead2, point2, gate[0], gatelen/leadlen, gatelen*dir); interpPoint(lead2, point2, gate[1], gatelen/leadlen, sim.gridSize*2*dir); } void draw(Graphics g) { setBbox(point1, point2, hs); adjustBbox(gate[0], gate[1]); double v1 = volts[anode]; double v2 = volts[cnode]; draw2Leads(g); // draw arrow thingy setPowerColor(g, true); setVoltageColor(g, v1); g.fillPolygon(poly); // draw thing arrow is pointing to setVoltageColor(g, v2); drawThickLine(g, cathode[0], cathode[1]); drawThickLine(g, lead2, gate[0]); drawThickLine(g, gate[0], gate[1]); curcount_a = updateDotCount(ia, curcount_a); curcount_c = updateDotCount(ic, curcount_c); curcount_g = updateDotCount(ig, curcount_g); if (sim.dragElm != this) { drawDots(g, point1, lead2, curcount_a); drawDots(g, point2, lead2, curcount_c); drawDots(g, gate[1], gate[0], curcount_g); drawDots(g, gate[0], lead2, curcount_g+distance(gate[1], gate[0])); } drawPosts(g); } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? point2 : gate[1]; } int getPostCount() { return 3; } int getInternalNodeCount() { return 1; } double getPower() { return (volts[anode]-volts[gnode])*ia + (volts[cnode]-volts[gnode])*ic; } double aresistance; void stamp() { sim.stampNonLinear(nodes[anode]); sim.stampNonLinear(nodes[cnode]); sim.stampNonLinear(nodes[gnode]); sim.stampNonLinear(nodes[inode]); sim.stampResistor(nodes[gnode], nodes[cnode], cresistance); diode.stamp(nodes[inode], nodes[gnode]); } void doStep() { double vac = volts[anode]-volts[cnode]; // typically negative double vag = volts[anode]-volts[gnode]; // typically positive if (Math.abs(vac-lastvac) > .01 || Math.abs(vag-lastvag) > .01) sim.converged = false; lastvac = vac; lastvag = vag; diode.doStep(volts[inode]-volts[gnode]); double icmult = 1/triggerI; double iamult = 1/holdingI - icmult; //System.out.println(icmult + " " + iamult); aresistance = (-icmult*ic + ia*iamult > 1) ? .0105 : 10e5; //System.out.println(vac + " " + vag + " " + sim.converged + " " + ic + " " + ia + " " + aresistance + " " + volts[inode] + " " + volts[gnode] + " " + volts[anode]); sim.stampResistor(nodes[anode], nodes[inode], aresistance); } void getInfo(String arr[]) { arr[0] = "SCR"; double vac = volts[anode]-volts[cnode]; double vag = volts[anode]-volts[gnode]; double vgc = volts[gnode]-volts[cnode]; arr[1] = "Ia = " + getCurrentText(ia); arr[2] = "Ig = " + getCurrentText(ig); arr[3] = "Vac = " + getVoltageText(vac); arr[4] = "Vag = " + getVoltageText(vag); arr[5] = "Vgc = " + getVoltageText(vgc); } void calculateCurrent() { ic = (volts[cnode]-volts[gnode])/cresistance; ia = (volts[anode]-volts[inode])/aresistance; ig = -ic-ia; } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Trigger Current (A)", triggerI, 0, 0); if (n == 1) return new EditInfo("Holding Current (A)", holdingI, 0, 0); if (n == 2) return new EditInfo("Gate-Cathode Resistance (ohms)", cresistance, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) triggerI = ei.value; if (n == 1 && ei.value > 0) holdingI = ei.value; if (n == 2 && ei.value > 0) cresistance = ei.value; } } ================================================ FILE: src/Scope.java ================================================ import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.util.StringTokenizer; import java.lang.reflect.Constructor; import java.lang.reflect.Method; class Scope { final int FLAG_YELM = 32; static final int VAL_POWER = 1; static final int VAL_IB = 1; static final int VAL_IC = 2; static final int VAL_IE = 3; static final int VAL_VBE = 4; static final int VAL_VBC = 5; static final int VAL_VCE = 6; static final int VAL_R = 2; double minV[], maxV[], minMaxV; double minI[], maxI[], minMaxI; int scopePointCount = 128; int ptr, ctr, speed, position; int value, ivalue; String text; Rectangle rect; boolean showI, showV, showMax, showMin, showFreq, lockScale, plot2d, plotXY; CircuitElm elm, xElm, yElm; MemoryImageSource imageSource; Image image; int pixels[]; int draw_ox, draw_oy; float dpixels[]; CirSim sim; Scope(CirSim s) { rect = new Rectangle(); reset(); sim = s; } void showCurrent(boolean b) { showI = b; value = ivalue = 0; } void showVoltage(boolean b) { showV = b; value = ivalue = 0; } void showMax (boolean b) { showMax = b; } void showMin (boolean b) { showMin = b; } void showFreq (boolean b) { showFreq = b; } void setLockScale (boolean b) { lockScale = b; } void resetGraph() { scopePointCount = 1; while (scopePointCount <= rect.width) scopePointCount *= 2; minV = new double[scopePointCount]; maxV = new double[scopePointCount]; minI = new double[scopePointCount]; maxI = new double[scopePointCount]; ptr = ctr = 0; allocImage(); } boolean active() { return elm != null; } void reset() { resetGraph(); minMaxV = 5; minMaxI = .1; speed = 64; showI = showV = showMax = true; showFreq = lockScale = showMin = false; plot2d = false; // no showI for Output if (elm != null && (elm instanceof OutputElm || elm instanceof LogicOutputElm || elm instanceof ProbeElm)) showI = false; value = ivalue = 0; if (elm instanceof TransistorElm) value = VAL_VCE; } void setRect(Rectangle r) { rect = r; resetGraph(); } int getWidth() { return rect.width; } int rightEdge() { return rect.x+rect.width; } void setElm(CircuitElm ce) { elm = ce; reset(); } void timeStep() { if (elm == null) return; double v = elm.getScopeValue(value); if (v < minV[ptr]) minV[ptr] = v; if (v > maxV[ptr]) maxV[ptr] = v; double i = 0; if (value == 0 || ivalue != 0) { i = (ivalue == 0) ? elm.getCurrent() : elm.getScopeValue(ivalue); if (i < minI[ptr]) minI[ptr] = i; if (i > maxI[ptr]) maxI[ptr] = i; } if (plot2d && dpixels != null) { boolean newscale = false; while (v > minMaxV || v < -minMaxV) { minMaxV *= 2; newscale = true; } double yval = i; if (plotXY) yval = (yElm == null) ? 0 : yElm.getVoltageDiff(); while (yval > minMaxI || yval < -minMaxI) { minMaxI *= 2; newscale = true; } if (newscale) clear2dView(); double xa = v/minMaxV; double ya = yval/minMaxI; int x = (int) (rect.width *(1+xa)*.499); int y = (int) (rect.height*(1-ya)*.499); drawTo(x, y); } else { ctr++; if (ctr >= speed) { ptr = (ptr+1) & (scopePointCount-1); minV[ptr] = maxV[ptr] = v; minI[ptr] = maxI[ptr] = i; ctr = 0; } } } void drawTo(int x2, int y2) { if (draw_ox == -1) { draw_ox = x2; draw_oy = y2; } // need to draw a line from x1,y1 to x2,y2 if (draw_ox == x2 && draw_oy == y2) { dpixels[x2+rect.width*y2] = 1; } else if (CircuitElm.abs(y2-draw_oy) > CircuitElm.abs(x2-draw_ox)) { // y difference is greater, so we step along y's // from min to max y and calculate x for each step double sgn = CircuitElm.sign(y2-draw_oy); int x, y; for (y = draw_oy; y != y2+sgn; y += sgn) { x = draw_ox+(x2-draw_ox)*(y-draw_oy)/(y2-draw_oy); dpixels[x+rect.width*y] = 1; } } else { // x difference is greater, so we step along x's // from min to max x and calculate y for each step double sgn = CircuitElm.sign(x2-draw_ox); int x, y; for (x = draw_ox; x != x2+sgn; x += sgn) { y = draw_oy+(y2-draw_oy)*(x-draw_ox)/(x2-draw_ox); dpixels[x+rect.width*y] = 1; } } draw_ox = x2; draw_oy = y2; } void clear2dView() { int i; for (i = 0; i != dpixels.length; i++) dpixels[i] = 0; draw_ox = draw_oy = -1; } void adjustScale(double x) { minMaxV *= x; minMaxI *= x; } void draw2d(Graphics g) { int i; if (pixels == null || dpixels == null) return; int col = (sim.printableCheckItem.getState()) ? 0xFFFFFFFF : 0; for (i = 0; i != pixels.length; i++) pixels[i] = col; for (i = 0; i != rect.width; i++) pixels[i+rect.width*(rect.height/2)] = 0xFF00FF00; int ycol = (plotXY) ? 0xFF00FF00 : 0xFFFFFF00; for (i = 0; i != rect.height; i++) pixels[rect.width/2+rect.width*i] = ycol; for (i = 0; i != pixels.length; i++) { int q = (int) (255*dpixels[i]); if (q > 0) pixels[i] = 0xFF000000 | (0x10101*q); dpixels[i] *= .997; } g.drawImage(image, rect.x, rect.y, null); g.setColor(elm.whiteColor); g.fillOval(rect.x+draw_ox-2, rect.y+draw_oy-2, 5, 5); int yt = rect.y+10; int x = rect.x; if (text != null && rect.y + rect.height > yt+5) { g.drawString(text, x, yt); yt += 15; } } void draw(Graphics g) { if (elm == null) return; if (plot2d) { draw2d(g); return; } if (pixels == null) return; int i; int col = (sim.printableCheckItem.getState()) ? 0xFFFFFFFF : 0; for (i = 0; i != pixels.length; i++) pixels[i] = col; int x = 0; int maxy = (rect.height-1)/2; int y = maxy; boolean gotI = false; boolean gotV = false; int minRange = 4; double realMaxV = -1e8; double realMaxI = -1e8; double realMinV = 1e8; double realMinI = 1e8; int curColor = 0xFFFFFF00; int voltColor = (value > 0) ? 0xFFFFFFFF : 0xFF00FF00; if (sim.scopeSelected == -1 && elm == sim.mouseElm) curColor = voltColor = 0xFF00FFFF; int ipa = ptr+scopePointCount-rect.width; for (i = 0; i != rect.width; i++) { int ip = (i+ipa) & (scopePointCount-1); while (maxV[ip] > minMaxV) minMaxV *= 2; while (minV[ip] < -minMaxV) minMaxV *= 2; while (maxI[ip] > minMaxI) minMaxI *= 2; while (minI[ip] < -minMaxI) minMaxI *= 2; } double gridStep = 1e-8; double gridMax = (showI ? minMaxI : minMaxV); while (gridStep*100 < gridMax) gridStep *= 10; if (maxy*gridStep/gridMax < .3) gridStep = 0; int ll; boolean sublines = (maxy*gridStep/gridMax > 3); for (ll = -100; ll <= 100; ll++) { // don't show gridlines if plotting multiple values, // or if lines are too close together (except for center line) if (ll != 0 && ((showI && showV) || gridStep == 0)) continue; int yl = maxy-(int) (maxy*ll*gridStep/gridMax); if (yl < 0 || yl >= rect.height-1) continue; col = ll == 0 ? 0xFF909090 : 0xFF404040; if (ll % 10 != 0) { col = 0xFF101010; if (!sublines) continue; } for (i = 0; i != rect.width; i++) pixels[i+yl*rect.width] = col; } gridStep = 1e-15; double ts = sim.timeStep*speed; while (gridStep < ts*5) gridStep *= 10; double tstart = sim.t-sim.timeStep*speed*rect.width; double tx = sim.t-(sim.t % gridStep); int first = 1; for (ll = 0; ; ll++) { double tl = tx-gridStep*ll; int gx = (int) ((tl-tstart)/ts); if (gx < 0) break; if (gx >= rect.width) continue; if (tl < 0) continue; col = 0xFF202020; first = 0; if (((tl+gridStep/4) % (gridStep*10)) < gridStep) { col = 0xFF909090; if (((tl+gridStep/4) % (gridStep*100)) < gridStep) col = 0xFF4040D0; } for (i = 0; i < pixels.length; i += rect.width) pixels[i+gx] = col; } // these two loops are pretty much the same, and should be // combined! if (value == 0 && showI) { int ox = -1, oy = -1; int j; for (i = 0; i != rect.width; i++) { int ip = (i+ipa) & (scopePointCount-1); int miniy = (int) ((maxy/minMaxI)*minI[ip]); int maxiy = (int) ((maxy/minMaxI)*maxI[ip]); if (maxI[ip] > realMaxI) realMaxI = maxI[ip]; if (minI[ip] < realMinI) realMinI = minI[ip]; if (miniy <= maxy) { if (miniy < -minRange || maxiy > minRange) gotI = true; if (ox != -1) { if (miniy == oy && maxiy == oy) continue; for (j = ox; j != x+i; j++) pixels[j+rect.width*(y-oy)] = curColor; ox = oy = -1; } if (miniy == maxiy) { ox = x+i; oy = miniy; continue; } for (j = miniy; j <= maxiy; j++) pixels[x+i+rect.width*(y-j)] = curColor; } } if (ox != -1) for (j = ox; j != x+i; j++) pixels[j+rect.width*(y-oy)] = curColor; } if (value != 0 || showV) { int ox = -1, oy = -1, j; for (i = 0; i != rect.width; i++) { int ip = (i+ipa) & (scopePointCount-1); int minvy = (int) ((maxy/minMaxV)*minV[ip]); int maxvy = (int) ((maxy/minMaxV)*maxV[ip]); if (maxV[ip] > realMaxV) realMaxV = maxV[ip]; if (minV[ip] < realMinV) realMinV = minV[ip]; if ((value != 0 || showV) && minvy <= maxy) { if (minvy < -minRange || maxvy > minRange) gotV = true; if (ox != -1) { if (minvy == oy && maxvy == oy) continue; for (j = ox; j != x+i; j++) pixels[j+rect.width*(y-oy)] = voltColor; ox = oy = -1; } if (minvy == maxvy) { ox = x+i; oy = minvy; continue; } for (j = minvy; j <= maxvy; j++) pixels[x+i+rect.width*(y-j)] = voltColor; } } if (ox != -1) for (j = ox; j != x+i; j++) pixels[j+rect.width*(y-oy)] = voltColor; } double freq = 0; if (showFreq) { // try to get frequency // get average double avg = 0; for (i = 0; i != rect.width; i++) { int ip = (i+ipa) & (scopePointCount-1); avg += minV[ip]+maxV[ip]; } avg /= i*2; int state = 0; double thresh = avg*.05; int oi = 0; double avperiod = 0; int periodct = -1; double avperiod2 = 0; // count period lengths for (i = 0; i != rect.width; i++) { int ip = (i+ipa) & (scopePointCount-1); double q = maxV[ip]-avg; int os = state; if (q < thresh) state = 1; else if (q > -thresh) state = 2; if (state == 2 && os == 1) { int pd = i-oi; oi = i; // short periods can't be counted properly if (pd < 12) continue; // skip first period, it might be too short if (periodct >= 0) { avperiod += pd; avperiod2 += pd*pd; } periodct++; } } avperiod /= periodct; avperiod2 /= periodct; double periodstd = Math.sqrt(avperiod2-avperiod*avperiod); freq = 1/(avperiod*sim.timeStep*speed); // don't show freq if standard deviation is too great if (periodct < 1 || periodstd > 2) freq = 0; // System.out.println(freq + " " + periodstd + " " + periodct); } g.drawImage(image, rect.x, rect.y, null); g.setColor(elm.whiteColor); int yt = rect.y+10; x += rect.x; if (showMax) { if (value != 0) g.drawString(elm.getUnitText(realMaxV, elm.getScopeUnits(value)), x, yt); else if (showV) g.drawString(elm.getVoltageText(realMaxV), x, yt); else if (showI) g.drawString(elm.getCurrentText(realMaxI), x, yt); yt += 15; } if (showMin) { int ym = rect.y+rect.height-5; if (value != 0) g.drawString(elm.getUnitText(realMinV, elm.getScopeUnits(value)), x, ym); else if (showV) g.drawString(elm.getVoltageText(realMinV), x, ym); else if (showI) g.drawString(elm.getCurrentText(realMinI), x, ym); } if (text != null && rect.y + rect.height > yt+5) { g.drawString(text, x, yt); yt += 15; } if (showFreq && freq != 0 && rect.y + rect.height > yt+5) g.drawString(elm.getUnitText(freq, "Hz"), x, yt); if (ptr > 5 && !lockScale) { if (!gotI && minMaxI > 1e-4) minMaxI /= 2; if (!gotV && minMaxV > 1e-4) minMaxV /= 2; } } void speedUp() { if (speed > 1) { speed /= 2; resetGraph(); } } void slowDown() { speed *= 2; resetGraph(); } PopupMenu getMenu() { if (elm == null) return null; if (elm instanceof TransistorElm) { sim.scopeIbMenuItem.setState(value == VAL_IB); sim.scopeIcMenuItem.setState(value == VAL_IC); sim.scopeIeMenuItem.setState(value == VAL_IE); sim.scopeVbeMenuItem.setState(value == VAL_VBE); sim.scopeVbcMenuItem.setState(value == VAL_VBC); sim.scopeVceMenuItem.setState(value == VAL_VCE && ivalue != VAL_IC); sim.scopeVceIcMenuItem.setState(value == VAL_VCE && ivalue == VAL_IC); return sim.transScopeMenu; } else { sim.scopeVMenuItem .setState(showV && value == 0); sim.scopeIMenuItem .setState(showI && value == 0); sim.scopeMaxMenuItem .setState(showMax); sim.scopeMinMenuItem .setState(showMin); sim.scopeFreqMenuItem .setState(showFreq); sim.scopePowerMenuItem.setState(value == VAL_POWER); sim.scopeVIMenuItem .setState(plot2d && !plotXY); sim.scopeXYMenuItem .setState(plotXY); sim.scopeSelectYMenuItem.setEnabled(plotXY); sim.scopeResistMenuItem.setState(value == VAL_R); sim.scopeResistMenuItem.setEnabled(elm instanceof MemristorElm); return sim.scopeMenu; } } void setValue(int x) { reset(); value = x; } String dump() { if (elm == null) return null; int flags = (showI ? 1 : 0) | (showV ? 2 : 0) | (showMax ? 0 : 4) | // showMax used to be always on (showFreq ? 8 : 0) | (lockScale ? 16 : 0) | (plot2d ? 64 : 0) | (plotXY ? 128 : 0) | (showMin ? 256 : 0); flags |= FLAG_YELM; // yelm present int eno = sim.locateElm(elm); if (eno < 0) return null; int yno = yElm == null ? -1 : sim.locateElm(yElm); String x = "o " + eno + " " + speed + " " + value + " " + flags + " " + minMaxV + " " + minMaxI + " " + position + " " + yno; if (text != null) x += " " + text; return x; } void undump(StringTokenizer st) { reset(); int e = new Integer(st.nextToken()).intValue(); if (e == -1) return; elm = sim.getElm(e); speed = new Integer(st.nextToken()).intValue(); value = new Integer(st.nextToken()).intValue(); int flags = new Integer(st.nextToken()).intValue(); minMaxV = new Double(st.nextToken()).doubleValue(); minMaxI = new Double(st.nextToken()).doubleValue(); if (minMaxV == 0) minMaxV = .5; if (minMaxI == 0) minMaxI = 1; text = null; yElm = null; try { position = new Integer(st.nextToken()).intValue(); int ye = -1; if ((flags & FLAG_YELM) != 0) { ye = new Integer(st.nextToken()).intValue(); if (ye != -1) yElm = sim.getElm(ye); } while (st.hasMoreTokens()) { if (text == null) text = st.nextToken(); else text += " " + st.nextToken(); } } catch (Exception ee) { } showI = (flags & 1) != 0; showV = (flags & 2) != 0; showMax = (flags & 4) == 0; showFreq = (flags & 8) != 0; lockScale = (flags & 16) != 0; plot2d = (flags & 64) != 0; plotXY = (flags & 128) != 0; showMin = (flags & 256) != 0; } void allocImage() { pixels = null; int w = rect.width; int h = rect.height; if (w == 0 || h == 0) return; if (sim.useBufferedImage) { try { /* simulate the following code using reflection: dbimage = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB); DataBuffer db = (DataBuffer)(((BufferedImage)dbimage). getRaster().getDataBuffer()); DataBufferInt dbi = (DataBufferInt) db; pixels = dbi.getData(); */ Class biclass = Class.forName("java.awt.image.BufferedImage"); Class dbiclass = Class.forName("java.awt.image.DataBufferInt"); Class rasclass = Class.forName("java.awt.image.Raster"); Constructor cstr = biclass.getConstructor( new Class[] { int.class, int.class, int.class }); image = (Image) cstr.newInstance(new Object[] { new Integer(w), new Integer(h), new Integer(BufferedImage.TYPE_INT_RGB)}); Method m = biclass.getMethod("getRaster"); Object ras = m.invoke(image); Object db = rasclass.getMethod("getDataBuffer").invoke(ras); pixels = (int[]) dbiclass.getMethod("getData").invoke(db); } catch (Exception ee) { // ee.printStackTrace(); System.out.println("BufferedImage failed"); } } if (pixels == null) { pixels = new int[w*h]; int i; for (i = 0; i != w*h; i++) pixels[i] = 0xFF000000; imageSource = new MemoryImageSource(w, h, pixels, 0, w); imageSource.setAnimated(true); imageSource.setFullBufferUpdates(true); image = sim.cv.createImage(imageSource); } dpixels = new float[w*h]; draw_ox = draw_oy = -1; } void handleMenu(ItemEvent e, Object mi) { if (mi == sim.scopeVMenuItem) showVoltage(sim.scopeVMenuItem.getState()); if (mi == sim.scopeIMenuItem) showCurrent(sim.scopeIMenuItem.getState()); if (mi == sim.scopeMaxMenuItem) showMax(sim.scopeMaxMenuItem.getState()); if (mi == sim.scopeMinMenuItem) showMin(sim.scopeMinMenuItem.getState()); if (mi == sim.scopeFreqMenuItem) showFreq(sim.scopeFreqMenuItem.getState()); if (mi == sim.scopePowerMenuItem) setValue(VAL_POWER); if (mi == sim.scopeIbMenuItem) setValue(VAL_IB); if (mi == sim.scopeIcMenuItem) setValue(VAL_IC); if (mi == sim.scopeIeMenuItem) setValue(VAL_IE); if (mi == sim.scopeVbeMenuItem) setValue(VAL_VBE); if (mi == sim.scopeVbcMenuItem) setValue(VAL_VBC); if (mi == sim.scopeVceMenuItem) setValue(VAL_VCE); if (mi == sim.scopeVceIcMenuItem) { plot2d = true; plotXY = false; value = VAL_VCE; ivalue = VAL_IC; resetGraph(); } if (mi == sim.scopeVIMenuItem) { plot2d = sim.scopeVIMenuItem.getState(); plotXY = false; resetGraph(); } if (mi == sim.scopeXYMenuItem) { plotXY = plot2d = sim.scopeXYMenuItem.getState(); if (yElm == null) selectY(); resetGraph(); } if (mi == sim.scopeResistMenuItem) setValue(VAL_R); } void select() { sim.mouseElm = elm; if (plotXY) { sim.plotXElm = elm; sim.plotYElm = yElm; } } void selectY() { int e = yElm == null ? -1 : sim.locateElm(yElm); int firstE = e; while (true) { for (e++; e < sim.elmList.size(); e++) { CircuitElm ce = sim.getElm(e); if ((ce instanceof OutputElm || ce instanceof ProbeElm) && ce != elm) { yElm = ce; return; } } if (firstE == -1) return; e = firstE = -1; } } } ================================================ FILE: src/SevenSegElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class SevenSegElm extends ChipElm { public SevenSegElm(int xx, int yy) { super(xx, yy); } public SevenSegElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "7-segment driver/display"; } Color darkred; void setupPins() { darkred = new Color(30, 0, 0); sizeX = 4; sizeY = 4; pins = new Pin[7]; pins[0] = new Pin(0, SIDE_W, "a"); pins[1] = new Pin(1, SIDE_W, "b"); pins[2] = new Pin(2, SIDE_W, "c"); pins[3] = new Pin(3, SIDE_W, "d"); pins[4] = new Pin(1, SIDE_S, "e"); pins[5] = new Pin(2, SIDE_S, "f"); pins[6] = new Pin(3, SIDE_S, "g"); } void draw(Graphics g) { drawChip(g); g.setColor(Color.red); int xl = x+cspc*5; int yl = y+cspc; setColor(g, 0); drawThickLine(g, xl, yl, xl+cspc, yl); setColor(g, 1); drawThickLine(g, xl+cspc, yl, xl+cspc, yl+cspc); setColor(g, 2); drawThickLine(g, xl+cspc, yl+cspc, xl+cspc, yl+cspc2); setColor(g, 3); drawThickLine(g, xl, yl+cspc2, xl+cspc, yl+cspc2); setColor(g, 4); drawThickLine(g, xl, yl+cspc, xl, yl+cspc2); setColor(g, 5); drawThickLine(g, xl, yl, xl, yl+cspc); setColor(g, 6); drawThickLine(g, xl, yl+cspc, xl+cspc, yl+cspc); } void setColor(Graphics g, int p) { g.setColor(pins[p].value ? Color.red : sim.printableCheckItem.getState() ? Color.white : darkred); } int getPostCount() { return 7; } int getVoltageSourceCount() { return 0; } int getDumpType() { return 157; } } ================================================ FILE: src/SparkGapElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class SparkGapElm extends CircuitElm { double resistance, onresistance, offresistance, breakdown, holdcurrent; boolean state; public SparkGapElm(int xx, int yy) { super(xx, yy); offresistance = 1e9; onresistance = 1e3; breakdown = 1e3; holdcurrent = 0.001; state = false; } public SparkGapElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); onresistance = new Double(st.nextToken()).doubleValue(); offresistance = new Double(st.nextToken()).doubleValue(); breakdown = new Double(st.nextToken()).doubleValue(); holdcurrent = new Double(st.nextToken()).doubleValue(); } boolean nonLinear() {return true;} int getDumpType() { return 187; } String dump() { return super.dump() + " " + onresistance + " " + offresistance + " " + breakdown + " " + holdcurrent; } Polygon arrow1, arrow2; void setPoints() { super.setPoints(); int dist = 16; int alen = 8; calcLeads(dist+alen); Point p1 = interpPoint(point1, point2, (dn-alen)/(2*dn)); arrow1 = calcArrow(point1, p1, alen, alen); p1 = interpPoint(point1, point2, (dn+alen)/(2*dn)); arrow2 = calcArrow(point2, p1, alen, alen); } void draw(Graphics g) { int i; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, 8); draw2Leads(g); setPowerColor(g, true); setVoltageColor(g, volts[0]); g.fillPolygon(arrow1); setVoltageColor(g, volts[1]); g.fillPolygon(arrow2); if (state) doDots(g); drawPosts(g); } void calculateCurrent() { double vd = volts[0] - volts[1]; current = vd/resistance; } void reset() { super.reset(); state = false; } void startIteration() { if (Math.abs(current) < holdcurrent) state = false; double vd = volts[0] - volts[1]; if (Math.abs(vd) > breakdown) state = true; } void doStep() { resistance = (state) ? onresistance : offresistance; sim.stampResistor(nodes[0], nodes[1], resistance); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void getInfo(String arr[]) { arr[0] = "spark gap"; getBasicInfo(arr); arr[3] = state ? "on" : "off"; arr[4] = "Ron = " + getUnitText(onresistance, sim.ohmString); arr[5] = "Roff = " + getUnitText(offresistance, sim.ohmString); arr[6] = "Vbreakdown = " + getUnitText(breakdown, "V"); } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("On resistance (ohms)", onresistance, 0, 0); if (n == 1) return new EditInfo("Off resistance (ohms)", offresistance, 0, 0); if (n == 2) return new EditInfo("Breakdown voltage", breakdown, 0, 0); if (n == 3) return new EditInfo("Holding current (A)", holdcurrent, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (ei.value > 0 && n == 0) onresistance = ei.value; if (ei.value > 0 && n == 1) offresistance = ei.value; if (ei.value > 0 && n == 2) breakdown = ei.value; if (ei.value > 0 && n == 3) holdcurrent = ei.value; } } ================================================ FILE: src/SquareRailElm.java ================================================ class SquareRailElm extends RailElm { public SquareRailElm(int xx, int yy) { super(xx, yy, WF_SQUARE); } Class getDumpClass() { return RailElm.class; } int getShortcut() { return 0; } } ================================================ FILE: src/SweepElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class SweepElm extends CircuitElm { double maxV, maxF, minF, sweepTime, frequency; final int FLAG_LOG = 1; final int FLAG_BIDIR = 2; public SweepElm(int xx, int yy) { super(xx, yy); minF = 20; maxF = 4000; maxV = 5; sweepTime = .1; flags = FLAG_BIDIR; reset(); } public SweepElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); minF = new Double(st.nextToken()).doubleValue(); maxF = new Double(st.nextToken()).doubleValue(); maxV = new Double(st.nextToken()).doubleValue(); sweepTime = new Double(st.nextToken()).doubleValue(); reset(); } int getDumpType() { return 170; } int getPostCount() { return 1; } final int circleSize = 17; String dump() { return super.dump() + " " + minF + " " + maxF + " " + maxV + " " + sweepTime; } void setPoints() { super.setPoints(); lead1 = interpPoint(point1, point2, 1-circleSize/dn); } void draw(Graphics g) { setBbox(point1, point2, circleSize); setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); g.setColor(needsHighlight() ? selectColor : Color.gray); setPowerColor(g, false); int xc = point2.x; int yc = point2.y; drawThickCircle(g, xc, yc, circleSize); int wl = 8; adjustBbox(xc-circleSize, yc-circleSize, xc+circleSize, yc+circleSize); int i; int xl = 10; int ox = -1, oy = -1; long tm = System.currentTimeMillis(); //double w = (this == mouseElm ? 3 : 2); tm %= 2000; if (tm > 1000) tm = 2000-tm; double w = 1+tm*.002; if (!sim.stoppedCheck.getState()) w = 1+2*(frequency-minF)/(maxF-minF); for (i = -xl; i <= xl; i++) { int yy = yc+(int) (.95*Math.sin(i*pi*w/xl)*wl); if (ox != -1) drawThickLine(g, ox, oy, xc+i, yy); ox = xc+i; oy = yy; } if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(frequency, "Hz"); if (dx == 0 || dy == 0) drawValues(g, s, circleSize); } drawPosts(g); curcount = updateDotCount(-current, curcount); if (sim.dragElm != this) drawDots(g, point1, lead1, curcount); } void stamp() { sim.stampVoltageSource(0, nodes[0], voltSource); } double fadd, fmul, freqTime, savedTimeStep; int dir = 1; void setParams() { if (frequency < minF || frequency > maxF) { frequency = minF; freqTime = 0; dir = 1; } if ((flags & FLAG_LOG) == 0) { fadd = dir*sim.timeStep*(maxF-minF)/sweepTime; fmul = 1; } else { fadd = 0; fmul = Math.pow(maxF/minF, dir*sim.timeStep/sweepTime); } savedTimeStep = sim.timeStep; } void reset() { frequency = minF; freqTime = 0; dir = 1; setParams(); } double v; void startIteration() { // has timestep been changed? if (sim.timeStep != savedTimeStep) setParams(); v = Math.sin(freqTime)*maxV; freqTime += frequency*2*pi*sim.timeStep; frequency = frequency*fmul+fadd; if (frequency >= maxF && dir == 1) { if ((flags & FLAG_BIDIR) != 0) { fadd = -fadd; fmul = 1/fmul; dir = -1; } else frequency = minF; } if (frequency <= minF && dir == -1) { fadd = -fadd; fmul = 1/fmul; dir = 1; } } void doStep() { sim.updateVoltageSource(0, nodes[0], voltSource, v); } double getVoltageDiff() { return volts[0]; } int getVoltageSourceCount() { return 1; } boolean hasGroundConnection(int n1) { return true; } void getInfo(String arr[]) { arr[0] = "sweep " + (((flags & FLAG_LOG) == 0) ? "(linear)" : "(log)"); arr[1] = "I = " + getCurrentDText(getCurrent()); arr[2] = "V = " + getVoltageText(volts[0]); arr[3] = "f = " + getUnitText(frequency, "Hz"); arr[4] = "range = " + getUnitText(minF, "Hz") + " .. " + getUnitText(maxF, "Hz"); arr[5] = "time = " + getUnitText(sweepTime, "s"); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Min Frequency (Hz)", minF, 0, 0); if (n == 1) return new EditInfo("Max Frequency (Hz)", maxF, 0, 0); if (n == 2) return new EditInfo("Sweep Time (s)", sweepTime, 0, 0); if (n == 3) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Logarithmic", (flags & FLAG_LOG) != 0); return ei; } if (n == 4) return new EditInfo("Max Voltage", maxV, 0, 0); if (n == 5) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Bidirectional", (flags & FLAG_BIDIR) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { double maxfreq = 1/(8*sim.timeStep); if (n == 0) { minF = ei.value; if (minF > maxfreq) minF = maxfreq; } if (n == 1) { maxF = ei.value; if (maxF > maxfreq) maxF = maxfreq; } if (n == 2) sweepTime = ei.value; if (n == 3) { flags &= ~FLAG_LOG; if (ei.checkbox.getState()) flags |= FLAG_LOG; } if (n == 4) maxV = ei.value; if (n == 5) { flags &= ~FLAG_BIDIR; if (ei.checkbox.getState()) flags |= FLAG_BIDIR; } setParams(); } } ================================================ FILE: src/Switch2Elm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class Switch2Elm extends SwitchElm { int link; static final int FLAG_CENTER_OFF = 1; public Switch2Elm(int xx, int yy) { super(xx, yy, false); noDiagonal = true; } Switch2Elm(int xx, int yy, boolean mm) { super(xx, yy, mm); noDiagonal = true; } public Switch2Elm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); link = new Integer(st.nextToken()).intValue(); noDiagonal = true; } int getDumpType() { return 'S'; } String dump() { return super.dump() + " " + link; } final int openhs = 16; Point swposts[], swpoles[]; void setPoints() { super.setPoints(); calcLeads(32); swposts = newPointArray(2); swpoles = newPointArray(3); interpPoint2(lead1, lead2, swpoles[0], swpoles[1], 1, openhs); swpoles[2] = lead2; interpPoint2(point1, point2, swposts[0], swposts[1], 1, openhs); posCount = hasCenterOff() ? 3 : 2; } void draw(Graphics g) { setBbox(point1, point2, openhs); // draw first lead setVoltageColor(g, volts[0]); drawThickLine(g, point1, lead1); // draw second lead setVoltageColor(g, volts[1]); drawThickLine(g, swpoles[0], swposts[0]); // draw third lead setVoltageColor(g, volts[2]); drawThickLine(g, swpoles[1], swposts[1]); // draw switch if (!needsHighlight()) g.setColor(whiteColor); drawThickLine(g, lead1, swpoles[position]); updateDotCount(); drawDots(g, point1, lead1, curcount); if (position != 2) drawDots(g, swpoles[position], swposts[position], curcount); drawPosts(g); } Point getPost(int n) { return (n == 0) ? point1 : swposts[n-1]; } int getPostCount() { return 3; } void calculateCurrent() { if (position == 2) current = 0; } void stamp() { if (position == 2) // in center? return; sim.stampVoltageSource(nodes[0], nodes[position+1], voltSource, 0); } int getVoltageSourceCount() { return (position == 2) ? 0 : 1; } void toggle() { super.toggle(); if (link != 0) { int i; for (i = 0; i != sim.elmList.size(); i++) { Object o = sim.elmList.elementAt(i); if (o instanceof Switch2Elm) { Switch2Elm s2 = (Switch2Elm) o; if (s2.link == link) s2.position = position; } } } } boolean getConnection(int n1, int n2) { if (position == 2) return false; return comparePair(n1, n2, 0, 1+position); } void getInfo(String arr[]) { arr[0] = (link == 0) ? "switch (SPDT)" : "switch (DPDT)"; arr[1] = "I = " + getCurrentDText(getCurrent()); } public EditInfo getEditInfo(int n) { if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Center Off", hasCenterOff()); return ei; } return super.getEditInfo(n); } public void setEditValue(int n, EditInfo ei) { if (n == 1) { flags &= ~FLAG_CENTER_OFF; if (ei.checkbox.getState()) flags |= FLAG_CENTER_OFF; if (hasCenterOff()) momentary = false; setPoints(); } else super.setEditValue(n, ei); } boolean hasCenterOff() { return (flags & FLAG_CENTER_OFF) != 0; } int getShortcut() { return 'S'; } } ================================================ FILE: src/SwitchElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class SwitchElm extends CircuitElm { boolean momentary; // position 0 == closed, position 1 == open int position, posCount; public SwitchElm(int xx, int yy) { super(xx, yy); momentary = false; position = 0; posCount = 2; } SwitchElm(int xx, int yy, boolean mm) { super(xx, yy); position = (mm) ? 1 : 0; momentary = mm; posCount = 2; } public SwitchElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); String str = st.nextToken(); if (str.compareTo("true") == 0) position = (this instanceof LogicInputElm) ? 0 : 1; else if (str.compareTo("false") == 0) position = (this instanceof LogicInputElm) ? 1 : 0; else position = new Integer(str).intValue(); momentary = new Boolean(st.nextToken()).booleanValue(); posCount = 2; } int getDumpType() { return 's'; } String dump() { return super.dump() + " " + position + " " + momentary; } Point ps, ps2; void setPoints() { super.setPoints(); calcLeads(32); ps = new Point(); ps2 = new Point(); } void draw(Graphics g) { int openhs = 16; int hs1 = (position == 1) ? 0 : 2; int hs2 = (position == 1) ? openhs : 2; setBbox(point1, point2, openhs); draw2Leads(g); if (position == 0) doDots(g); if (!needsHighlight()) g.setColor(whiteColor); interpPoint(lead1, lead2, ps, 0, hs1); interpPoint(lead1, lead2, ps2, 1, hs2); drawThickLine(g, ps, ps2); drawPosts(g); } void calculateCurrent() { if (position == 1) current = 0; } void stamp() { if (position == 0) sim.stampVoltageSource(nodes[0], nodes[1], voltSource, 0); } int getVoltageSourceCount() { return (position == 1) ? 0 : 1; } void mouseUp() { if (momentary) toggle(); } void toggle() { position++; if (position >= posCount) position = 0; } void getInfo(String arr[]) { arr[0] = (momentary) ? "push switch (SPST)" : "switch (SPST)"; if (position == 1) { arr[1] = "open"; arr[2] = "Vd = " + getVoltageDText(getVoltageDiff()); } else { arr[1] = "closed"; arr[2] = "V = " + getVoltageText(volts[0]); arr[3] = "I = " + getCurrentDText(getCurrent()); } } boolean getConnection(int n1, int n2) { return position == 0; } boolean isWire() { return true; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Momentary Switch", momentary); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) momentary = ei.checkbox.getState(); } int getShortcut() { return 's'; } } ================================================ FILE: src/TappedTransformerElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TappedTransformerElm extends CircuitElm { double inductance, ratio; Point ptEnds[], ptCoil[], ptCore[]; double current[], curcount[]; public TappedTransformerElm(int xx, int yy) { super(xx, yy); inductance = 4; ratio = 1; noDiagonal = true; current = new double[4]; curcount = new double[4]; voltdiff = new double[3]; curSourceValue = new double[3]; a = new double[9]; } public TappedTransformerElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); inductance = new Double(st.nextToken()).doubleValue(); ratio = new Double(st.nextToken()).doubleValue(); current = new double[4]; curcount = new double[4]; current[0] = new Double(st.nextToken()).doubleValue(); current[1] = new Double(st.nextToken()).doubleValue(); try { current[2] = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } voltdiff = new double[3]; curSourceValue = new double[3]; noDiagonal = true; a = new double[9]; } int getDumpType() { return 169; } String dump() { return super.dump() + " " + inductance + " " + ratio + " " + current[0] + " " + current[1] + " " + current[2]; } void draw(Graphics g) { int i; for (i = 0; i != 5; i++) { setVoltageColor(g, volts[i]); drawThickLine(g, ptEnds[i], ptCoil[i]); } for (i = 0; i != 4; i++) { if (i == 1) continue; setPowerColor(g, current[i]*(volts[i]-volts[i+1])); drawCoil(g, i > 1 ? -6 : 6, ptCoil[i], ptCoil[i+1], volts[i], volts[i+1]); } g.setColor(needsHighlight() ? selectColor : lightGrayColor); for (i = 0; i != 4; i += 2) { drawThickLine(g, ptCore[i], ptCore[i+1]); } // calc current of tap wire current[3] = current[1]-current[2]; for (i = 0; i != 4; i++) curcount[i] = updateDotCount(current[i], curcount[i]); // primary dots drawDots(g, ptEnds[0], ptCoil[0], curcount[0]); drawDots(g, ptCoil[0], ptCoil[1], curcount[0]); drawDots(g, ptCoil[1], ptEnds[1], curcount[0]); // secondary dots drawDots(g, ptEnds[2], ptCoil[2], curcount[1]); drawDots(g, ptCoil[2], ptCoil[3], curcount[1]); drawDots(g, ptCoil[3], ptEnds[3], curcount[3]); drawDots(g, ptCoil[3], ptCoil[4], curcount[2]); drawDots(g, ptCoil[4], ptEnds[4], curcount[2]); drawPosts(g); setBbox(ptEnds[0], ptEnds[4], 0); } void setPoints() { super.setPoints(); int hs = 32; ptEnds = newPointArray(5); ptCoil = newPointArray(5); ptCore = newPointArray(4); ptEnds[0] = point1; ptEnds[2] = point2; interpPoint(point1, point2, ptEnds[1], 0, -hs*2); interpPoint(point1, point2, ptEnds[3], 1, -hs); interpPoint(point1, point2, ptEnds[4], 1, -hs*2); double ce = .5-12/dn; double cd = .5-2/dn; int i; interpPoint(ptEnds[0], ptEnds[2], ptCoil[0], ce); interpPoint(ptEnds[0], ptEnds[2], ptCoil[1], ce, -hs*2); interpPoint(ptEnds[0], ptEnds[2], ptCoil[2], 1-ce); interpPoint(ptEnds[0], ptEnds[2], ptCoil[3], 1-ce, -hs); interpPoint(ptEnds[0], ptEnds[2], ptCoil[4], 1-ce, -hs*2); for (i = 0; i != 2; i++) { int b = -hs*i*2; interpPoint(ptEnds[0], ptEnds[2], ptCore[i], cd, b); interpPoint(ptEnds[0], ptEnds[2], ptCore[i+2], 1-cd, b); } } Point getPost(int n) { return ptEnds[n]; } int getPostCount() { return 5; } void reset() { current[0] = current[1] = volts[0] = volts[1] = volts[2] = volts[3] = curcount[0] = curcount[1] = 0; } double a[]; void stamp() { // equations for transformer: // v1 = L1 di1/dt + M1 di2/dt + M1 di3/dt // v2 = M1 di1/dt + L2 di2/dt + M2 di3/dt // v3 = M1 di1/dt + M2 di2/dt + L2 di3/dt // we invert that to get: // di1/dt = a1 v1 + a2 v2 + a3 v3 // di2/dt = a4 v1 + a5 v2 + a6 v3 // di3/dt = a7 v1 + a8 v2 + a9 v3 // integrate di1/dt using trapezoidal approx and we get: // i1(t2) = i1(t1) + dt/2 (i1(t1) + i1(t2)) // = i1(t1) + a1 dt/2 v1(t1)+a2 dt/2 v2(t1)+a3 dt/2 v3(t3) + // a1 dt/2 v1(t2)+a2 dt/2 v2(t2)+a3 dt/2 v3(t3) // the norton equivalent of this for i1 is: // a. current source, I = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1) // + a3 dt/2 v3(t1) // b. resistor, G = a1 dt/2 // c. current source controlled by voltage v2, G = a2 dt/2 // d. current source controlled by voltage v3, G = a3 dt/2 // and similarly for i2 // // first winding goes from node 0 to 1, second is from 2 to 3 to 4 double l1 = inductance; // second winding is split in half, so each part has half the turns; // we square the 1/2 to divide by 4 double l2 = inductance*ratio*ratio/4; double cc = .99; //double m1 = .999*Math.sqrt(l1*l2); // mutual inductance between two halves of the second winding // is equal to self-inductance of either half (slightly less // because the coupling is not perfect) //double m2 = .999*l2; // load pre-inverted matrix a[0] = (1+cc)/(l1*(1+cc-2*cc*cc)); a[1] = a[2] = a[3] = a[6] = 2*cc/((2*cc*cc-cc-1)*inductance*ratio); a[4] = a[8] = -4*(1+cc)/((2*cc*cc-cc-1)*l1*ratio*ratio); a[5] = a[7] = 4*cc/((2*cc*cc-cc-1)*l1*ratio*ratio); int i; for (i = 0; i != 9; i++) a[i] *= sim.timeStep/2; sim.stampConductance(nodes[0], nodes[1], a[0]); sim.stampVCCurrentSource(nodes[0], nodes[1], nodes[2], nodes[3], a[1]); sim.stampVCCurrentSource(nodes[0], nodes[1], nodes[3], nodes[4], a[2]); sim.stampVCCurrentSource(nodes[2], nodes[3], nodes[0], nodes[1], a[3]); sim.stampConductance (nodes[2], nodes[3], a[4]); sim.stampVCCurrentSource(nodes[2], nodes[3], nodes[3], nodes[4], a[5]); sim.stampVCCurrentSource(nodes[3], nodes[4], nodes[0], nodes[1], a[6]); sim.stampVCCurrentSource(nodes[3], nodes[4], nodes[2], nodes[3], a[7]); sim.stampConductance (nodes[3], nodes[4], a[8]); for (i = 0; i != 5; i++) sim.stampRightSide(nodes[i]); } void startIteration() { voltdiff[0] = volts[0]-volts[1]; voltdiff[1] = volts[2]-volts[3]; voltdiff[2] = volts[3]-volts[4]; int i, j; for (i = 0; i != 3; i++) { curSourceValue[i] = current[i]; for (j = 0; j != 3; j++) curSourceValue[i] += a[i*3+j]*voltdiff[j]; } } double curSourceValue[], voltdiff[]; void doStep() { sim.stampCurrentSource(nodes[0], nodes[1], curSourceValue[0]); sim.stampCurrentSource(nodes[2], nodes[3], curSourceValue[1]); sim.stampCurrentSource(nodes[3], nodes[4], curSourceValue[2]); } void calculateCurrent() { voltdiff[0] = volts[0]-volts[1]; voltdiff[1] = volts[2]-volts[3]; voltdiff[2] = volts[3]-volts[4]; int i, j; for (i = 0; i != 3; i++) { current[i] = curSourceValue[i]; for (j = 0; j != 3; j++) current[i] += a[i*3+j]*voltdiff[j]; } } void getInfo(String arr[]) { arr[0] = "transformer"; arr[1] = "L = " + getUnitText(inductance, "H"); arr[2] = "Ratio = " + ratio; //arr[3] = "I1 = " + getCurrentText(current1); arr[3] = "Vd1 = " + getVoltageText(volts[0]-volts[2]); //arr[5] = "I2 = " + getCurrentText(current2); arr[4] = "Vd2 = " + getVoltageText(volts[1]-volts[3]); } boolean getConnection(int n1, int n2) { if (comparePair(n1, n2, 0, 1)) return true; if (comparePair(n1, n2, 2, 3)) return true; if (comparePair(n1, n2, 3, 4)) return true; if (comparePair(n1, n2, 2, 4)) return true; return false; } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Primary Inductance (H)", inductance, .01, 5); if (n == 1) return new EditInfo("Ratio", ratio, 1, 10).setDimensionless(); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) inductance = ei.value; if (n == 1) ratio = ei.value; } } ================================================ FILE: src/TextElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; import java.util.Vector; class TextElm extends GraphicElm { String text; Vector lines; int size; final int FLAG_CENTER = 1; final int FLAG_BAR = 2; public TextElm(int xx, int yy) { super(xx, yy); text = "hello"; lines = new Vector(); lines.add(text); size = 24; } public TextElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); size = new Integer(st.nextToken()).intValue(); text = st.nextToken(); while (st.hasMoreTokens()) text += ' ' + st.nextToken(); split(); } void split() { int i; lines = new Vector(); StringBuffer sb = new StringBuffer(text); for (i = 0; i < sb.length(); i++) { char c = sb.charAt(i); if (c == '\\') { sb.deleteCharAt(i); c = sb.charAt(i); if (c == 'n') { lines.add(sb.substring(0, i)); sb.delete(0, i+1); i = -1; continue; } } } lines.add(sb.toString()); } String dump() { return super.dump() + " " + size + " " + text; } int getDumpType() { return 'x'; } void drag(int xx, int yy) { x = xx; y = yy; x2 = xx+16; y2 = yy; } void draw(Graphics g) { //Graphics2D g2 = (Graphics2D)g; //g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(needsHighlight() ? selectColor : lightGrayColor); Font f = new Font("SansSerif", 0, size); g.setFont(f); FontMetrics fm = g.getFontMetrics(); int i; int maxw = -1; for (i = 0; i != lines.size(); i++) { int w = fm.stringWidth((String) (lines.elementAt(i))); if (w > maxw) maxw = w; } int cury = y; setBbox(x, y, x, y); for (i = 0; i != lines.size(); i++) { String s = (String) (lines.elementAt(i)); if ((flags & FLAG_CENTER) != 0) x = (sim.winSize.width-fm.stringWidth(s))/2; g.drawString(s, x, cury); if ((flags & FLAG_BAR) != 0) { int by = cury-fm.getAscent(); g.drawLine(x, by, x+fm.stringWidth(s)-1, by); } adjustBbox(x, cury-fm.getAscent(), x+fm.stringWidth(s), cury+fm.getDescent()); cury += fm.getHeight(); } x2 = boundingBox.x + boundingBox.width; y2 = boundingBox.y + boundingBox.height; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("Text", 0, -1, -1); ei.text = text; return ei; } if (n == 1) return new EditInfo("Size", size, 5, 100); if (n == 2) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Center", (flags & FLAG_CENTER) != 0); return ei; } if (n == 3) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Draw Bar On Top", (flags & FLAG_BAR) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { text = ei.textf.getText(); split(); } if (n == 1) size = (int) ei.value; if (n == 3) { if (ei.checkbox.getState()) flags |= FLAG_BAR; else flags &= ~FLAG_BAR; } if (n == 2) { if (ei.checkbox.getState()) flags |= FLAG_CENTER; else flags &= ~FLAG_CENTER; } } boolean isCenteredText() { return (flags & FLAG_CENTER) != 0; } void getInfo(String arr[]) { arr[0] = text; } @Override int getShortcut() { return 't'; } } ================================================ FILE: src/ThermistorElm.java ================================================ // stub ThermistorElm based on SparkGapElm // FIXME need to uncomment ThermistorElm line from CirSim.java // FIXME need to add ThermistorElm.java to srclist import java.awt.*; import java.util.StringTokenizer; class ThermistorElm extends CircuitElm { double minresistance, maxresistance; double resistance; Scrollbar slider; Label label; public ThermistorElm(int xx, int yy) { super(xx, yy); maxresistance = 1e9; minresistance = 1e3; createSlider(); } public ThermistorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); minresistance = new Double(st.nextToken()).doubleValue(); maxresistance = new Double(st.nextToken()).doubleValue(); createSlider(); } boolean nonLinear() {return true;} int getDumpType() { return 188; } String dump() { return super.dump() + " " + minresistance + " " + maxresistance; } Point ps3, ps4; void createSlider() { sim.main.add(label = new Label("Temperature", Label.CENTER)); int value = 50; sim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101)); sim.main.validate(); } void setPoints() { super.setPoints(); calcLeads(32); ps3 = new Point(); ps4 = new Point(); } void delete() { sim.main.remove(label); sim.main.remove(slider); } void draw(Graphics g) { int i; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, 6); draw2Leads(g); // FIXME need to draw properly, see ResistorElm.java setPowerColor(g, true); doDots(g); drawPosts(g); } void calculateCurrent() { double vd = volts[0] - volts[1]; current = vd/resistance; } void startIteration() { double vd = volts[0] - volts[1]; // FIXME set resistance as appropriate, using slider.getValue() resistance = minresistance; //System.out.print(this + " res current set to " + current + "\n"); } void doStep() { sim.stampResistor(nodes[0], nodes[1], resistance); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } void getInfo(String arr[]) { // FIXME arr[0] = "spark gap"; getBasicInfo(arr); arr[3] = "R = " + getUnitText(resistance, sim.ohmString); arr[4] = "Ron = " + getUnitText(minresistance, sim.ohmString); arr[5] = "Roff = " + getUnitText(maxresistance, sim.ohmString); } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Min resistance (ohms)", minresistance, 0, 0); if (n == 1) return new EditInfo("Max resistance (ohms)", maxresistance, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (ei.value > 0 && n == 0) minresistance = ei.value; if (ei.value > 0 && n == 1) maxresistance = ei.value; } } ================================================ FILE: src/TimerElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TimerElm extends ChipElm { final int FLAG_RESET = 2; final int N_DIS = 0; final int N_TRIG = 1; final int N_THRES = 2; final int N_VIN = 3; final int N_CTL = 4; final int N_OUT = 5; final int N_RST = 6; int getDefaultFlags() { return FLAG_RESET; } public TimerElm(int xx, int yy) { super(xx, yy); } public TimerElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "555 Timer"; } void setupPins() { sizeX = 3; sizeY = 5; pins = new Pin[7]; pins[N_DIS] = new Pin(1, SIDE_W, "dis"); pins[N_TRIG] = new Pin(3, SIDE_W, "tr"); pins[N_TRIG].lineOver = true; pins[N_THRES] = new Pin(4, SIDE_W, "th"); pins[N_VIN] = new Pin(1, SIDE_N, "Vin"); pins[N_CTL] = new Pin(1, SIDE_S, "ctl"); pins[N_OUT] = new Pin(2, SIDE_E, "out"); pins[N_OUT].output = pins[N_OUT].state = true; pins[N_RST] = new Pin(1, SIDE_E, "rst"); } boolean nonLinear() { return true; } boolean hasReset() { return (flags & FLAG_RESET) != 0; } void stamp() { // stamp voltage divider to put ctl pin at 2/3 V sim.stampResistor(nodes[N_VIN], nodes[N_CTL], 5000); sim.stampResistor(nodes[N_CTL], 0, 10000); // output pin sim.stampVoltageSource(0, nodes[N_OUT], pins[N_OUT].voltSource); // discharge pin sim.stampNonLinear(nodes[N_DIS]); } void calculateCurrent() { // need current for V, discharge, control; output current is // calculated for us, and other pins have no current pins[N_VIN].current = (volts[N_CTL]-volts[N_VIN])/5000; pins[N_CTL].current = -volts[N_CTL]/10000 - pins[N_VIN].current; pins[N_DIS].current = (!out && !setOut) ? -volts[N_DIS]/10 : 0; } boolean setOut, out; void startIteration() { out = volts[N_OUT] > volts[N_VIN]/2; setOut = false; // check comparators if (volts[N_CTL]/2 > volts[N_TRIG]) setOut = out = true; if (volts[N_THRES] > volts[N_CTL] || (hasReset() && volts[N_RST] < .7)) out = false; } void doStep() { // if output is low, discharge pin 0. we use a small // resistor because it's easier, and sometimes people tie // the discharge pin to the trigger and threshold pins. // We check setOut to properly emulate the case where // trigger is low and threshold is high. if (!out && !setOut) sim.stampResistor(nodes[N_DIS], 0, 10); // output sim.updateVoltageSource(0, nodes[N_OUT], pins[N_OUT].voltSource, out ? volts[N_VIN] : 0); } int getPostCount() { return hasReset() ? 7 : 6; } int getVoltageSourceCount() { return 1; } int getDumpType() { return 165; } } ================================================ FILE: src/TransLineElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TransLineElm extends CircuitElm { double delay, imped; double voltageL[], voltageR[]; int lenSteps, ptr, width; public TransLineElm(int xx, int yy) { super(xx, yy); delay = 1000*sim.timeStep; imped = 75; noDiagonal = true; reset(); } public TransLineElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); delay = new Double(st.nextToken()).doubleValue(); imped = new Double(st.nextToken()).doubleValue(); width = new Integer(st.nextToken()).intValue(); // next slot is for resistance (losses), which is not implemented st.nextToken(); noDiagonal = true; reset(); } int getDumpType() { return 171; } int getPostCount() { return 4; } int getInternalNodeCount() { return 2; } String dump() { return super.dump() + " " + delay + " " + imped + " " + width + " " + 0.; } void drag(int xx, int yy) { xx = sim.snapGrid(xx); yy = sim.snapGrid(yy); int w1 = max(sim.gridSize, abs(yy-y)); int w2 = max(sim.gridSize, abs(xx-x)); if (w1 > w2) { xx = x; width = w2; } else { yy = y; width = w1; } x2 = xx; y2 = yy; setPoints(); } Point posts[], inner[]; void reset() { if (sim.timeStep == 0) return; lenSteps = (int) (delay/sim.timeStep); System.out.println(lenSteps + " steps"); if (lenSteps > 100000) voltageL = voltageR = null; else { voltageL = new double[lenSteps]; voltageR = new double[lenSteps]; } ptr = 0; super.reset(); } void setPoints() { super.setPoints(); int ds = (dy == 0) ? sign(dx) : -sign(dy); Point p3 = interpPoint(point1, point2, 0, -width*ds); Point p4 = interpPoint(point1, point2, 1, -width*ds); int sep = sim.gridSize/2; Point p5 = interpPoint(point1, point2, 0, -(width/2-sep)*ds); Point p6 = interpPoint(point1, point2, 1, -(width/2-sep)*ds); Point p7 = interpPoint(point1, point2, 0, -(width/2+sep)*ds); Point p8 = interpPoint(point1, point2, 1, -(width/2+sep)*ds); // we number the posts like this because we want the lower-numbered // points to be on the bottom, so that if some of them are unconnected // (which is often true) then the bottom ones will get automatically // attached to ground. posts = new Point[] { p3, p4, point1, point2 }; inner = new Point[] { p7, p8, p5, p6 }; } void draw(Graphics g) { setBbox(posts[0], posts[3], 0); int segments = (int) (dn/2); int ix0 = ptr-1+lenSteps; double segf = 1./segments; int i; g.setColor(Color.darkGray); g.fillRect(inner[2].x, inner[2].y, inner[1].x-inner[2].x+2, inner[1].y-inner[2].y+2); for (i = 0; i != 4; i++) { setVoltageColor(g, volts[i]); drawThickLine(g, posts[i], inner[i]); } if (voltageL != null) { for (i = 0; i != segments; i++) { int ix1 = (ix0-lenSteps*i/segments) % lenSteps; int ix2 = (ix0-lenSteps*(segments-1-i)/segments) % lenSteps; double v = (voltageL[ix1]+voltageR[ix2])/2; setVoltageColor(g, v); interpPoint(inner[0], inner[1], ps1, i*segf); interpPoint(inner[2], inner[3], ps2, i*segf); g.drawLine(ps1.x, ps1.y, ps2.x, ps2.y); interpPoint(inner[2], inner[3], ps1, (i+1)*segf); drawThickLine(g, ps1, ps2); } } setVoltageColor(g, volts[0]); drawThickLine(g, inner[0], inner[1]); drawPosts(g); curCount1 = updateDotCount(-current1, curCount1); curCount2 = updateDotCount(current2, curCount2); if (sim.dragElm != this) { drawDots(g, posts[0], inner[0], curCount1); drawDots(g, posts[2], inner[2], -curCount1); drawDots(g, posts[1], inner[1], -curCount2); drawDots(g, posts[3], inner[3], curCount2); } } int voltSource1, voltSource2; double current1, current2, curCount1, curCount2; void setVoltageSource(int n, int v) { if (n == 0) voltSource1 = v; else voltSource2 = v; } void setCurrent(int v, double c) { if (v == voltSource1) current1 = c; else current2 = c; } void stamp() { sim.stampVoltageSource(nodes[4], nodes[0], voltSource1); sim.stampVoltageSource(nodes[5], nodes[1], voltSource2); sim.stampResistor(nodes[2], nodes[4], imped); sim.stampResistor(nodes[3], nodes[5], imped); } void startIteration() { // calculate voltages, currents sent over wire if (voltageL == null) { sim.stop("Transmission line delay too large!", this); return; } voltageL[ptr] = volts[2]-volts[0] + volts[2]-volts[4]; voltageR[ptr] = volts[3]-volts[1] + volts[3]-volts[5]; //System.out.println(volts[2] + " " + volts[0] + " " + (volts[2]-volts[0]) + " " + (imped*current1) + " " + voltageL[ptr]); /*System.out.println("sending fwd " + currentL[ptr] + " " + current1); System.out.println("sending back " + currentR[ptr] + " " + current2);*/ //System.out.println("sending back " + voltageR[ptr]); ptr = (ptr+1) % lenSteps; } void doStep() { if (voltageL == null) { sim.stop("Transmission line delay too large!", this); return; } sim.updateVoltageSource(nodes[4], nodes[0], voltSource1, -voltageR[ptr]); sim.updateVoltageSource(nodes[5], nodes[1], voltSource2, -voltageL[ptr]); if (Math.abs(volts[0]) > 1e-5 || Math.abs(volts[1]) > 1e-5) { sim.stop("Need to ground transmission line!", this); return; } } Point getPost(int n) { return posts[n]; } //double getVoltageDiff() { return volts[0]; } int getVoltageSourceCount() { return 2; } boolean hasGroundConnection(int n1) { return false; } boolean getConnection(int n1, int n2) { return false; /*if (comparePair(n1, n2, 0, 1)) return true; if (comparePair(n1, n2, 2, 3)) return true; return false;*/ } void getInfo(String arr[]) { arr[0] = "transmission line"; arr[1] = getUnitText(imped, sim.ohmString); arr[2] = "length = " + getUnitText(2.9979e8*delay, "m"); arr[3] = "delay = " + getUnitText(delay, "s"); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Delay (s)", delay, 0, 0); if (n == 1) return new EditInfo("Impedance (ohms)", imped, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { delay = ei.value; reset(); } if (n == 1) { imped = ei.value; reset(); } } } ================================================ FILE: src/TransformerElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TransformerElm extends CircuitElm { double inductance, ratio, couplingCoef; Point ptEnds[], ptCoil[], ptCore[]; double current[], curcount[]; int width; public static final int FLAG_BACK_EULER = 2; public TransformerElm(int xx, int yy) { super(xx, yy); inductance = 4; ratio = 1; width = 32; noDiagonal = true; couplingCoef = .999; current = new double[2]; curcount = new double[2]; } public TransformerElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); width = max(32, abs(yb-ya)); inductance = new Double(st.nextToken()).doubleValue(); ratio = new Double(st.nextToken()).doubleValue(); current = new double[2]; curcount = new double[2]; current[0] = new Double(st.nextToken()).doubleValue(); current[1] = new Double(st.nextToken()).doubleValue(); couplingCoef = .999; try { couplingCoef = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } noDiagonal = true; } void drag(int xx, int yy) { xx = sim.snapGrid(xx); yy = sim.snapGrid(yy); width = max(32, abs(yy-y)); if (xx == x) yy = y; x2 = xx; y2 = yy; setPoints(); } int getDumpType() { return 'T'; } String dump() { return super.dump() + " " + inductance + " " + ratio + " " + current[0] + " " + current[1] + " " + couplingCoef; } boolean isTrapezoidal() { return (flags & FLAG_BACK_EULER) == 0; } void draw(Graphics g) { int i; for (i = 0; i != 4; i++) { setVoltageColor(g, volts[i]); drawThickLine(g, ptEnds[i], ptCoil[i]); } for (i = 0; i != 2; i++) { setPowerColor(g, current[i]*(volts[i]-volts[i+2])); drawCoil(g, dsign*(i == 1 ? -6 : 6), ptCoil[i], ptCoil[i+2], volts[i], volts[i+2]); } g.setColor(needsHighlight() ? selectColor : lightGrayColor); for (i = 0; i != 2; i++) { drawThickLine(g, ptCore[i], ptCore[i+2]); curcount[i] = updateDotCount(current[i], curcount[i]); } for (i = 0; i != 2; i++) { drawDots(g, ptEnds[i], ptCoil[i], curcount[i]); drawDots(g, ptCoil[i], ptCoil[i+2], curcount[i]); drawDots(g, ptEnds[i+2], ptCoil[i+2], -curcount[i]); } drawPosts(g); setBbox(ptEnds[0], ptEnds[3], 0); } void setPoints() { super.setPoints(); point2.y = point1.y; ptEnds = newPointArray(4); ptCoil = newPointArray(4); ptCore = newPointArray(4); ptEnds[0] = point1; ptEnds[1] = point2; interpPoint(point1, point2, ptEnds[2], 0, -dsign*width); interpPoint(point1, point2, ptEnds[3], 1, -dsign*width); double ce = .5-12/dn; double cd = .5-2/dn; int i; for (i = 0; i != 4; i += 2) { interpPoint(ptEnds[i], ptEnds[i+1], ptCoil[i], ce); interpPoint(ptEnds[i], ptEnds[i+1], ptCoil[i+1], 1-ce); interpPoint(ptEnds[i], ptEnds[i+1], ptCore[i], cd); interpPoint(ptEnds[i], ptEnds[i+1], ptCore[i+1], 1-cd); } } Point getPost(int n) { return ptEnds[n]; } int getPostCount() { return 4; } void reset() { current[0] = current[1] = volts[0] = volts[1] = volts[2] = volts[3] = curcount[0] = curcount[1] = 0; } double a1, a2, a3, a4; void stamp() { // equations for transformer: // v1 = L1 di1/dt + M di2/dt // v2 = M di1/dt + L2 di2/dt // we invert that to get: // di1/dt = a1 v1 + a2 v2 // di2/dt = a3 v1 + a4 v2 // integrate di1/dt using trapezoidal approx and we get: // i1(t2) = i1(t1) + dt/2 (i1(t1) + i1(t2)) // = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1) + // a1 dt/2 v1(t2) + a2 dt/2 v2(t2) // the norton equivalent of this for i1 is: // a. current source, I = i1(t1) + a1 dt/2 v1(t1) + a2 dt/2 v2(t1) // b. resistor, G = a1 dt/2 // c. current source controlled by voltage v2, G = a2 dt/2 // and for i2: // a. current source, I = i2(t1) + a3 dt/2 v1(t1) + a4 dt/2 v2(t1) // b. resistor, G = a3 dt/2 // c. current source controlled by voltage v2, G = a4 dt/2 // // For backward euler, // // i1(t2) = i1(t1) + a1 dt v1(t2) + a2 dt v2(t2) // // So the current source value is just i1(t1) and we use // dt instead of dt/2 for the resistor and VCCS. // // first winding goes from node 0 to 2, second is from 1 to 3 double l1 = inductance; double l2 = inductance*ratio*ratio; double m = couplingCoef*Math.sqrt(l1*l2); // build inverted matrix double deti = 1/(l1*l2-m*m); double ts = isTrapezoidal() ? sim.timeStep/2 : sim.timeStep; a1 = l2*deti*ts; // we multiply dt/2 into a1..a4 here a2 = -m*deti*ts; a3 = -m*deti*ts; a4 = l1*deti*ts; sim.stampConductance(nodes[0], nodes[2], a1); sim.stampVCCurrentSource(nodes[0], nodes[2], nodes[1], nodes[3], a2); sim.stampVCCurrentSource(nodes[1], nodes[3], nodes[0], nodes[2], a3); sim.stampConductance(nodes[1], nodes[3], a4); sim.stampRightSide(nodes[0]); sim.stampRightSide(nodes[1]); sim.stampRightSide(nodes[2]); sim.stampRightSide(nodes[3]); } void startIteration() { double voltdiff1 = volts[0]-volts[2]; double voltdiff2 = volts[1]-volts[3]; if (isTrapezoidal()) { curSourceValue1 = voltdiff1*a1+voltdiff2*a2+current[0]; curSourceValue2 = voltdiff1*a3+voltdiff2*a4+current[1]; } else { curSourceValue1 = current[0]; curSourceValue2 = current[1]; } } double curSourceValue1, curSourceValue2; void doStep() { sim.stampCurrentSource(nodes[0], nodes[2], curSourceValue1); sim.stampCurrentSource(nodes[1], nodes[3], curSourceValue2); } void calculateCurrent() { double voltdiff1 = volts[0]-volts[2]; double voltdiff2 = volts[1]-volts[3]; current[0] = voltdiff1*a1 + voltdiff2*a2 + curSourceValue1; current[1] = voltdiff1*a3 + voltdiff2*a4 + curSourceValue2; } void getInfo(String arr[]) { arr[0] = "transformer"; arr[1] = "L = " + getUnitText(inductance, "H"); arr[2] = "Ratio = 1:" + ratio; arr[3] = "Vd1 = " + getVoltageText(volts[0]-volts[2]); arr[4] = "Vd2 = " + getVoltageText(volts[1]-volts[3]); arr[5] = "I1 = " + getCurrentText(current[0]); arr[6] = "I2 = " + getCurrentText(current[1]); } boolean getConnection(int n1, int n2) { if (comparePair(n1, n2, 0, 2)) return true; if (comparePair(n1, n2, 1, 3)) return true; return false; } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Primary Inductance (H)", inductance, .01, 5); if (n == 1) return new EditInfo("Ratio", ratio, 1, 10).setDimensionless(); if (n == 2) return new EditInfo("Coupling Coefficient", couplingCoef, 0, 1). setDimensionless(); if (n == 3) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Trapezoidal Approximation", isTrapezoidal()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) inductance = ei.value; if (n == 1) ratio = ei.value; if (n == 2 && ei.value > 0 && ei.value < 1) couplingCoef = ei.value; if (n == 3) { if (ei.checkbox.getState()) flags &= ~Inductor.FLAG_BACK_EULER; else flags |= Inductor.FLAG_BACK_EULER; } } } ================================================ FILE: src/TransistorElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TransistorElm extends CircuitElm { int pnp; double beta; double fgain; double gmin; final int FLAG_FLIP = 1; TransistorElm(int xx, int yy, boolean pnpflag) { super(xx, yy); pnp = (pnpflag) ? -1 : 1; beta = 100; setup(); } public TransistorElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); pnp = new Integer(st.nextToken()).intValue(); beta = 100; try { lastvbe = new Double(st.nextToken()).doubleValue(); lastvbc = new Double(st.nextToken()).doubleValue(); volts[0] = 0; volts[1] = -lastvbe; volts[2] = -lastvbc; beta = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } setup(); } void setup() { vcrit = vt * Math.log(vt/(Math.sqrt(2)*leakage)); fgain = beta/(beta+1); noDiagonal = true; } boolean nonLinear() { return true; } void reset() { volts[0] = volts[1] = volts[2] = 0; lastvbc = lastvbe = curcount_c = curcount_e = curcount_b = 0; } int getDumpType() { return 't'; } String dump() { return super.dump() + " " + pnp + " " + (volts[0]-volts[1]) + " " + (volts[0]-volts[2]) + " " + beta; } double ic, ie, ib, curcount_c, curcount_e, curcount_b; Polygon rectPoly, arrowPoly; void draw(Graphics g) { setBbox(point1, point2, 16); setPowerColor(g, true); // draw collector setVoltageColor(g, volts[1]); drawThickLine(g, coll[0], coll[1]); // draw emitter setVoltageColor(g, volts[2]); drawThickLine(g, emit[0], emit[1]); // draw arrow g.setColor(lightGrayColor); g.fillPolygon(arrowPoly); // draw base setVoltageColor(g, volts[0]); if (sim.powerCheckItem.getState()) g.setColor(Color.gray); drawThickLine(g, point1, base); // draw dots curcount_b = updateDotCount(-ib, curcount_b); drawDots(g, base, point1, curcount_b); curcount_c = updateDotCount(-ic, curcount_c); drawDots(g, coll[1], coll[0], curcount_c); curcount_e = updateDotCount(-ie, curcount_e); drawDots(g, emit[1], emit[0], curcount_e); // draw base rectangle setVoltageColor(g, volts[0]); setPowerColor(g, true); g.fillPolygon(rectPoly); if ((needsHighlight() || sim.dragElm == this) && dy == 0) { g.setColor(Color.white); g.setFont(unitsFont); int ds = sign(dx); g.drawString("B", base.x-10*ds, base.y-5); g.drawString("C", coll[0].x-3+9*ds, coll[0].y+4); // x+6 if ds=1, -12 if -1 g.drawString("E", emit[0].x-3+9*ds, emit[0].y+4); } drawPosts(g); } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? coll[0] : emit[0]; } int getPostCount() { return 3; } double getPower() { return (volts[0]-volts[2])*ib + (volts[1]-volts[2])*ic; } Point rect[], coll[], emit[], base; void setPoints() { super.setPoints(); int hs = 16; if ((flags & FLAG_FLIP) != 0) dsign = -dsign; int hs2 = hs*dsign*pnp; // calc collector, emitter posts coll = newPointArray(2); emit = newPointArray(2); interpPoint2(point1, point2, coll[0], emit[0], 1, hs2); // calc rectangle edges rect = newPointArray(4); interpPoint2(point1, point2, rect[0], rect[1], 1-16/dn, hs); interpPoint2(point1, point2, rect[2], rect[3], 1-13/dn, hs); // calc points where collector/emitter leads contact rectangle interpPoint2(point1, point2, coll[1], emit[1], 1-13/dn, 6*dsign*pnp); // calc point where base lead contacts rectangle base = new Point(); interpPoint (point1, point2, base, 1-16/dn); // rectangle rectPoly = createPolygon(rect[0], rect[2], rect[3], rect[1]); // arrow if (pnp == 1) arrowPoly = calcArrow(emit[1], emit[0], 8, 4); else { Point pt = interpPoint(point1, point2, 1-11/dn, -5*dsign*pnp); arrowPoly = calcArrow(emit[0], pt, 8, 4); } } static final double leakage = 1e-13; // 1e-6; static final double vt = .025; static final double vdcoef = 1/vt; static final double rgain = .5; double vcrit; double lastvbc, lastvbe; double limitStep(double vnew, double vold) { double arg; double oo = vnew; if (vnew > vcrit && Math.abs(vnew - vold) > (vt + vt)) { if(vold > 0) { arg = 1 + (vnew - vold) / vt; if(arg > 0) { vnew = vold + vt * Math.log(arg); } else { vnew = vcrit; } } else { vnew = vt *Math.log(vnew/vt); } sim.converged = false; //System.out.println(vnew + " " + oo + " " + vold); } return(vnew); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); sim.stampNonLinear(nodes[2]); } void doStep() { double vbc = volts[0]-volts[1]; // typically negative double vbe = volts[0]-volts[2]; // typically positive if (Math.abs(vbc-lastvbc) > .01 || // .01 Math.abs(vbe-lastvbe) > .01) sim.converged = false; gmin = 0; if (sim.subIterations > 100) { // if we have trouble converging, put a conductance in parallel with all P-N junctions. // Gradually increase the conductance value for each iteration. gmin = Math.exp(-9*Math.log(10)*(1-sim.subIterations/3000.)); if (gmin > .1) gmin = .1; } //System.out.print("T " + vbc + " " + vbe + "\n"); vbc = pnp*limitStep(pnp*vbc, pnp*lastvbc); vbe = pnp*limitStep(pnp*vbe, pnp*lastvbe); lastvbc = vbc; lastvbe = vbe; double pcoef = vdcoef*pnp; double expbc = Math.exp(vbc*pcoef); /*if (expbc > 1e13 || Double.isInfinite(expbc)) expbc = 1e13;*/ double expbe = Math.exp(vbe*pcoef); if (expbe < 1) expbe = 1; /*if (expbe > 1e13 || Double.isInfinite(expbe)) expbe = 1e13;*/ ie = pnp*leakage*(-(expbe-1)+rgain*(expbc-1)); ic = pnp*leakage*(fgain*(expbe-1)-(expbc-1)); ib = -(ie+ic); //System.out.println("gain " + ic/ib); //System.out.print("T " + vbc + " " + vbe + " " + ie + " " + ic + "\n"); double gee = -leakage*vdcoef*expbe; double gec = rgain*leakage*vdcoef*expbc; double gce = -gee*fgain; double gcc = -gec*(1/rgain); /*System.out.print("gee = " + gee + "\n"); System.out.print("gec = " + gec + "\n"); System.out.print("gce = " + gce + "\n"); System.out.print("gcc = " + gcc + "\n"); System.out.print("gce+gcc = " + (gce+gcc) + "\n"); System.out.print("gee+gec = " + (gee+gec) + "\n");*/ // stamps from page 302 of Pillage. Node 0 is the base, // node 1 the collector, node 2 the emitter. Also stamp // minimum conductance (gmin) between b,e and b,c sim.stampMatrix(nodes[0], nodes[0], -gee-gec-gce-gcc + gmin*2); sim.stampMatrix(nodes[0], nodes[1], gec+gcc - gmin); sim.stampMatrix(nodes[0], nodes[2], gee+gce - gmin); sim.stampMatrix(nodes[1], nodes[0], gce+gcc - gmin); sim.stampMatrix(nodes[1], nodes[1], -gcc + gmin); sim.stampMatrix(nodes[1], nodes[2], -gce); sim.stampMatrix(nodes[2], nodes[0], gee+gec - gmin); sim.stampMatrix(nodes[2], nodes[1], -gec); sim.stampMatrix(nodes[2], nodes[2], -gee + gmin); // we are solving for v(k+1), not delta v, so we use formula // 10.5.13, multiplying J by v(k) sim.stampRightSide(nodes[0], -ib - (gec+gcc)*vbc - (gee+gce)*vbe); sim.stampRightSide(nodes[1], -ic + gce*vbe + gcc*vbc); sim.stampRightSide(nodes[2], -ie + gee*vbe + gec*vbc); } void getInfo(String arr[]) { arr[0] = "transistor (" + ((pnp == -1) ? "PNP)" : "NPN)") + " beta=" + showFormat.format(beta); double vbc = volts[0]-volts[1]; double vbe = volts[0]-volts[2]; double vce = volts[1]-volts[2]; if (vbc*pnp > .2) arr[1] = vbe*pnp > .2 ? "saturation" : "reverse active"; else arr[1] = vbe*pnp > .2 ? "fwd active" : "cutoff"; arr[2] = "Ic = " + getCurrentText(ic); arr[3] = "Ib = " + getCurrentText(ib); arr[4] = "Vbe = " + getVoltageText(vbe); arr[5] = "Vbc = " + getVoltageText(vbc); arr[6] = "Vce = " + getVoltageText(vce); } double getScopeValue(int x) { switch (x) { case Scope.VAL_IB: return ib; case Scope.VAL_IC: return ic; case Scope.VAL_IE: return ie; case Scope.VAL_VBE: return volts[0]-volts[2]; case Scope.VAL_VBC: return volts[0]-volts[1]; case Scope.VAL_VCE: return volts[1]-volts[2]; } return 0; } String getScopeUnits(int x) { switch (x) { case Scope.VAL_IB: case Scope.VAL_IC: case Scope.VAL_IE: return "A"; default: return "V"; } } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Beta/hFE", beta, 10, 1000). setDimensionless(); if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Swap E/C", (flags & FLAG_FLIP) != 0); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { beta = ei.value; setup(); } if (n == 1) { if (ei.checkbox.getState()) flags |= FLAG_FLIP; else flags &= ~FLAG_FLIP; setPoints(); } } boolean canViewInScope() { return true; } } ================================================ FILE: src/TriacElm.java ================================================ // stub implementation of TriacElm, based on SCRElm // FIXME need to add TriacElm to srclist // FIXME need to uncomment TriacElm line from CirSim.java import java.awt.*; import java.util.StringTokenizer; // Silicon-Controlled Rectifier // 3 nodes, 1 internal node // 0 = anode, 1 = cathode, 2 = gate // 0, 3 = variable resistor // 3, 2 = diode // 2, 1 = 50 ohm resistor class TriacElm extends CircuitElm { final int anode = 0; final int cnode = 1; final int gnode = 2; final int inode = 3; Diode diode; public TriacElm(int xx, int yy) { super(xx, yy); setDefaults(); setup(); } public TriacElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); setDefaults(); try { lastvac = new Double(st.nextToken()).doubleValue(); lastvag = new Double(st.nextToken()).doubleValue(); volts[anode] = 0; volts[cnode] = -lastvac; volts[gnode] = -lastvag; triggerI = new Double(st.nextToken()).doubleValue(); holdingI = new Double(st.nextToken()).doubleValue(); cresistance = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } setup(); } void setDefaults() { cresistance = 50; holdingI = .0082; triggerI = .01; } void setup() { diode = new Diode(sim); diode.setup(.8, 0); } boolean nonLinear() { return true; } void reset() { volts[anode] = volts[cnode] = volts[gnode] = 0; diode.reset(); lastvag = lastvac = curcount_a = curcount_c = curcount_g = 0; } int getDumpType() { return 183; } String dump() { return super.dump() + " " + (volts[anode]-volts[cnode]) + " " + (volts[anode]-volts[gnode]) + " " + triggerI + " "+ holdingI + " " + cresistance; } double ia, ic, ig, curcount_a, curcount_c, curcount_g; double lastvac, lastvag; double cresistance, triggerI, holdingI; final int hs = 8; Polygon poly; Point cathode[], gate[]; void setPoints() { super.setPoints(); int dir = 0; if (abs(dx) > abs(dy)) { dir = -sign(dx)*sign(dy); point2.y = point1.y; } else { dir = sign(dy)*sign(dx); point2.x = point1.x; } if (dir == 0) dir = 1; calcLeads(16); cathode = newPointArray(2); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); poly = createPolygon(pa[0], pa[1], lead2); gate = newPointArray(2); double leadlen = (dn-16)/2; int gatelen = sim.gridSize; gatelen += leadlen % sim.gridSize; if (leadlen < gatelen) { x2 = x; y2 = y; return; } interpPoint(lead2, point2, gate[0], gatelen/leadlen, gatelen*dir); interpPoint(lead2, point2, gate[1], gatelen/leadlen, sim.gridSize*2*dir); } void draw(Graphics g) { setBbox(point1, point2, hs); adjustBbox(gate[0], gate[1]); double v1 = volts[anode]; double v2 = volts[cnode]; draw2Leads(g); // draw arrow thingy setPowerColor(g, true); setVoltageColor(g, v1); g.fillPolygon(poly); // draw thing arrow is pointing to setVoltageColor(g, v2); drawThickLine(g, cathode[0], cathode[1]); drawThickLine(g, lead2, gate[0]); drawThickLine(g, gate[0], gate[1]); curcount_a = updateDotCount(ia, curcount_a); curcount_c = updateDotCount(ic, curcount_c); curcount_g = updateDotCount(ig, curcount_g); if (sim.dragElm != this) { drawDots(g, point1, lead2, curcount_a); drawDots(g, point2, lead2, curcount_c); drawDots(g, gate[1], gate[0], curcount_g); drawDots(g, gate[0], lead2, curcount_g+distance(gate[1], gate[0])); } drawPosts(g); } Point getPost(int n) { return (n == 0) ? point1 : (n == 1) ? point2 : gate[1]; } int getPostCount() { return 3; } int getInternalNodeCount() { return 1; } double getPower() { return (volts[anode]-volts[gnode])*ia + (volts[cnode]-volts[gnode])*ic; } double aresistance; void stamp() { sim.stampNonLinear(nodes[anode]); sim.stampNonLinear(nodes[cnode]); sim.stampNonLinear(nodes[gnode]); sim.stampNonLinear(nodes[inode]); sim.stampResistor(nodes[gnode], nodes[cnode], cresistance); diode.stamp(nodes[inode], nodes[gnode]); } void doStep() { double vac = volts[anode]-volts[cnode]; // typically negative double vag = volts[anode]-volts[gnode]; // typically positive if (Math.abs(vac-lastvac) > .01 || Math.abs(vag-lastvag) > .01) sim.converged = false; lastvac = vac; lastvag = vag; diode.doStep(volts[inode]-volts[gnode]); double icmult = 1/triggerI; double iamult = 1/holdingI - icmult; //System.out.println(icmult + " " + iamult); aresistance = (-icmult*ic + ia*iamult > 1) ? .0105 : 10e5; //System.out.println(vac + " " + vag + " " + sim.converged + " " + ic + " " + ia + " " + aresistance + " " + volts[inode] + " " + volts[gnode] + " " + volts[anode]); sim.stampResistor(nodes[anode], nodes[inode], aresistance); } void getInfo(String arr[]) { arr[0] = "SCR"; double vac = volts[anode]-volts[cnode]; double vag = volts[anode]-volts[gnode]; double vgc = volts[gnode]-volts[cnode]; arr[1] = "Ia = " + getCurrentText(ia); arr[2] = "Ig = " + getCurrentText(ig); arr[3] = "Vac = " + getVoltageText(vac); arr[4] = "Vag = " + getVoltageText(vag); arr[5] = "Vgc = " + getVoltageText(vgc); } void calculateCurrent() { ic = (volts[cnode]-volts[gnode])/cresistance; ia = (volts[anode]-volts[inode])/aresistance; ig = -ic-ia; } public EditInfo getEditInfo(int n) { // ohmString doesn't work here on linux if (n == 0) return new EditInfo("Trigger Current (A)", triggerI, 0, 0); if (n == 1) return new EditInfo("Holding Current (A)", holdingI, 0, 0); if (n == 2) return new EditInfo("Gate-Cathode Resistance (ohms)", cresistance, 0, 0); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0 && ei.value > 0) triggerI = ei.value; if (n == 1 && ei.value > 0) holdingI = ei.value; if (n == 2 && ei.value > 0) cresistance = ei.value; } } ================================================ FILE: src/TriodeElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TriodeElm extends CircuitElm { double mu, kg1; double curcountp, curcountc, curcountg, currentp, currentg, currentc; final double gridCurrentR = 6000; public TriodeElm(int xx, int yy) { super(xx, yy); mu = 93; kg1 = 680; setup(); } public TriodeElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); mu = new Double(st.nextToken()).doubleValue(); kg1 = new Double(st.nextToken()).doubleValue(); setup(); } void setup() { noDiagonal = true; } boolean nonLinear() { return true; } void reset() { volts[0] = volts[1] = volts[2] = 0; curcount = 0; } String dump() { return super.dump() + " " + mu + " " + kg1; } int getDumpType() { return 173; } Point plate[], grid[], cath[], midgrid, midcath; int circler; void setPoints() { super.setPoints(); plate = newPointArray(4); grid = newPointArray(8); cath = newPointArray(4); grid[0] = point1; int nearw = 8; interpPoint(point1, point2, plate[1], 1, nearw); int farw = 32; interpPoint(point1, point2, plate[0], 1, farw); int platew = 18; interpPoint2(point2, plate[1], plate[2], plate[3], 1, platew); circler = 24; interpPoint(point1, point2, grid[1], (dn-circler)/dn, 0); int i; for (i = 0; i != 3; i++) { interpPoint(grid[1], point2, grid[2+i*2], (i*3+1)/4.5, 0); interpPoint(grid[1], point2, grid[3+i*2], (i*3+2)/4.5, 0); } midgrid = point2; int cathw = 16; midcath = interpPoint(point1, point2, 1, -nearw); interpPoint2(point2, plate[1], cath[1], cath[2], -1, cathw); interpPoint(point2, plate[1], cath[3], -1.2, -cathw); interpPoint(point2, plate[1], cath[0], -farw/(double) nearw, cathw); } void draw(Graphics g) { g.setColor(Color.gray); drawThickCircle(g, point2.x, point2.y, circler); setBbox(point1, plate[0], 16); adjustBbox(cath[0].x, cath[1].y, point2.x+circler, point2.y+circler); setPowerColor(g, true); // draw plate setVoltageColor(g, volts[0]); drawThickLine(g, plate[0], plate[1]); drawThickLine(g, plate[2], plate[3]); // draw grid setVoltageColor(g, volts[1]); int i; for (i = 0; i != 8; i += 2) drawThickLine(g, grid[i], grid[i+1]); // draw cathode setVoltageColor(g, volts[2]); for (i = 0; i != 3; i++) drawThickLine(g, cath[i], cath[i+1]); // draw dots curcountp = updateDotCount(currentp, curcountp); curcountc = updateDotCount(currentc, curcountc); curcountg = updateDotCount(currentg, curcountg); if (sim.dragElm != this) { drawDots(g, plate[0], midgrid, curcountp); drawDots(g, midgrid, midcath, curcountc); drawDots(g, midcath, cath[1], curcountc+8); drawDots(g, cath[1], cath[0], curcountc+8); drawDots(g, point1, midgrid, curcountg); } drawPosts(g); } Point getPost(int n) { return (n == 0) ? plate[0] : (n == 1) ? grid[0] : cath[0]; } int getPostCount() { return 3; } double getPower() { return (volts[0]-volts[2])*current; } double lastv0, lastv1, lastv2; void doStep() { double vs[] = new double[3]; vs[0] = volts[0]; vs[1] = volts[1]; vs[2] = volts[2]; if (vs[1] > lastv1 + .5) vs[1] = lastv1 + .5; if (vs[1] < lastv1 - .5) vs[1] = lastv1 - .5; if (vs[2] > lastv2 + .5) vs[2] = lastv2 + .5; if (vs[2] < lastv2 - .5) vs[2] = lastv2 - .5; int grid = 1; int cath = 2; int plate = 0; double vgk = vs[grid] -vs[cath]; double vpk = vs[plate]-vs[cath]; if (Math.abs(lastv0-vs[0]) > .01 || Math.abs(lastv1-vs[1]) > .01 || Math.abs(lastv2-vs[2]) > .01) sim.converged = false; lastv0 = vs[0]; lastv1 = vs[1]; lastv2 = vs[2]; double ids = 0; double gm = 0; double Gds = 0; double ival = vgk+vpk/mu; currentg = 0; if (vgk > .01) { sim.stampResistor(nodes[grid], nodes[cath], gridCurrentR); currentg = vgk/gridCurrentR; } if (ival < 0) { // should be all zero, but that causes a singular matrix, // so instead we treat it as a large resistor Gds = 1e-8; ids = vpk*Gds; } else { ids = Math.pow(ival, 1.5)/kg1; double q = 1.5*Math.sqrt(ival)/kg1; // gm = dids/dgk; // Gds = dids/dpk; Gds = q; gm = q/mu; } currentp = ids; currentc = ids+currentg; double rs = -ids + Gds*vpk + gm*vgk; sim.stampMatrix(nodes[plate], nodes[plate], Gds); sim.stampMatrix(nodes[plate], nodes[cath], -Gds-gm); sim.stampMatrix(nodes[plate], nodes[grid], gm); sim.stampMatrix(nodes[cath], nodes[plate], -Gds); sim.stampMatrix(nodes[cath], nodes[cath], Gds+gm); sim.stampMatrix(nodes[cath], nodes[grid], -gm); sim.stampRightSide(nodes[plate], rs); sim.stampRightSide(nodes[cath ], -rs); } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); sim.stampNonLinear(nodes[2]); } void getInfo(String arr[]) { arr[0] = "triode"; double vbc = volts[0]-volts[1]; double vbe = volts[0]-volts[2]; double vce = volts[1]-volts[2]; arr[1] = "Vbe = " + getVoltageText(vbe); arr[2] = "Vbc = " + getVoltageText(vbc); arr[3] = "Vce = " + getVoltageText(vce); } // grid not connected to other terminals boolean getConnection(int n1, int n2) { return !(n1 == 1 || n2 == 1); } } ================================================ FILE: src/TunnelDiodeElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class TunnelDiodeElm extends CircuitElm { public TunnelDiodeElm(int xx, int yy) { super(xx, yy); setup(); } public TunnelDiodeElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); setup(); } boolean nonLinear() { return true; } void setup() { } int getDumpType() { return 175; } final int hs = 8; Polygon poly; Point cathode[]; void setPoints() { super.setPoints(); calcLeads(16); cathode = newPointArray(4); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); interpPoint2(lead1, lead2, cathode[2], cathode[3], .8, hs); poly = createPolygon(pa[0], pa[1], lead2); } void draw(Graphics g) { setBbox(point1, point2, hs); double v1 = volts[0]; double v2 = volts[1]; draw2Leads(g); // draw arrow thingy setPowerColor(g, true); setVoltageColor(g, v1); g.fillPolygon(poly); // draw thing arrow is pointing to setVoltageColor(g, v2); drawThickLine(g, cathode[0], cathode[1]); drawThickLine(g, cathode[2], cathode[0]); drawThickLine(g, cathode[3], cathode[1]); doDots(g); drawPosts(g); } void reset() { lastvoltdiff = volts[0] = volts[1] = curcount = 0; } double lastvoltdiff; double limitStep(double vnew, double vold) { // Prevent voltage changes of more than 1V when iterating. Wow, I thought it would be // much harder than this to prevent convergence problems. if (vnew > vold+1) return vold+1; if (vnew < vold-1) return vold-1; return vnew; } void stamp() { sim.stampNonLinear(nodes[0]); sim.stampNonLinear(nodes[1]); } static final double pvp = .1; static final double pip = 4.7e-3; static final double pvv = .37; static final double pvt = .026; static final double pvpp = .525; static final double piv = 370e-6; void doStep() { double voltdiff = volts[0] - volts[1]; if (Math.abs(voltdiff-lastvoltdiff) > .01) sim.converged = false; //System.out.println(voltdiff + " " + lastvoltdiff + " " + Math.abs(voltdiff-lastvoltdiff)); voltdiff = limitStep(voltdiff, lastvoltdiff); lastvoltdiff = voltdiff; double i = pip*Math.exp(-pvpp/pvt)*(Math.exp(voltdiff/pvt)-1) + pip*(voltdiff/pvp)*Math.exp(1-voltdiff/pvp) + piv*Math.exp(voltdiff-pvv); double geq = pip*Math.exp(-pvpp/pvt)*Math.exp(voltdiff/pvt)/pvt + pip*Math.exp(1-voltdiff/pvp)/pvp - Math.exp(1-voltdiff/pvp)*pip*voltdiff/(pvp*pvp) + Math.exp(voltdiff-pvv)*piv; double nc = i - geq*voltdiff; sim.stampConductance(nodes[0], nodes[1], geq); sim.stampCurrentSource(nodes[0], nodes[1], nc); } void calculateCurrent() { double voltdiff = volts[0] - volts[1]; current = pip*Math.exp(-pvpp/pvt)*(Math.exp(voltdiff/pvt)-1) + pip*(voltdiff/pvp)*Math.exp(1-voltdiff/pvp) + piv*Math.exp(voltdiff-pvv); } void getInfo(String arr[]) { arr[0] = "tunnel diode"; arr[1] = "I = " + getCurrentText(getCurrent()); arr[2] = "Vd = " + getVoltageText(getVoltageDiff()); arr[3] = "P = " + getUnitText(getPower(), "W"); } } ================================================ FILE: src/VCOElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class VCOElm extends ChipElm { public VCOElm(int xx, int yy) { super(xx, yy); } public VCOElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getChipName() { return "VCO"; } void setupPins() { sizeX = 2; sizeY = 4; pins = new Pin[6]; pins[0] = new Pin(0, SIDE_W, "Vi"); pins[1] = new Pin(3, SIDE_W, "Vo"); pins[1].output = true; pins[2] = new Pin(0, SIDE_E, "C"); pins[3] = new Pin(1, SIDE_E, "C"); pins[4] = new Pin(2, SIDE_E, "R1"); pins[4].output = true; pins[5] = new Pin(3, SIDE_E, "R2"); pins[5].output = true; } boolean nonLinear() { return true; } void stamp() { // output pin sim.stampVoltageSource(0, nodes[1], pins[1].voltSource); // attach Vi to R1 pin so its current is proportional to Vi sim.stampVoltageSource(nodes[0], nodes[4], pins[4].voltSource, 0); // attach 5V to R2 pin so we get a current going sim.stampVoltageSource(0, nodes[5], pins[5].voltSource, 5); // put resistor across cap pins to give current somewhere to go // in case cap is not connected sim.stampResistor(nodes[2], nodes[3], cResistance); sim.stampNonLinear(nodes[2]); sim.stampNonLinear(nodes[3]); } final double cResistance = 1e6; double cCurrent; int cDir; void doStep() { double vc = volts[3]-volts[2]; double vo = volts[1]; int dir = (vo < 2.5) ? 1 : -1; // switch direction of current through cap as we oscillate if (vo < 2.5 && vc > 4.5) { vo = 5; dir = -1; } if (vo > 2.5 && vc < .5) { vo = 0; dir = 1; } // generate output voltage sim.updateVoltageSource(0, nodes[1], pins[1].voltSource, vo); // now we set the current through the cap to be equal to the // current through R1 and R2, so we can measure the voltage // across the cap int cur1 = sim.nodeList.size() + pins[4].voltSource; int cur2 = sim.nodeList.size() + pins[5].voltSource; sim.stampMatrix(nodes[2], cur1, dir); sim.stampMatrix(nodes[2], cur2, dir); sim.stampMatrix(nodes[3], cur1, -dir); sim.stampMatrix(nodes[3], cur2, -dir); cDir = dir; } // can't do this in calculateCurrent() because it's called before // we get pins[4].current and pins[5].current, which we need void computeCurrent() { if (cResistance == 0) return; double c = cDir*(pins[4].current + pins[5].current) + (volts[3]-volts[2])/cResistance; pins[2].current = -c; pins[3].current = c; pins[0].current = -pins[4].current; } void draw(Graphics g) { computeCurrent(); drawChip(g); } int getPostCount() { return 6; } int getVoltageSourceCount() { return 3; } int getDumpType() { return 158; } } ================================================ FILE: src/VarRailElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class VarRailElm extends RailElm { Scrollbar slider; Label label; String sliderText; public VarRailElm(int xx, int yy) { super(xx, yy, WF_VAR); sliderText = "Voltage"; frequency = maxVoltage; createSlider(); } public VarRailElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); sliderText = st.nextToken(); while (st.hasMoreTokens()) sliderText += ' ' + st.nextToken(); createSlider(); } String dump() { return super.dump() + " " + sliderText; } int getDumpType() { return 172; } void createSlider() { waveform = WF_VAR; sim.main.add(label = new Label(sliderText, Label.CENTER)); int value = (int) ((frequency-bias)*100/(maxVoltage-bias)); sim.main.add(slider = new Scrollbar(Scrollbar.HORIZONTAL, value, 1, 0, 101)); sim.main.validate(); } double getVoltage() { frequency = slider.getValue() * (maxVoltage-bias) / 100. + bias; return frequency; } void delete() { sim.main.remove(label); sim.main.remove(slider); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Min Voltage", bias, -20, 20); if (n == 1) return new EditInfo("Max Voltage", maxVoltage, -20, 20); if (n == 2) { EditInfo ei = new EditInfo("Slider Text", 0, -1, -1); ei.text = sliderText; return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) bias = ei.value; if (n == 1) maxVoltage = ei.value; if (n == 2) { sliderText = ei.textf.getText(); label.setText(sliderText); } } int getShortcut() { return 0; } } ================================================ FILE: src/VoltageElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class VoltageElm extends CircuitElm { static final int FLAG_COS = 2; int waveform; static final int WF_DC = 0; static final int WF_AC = 1; static final int WF_SQUARE = 2; static final int WF_TRIANGLE = 3; static final int WF_SAWTOOTH = 4; static final int WF_PULSE = 5; static final int WF_VAR = 6; double frequency, maxVoltage, freqTimeZero, bias, phaseShift, dutyCycle; VoltageElm(int xx, int yy, int wf) { super(xx, yy); waveform = wf; maxVoltage = 5; frequency = 40; dutyCycle = .5; reset(); } public VoltageElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f); maxVoltage = 5; frequency = 40; waveform = WF_DC; dutyCycle = .5; try { waveform = new Integer(st.nextToken()).intValue(); frequency = new Double(st.nextToken()).doubleValue(); maxVoltage = new Double(st.nextToken()).doubleValue(); bias = new Double(st.nextToken()).doubleValue(); phaseShift = new Double(st.nextToken()).doubleValue(); dutyCycle = new Double(st.nextToken()).doubleValue(); } catch (Exception e) { } if ((flags & FLAG_COS) != 0) { flags &= ~FLAG_COS; phaseShift = pi/2; } reset(); } int getDumpType() { return 'v'; } String dump() { return super.dump() + " " + waveform + " " + frequency + " " + maxVoltage + " " + bias + " " + phaseShift + " " + dutyCycle; } /*void setCurrent(double c) { current = c; System.out.print("v current set to " + c + "\n"); }*/ void reset() { freqTimeZero = 0; curcount = 0; } double triangleFunc(double x) { if (x < pi) return x*(2/pi)-1; return 1-(x-pi)*(2/pi); } void stamp() { if (waveform == WF_DC) sim.stampVoltageSource(nodes[0], nodes[1], voltSource, getVoltage()); else sim.stampVoltageSource(nodes[0], nodes[1], voltSource); } void doStep() { if (waveform != WF_DC) sim.updateVoltageSource(nodes[0], nodes[1], voltSource, getVoltage()); } double getVoltage() { double w = 2*pi*(sim.t-freqTimeZero)*frequency + phaseShift; switch (waveform) { case WF_DC: return maxVoltage+bias; case WF_AC: return Math.sin(w)*maxVoltage+bias; case WF_SQUARE: return bias+((w % (2*pi) > (2*pi*dutyCycle)) ? -maxVoltage : maxVoltage); case WF_TRIANGLE: return bias+triangleFunc(w % (2*pi))*maxVoltage; case WF_SAWTOOTH: return bias+(w % (2*pi))*(maxVoltage/pi)-maxVoltage; case WF_PULSE: return ((w % (2*pi)) < 1) ? maxVoltage+bias : bias; default: return 0; } } final int circleSize = 17; void setPoints() { super.setPoints(); calcLeads((waveform == WF_DC || waveform == WF_VAR) ? 8 : circleSize*2); } void draw(Graphics g) { setBbox(x, y, x2, y2); draw2Leads(g); if (waveform == WF_DC) { setPowerColor(g, false); setVoltageColor(g, volts[0]); interpPoint2(lead1, lead2, ps1, ps2, 0, 10); drawThickLine(g, ps1, ps2); setVoltageColor(g, volts[1]); int hs = 16; setBbox(point1, point2, hs); interpPoint2(lead1, lead2, ps1, ps2, 1, hs); drawThickLine(g, ps1, ps2); } else { setBbox(point1, point2, circleSize); interpPoint(lead1, lead2, ps1, .5); drawWaveform(g, ps1); } updateDotCount(); if (sim.dragElm != this) { if (waveform == WF_DC) drawDots(g, point1, point2, curcount); else { drawDots(g, point1, lead1, curcount); drawDots(g, point2, lead2, -curcount); } } drawPosts(g); } void drawWaveform(Graphics g, Point center) { g.setColor(needsHighlight() ? selectColor : Color.gray); setPowerColor(g, false); int xc = center.x; int yc = center.y; drawThickCircle(g, xc, yc, circleSize); int wl = 8; adjustBbox(xc-circleSize, yc-circleSize, xc+circleSize, yc+circleSize); int xc2; switch (waveform) { case WF_DC: { break; } case WF_SQUARE: xc2 = (int) (wl*2*dutyCycle-wl+xc); xc2 = max(xc-wl+3, min(xc+wl-3, xc2)); drawThickLine(g, xc-wl, yc-wl, xc-wl, yc ); drawThickLine(g, xc-wl, yc-wl, xc2 , yc-wl); drawThickLine(g, xc2 , yc-wl, xc2 , yc+wl); drawThickLine(g, xc+wl, yc+wl, xc2 , yc+wl); drawThickLine(g, xc+wl, yc , xc+wl, yc+wl); break; case WF_PULSE: yc += wl/2; drawThickLine(g, xc-wl, yc-wl, xc-wl, yc ); drawThickLine(g, xc-wl, yc-wl, xc-wl/2, yc-wl); drawThickLine(g, xc-wl/2, yc-wl, xc-wl/2, yc); drawThickLine(g, xc-wl/2, yc, xc+wl, yc); break; case WF_SAWTOOTH: drawThickLine(g, xc , yc-wl, xc-wl, yc ); drawThickLine(g, xc , yc-wl, xc , yc+wl); drawThickLine(g, xc , yc+wl, xc+wl, yc ); break; case WF_TRIANGLE: { int xl = 5; drawThickLine(g, xc-xl*2, yc , xc-xl, yc-wl); drawThickLine(g, xc-xl, yc-wl, xc, yc); drawThickLine(g, xc , yc, xc+xl, yc+wl); drawThickLine(g, xc+xl, yc+wl, xc+xl*2, yc); break; } case WF_AC: { int i; int xl = 10; int ox = -1, oy = -1; for (i = -xl; i <= xl; i++) { int yy = yc+(int) (.95*Math.sin(i*pi/xl)*wl); if (ox != -1) drawThickLine(g, ox, oy, xc+i, yy); ox = xc+i; oy = yy; } break; } } if (sim.showValuesCheckItem.getState()) { String s = getShortUnitText(frequency, "Hz"); if (dx == 0 || dy == 0) drawValues(g, s, circleSize); } } int getVoltageSourceCount() { return 1; } double getPower() { return -getVoltageDiff()*current; } double getVoltageDiff() { return volts[1] - volts[0]; } void getInfo(String arr[]) { switch (waveform) { case WF_DC: case WF_VAR: arr[0] = "voltage source"; break; case WF_AC: arr[0] = "A/C source"; break; case WF_SQUARE: arr[0] = "square wave gen"; break; case WF_PULSE: arr[0] = "pulse gen"; break; case WF_SAWTOOTH: arr[0] = "sawtooth gen"; break; case WF_TRIANGLE: arr[0] = "triangle gen"; break; } arr[1] = "I = " + getCurrentText(getCurrent()); arr[2] = ((this instanceof RailElm) ? "V = " : "Vd = ") + getVoltageText(getVoltageDiff()); if (waveform != WF_DC && waveform != WF_VAR) { arr[3] = "f = " + getUnitText(frequency, "Hz"); arr[4] = "Vmax = " + getVoltageText(maxVoltage); int i = 5; if (bias != 0) arr[i++] = "Voff = " + getVoltageText(bias); else if (frequency > 500) arr[i++] = "wavelength = " + getUnitText(2.9979e8/frequency, "m"); arr[i++] = "P = " + getUnitText(getPower(), "W"); } } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo(waveform == WF_DC ? "Voltage" : "Max Voltage", maxVoltage, -20, 20); if (n == 1) { EditInfo ei = new EditInfo("Waveform", waveform, -1, -1); ei.choice = new Choice(); ei.choice.add("D/C"); ei.choice.add("A/C"); ei.choice.add("Square Wave"); ei.choice.add("Triangle"); ei.choice.add("Sawtooth"); ei.choice.add("Pulse"); ei.choice.select(waveform); return ei; } if (waveform == WF_DC) return null; if (n == 2) return new EditInfo("Frequency (Hz)", frequency, 4, 500); if (n == 3) return new EditInfo("DC Offset (V)", bias, -20, 20); if (n == 4) return new EditInfo("Phase Offset (degrees)", phaseShift*180/pi, -180, 180).setDimensionless(); if (n == 5 && waveform == WF_SQUARE) return new EditInfo("Duty Cycle", dutyCycle*100, 0, 100). setDimensionless(); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) maxVoltage = ei.value; if (n == 3) bias = ei.value; if (n == 2) { // adjust time zero to maintain continuity ind the waveform // even though the frequency has changed. double oldfreq = frequency; frequency = ei.value; double maxfreq = 1/(8*sim.timeStep); if (frequency > maxfreq) frequency = maxfreq; double adj = frequency-oldfreq; freqTimeZero = sim.t-oldfreq*(sim.t-freqTimeZero)/frequency; } if (n == 1) { int ow = waveform; waveform = ei.choice.getSelectedIndex(); if (waveform == WF_DC && ow != WF_DC) { ei.newDialog = true; bias = 0; } else if (waveform != WF_DC && ow == WF_DC) { ei.newDialog = true; } if ((waveform == WF_SQUARE || ow == WF_SQUARE) && waveform != ow) ei.newDialog = true; setPoints(); } if (n == 4) phaseShift = ei.value*pi/180; if (n == 5) dutyCycle = ei.value*.01; } } ================================================ FILE: src/WireElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class WireElm extends ResistorElm { public static boolean ideal = false; private static final double defaultResistance = 1E-06; public WireElm(int xx, int yy) { super(xx, yy); resistance = defaultResistance; } public WireElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, new StringTokenizer("0.0")); resistance = defaultResistance; } static final int FLAG_SHOWCURRENT = 1; static final int FLAG_SHOWVOLTAGE = 2; void draw(Graphics g) { setVoltageColor(g, volts[0]); drawThickLine(g, point1, point2); doDots(g); setBbox(point1, point2, 3); if (mustShowCurrent()) { String s = getShortUnitText(Math.abs(getCurrent()), "A"); drawValues(g, s, 4); } else if (mustShowVoltage()) { String s = getShortUnitText(volts[0], "V"); drawValues(g, s, 4); } drawPosts(g); } void calculateCurrent() { if (!ideal) { super.calculateCurrent(); } } void stamp() { if (ideal) { sim.stampVoltageSource(nodes[0], nodes[1], voltSource, 0); } else { sim.stampResistor(nodes[0], nodes[1], resistance); } } boolean mustShowCurrent() { return (flags & FLAG_SHOWCURRENT) != 0; } boolean mustShowVoltage() { return (flags & FLAG_SHOWVOLTAGE) != 0; } int getVoltageSourceCount() { if(ideal) { return 1; } else { return super.getVoltageSourceCount(); } } void getInfo(String arr[]) { arr[0] = "wire"; arr[1] = "I = " + getCurrentDText(getCurrent()); arr[2] = "V = " + getVoltageText(volts[0]); } double getPower() { if (ideal) { return 0; } else { return super.getPower(); } } double getVoltageDiff() { if (ideal) { return volts[0]; } else { return super.getVoltageDiff(); } } boolean isWire() { return ideal; } public EditInfo getEditInfo(int n) { if (n == 0) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Show Current", mustShowCurrent()); return ei; } if (n == 1) { EditInfo ei = new EditInfo("", 0, -1, -1); ei.checkbox = new Checkbox("Show Voltage", mustShowVoltage()); return ei; } return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) { if (ei.checkbox.getState()) flags = FLAG_SHOWCURRENT; else flags &= ~FLAG_SHOWCURRENT; } if (n == 1) { if (ei.checkbox.getState()) flags = FLAG_SHOWVOLTAGE; else flags &= ~FLAG_SHOWVOLTAGE; } } int getShortcut() { return 'w'; } int getDumpType() { return 'w'; } String dump() { int t = getDumpType(); return (t < 127 ? ((char)t)+" " : t+" ") + x + " " + y + " " + x2 + " " + y2 + " " + flags; } } ================================================ FILE: src/XorGateElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; class XorGateElm extends OrGateElm { public XorGateElm(int xx, int yy) { super(xx, yy); } public XorGateElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); } String getGateName() { return "XOR gate"; } boolean calcFunction() { int i; boolean f = false; for (i = 0; i != inputCount; i++) f ^= getInput(i); return f; } int getDumpType() { return 154; } int getShortcut() { return '4'; } } ================================================ FILE: src/ZenerElm.java ================================================ import java.awt.*; import java.util.StringTokenizer; // Zener code contributed by J. Mike Rollins // http://www.camotruck.net/rollins/simulator.html class ZenerElm extends DiodeElm { public ZenerElm(int xx, int yy) { super(xx, yy); zvoltage = default_zvoltage; setup(); } public ZenerElm(int xa, int ya, int xb, int yb, int f, StringTokenizer st) { super(xa, ya, xb, yb, f, st); zvoltage = new Double(st.nextToken()).doubleValue(); setup(); } void setup() { diode.leakage = 5e-6; // 1N4004 is 5.0 uAmp super.setup(); } int getDumpType() { return 'z'; } String dump() { return super.dump() + " " + zvoltage; } final int hs = 8; Polygon poly; Point cathode[]; Point wing[]; void setPoints() { super.setPoints(); calcLeads(16); cathode = newPointArray(2); wing = newPointArray(2); Point pa[] = newPointArray(2); interpPoint2(lead1, lead2, pa[0], pa[1], 0, hs); interpPoint2(lead1, lead2, cathode[0], cathode[1], 1, hs); interpPoint(cathode[0], cathode[1], wing[0], -0.2, -hs); interpPoint(cathode[1], cathode[0], wing[1], -0.2, -hs); poly = createPolygon(pa[0], pa[1], lead2); } void draw(Graphics g) { setBbox(point1, point2, hs); double v1 = volts[0]; double v2 = volts[1]; draw2Leads(g); // draw arrow thingy setPowerColor(g, true); setVoltageColor(g, v1); g.fillPolygon(poly); // draw thing arrow is pointing to setVoltageColor(g, v2); drawThickLine(g, cathode[0], cathode[1]); // draw wings on cathode drawThickLine(g, wing[0], cathode[0]); drawThickLine(g, wing[1], cathode[1]); doDots(g); drawPosts(g); } final double default_zvoltage = 5.6; void getInfo(String arr[]) { super.getInfo(arr); arr[0] = "Zener diode"; arr[5] = "Vz = " + getVoltageText(zvoltage); } public EditInfo getEditInfo(int n) { if (n == 0) return new EditInfo("Fwd Voltage @ 1A", fwdrop, 10, 1000); if (n == 1) return new EditInfo("Zener Voltage @ 5mA", zvoltage, 1, 25); return null; } public void setEditValue(int n, EditInfo ei) { if (n == 0) fwdrop = ei.value; if (n == 1) zvoltage = ei.value; setup(); } int getShortcut() { return 0; } } ================================================ FILE: src/circuits/3-cgand.txt ================================================ $ 1 5.0E-6 11.251013186076355 50 5.0 50 f 352 416 464 416 6 3.25 f 352 368 464 368 6 3.25 w 464 384 464 400 0 f 304 304 352 304 7 -1.75 f 224 304 272 304 7 -1.75 w 352 320 352 336 0 w 272 320 272 336 0 w 272 336 352 336 0 w 352 336 464 336 0 w 464 336 464 352 0 w 272 272 272 288 0 w 272 272 352 272 0 w 352 272 352 288 0 f 304 240 352 240 6 -1.75 f 304 192 352 192 6 -1.75 w 352 256 352 272 0 w 352 208 352 224 0 R 352 176 352 144 0 0 40.0 2.5 0.0 0.0 0.5 w 304 192 224 192 0 w 224 192 224 304 0 w 304 240 304 304 0 w 304 240 192 240 0 w 192 240 192 368 0 w 192 368 352 368 0 w 160 192 224 192 0 w 160 192 160 416 0 w 160 416 352 416 0 g 464 432 464 448 0 f 368 112 416 112 7 3.25 f 400 64 464 64 7 3.25 w 464 16 464 48 0 w 416 16 416 96 0 w 416 16 464 16 0 w 464 240 464 336 0 w 400 64 160 64 0 w 160 64 160 192 0 w 192 240 192 112 0 w 192 112 368 112 0 R 416 16 368 16 0 0 40.0 5.0 0.0 0.0 0.5 w 416 128 416 144 0 w 416 144 464 144 0 w 464 144 464 80 0 w 464 144 464 240 0 M 464 240 528 240 1 2.5 L 160 192 96 192 1 2 false 5.0 0.0 L 192 240 96 240 1 1 false 5.0 0.0 ================================================ FILE: src/circuits/3-cgor.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 f 368 368 480 368 6 3.25 w 480 384 480 400 0 w 368 320 368 336 0 w 288 320 288 336 0 w 288 336 368 336 0 w 480 336 480 352 0 w 288 272 288 288 0 w 288 272 368 272 0 w 368 272 368 288 0 w 368 256 368 272 0 w 368 208 368 224 0 R 368 176 368 144 0 0 40.0 2.5 0.0 0.0 0.5 w 320 192 240 192 0 w 240 192 240 304 0 w 320 240 320 304 0 w 320 240 208 240 0 w 208 240 208 368 0 w 208 368 368 368 0 w 176 192 240 192 0 w 176 192 176 416 0 w 176 416 368 416 0 f 416 64 480 64 7 3.25 w 480 16 480 48 0 w 432 16 480 16 0 w 480 240 480 336 0 M 480 240 544 240 1 2.5 w 416 64 176 64 0 w 176 64 176 192 0 w 208 240 208 112 0 L 176 192 80 192 1 2 false 5.0 0.0 L 208 240 80 240 1 1 false 5.0 0.0 R 432 16 384 16 0 0 40.0 5.0 0.0 0.0 0.5 w 480 144 480 240 0 f 416 112 480 112 7 3.25 w 480 80 480 96 0 w 480 128 480 144 0 w 208 112 416 112 0 f 368 416 432 416 6 3.25 g 480 400 480 416 0 g 432 432 432 448 0 w 368 336 432 336 0 w 432 336 432 400 0 w 432 336 480 336 0 f 240 304 288 304 6 -1.75 f 320 304 368 304 6 -1.75 f 320 192 368 192 7 -1.75 f 320 240 368 240 7 -1.75 ================================================ FILE: src/circuits/3-f211.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 f 288 288 352 288 6 -1.75 w 352 272 352 240 0 w 352 240 352 208 0 f 288 192 352 192 7 3.25 w 288 192 288 240 0 w 288 240 288 288 0 R 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5 M 352 240 400 240 1 2.5 L 288 240 240 240 1 0 false 5.0 0.0 R 352 304 352 352 0 0 40.0 2.5 0.0 0.0 0.5 ================================================ FILE: src/circuits/3-f220.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 f 288 288 352 288 6 3.25 w 352 272 352 240 0 w 352 240 352 208 0 f 288 192 352 192 7 0.75 w 288 192 288 240 0 w 288 240 288 288 0 R 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5 M 352 240 400 240 1 2.5 L 288 240 240 240 1 0 false 5.0 0.0 g 352 304 352 336 0 ================================================ FILE: src/circuits/3-f221.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 f 288 288 352 288 6 0.75 w 352 272 352 240 0 w 352 240 352 208 0 f 288 192 352 192 7 0.75 w 288 192 288 240 0 w 288 240 288 288 0 R 352 176 352 128 0 0 40.0 5.0 0.0 0.0 0.5 M 352 240 400 240 1 2.5 L 288 240 240 240 1 0 false 5.0 0.0 R 352 304 352 352 0 0 40.0 2.5 0.0 0.0 0.5 ================================================ FILE: src/circuits/3-invert.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 f 336 352 384 352 6 3.25 f 256 272 304 272 6 -1.75 f 256 208 304 208 7 -1.75 w 304 320 384 320 0 w 384 320 384 336 0 w 256 272 256 352 0 w 256 352 336 352 0 w 304 224 304 256 0 R 304 192 304 160 0 0 40.0 2.5 0.0 0.0 0.5 f 256 128 384 128 7 3.25 w 256 128 256 208 0 R 384 112 384 80 0 0 40.0 5.0 0.0 0.0 0.5 g 384 368 384 400 0 w 384 240 384 320 0 w 384 144 384 240 0 M 384 240 448 240 1 2.5 w 256 272 256 240 0 w 256 240 256 208 0 L 256 240 192 240 1 2 false 5.0 0.0 w 304 288 304 320 0 ================================================ FILE: src/circuits/3way.txt ================================================ $ 1 5.0E-6 3 44 120.0 15 v 32 320 32 80 0 1 60.0 120.0 0.0 r 496 80 496 320 0 150.0 w 32 80 112 80 0 w 416 80 496 80 0 S 112 208 192 208 0 true false 0 w 112 80 112 208 0 w 416 80 416 208 0 S 416 208 336 208 0 false false 0 w 192 192 336 192 0 w 336 224 192 224 0 w 32 320 496 320 0 ================================================ FILE: src/circuits/4way.txt ================================================ $ 1 5.0E-6 3 44 120.0 15 v 32 320 32 80 0 1 60.0 120.0 0.0 r 480 80 480 320 0 150.0 w 32 80 80 80 0 S 336 176 240 176 0 false false 2 S 336 240 240 240 0 false false 2 w 432 80 480 80 0 w 32 320 80 320 0 w 80 320 480 320 0 w 208 256 240 256 0 w 208 160 240 160 0 w 240 192 240 224 0 S 80 208 176 208 0 false false 0 w 80 80 80 208 0 w 176 224 240 224 0 w 208 160 208 192 0 w 176 192 208 192 0 w 208 192 208 256 0 S 432 208 336 208 0 false false 0 w 336 176 336 192 0 w 336 224 336 240 0 w 432 80 432 208 0 ================================================ FILE: src/circuits/555int.txt ================================================ $ 3 5.0E-6 5 64 7.0 a 288 168 384 168 1 5.0 0.0 a 288 264 384 264 1 5.0 0.0 r 240 56 240 104 0 5000.0 r 240 104 240 152 0 5000.0 w 240 152 240 280 0 r 240 280 240 328 0 5000.0 g 240 328 240 336 0 w 240 152 288 152 0 w 240 104 272 104 0 w 272 104 272 280 0 w 272 280 288 280 0 w 464 176 464 192 0 w 384 184 384 192 0 w 384 192 464 240 0 w 464 240 464 256 0 w 384 240 384 248 0 w 384 240 464 192 0 R 240 56 240 24 0 0 40.0 10.0 0.0 R 88 56 88 24 0 0 40.0 10.0 0.0 r 88 56 88 120 0 10000.0 r 88 120 88 184 0 10000.0 w 88 120 216 120 0 w 216 120 216 352 0 w 88 184 88 248 0 c 88 248 88 352 0 3.0E-7 0 g 88 352 88 368 0 r 384 368 464 368 0 10000.0 w 464 176 496 176 0 w 464 368 496 368 0 153 384 256 464 256 1 2 5.0 153 384 176 464 176 1 2 0.0 w 496 176 496 368 0 O 464 256 544 256 0 w 88 184 288 184 0 w 88 248 288 248 0 t 328 368 296 368 0 1 -7.876671689823544 4.999999997999999E-10 w 216 352 296 352 0 g 296 384 296 400 0 w 328 368 384 368 0 x 120 115 136 115 0 16 discharge x 129 178 145 178 0 16 trigger x 120 242 136 242 0 16 threshold w 272 104 272 56 0 x 284 62 300 62 0 16 control o 24 16 0 3 10.0 7.8125E-4 0 o 32 32 0 10 5.0 9.765625E-5 1 ================================================ FILE: src/circuits/555lowduty.txt ================================================ $ 1 5.0E-6 10 69 10.0 50 165 224 144 272 144 0 0.0 w 224 176 192 176 0 r 192 176 192 240 0 150000.0 w 192 240 224 240 0 w 192 240 192 272 0 w 192 272 224 272 0 w 192 272 192 336 0 c 192 336 192 384 0 1.0E-7 4.232783461263634 g 192 384 192 400 0 r 192 336 304 336 0 10000.0 d 352 336 304 336 0 w 352 208 352 336 0 R 288 112 288 80 0 0 40.0 10.0 0.0 O 352 208 416 208 0 o 7 16 0 3 10.0 0.0015625 0 o 13 64 0 10 10.0 9.765625E-5 1 ================================================ FILE: src/circuits/555missing.txt ================================================ $ 1 5.0E-6 10.391409633455755 56 5.0 50 165 336 176 448 176 0 5.0 w 336 208 336 304 0 w 336 208 304 208 0 w 304 208 304 304 0 c 304 304 304 368 0 9.999999999999999E-6 -0.21686387276521343 g 304 368 304 384 0 r 304 208 304 144 0 1000.0 w 304 144 400 144 0 O 464 240 528 240 0 82 304 144 304 96 0 0 40.0 5.0 0.0 0.0 0.5 t 208 336 256 336 0 -1 0.0 0.21686387276521343 w 256 320 256 304 0 r 256 304 304 304 0 100 w 256 352 256 368 0 w 256 368 304 368 0 w 208 272 208 336 0 152 96 272 208 272 0 2 0.0 82 96 288 96 336 0 2 60.0 2.5 2.5 0.0 0.5 L 96 256 96 208 0 true false 5.0 0.0 w 208 272 336 272 0 o 19 64 0 6 5.0 9.765625E-5 0 input o 8 64 0 6 5.0 9.765625E-5 0 output ================================================ FILE: src/circuits/555monostable.txt ================================================ $ 1 5.0E-6 10 56 5.0 50 165 208 144 320 144 0 0.0 w 208 176 208 272 0 w 208 176 176 176 0 w 208 240 128 240 0 w 176 176 176 272 0 c 176 272 176 320 0 9.999999999999999E-6 0.04950495049504963 g 176 320 176 336 0 r 176 176 176 112 0 1000.0 w 176 112 272 112 0 R 128 112 48 112 0 0 40.0 5.0 0.0 O 336 208 400 208 0 r 128 112 128 240 0 100.0 w 128 112 176 112 0 c 128 240 80 240 0 1.0E-5 0.7835212122555424 L 80 240 48 240 0 false true 5.0 0.0 o 14 64 0 6 5.0 9.765625E-5 0 o 10 64 0 6 5.0 9.765625E-5 0 h 2 7 5 ================================================ FILE: src/circuits/555pulsemod.txt ================================================ $ 1 5.0E-6 4.8 56 5.0 50 165 240 128 256 128 0 5.0 R 304 96 304 80 0 0 40.0 5.0 0.0 R 304 288 304 336 0 3 20.0 2.0 3.0 O 368 192 416 192 0 w 240 160 208 160 0 r 208 160 208 96 0 300.0 w 208 96 304 96 0 w 208 256 240 256 0 c 208 256 208 304 0 3.0E-6 2.1430988725222426 g 208 304 208 320 0 w 208 224 208 256 0 w 208 224 240 224 0 r 208 160 208 224 0 300.0 o 2 32 0 6 5.0 3.90625E-4 0 ctl o 3 32 0 6 5.0 9.765625E-5 0 output ================================================ FILE: src/circuits/555saw.txt ================================================ $ 1 5.0E-6 16.817414165184545 66 15.0 50 r 240 112 240 48 0 39000.0 r 192 128 192 48 0 27000.0 r 192 128 192 208 0 120000.0 w 192 48 240 48 0 R 192 48 144 48 0 0 40.0 15.0 0.0 0.0 0.5 w 240 144 240 208 1 g 192 208 192 224 0 w 240 208 240 272 0 w 240 272 240 304 0 w 240 304 240 368 0 c 240 368 240 400 0 2.0E-7 5.858523256602457 g 240 400 240 416 0 r 240 208 288 208 0 10000.0 w 288 272 240 272 0 w 240 304 288 304 0 w 240 48 352 48 0 w 352 48 352 144 0 O 240 368 468 368 0 t 192 128 240 128 0 -1 6.398899615692838 -0.5042009986318234 100.0 165 288 176 304 176 2 15.0 w 352 48 416 48 0 w 416 48 416 208 0 o 17 64 0 42 11.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/555schmitt.txt ================================================ $ 1 5.0E-6 10.391409633455755 56 5.0 50 165 304 160 416 160 0 0.0 w 256 128 368 128 0 R 256 128 144 128 0 0 40.0 5.0 0.0 O 432 224 496 224 0 w 256 288 256 256 0 w 256 256 304 256 0 w 256 288 304 288 0 v 256 256 192 256 0 1 400.0 1 0.0 R 192 256 144 256 0 1 40.0 2.5 2.5 p 256 288 256 336 0 g 256 336 256 352 0 o 9 64 0 6 6.1 9.765625E-5 0 o 3 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/555sequencer.txt ================================================ $ 3 5.0E-6 2.800975890892825 50 5.0 50 165 160 208 168 208 1 -0.0 w 160 224 152 224 0 w 152 224 152 272 0 w 152 272 160 272 0 c 152 272 152 336 0 2.0E-6 0.04950495049504953 w 152 224 152 192 0 r 152 192 152 136 0 1000.0 r 112 192 112 136 0 100.0 w 112 192 112 256 0 w 112 256 160 256 0 c 112 256 72 256 0 1.0E-5 4.534530440025719E-8 L 72 256 48 256 0 false true 5.0 0.0 w 112 136 152 136 0 w 152 136 192 136 0 w 192 136 192 192 0 82 112 136 48 136 0 0 40.0 5.0 0.0 0.0 0.5 g 152 336 152 352 0 w 224 240 224 256 0 c 224 256 272 256 0 1.0E-5 -4.9999993594834615 w 272 256 272 192 0 r 272 136 272 192 0 100.0 r 312 136 312 192 0 1000.0 w 192 136 272 136 0 w 272 136 312 136 0 165 320 208 352 208 1 -0.0 w 352 192 352 136 0 w 352 136 312 136 0 w 312 224 320 224 0 w 312 192 312 224 0 w 312 224 312 272 0 w 312 272 320 272 0 w 272 256 320 256 0 c 312 272 312 336 0 2.0E-6 0.04950495049504953 g 312 336 312 352 0 w 384 240 384 256 0 c 384 256 432 256 0 1.0E-5 -4.9999935925136505 w 432 256 432 192 0 r 432 192 432 136 0 100.0 r 472 136 472 192 0 1000.0 w 352 136 432 136 0 w 432 136 472 136 0 165 480 208 488 208 1 0.0 w 472 192 472 224 0 w 472 224 480 224 0 w 472 224 472 272 0 w 472 272 480 272 0 w 512 192 512 136 0 w 512 136 472 136 0 w 432 256 480 256 0 c 472 272 472 336 0 2.0E-6 0.04950495049504953 g 472 336 472 352 0 M 224 256 224 328 0 2.5 M 384 256 384 328 0 2.5 M 544 240 584 240 0 2.5 o 11 16 0 38 5.1 0.0015625 0 -1 o 51 16 0 38 7.781982421875E-5 4.8828125E-5 0 -1 o 52 16 0 38 5.1 9.765625E-5 0 -1 o 53 16 0 38 5.1 9.765625E-5 0 -1 ================================================ FILE: src/circuits/555square.txt ================================================ $ 1 5.0E-6 5.023272298708815 64 7.0 50 w 272 176 240 176 0 r 240 176 240 240 0 10000.0 w 240 240 272 240 0 w 240 240 240 272 0 w 240 272 272 272 0 c 240 272 240 336 0 3.0E-7 6.6394202099608295 g 240 336 240 352 0 r 240 176 240 112 0 10000.0 w 240 112 336 112 0 R 240 112 176 112 0 0 40.0 10.0 0.0 0.0 0.5 O 400 208 464 208 0 165 272 144 288 144 2 10.0 w 336 112 400 112 0 w 400 112 400 176 0 o 5 32 0 35 10.0 0.0015625 0 -1 o 10 32 0 42 10.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/7segdecoder.txt ================================================ $ 3 5.0E-6 10.20027730826997 50 5.0 50 L 240 40 240 16 2 0 false 5.0 0.0 L 288 40 288 16 2 1 false 5.0 0.0 L 336 40 336 16 2 0 false 5.0 0.0 L 384 40 384 16 2 1 false 5.0 0.0 I 240 40 240 88 0 0.5 I 288 40 288 88 0 0.5 I 336 40 336 88 0 0.5 I 384 40 384 88 0 0.5 w 288 40 312 40 0 w 312 40 312 104 0 151 40 176 40 224 1 4 0.0 151 96 176 96 224 1 3 5.0 151 152 176 152 224 1 2 5.0 151 208 176 208 224 1 4 5.0 151 568 176 568 224 1 3 5.0 151 520 176 520 224 1 3 5.0 151 472 176 472 224 1 3 5.0 151 424 176 424 224 1 3 5.0 151 368 176 368 224 1 3 5.0 150 272 176 272 224 1 2 5.0 152 320 176 320 224 1 2 5.0 w 312 104 88 104 0 w 88 104 88 176 0 w 312 104 480 104 0 w 480 104 528 104 0 w 528 104 576 104 0 w 576 104 576 176 0 w 528 176 528 104 0 w 480 176 480 104 0 w 336 40 360 40 0 w 360 40 360 112 0 w 160 176 160 112 0 w 96 176 96 112 0 w 96 112 160 112 0 w 160 112 360 112 0 w 360 112 424 112 0 w 424 112 424 176 0 w 424 112 568 112 0 w 568 112 568 176 0 w 384 40 408 40 0 w 408 40 408 120 0 w 408 120 520 120 0 w 520 120 520 176 0 w 408 120 376 120 0 w 376 176 376 120 0 w 376 120 224 120 0 w 224 120 224 176 0 w 224 120 104 120 0 w 104 120 104 176 0 w 240 88 240 128 0 w 240 128 216 128 0 w 216 128 216 176 0 w 216 128 24 128 0 w 24 128 24 176 0 w 240 128 328 128 0 w 328 128 328 176 0 w 288 88 288 136 0 w 280 176 280 136 0 w 280 136 288 136 0 w 200 176 200 136 0 w 280 136 200 136 0 w 200 136 144 136 0 w 144 136 144 176 0 w 144 136 32 136 0 w 32 136 32 176 0 w 288 136 360 136 0 w 360 136 360 176 0 w 360 136 432 136 0 w 432 136 432 176 0 w 336 88 336 144 0 w 336 144 368 144 0 w 368 144 368 176 0 w 368 144 472 144 0 w 472 144 472 176 0 w 336 144 264 144 0 w 264 144 264 176 0 w 264 144 192 144 0 w 192 144 192 176 0 w 192 144 48 144 0 w 48 144 48 176 0 w 384 88 384 152 0 w 472 144 512 144 0 w 512 144 512 176 0 w 384 152 416 152 0 w 416 152 416 176 0 w 416 152 464 152 0 w 464 152 464 176 0 w 464 152 560 152 0 w 560 152 560 176 0 w 384 152 240 152 0 w 240 152 56 152 0 w 56 152 56 176 0 w 272 224 296 224 0 w 296 224 296 176 0 w 296 176 312 176 0 150 56 288 56 336 1 4 0.0 150 232 288 232 336 1 4 5.0 150 384 288 384 336 1 4 5.0 150 336 288 336 336 1 3 5.0 150 288 288 288 336 1 2 5.0 150 176 288 176 336 1 3 5.0 150 120 288 120 336 1 4 5.0 w 40 224 40 288 0 w 240 152 240 232 0 w 240 232 168 232 0 w 168 232 168 288 0 w 176 288 176 240 0 w 176 240 240 240 0 w 240 240 240 288 0 w 240 240 400 240 0 w 400 240 400 288 0 w 400 240 472 240 0 w 472 240 472 224 0 w 184 288 184 256 0 w 184 256 128 256 0 w 128 256 128 288 0 w 128 256 64 256 0 w 64 256 64 288 0 w 48 288 48 248 0 w 72 288 72 264 0 w 72 264 136 264 0 w 136 264 136 288 0 w 48 248 96 248 0 w 96 248 96 224 0 w 96 248 112 248 0 w 112 248 112 288 0 w 152 224 152 232 0 w 152 232 104 232 0 w 104 232 104 288 0 w 392 288 392 248 0 w 392 248 344 248 0 w 344 248 344 288 0 w 392 248 568 248 0 w 568 248 568 224 0 w 112 248 224 248 0 w 224 248 224 288 0 w 184 256 216 256 0 w 216 256 216 288 0 w 208 224 208 264 0 w 136 264 208 264 0 w 208 264 368 264 0 w 368 264 368 288 0 w 376 288 376 256 0 w 376 256 328 256 0 w 328 256 328 288 0 w 328 256 280 256 0 w 280 256 280 288 0 w 320 224 328 224 0 w 328 224 328 256 0 w 280 256 216 256 0 w 248 288 248 232 0 w 248 232 368 232 0 w 368 232 368 224 0 w 296 288 296 272 0 w 296 272 424 272 0 w 424 272 424 224 0 w 336 288 336 280 0 w 336 280 520 280 0 w 520 280 520 224 0 157 432 320 552 320 0 w 432 320 416 320 0 w 416 320 416 336 0 w 416 336 384 336 0 w 432 352 336 352 0 w 336 352 336 336 0 w 432 384 288 384 0 w 288 384 288 336 0 w 432 416 232 416 0 w 232 416 232 336 0 w 496 448 176 448 0 w 176 448 176 336 0 w 528 448 528 456 0 w 528 456 120 456 0 w 120 456 120 336 0 w 560 448 560 464 0 w 560 464 56 464 0 w 56 464 56 336 0 ================================================ FILE: src/circuits/allpass1.txt ================================================ $ 1 5.0E-6 10.634267539816555 50 5.0 50 a 320 224 416 224 0 15.0 -15.0 r 320 208 240 208 0 1000.0 r 320 240 240 240 0 1000.0 w 320 208 320 144 0 r 320 144 416 144 0 1000.0 w 416 144 416 224 0 c 320 240 320 320 0 1.0E-6 -3.138168736927825 g 320 320 320 336 0 w 240 208 240 240 0 170 240 208 192 208 3 10.0 2000.0 5.0 0.1 O 416 224 480 224 0 o 9 8 0 34 6.0 0.00625 0 -1 input o 10 8 0 34 6.0 9.765625E-55 0 -1 output ================================================ FILE: src/circuits/allpass2.txt ================================================ $ 1 5.0E-6 10.634267539816555 55 5.0 50 a 320 224 416 224 0 15.0 -15.0 r 320 208 240 208 0 1000.0 r 320 240 240 240 0 1000.0 w 320 208 320 144 0 r 320 144 416 144 0 1000.0 w 416 144 416 224 0 c 320 240 320 320 0 1.0E-6 -4.292934919713338 g 320 320 320 336 0 w 240 208 240 240 0 O 416 224 480 224 0 R 240 208 192 208 0 2 100.0 5.0 0.0 0.0 0.5 o 9 16 0 34 24.0 9.765625E-55 0 -1 output ================================================ FILE: src/circuits/amdetect.txt ================================================ $ 4 5.0E-6 25.23 50 5.0 50 r 144 272 208 272 0 3000.0 l 208 144 208 272 0 0.0010 0.18734471432590385 w 208 144 272 144 0 c 272 144 272 272 0 2.8144799999999998E-6 -2.5493952165122247 w 208 272 272 272 0 c 400 144 400 272 0 3.0E-7 3.6693609627456207 w 400 144 464 144 0 r 464 144 464 272 0 47000.0 w 400 272 464 272 0 w 144 144 208 144 0 A 144 144 144 112 0 g 144 272 144 320 0 p 144 144 144 272 0 d 336 144 400 144 0 w 272 144 336 144 0 w 272 272 336 272 0 w 336 272 400 272 0 p 336 144 336 272 0 x 260 127 276 127 0 20 C1 x 387 127 403 127 0 20 C2 o 12 8 0 6 40.0 9.765625E-5 0 antenna o 17 4 0 14 10.0 9.765625E-5 1 carrier o 7 256 0 14 10.0 9.765625E-5 2 out h 1 1 3 ================================================ FILE: src/circuits/amp-dfdx.txt ================================================ $ 1 5.0E-6 10 57 5.0 v 112 256 112 96 0 3 40.0 5.0 0.0 g 112 256 112 304 0 w 352 128 352 192 0 w 208 128 208 176 0 w 112 256 208 256 0 w 208 208 208 256 0 a 208 192 352 192 4 c 112 96 208 96 0 2.0E-6 0.16559840149986407 r 208 128 352 128 0 5000.0 w 208 96 208 128 0 O 352 192 416 192 0 o 0 32 0 2 10.0 0.0125 0 o 10 64 0 2 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/amp-diff.txt ================================================ $ 1 5.0E-6 10 57 5.0 50 a 288 192 432 192 0 15.0 -15.0 w 288 112 288 176 0 w 432 192 432 112 0 r 288 112 432 112 0 1000.0 r 192 112 288 112 0 1000.0 r 288 208 288 256 0 1000.0 g 288 256 288 304 0 r 288 208 192 208 0 1000.0 R 192 112 128 112 0 1 60.0 5.0 0.0 O 432 192 496 192 0 v 192 208 128 208 0 2 120.0 1.0 0.0 R 128 208 96 208 0 1 60.0 5.0 0.0 p 192 208 192 256 0 g 192 256 192 304 0 o 8 64 0 2 7.0 0.025 0 o 12 64 0 2 7.0 9.765625E-5 0 o 9 64 0 2 2.5 2.44140625E-5 1 ================================================ FILE: src/circuits/amp-follower.txt ================================================ $ 1 5.0E-6 10.391409633455755 57 5.0 50 v 96 224 96 80 0 1 40.0 5.0 0.0 0.0 0.5 g 96 224 96 272 0 w 192 176 192 224 0 a 192 160 320 160 1 15.0 -15.0 w 320 160 320 224 0 w 96 80 192 80 0 w 192 80 192 144 0 w 192 224 320 224 0 O 384 160 432 160 0 w 320 160 384 160 0 r 384 160 384 224 0 1000.0 g 384 224 384 272 0 o 0 64 0 34 5.0 9.765625E-5 0 -1 o 8 64 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/amp-fullrect.txt ================================================ $ 1 5.0E-6 16 62 1.0 50 a 176 288 272 288 0 15.0 -15.0 g 176 304 176 336 0 w 272 288 272 240 0 d 272 240 176 240 0 w 272 288 304 288 0 d 304 192 304 288 0 w 176 240 176 272 0 w 176 240 176 192 0 r 176 192 304 192 0 1000.0 r 176 192 176 128 0 1000.0 r 176 128 304 128 0 1000.0 r 304 128 304 192 0 500.0 a 352 144 448 144 0 15.0 -15.0 w 304 128 352 128 0 w 352 128 352 96 0 r 352 96 448 96 0 1000.0 w 448 96 448 144 0 g 352 160 352 192 0 O 448 144 496 144 0 R 176 128 128 128 0 1 40.0 1.0 0.0 o 19 64 0 2 5.0 0.1 o 18 64 0 2 5.0 9.765625E-5 ================================================ FILE: src/circuits/amp-integ.txt ================================================ $ 1 5.0E-6 10.391409633455755 57 5.0 50 g 96 224 96 272 0 w 336 112 336 160 0 w 192 80 192 112 0 w 192 112 192 144 0 w 192 176 192 224 0 a 192 160 336 160 0 15.0 -15.0 c 192 112 336 112 0 5.8E-6 0 O 336 160 400 160 0 v 96 224 96 144 0 2 40.0 5.0 0.0 3.141592653589793 0.5 v 96 144 96 80 0 2 80.0 2.0 0.0 0.0 0.5 p 128 224 128 80 0 w 96 224 128 224 0 w 128 224 192 224 0 w 96 80 128 80 0 r 128 80 192 80 0 1000.0 o 10 32 0 34 10.0 9.765625E-5 0 -1 input o 7 32 0 34 11.0 9.765625E-5 1 -1 integral ================================================ FILE: src/circuits/amp-invert.txt ================================================ $ 1 5.0E-6 10 57 5.0 v 96 256 96 112 0 1 40.0 5.0 0.0 g 96 256 96 304 0 r 96 112 192 112 0 1000.0 r 192 144 336 144 0 3000.0 w 336 144 336 192 0 w 192 112 192 144 0 w 192 144 192 176 0 w 96 256 192 256 0 w 192 208 192 256 0 a 192 192 336 192 0 O 336 192 400 192 0 o 0 64 0 2 5.0 0.025 o 10 64 0 2 20.0 9.765625E-5 ================================================ FILE: src/circuits/amp-noninvert.txt ================================================ $ 1 5.0E-6 10 57 5.0 v 96 256 96 112 0 1 40.0 5.0 0.0 g 96 256 96 304 0 w 192 208 192 256 0 a 192 192 336 192 1 w 336 192 336 256 0 r 192 256 336 256 0 2000.0 r 96 256 192 256 0 1000.0 w 96 112 192 112 0 w 192 112 192 176 0 O 336 192 400 192 0 o 0 64 0 2 5.0 9.765625E-5 o 9 64 0 2 10.0 9.765625E-5 ================================================ FILE: src/circuits/amp-rect.txt ================================================ $ 1 5.0E-6 10 71 1.0 a 240 192 352 192 0 w 240 176 240 128 0 d 352 192 352 128 0 w 208 176 240 176 0 r 208 176 128 176 0 10000.0 w 208 176 208 256 0 w 208 256 352 256 0 d 352 256 352 192 0 r 240 128 352 128 0 10000.0 R 128 176 96 176 0 1 40.0 0.5 0.0 g 240 208 240 224 0 O 352 128 416 128 0 o 9 64 0 2 0.625 9.765625E-5 o 11 64 0 2 0.625 4.8828125E-5 ================================================ FILE: src/circuits/amp-schmitt.txt ================================================ $ 1 5.0E-6 10 66 5.0 a 320 208 432 208 0 15.0 -15.0 w 432 208 432 272 0 r 432 272 288 272 0 100000.0 w 288 224 320 224 0 w 288 224 288 272 0 w 288 224 288 144 0 r 288 144 288 80 0 10000.0 r 288 272 288 336 0 10000.0 g 288 336 288 368 0 O 432 208 480 208 0 R 288 80 288 48 0 0 40.0 10.0 0.0 w 320 192 224 192 0 v 224 192 160 192 0 1 40.0 5.0 0.0 R 160 192 128 192 0 1 1000.0 1.0 5.0 p 224 192 224 336 0 w 224 336 256 336 0 w 256 336 288 336 0 p 256 224 256 336 0 w 256 224 288 224 0 o 14 32 0 2 11.0 9.765625E-5 0 in o 17 64 0 2 11.0 9.765625E-5 1 threshold o 14 64 0 226 20.0 25.6 2 9 out vs in ================================================ FILE: src/circuits/amp-sum.txt ================================================ $ 1 5.0E-6 16 57 5.0 50 a 288 208 432 208 0 15.0 -15.0 w 288 128 288 192 0 w 432 208 432 128 0 r 288 128 432 128 0 1000.0 w 288 224 288 272 0 g 288 272 288 304 0 w 288 192 240 192 0 w 240 192 240 160 0 w 240 192 240 224 0 r 240 160 176 160 0 1000.0 r 176 224 240 224 0 1000.0 R 176 160 128 160 0 1 200.0 5.0 0.0 R 176 224 128 224 0 2 20.0 2.0 0.0 O 432 208 496 208 0 o 11 64 0 2 5.0 0.025 0 o 12 64 0 2 5.0 0.0125 0 o 13 64 0 2 10.0 9.765625E-5 1 ================================================ FILE: src/circuits/bandpass.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 46 w 352 144 352 208 0 w 352 288 352 336 0 w 304 288 352 288 0 w 352 288 400 288 0 w 304 208 352 208 0 w 352 208 400 208 0 l 304 208 304 288 0 0.5 0 c 400 208 400 288 0 3.17E-5 0 r 240 144 352 144 0 250.0 O 352 144 448 144 0 g 352 336 352 352 0 170 240 144 208 144 3 10.0 150.0 5.0 0.5 o 11 128 0 34 5.0 9.765625E-5 0 -1 o 9 128 0 34 5.0 9.765625E-5 1 -1 h 1 6 7 ================================================ FILE: src/circuits/besselbutter.txt ================================================ $ 1 5.0E-6 1.1685319768402522 49 5.0 50 c 208 96 208 192 0 6.083084599140672E-6 -4.999993387010308 l 144 96 208 96 0 0.022668006177034163 -0.09999921210610777 w 464 96 528 96 0 r 528 96 528 192 0 50.0 g 208 192 208 208 0 g 528 192 528 208 0 O 528 96 576 96 0 c 272 96 272 192 0 4.3948121369507934E-6 -5.000480507723924 l 208 96 272 96 0 0.012560685575556797 -0.1000058296956149 g 272 192 272 208 0 c 336 96 336 192 0 3.2704856949098034E-6 -4.999333512699853 l 272 96 336 96 0 0.009621226664444704 -0.10000178631255717 g 336 192 336 208 0 c 400 96 400 192 0 1.9267432478517496E-6 -4.9985368414433955 l 336 96 400 96 0 0.006573613744873482 -0.0999748516250718 g 400 192 400 208 0 c 464 96 464 192 0 3.953712484972596E-7 -4.99868176000584 l 400 96 464 96 0 0.0029400148153217306 -0.09997178060465385 g 464 192 464 208 0 g 464 352 464 368 0 l 400 272 464 272 0 0.0037033695101520102 -0.10336833872744124 c 464 272 464 352 0 4.979463676217806E-7 -5.226853560161393 g 400 352 400 368 0 l 336 272 400 272 0 0.0082809859705 -0.0973916022814173 c 400 272 400 352 0 2.427517293683718E-6 -5.045542492104053 g 336 352 336 368 0 l 272 272 336 272 0 0.012016178653842758 -0.09363197455759392 c 336 272 336 352 0 4.112858198910477E-6 -4.706292766508745 g 272 352 272 368 0 l 208 272 272 272 0 0.01442033310922977 -0.10308412962676379 c 272 272 272 352 0 5.369543031057315E-6 -4.878852155807363 O 528 272 576 272 0 g 528 352 528 368 0 g 208 352 208 368 0 r 528 272 528 352 0 50.0 w 464 272 528 272 0 l 144 272 208 272 0 0.012448659190544548 -0.09950752670846397 c 208 272 208 352 0 5.9051646250635805E-6 -5.184027928619852 w 144 96 144 192 0 w 144 192 144 272 0 R 144 192 96 192 0 2 80.0 5.0 0.0 0.0 0.5 o 6 32 0 34 10.0 9.765625E-5 0 -1 bessel o 31 32 0 34 10.0 9.765625E-5 1 -1 butterworth ================================================ FILE: src/circuits/blank.txt ================================================ $ 1 5.0E-6 10 50 5.0 ================================================ FILE: src/circuits/butter10lo.txt ================================================ $ 1 5.0E-6 5.023272298708815 49 5.0 50 c 208 176 208 288 0 5.9051646250635805E-6 4.062633211426473 l 144 176 208 176 0 0.012448659190544548 0.053140078678806095 w 464 176 528 176 0 r 528 176 528 288 0 50.0 g 208 288 208 304 0 g 528 288 528 304 0 O 528 176 576 176 0 170 144 176 112 176 2 100.0 2000.0 5.0 0.15 c 272 176 272 288 0 5.369543031057315E-6 5.1257083029780235 l 208 176 272 176 0 0.01442033310922977 0.09832852911113443 g 272 288 272 304 0 c 336 176 336 288 0 4.112858198910477E-6 4.157511982611728 l 272 176 336 176 0 0.012016178653842758 0.09606883211091816 g 336 288 336 304 0 c 400 176 400 288 0 2.427517293683718E-6 2.7175532901374186 l 336 176 400 176 0 0.0082809859705 0.06809087838027278 g 400 288 400 304 0 c 464 176 464 288 0 4.979463676217806E-7 1.9434101865833442 l 400 176 464 176 0 0.0037033695101520102 0.04419890622586078 g 464 288 464 304 0 o 6 16 0 34 10.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/cap.txt ================================================ $ 1 5.0E-6 16 50 5.0 v 96 336 96 64 0 0 40.0 5.0 0.0 S 256 144 256 64 0 false false 0 w 96 64 240 64 0 w 272 64 400 64 0 w 400 64 400 336 0 c 256 144 256 256 0 1.9999999999999996E-4 0 r 256 256 256 336 0 100.0 w 96 336 256 336 0 w 256 336 400 336 0 o 5 128 0 3 5.0 0.05 h 2 6 5 ================================================ FILE: src/circuits/capac.txt ================================================ $ 1 5.0E-6 14.3 55 5.0 v 176 256 176 80 0 1 40.0 5.0 0.0 r 176 80 336 80 0 180.0 c 336 80 336 256 0 3.3E-5 0.20495321439656933 w 176 256 336 256 0 o 2 64 0 3 5.0 0.05 ================================================ FILE: src/circuits/capmult.txt ================================================ $ 1 5.0E-6 18.278915558614752 60 5.0 50 a 368 192 480 192 0 15.0 -15.0 1000000.0 w 368 176 368 128 0 w 368 128 480 128 0 w 480 128 480 192 0 w 480 128 480 96 0 r 480 96 304 96 0 1000.0 w 304 96 304 208 0 r 304 208 368 208 0 100000.0 c 368 208 368 288 0 1.0E-7 2.3114879192195272 g 368 288 368 320 0 w 304 208 240 208 0 R 240 208 192 208 0 2 30.0 5.0 0.0 0.0 0.5 R 240 368 192 368 0 2 30.0 5.0 0.0 0.0 0.5 c 240 368 304 368 0 1.0E-5 2.3114879192202653 r 304 368 368 368 0 1000.0 g 368 368 368 400 0 x 377 70 407 76 0 24 R2 x 323 180 353 186 0 24 R1 x 415 258 447 264 0 24 C1 x 258 408 290 414 0 24 C2 x 319 408 349 414 0 24 R3 o 13 64 0 34 5.0 0.003125 0 -1 o 8 64 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/capmultcaps.txt ================================================ $ 1 5.0E-6 10 54 5.0 50 v 176 96 176 32 0 1 80.0 5.0 0.0 r 176 32 336 32 0 200.0 c 336 32 336 96 0 7.999999999999999E-5 -0.5102063628995691 w 176 96 336 96 0 v 176 192 176 128 0 1 80.0 5.0 0.0 r 176 128 336 128 0 200.0 w 176 192 336 192 0 c 336 128 336 192 0 1.0E-5 -3.485547023514335 v 176 288 176 224 0 1 80.0 5.0 0.0 w 176 288 336 288 0 c 336 224 336 288 0 1.0E-6 -3.321428082201859 r 176 224 336 224 0 200.0 o 2 64 0 1 1.25 0.05 o 7 64 0 1 5.0 0.05 o 10 64 0 1 5.0 0.05 ================================================ FILE: src/circuits/capmultfreq.txt ================================================ $ 1 5.0E-6 10 54 5.0 50 v 224 144 224 80 0 1 15.0 5.0 0.0 r 224 80 384 80 0 200.0 c 384 80 384 144 0 2.9999999999999997E-5 0.4703928719421789 w 224 144 384 144 0 v 224 240 224 176 0 1 40.0 5.0 0.0 r 224 176 384 176 0 200.0 w 224 240 384 240 0 c 384 176 384 240 0 2.9999999999999997E-5 2.2457974270921146 v 224 336 224 272 0 1 80.0 5.0 0.0 w 224 336 384 336 0 c 384 272 384 336 0 2.9999999999999997E-5 -1.4536204423595571 r 224 272 384 272 0 200.0 o 2 64 0 17 2.5 0.05 0 o 7 64 0 17 2.5 0.05 1 o 10 64 0 17 2.5 0.05 2 ================================================ FILE: src/circuits/cappar.txt ================================================ $ 1 5.0E-6 18 50 5.0 v 48 336 48 64 0 0 40.0 5.0 0.0 S 144 144 144 64 0 false false 1 w 240 64 240 336 0 r 48 336 144 336 0 100.0 r 144 336 240 336 0 100.0 w 48 64 128 64 0 w 160 64 240 64 0 r 288 336 384 336 0 100.0 r 384 336 480 336 0 100.0 w 480 64 480 336 0 S 384 144 384 64 0 false false 1 w 288 64 368 64 0 w 400 64 480 64 0 c 384 144 384 336 0 3.0E-4 0 v 288 336 288 64 0 0 40.0 5.0 0.0 w 144 144 144 192 0 w 144 336 144 288 0 w 144 288 96 288 0 w 96 192 144 192 0 w 144 192 192 192 0 c 192 192 192 288 0 1.9999999999999998E-4 0 r 144 288 192 288 0 0.01 c 96 192 96 288 0 9.999999999999999E-5 0 ================================================ FILE: src/circuits/capseries.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 48 336 48 64 0 0 40.0 5.0 0.0 S 144 144 144 64 0 false false 1 w 240 64 240 336 0 r 48 336 144 336 0 100.0 r 144 336 240 336 0 100.0 c 144 144 144 240 0 0.0010 0 c 144 240 144 336 0 9.999999999999999E-5 0 w 48 64 128 64 0 w 160 64 240 64 0 r 288 336 384 336 0 100.0 r 384 336 480 336 0 100.0 w 480 64 480 336 0 S 384 144 384 64 0 false false 1 w 288 64 368 64 0 w 400 64 480 64 0 c 384 144 384 336 0 9.091E-5 0 v 288 336 288 64 0 0 40.0 5.0 0.0 ================================================ FILE: src/circuits/cc2.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 272 224 304 224 0 1.0 r 368 256 480 256 0 100.0 g 480 256 480 288 0 172 272 288 192 288 0 6 4.5 5.0 0.0 0.0 0.5 Y Voltage 174 272 224 208 176 0 1000.0 0.5 X Resistance r 240 176 144 176 0 100.0 g 144 176 144 192 0 ================================================ FILE: src/circuits/cc2imp.txt ================================================ $ 1 5.0E-6 1.1208435524800693 51 5.0 50 a 160 208 272 208 1 15.0 -15.0 f 272 176 336 176 0 1.5 f 272 240 336 240 1 1.5 w 272 176 272 208 0 w 272 208 272 240 0 w 336 192 336 208 0 w 336 208 336 224 0 w 336 208 368 208 0 w 160 288 160 224 1 w 336 256 336 320 0 f 400 368 336 368 0 1.5 f 400 368 464 368 0 1.5 w 336 320 400 320 0 w 400 320 400 368 0 w 336 320 336 352 0 f 400 112 336 112 1 1.5 f 400 112 464 112 1 1.5 w 336 128 336 160 0 w 336 160 400 160 0 w 400 160 400 112 0 w 464 128 464 208 0 w 464 208 464 352 0 172 160 192 96 192 0 6 2.0 4.0 -4.0 0.0 0.5 Y Voltage 174 64 224 160 256 0 500.0 0.7079000000000001 X Resistance r 112 256 112 320 0 100.0 g 112 320 112 336 0 w 464 208 512 208 1 r 512 208 576 208 0 100.0 g 576 208 576 224 0 R 336 96 336 48 0 0 40.0 10.0 0.0 0.0 0.5 R 464 96 464 48 0 0 40.0 10.0 0.0 0.0 0.5 R 336 384 336 432 0 0 40.0 -10.0 0.0 0.0 0.5 R 464 384 464 432 0 0 40.0 -10.0 0.0 0.0 0.5 w 160 288 368 288 2 w 368 288 368 208 0 x 94 165 109 171 0 24 Y x 156 326 171 332 0 24 X x 501 177 516 183 0 24 Z ================================================ FILE: src/circuits/cc2impn.txt ================================================ $ 1 5.0E-6 1.1208435524800693 51 5.0 50 a 144 208 240 208 1 15.0 -15.0 f 240 176 288 176 0 1.5 f 240 240 288 240 1 1.5 w 240 176 240 208 0 w 240 208 240 240 0 w 288 192 288 208 0 w 288 208 288 224 0 w 288 208 336 208 0 w 144 288 144 224 1 w 288 256 288 320 0 f 336 368 288 368 0 1.5 f 336 368 384 368 0 1.5 w 288 320 336 320 0 w 336 320 336 368 0 w 288 320 288 352 0 f 336 112 288 112 1 1.5 f 336 112 384 112 1 1.5 w 288 128 288 160 0 w 288 160 336 160 0 w 336 160 336 112 0 172 144 192 80 192 0 6 2.6399999999999997 4.0 -4.0 0.0 0.5 Y Voltage 174 48 224 144 256 0 500.0 0.9158000000000001 X Resistance r 96 256 96 320 0 100.0 g 96 320 96 336 0 R 288 96 288 48 0 0 40.0 10.0 0.0 0.0 0.5 R 384 96 384 48 0 0 40.0 10.0 0.0 0.0 0.5 R 288 384 288 432 0 0 40.0 -10.0 0.0 0.0 0.5 R 384 384 384 432 0 0 40.0 -10.0 0.0 0.0 0.5 w 144 288 336 288 2 w 336 288 336 208 0 f 496 112 448 112 1 1.5 f 496 112 544 112 1 1.5 w 496 112 496 160 0 w 496 160 448 160 0 w 448 128 448 160 0 w 384 128 384 160 0 f 496 368 448 368 0 1.5 f 496 368 544 368 0 1.5 w 448 320 496 320 0 w 496 320 496 368 0 w 448 320 448 352 0 w 544 352 544 208 0 w 544 208 544 128 0 w 384 320 384 352 0 w 384 160 448 320 0 w 384 320 448 160 0 R 448 384 448 432 0 0 40.0 -10.0 0.0 0.0 0.5 R 544 384 544 432 0 0 40.0 -10.0 0.0 0.0 0.5 R 448 96 448 48 0 0 40.0 10.0 0.0 0.0 0.5 R 544 96 544 48 0 0 40.0 10.0 0.0 0.0 0.5 r 592 208 592 272 0 100.0 g 592 272 592 288 0 w 544 208 592 208 1 x 99 172 114 178 0 24 Y x 136 327 151 333 0 24 X x 578 177 593 183 0 24 Z ================================================ FILE: src/circuits/cc2n.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 272 224 304 224 0 -1.0 r 368 256 480 256 0 100.0 g 480 256 480 288 0 172 272 288 192 288 0 6 4.5 5.0 0.0 0.0 0.5 Y Voltage 174 272 224 208 176 0 1000.0 0.5 X Resistance r 240 176 144 176 0 100.0 g 144 176 144 192 0 ================================================ FILE: src/circuits/ccdiff.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 368 160 400 160 0 1.0 c 368 160 304 160 0 1.0E-5 0 r 304 160 256 160 0 1.0 g 256 160 256 176 0 r 464 192 544 192 0 100.0 g 544 192 544 224 0 179 144 256 272 256 0 1.0 r 144 256 96 256 0 100.0 g 96 256 96 272 0 w 368 288 368 224 0 r 368 224 304 224 0 100.0 g 304 224 304 240 0 R 144 320 112 320 0 3 40.0 5.0 0.0 1.5707963267948966 0.5 w 240 288 368 288 0 o 10 64 0 33 2.5 0.05 0 -1 input o 4 64 0 33 0.5114672824837722 0.009 0 -1 output ================================================ FILE: src/circuits/cciamp.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 208 176 304 176 0 1.0 i 144 304 208 304 0 0.01 g 144 304 144 320 0 w 208 240 208 304 0 r 208 176 112 176 0 10.0 g 112 176 112 192 0 g 400 256 400 272 0 w 208 240 144 240 0 174 144 240 80 272 0 100.0 0.7277 Multiplier 174 352 208 448 256 0 100.0 0.32180000000000003 Z Resistance g 112 272 112 288 0 w 304 208 352 208 1 ================================================ FILE: src/circuits/ccinductor.txt ================================================ $ 1 5.0E-6 10.20027730826997 48 5.0 50 179 240 80 256 80 1024 1.0 179 240 256 272 256 1024 -1.0 R 128 176 96 176 0 1 40.0 5.0 0.0 0.0 0.5 r 128 176 224 176 0 50.0 R 480 176 448 176 0 1 40.0 5.0 0.0 0.0 0.5 r 480 176 544 176 0 50.0 l 544 176 544 272 0 0.1 -0.05978684403333334 g 544 272 544 288 0 w 240 112 224 112 0 w 224 112 224 176 0 r 336 80 400 80 0 100.0 g 400 80 400 96 0 w 336 144 336 208 0 w 240 288 240 208 0 w 240 208 336 208 0 w 336 256 384 256 0 r 384 256 384 368 0 100.0 g 384 368 384 384 0 w 336 320 336 352 0 w 336 352 224 352 0 w 224 352 224 176 0 w 240 288 176 288 0 c 176 288 176 368 0 1.0E-5 5.9786844033333315 g 176 368 176 384 0 o 2 64 0 35 5.0 0.1 0 -1 o 4 64 0 35 5.0 0.1 0 -1 ================================================ FILE: src/circuits/ccint.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 368 160 400 160 0 1.0 g 304 160 304 176 0 r 464 192 544 192 0 100.0 g 544 192 544 224 0 179 144 256 272 256 0 1.0 r 144 256 96 256 0 100.0 g 96 256 96 272 0 w 368 288 368 224 0 g 304 224 304 240 0 R 144 320 112 320 0 2 40.0 5.0 0.0 1.5707963267948966 0.5 w 240 288 368 288 0 c 304 224 368 224 0 1.0E-5 -5.786500000000048 r 304 160 368 160 0 1000.0 o 10 64 0 33 20.0 0.1 0 -1 input o 2 64 0 33 2.3384026197294445 0.046768052394588894 0 -1 output ================================================ FILE: src/circuits/ccitov.txt ================================================ $ 1 5.0E-6 10.20027730826997 59 5.0 50 S 224 320 224 240 0 1 false 0 S 224 160 224 240 0 1 false 0 w 144 160 144 240 0 w 144 240 144 320 0 r 144 240 208 240 0 1000.0 i 144 160 224 160 0 0.0010 i 144 320 224 320 0 0.0020 O 304 176 304 80 1 w 240 240 304 240 1 r 304 240 304 320 0 1000.0 g 304 320 304 336 0 179 304 176 368 176 0 1.0 g 400 208 400 288 0 R 144 240 96 240 0 0 40.0 5.0 0.0 0.0 0.5 o 8 64 0 33 2.5 0.003125 0 -1 o 7 64 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/ccvccs.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 179 208 192 336 192 0 1.0 r 208 192 160 192 0 100.0 g 160 192 160 208 0 R 208 256 176 256 0 1 40.0 5.0 0.0 1.5707963267948966 0.5 174 368 224 464 272 0 200.0 0.5297000000000001 Resistance g 416 272 416 288 0 w 304 224 368 224 0 o 3 64 0 34 5.0 9.765625E-5 0 -1 o 6 64 0 33 40.0 0.1 0 -1 ================================================ FILE: src/circuits/ceamp.txt ================================================ $ 1 5.0E-6 16 60 15.0 53 w 240 48 336 48 0 r 240 48 240 208 0 110000.0 r 240 208 240 352 0 10000.0 t 240 208 336 208 0 1 -10.980847640834186 0.5689504449104646 w 240 352 336 352 0 g 240 352 240 384 0 R 240 48 144 48 0 0 40.0 20.0 0.0 r 336 48 336 192 0 10000.0 r 336 224 336 352 0 1000.0 c 240 208 160 208 0 4.9999999999999996E-6 1.5542375158881994 R 160 208 112 208 0 1 80.0 0.5 0.0 c 336 192 416 192 0 4.9999999999999996E-6 10.088518798851988 O 416 192 464 192 0 r 416 192 416 272 0 1000000.0 g 416 272 416 304 0 o 10 64 0 2 0.625 9.765625E-5 o 12 64 0 2 10.0 9.765625E-5 ================================================ FILE: src/circuits/classd.txt ================================================ $ 1 5.0E-6 8.531194996067258 50 5.0 50 a 160 224 256 224 0 15.0 -15.0 f 256 256 304 256 1 1.5 f 256 192 304 192 0 1.5 w 256 192 256 224 0 w 256 224 256 256 0 w 304 208 304 224 0 w 304 224 304 240 0 R 304 176 304 128 0 0 40.0 15.0 0.0 0.0 0.5 l 304 224 400 224 0 0.08 0.062136746137611415 c 400 224 400 304 0 1.0E-5 -6.657326718051054 g 400 304 400 336 0 w 304 272 304 288 0 O 400 224 464 224 0 w 160 240 160 256 0 w 160 208 160 192 0 R 160 256 112 256 0 3 1000.0 1.001 0.0 0.0 0.5 R 160 192 112 192 0 1 30.0 1.001 0.0 0.0 0.5 R 304 288 304 336 0 0 40.0 -15.0 0.0 0.0 0.5 g 256 320 256 336 0 p 256 256 256 320 0 o 16 64 0 34 1.2 9.765625E-5 0 -1 input o 19 16 0 34 20.0 9.765625E-5 1 -1 o 12 64 0 34 15.0 4.8828125E-5 2 -1 output ================================================ FILE: src/circuits/clockedsrff.txt ================================================ $ 1 5.0E-6 10 50 5.0 151 256 272 368 272 0 2 5 151 256 144 368 144 0 2 0 w 368 144 368 176 0 w 368 176 256 240 0 w 368 272 368 240 0 w 368 240 256 176 0 w 256 176 256 160 0 w 256 240 256 256 0 M 368 144 448 144 0 M 368 272 448 272 0 151 128 128 256 128 0 2 5 151 128 288 256 288 0 2 0 w 128 304 96 304 0 w 96 304 96 144 0 w 96 144 128 144 0 L 128 112 64 112 0 true true L 128 272 64 272 0 true true R 96 304 96 352 1 2 100.0 2.5 2.5 o 15 64 0 6 5.0 9.765625E-5 0 set o 16 64 0 6 5.0 9.765625E-5 0 reset o 8 64 0 6 5.0 9.765625E-5 0 Q o 17 64 0 6 5.0 9.765625E-5 0 clk ================================================ FILE: src/circuits/cmosff.txt ================================================ $ 0 5.0E-6 10 50 5.0 f 160 80 208 80 5 f 160 176 208 176 4 w 208 96 208 128 0 w 208 128 208 160 0 f 160 240 208 240 4 w 208 192 208 224 0 g 208 256 208 288 0 w 160 80 160 176 0 f 80 80 128 80 5 w 128 32 128 64 0 w 128 32 208 32 0 w 208 32 208 64 0 R 128 32 80 32 0 0 40.0 5.0 0.0 w 80 80 80 240 0 w 80 240 160 240 0 L 160 176 32 176 0 false true w 128 96 128 128 0 w 128 128 208 128 0 w 288 240 288 176 0 w 288 176 288 80 0 f 288 80 336 80 5 f 368 80 416 80 5 w 336 96 336 128 0 w 336 128 416 128 0 w 416 96 416 128 0 w 336 64 336 32 0 w 416 64 416 32 0 w 416 32 336 32 0 w 208 32 336 32 0 w 368 80 368 176 0 f 368 176 416 176 4 f 368 240 416 240 4 w 416 192 416 224 0 w 416 128 416 160 0 w 368 240 288 240 0 g 416 256 416 288 0 L 288 240 288 288 0 false true w 416 128 464 128 0 w 464 128 464 336 0 w 464 336 80 336 0 w 80 336 80 240 0 w 368 176 240 176 0 w 208 128 240 128 0 w 240 128 240 176 0 M 240 176 240 368 0 M 464 336 464 368 0 x 281 328 297 328 0 24 R x 26 151 42 151 0 24 S x 202 378 218 378 0 24 Q x 422 380 438 380 2 24 Q ================================================ FILE: src/circuits/cmosinverter.txt ================================================ $ 0 5.0E-6 10 50 5.0 f 208 176 272 176 1 f 208 272 272 272 0 w 272 192 272 224 0 w 272 224 272 256 0 w 208 176 208 224 0 w 208 224 208 272 0 L 208 224 160 224 0 false false M 272 224 336 224 0 R 272 160 272 112 0 0 40.0 5.0 0.0 g 272 288 272 320 0 ================================================ FILE: src/circuits/cmosinvertercap.txt ================================================ $ 1 1.0E-12 10 50 5.0 38 f 224 144 288 144 1 f 224 272 288 272 0 w 288 160 288 208 0 M 288 208 352 208 0 w 288 128 288 96 0 c 224 96 288 96 0 1.0000000000000001E-11 -5.000000000000001 c 288 208 224 208 0 1.0000000000000001E-11 4.999999285714189 w 224 144 224 208 0 w 224 208 224 272 0 w 288 208 288 256 0 c 288 320 224 320 0 1.0000000000000001E-11 1.6279405589908862E-23 w 288 288 288 320 0 R 288 96 288 48 0 0 40.0 5.0 0.0 L 224 208 160 208 0 true false g 288 320 288 368 0 r 224 96 224 144 0 5.0 r 224 272 224 320 0 5.0 ================================================ FILE: src/circuits/cmosinverterslow.txt ================================================ $ 1 3.0E-13 10 52 5.0 f 272 144 336 144 1 f 272 240 336 240 0 w 336 160 336 192 0 w 336 192 336 224 0 w 272 144 272 192 0 w 272 192 272 240 0 M 336 192 400 192 0 R 336 128 336 80 0 0 40.0 5.0 0.0 g 336 256 336 288 0 w 272 192 208 192 0 c 208 192 208 256 0 1.0000000000000001E-11 4.81990995096849 g 208 256 208 288 0 r 208 192 144 192 0 100.0 L 144 192 96 192 0 false false o 10 64 0 2 5.0 0.0015625 o 0 64 0 3 5.0 9.765625E-5 o 1 64 0 3 7.62939453125E-5 9.765625E-5 ================================================ FILE: src/circuits/cmosmsff.txt ================================================ $ 0 5.0E-6 9 50 5.0 50 159 144 112 208 112 0 w 208 112 208 192 0 159 208 192 272 192 0 I 208 112 272 112 0 2.0E-4 I 272 112 272 192 0 2.0E-4 159 272 112 336 112 0 159 336 192 400 192 0 w 336 112 336 192 0 I 336 112 400 112 0 2.0E-4 I 400 112 400 192 0 2.0E-4 I 400 112 464 112 0 0.5 I 400 192 464 192 0 0.5 w 176 128 176 336 0 w 240 208 240 240 0 w 368 240 368 208 0 I 240 336 240 240 0 0.5 w 176 336 240 336 0 w 240 336 368 336 0 w 240 240 304 240 0 w 304 240 304 128 0 w 368 240 368 336 0 R 176 336 80 336 1 2 100.0 2.5 2.5 L 144 112 80 112 0 true false 5.0 0.0 M 464 112 512 112 0 2.5 M 464 192 512 192 0 2.5 x 71 80 87 80 0 24 D x 543 122 559 122 2 24 Q x 542 202 558 202 0 24 Q ================================================ FILE: src/circuits/cmosnand.txt ================================================ $ 0 5.0E-6 10 50 5.0 f 288 128 352 128 5 f 288 224 352 224 4 w 352 144 352 176 0 w 352 176 352 208 0 M 352 176 416 176 0 f 288 288 352 288 4 w 352 240 352 272 0 g 352 304 352 336 0 w 288 128 288 224 0 f 192 128 256 128 5 w 256 80 256 112 0 w 256 80 352 80 0 w 352 80 352 112 0 R 256 80 192 80 0 0 40.0 5.0 0.0 w 192 128 192 288 0 w 192 288 288 288 0 L 288 224 128 224 0 false false L 192 288 128 288 0 false false w 256 144 256 176 0 w 256 176 352 176 0 ================================================ FILE: src/circuits/cmosnor.txt ================================================ $ 0 5.0E-6 10 50 5.0 f 272 144 336 144 5 w 336 160 336 192 0 R 336 128 336 80 0 0 40.0 5.0 0.0 f 272 208 336 208 5 w 336 224 336 240 0 w 336 240 336 256 0 f 272 272 336 272 4 M 336 240 400 240 0 f 176 272 240 272 4 w 240 240 240 256 0 w 240 240 336 240 0 g 240 288 240 320 0 g 336 288 336 320 0 w 272 208 272 272 0 w 176 144 176 272 0 w 176 144 272 144 0 L 176 144 128 144 0 false false L 272 208 128 208 0 false false ================================================ FILE: src/circuits/cmostransgate.txt ================================================ $ 1 5.0E-6 16.13108636308289 50 5.0 50 w 320 192 400 192 0 r 400 192 400 272 0 100.0 g 400 272 400 304 0 w 208 240 208 144 0 w 288 192 144 192 0 L 208 240 96 240 0 false false R 144 192 96 192 0 1 40.0 2.5 2.5 f 304 144 304 192 1 f 304 240 304 192 0 I 208 144 304 144 0 w 208 240 304 240 0 ================================================ FILE: src/circuits/cmosxor.txt ================================================ $ 0 5.0E-6 10 50 5.0 f 192 128 256 128 5 f 192 224 256 224 4 w 256 144 256 176 0 w 256 176 256 208 0 w 192 128 192 176 0 w 192 176 192 224 0 f 336 112 336 176 5 f 336 240 336 176 4 w 256 240 336 240 0 w 256 112 336 112 0 w 192 176 144 176 0 w 144 176 144 272 0 w 144 272 384 272 0 w 384 272 384 176 0 w 336 112 336 80 0 w 336 80 144 80 0 L 144 80 64 80 0 true false L 144 176 64 176 0 true false w 336 240 432 240 0 I 432 80 432 240 0 w 336 80 432 80 0 w 256 176 288 176 0 w 288 176 320 176 0 w 288 176 288 304 0 M 288 304 288 352 0 w 352 176 384 176 0 x 199 361 215 361 0 20 output ================================================ FILE: src/circuits/colpitts.txt ================================================ $ 1 5.0E-6 2.898875293967098 50 5.0 50 l 80 128 80 304 0 0.01 -0.010136293111238402 c 192 128 192 224 0 9.999999999999999E-5 0.6813812722941772 t 256 128 304 128 0 1 0.647542643140423 0.6813812722941772 100.0 c 192 224 192 304 0 9.999999999999999E-5 -0.627840195243891 w 80 304 192 304 0 w 80 128 192 128 0 w 192 128 256 128 0 w 192 224 304 224 0 w 304 144 304 224 0 w 304 112 352 112 0 r 352 112 352 304 0 1000.0 w 192 304 352 304 0 r 304 112 304 48 0 100.0 R 304 48 256 48 0 0 40.0 5.0 0.0 0.0 0.5 g 304 224 304 256 0 O 352 112 432 112 0 x 150 182 170 186 0 16 C1 x 150 271 171 275 0 16 C2 o 15 32 0 42 5.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/counter.txt ================================================ $ 1 5.0E-6 10 50 5.0 156 80 224 128 224 0 0.0 156 208 224 240 224 0 0.0 156 336 224 368 224 0 0.0 156 464 224 480 224 0 0.0 w 176 224 176 256 0 w 176 256 208 256 0 w 304 224 304 256 0 w 304 256 336 256 0 w 432 224 432 256 0 w 432 256 464 256 0 w 464 224 448 224 0 w 448 224 448 288 0 w 448 288 464 288 0 w 448 288 448 336 0 w 448 336 320 336 0 w 320 336 320 288 0 w 320 288 336 288 0 w 320 288 320 224 0 w 320 224 336 224 0 w 208 224 192 224 0 w 192 224 192 288 0 w 192 288 208 288 0 w 192 288 192 336 0 w 192 336 320 336 0 w 80 224 64 224 0 w 64 224 64 288 0 w 64 288 80 288 0 w 64 288 64 336 0 w 64 336 192 336 0 R 80 256 32 256 1 2 200.0 2.5 2.5 R 64 336 32 336 0 0 40.0 5.0 0.0 w 560 224 560 64 0 w 432 224 432 96 0 w 304 224 304 128 0 w 176 224 176 160 0 M 560 64 592 64 2 M 432 96 592 96 2 M 304 128 592 128 2 M 176 160 592 160 2 o 35 64 0 6 5.0 9.765625E-5 0 o 36 64 0 6 5.0 9.765625E-5 0 o 37 64 0 6 5.0 9.765625E-5 0 o 38 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/counter8.txt ================================================ $ 3 5.0E-6 23 50 5.0 156 88 272 104 272 1 0 156 152 272 168 272 1 0 w 152 272 144 272 0 w 144 272 144 304 0 w 144 304 152 304 0 w 136 272 136 288 0 w 136 288 152 288 0 156 216 272 232 272 1 0.0 156 280 272 296 272 1 0.0 156 344 272 352 272 1 0.0 156 408 272 424 272 1 0.0 156 472 272 488 272 1 0.0 w 200 272 200 288 0 w 200 288 216 288 0 w 264 272 264 288 0 w 264 288 280 288 0 w 328 272 328 288 0 w 328 288 344 288 0 w 392 272 392 288 0 w 392 288 408 288 0 w 456 272 456 288 0 w 456 288 472 288 0 w 216 272 208 272 0 w 208 272 208 304 0 w 208 304 216 304 0 w 280 272 272 272 0 w 272 272 272 304 0 w 272 304 280 304 0 w 344 272 336 272 0 w 336 272 336 304 0 w 336 304 344 304 0 w 408 272 400 272 0 w 400 272 400 304 0 w 400 304 408 304 0 w 472 272 464 272 0 w 464 272 464 304 0 w 464 304 472 304 0 w 144 304 144 336 0 w 208 304 208 336 0 w 144 336 208 336 0 w 208 336 272 336 0 w 272 304 272 336 0 w 272 336 336 336 0 w 336 336 400 336 0 w 400 336 464 336 0 w 464 336 464 304 0 w 400 304 400 336 0 w 336 304 336 336 0 R 88 288 32 288 1 2 1000.0 2.5 2.5 w 88 272 80 272 0 w 80 272 80 304 0 w 80 304 88 304 0 w 80 304 80 336 0 w 80 336 144 336 0 R 80 336 32 336 0 0 40.0 5.0 0.0 w 136 272 136 224 0 w 200 272 200 200 0 w 264 272 264 176 0 w 328 272 328 152 0 w 392 272 392 128 0 w 456 272 456 104 0 w 520 272 520 80 0 M 136 224 80 224 2 M 200 200 80 200 2 M 264 176 80 176 2 M 328 152 80 152 2 M 392 128 80 128 2 M 456 104 80 104 2 M 520 80 80 80 2 w 464 336 528 336 0 w 528 336 528 304 0 w 520 272 520 288 0 w 520 288 536 288 0 156 536 272 552 272 1 0.0 w 528 272 528 304 0 w 528 272 536 272 0 w 584 272 584 56 0 w 528 304 536 304 0 M 584 56 80 56 2 o 78 64 0 6 5.0 9.765625E-5 0 o 68 64 0 6 7.62939453125E-5 9.765625E-5 0 o 67 64 0 6 5.0 9.765625E-5 0 o 66 64 0 6 5.0 9.765625E-5 0 o 65 64 0 6 5.0 9.765625E-5 0 o 64 64 0 6 5.0 9.765625E-5 0 o 63 64 0 6 5.0 9.765625E-5 0 o 62 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/coupled1.txt ================================================ $ 1 5.0E-6 12.682493960703473 55 5.0 50 l 192 240 304 240 0 1.0 0.0 l 304 240 416 240 0 1.0 0.0 c 192 240 192 368 0 1.0E-5 5.0 c 304 240 304 368 0 1.0E-5 -0.0 c 416 240 416 368 0 1.0E-5 5.0 r 192 368 304 368 0 1.0 r 304 368 416 368 0 1.0 g 304 368 304 384 0 l 192 32 304 32 0 1.0 0.0 l 304 32 416 32 0 1.0 0.0 c 192 32 192 160 0 1.0E-5 5.0 c 304 32 304 160 0 1.0E-5 -0.0 c 416 32 416 160 0 1.0E-5 -5.0 r 192 160 304 160 0 1.0 r 304 160 416 160 0 1.0 g 304 160 304 176 0 o 13 64 0 43 0.01953125 0.025 0 -1 o 5 64 0 43 0.009765625 0.0125 1 -1 ================================================ FILE: src/circuits/coupled2.txt ================================================ $ 1 5.0E-6 11.251013186076355 63 5.0 50 l 208 160 320 160 0 1.0 -0.001826652874703726 l 320 160 432 160 0 1.0 3.59207891615332E-4 c 208 160 208 288 0 1.0E-6 0.7201238956969189 c 320 160 320 288 0 1.9999999999999998E-5 0.2893723277533031 c 432 160 432 288 0 1.0E-6 -1.5075704507629162 r 208 288 320 288 0 1.0 r 320 288 432 288 0 1.0 g 320 288 320 304 0 w 432 160 480 160 0 w 432 288 480 288 0 p 480 160 480 288 0 w 208 160 160 160 0 w 208 288 160 288 0 p 160 160 160 288 0 o 2 64 0 35 5.0 0.00625 0 -1 o 4 64 0 35 5.0 0.00625 1 -1 o 13 64 0 226 2.8 2.8 2 10 ================================================ FILE: src/circuits/coupled3.txt ================================================ $ 1 5.0E-6 17.50203994009402 55 5.0 50 l 144 32 256 32 0 1.0 -0.010526054531836967 l 256 32 368 32 0 1.0 -0.014780859108181294 c 144 32 144 112 0 1.0E-5 -1.5283359644818593 c 256 32 256 112 0 1.0E-5 -0.6226471660960838 c 368 32 368 112 0 1.0E-5 0.6226471660960479 r 144 112 256 112 0 1.0 r 256 112 368 112 0 1.0 l 368 32 480 32 0 1.0 -0.010526054531837074 c 480 32 480 112 0 1.0E-5 1.528335964481852 r 368 112 480 112 0 1.0 g 144 112 144 128 0 l 144 160 256 160 0 1.0 0.0146359989059815 l 256 160 368 160 0 1.0 -7.561108857079762E-17 c 144 160 144 240 0 1.0E-5 -3.205717865478435 c 256 160 256 240 0 1.0E-5 3.2057178654783622 c 368 160 368 240 0 1.0E-5 3.205717865478375 r 144 240 256 240 0 1.0 r 256 240 368 240 0 1.0 l 368 160 480 160 0 1.0 -0.014635998905981084 c 480 160 480 240 0 1.0E-5 -3.2057178654783813 r 368 240 480 240 0 1.0 g 144 240 144 256 0 l 144 288 256 288 0 1.0 0.009608347545030023 l 256 288 368 288 0 1.0 -0.013588266474160417 c 144 288 144 368 0 1.0E-5 0.9505461007504308 c 256 288 256 368 0 1.0E-5 -2.2948228963492374 c 368 288 368 368 0 1.0E-5 2.2948228963492827 r 144 368 256 368 0 1.0 r 256 368 368 368 0 1.0 l 368 288 480 288 0 1.0 0.009608347545029965 c 480 288 480 368 0 1.0E-5 -0.9505461007504287 r 368 368 480 368 0 1.0 g 144 368 144 384 0 o 9 128 0 43 0.01953125 0.0125 0 -1 o 20 128 0 43 0.0390625 0.025 1 -1 o 31 128 0 43 0.01953125 0.0125 2 -1 ================================================ FILE: src/circuits/crossover.txt ================================================ $ 0 5.0E-6 10.812258501325767 50 5.0 50 170 208 48 160 48 3 100.0 20000.0 5.0 0.25 l 208 48 304 48 0 0.00212 -0.08881265679389214 c 304 48 304 112 0 5.9999999999999995E-5 -0.2894173322846854 l 304 48 400 48 0 7.0E-4 -0.0064227679597185445 r 400 48 400 112 0 5.6 g 304 112 304 128 0 g 400 112 400 128 0 w 208 48 208 176 0 c 208 176 272 176 0 2.1E-5 -0.8398710078174956 c 272 176 336 176 0 6.3E-5 0.090455613711665 l 336 176 400 176 0 2.4E-4 0.6844180361930992 l 400 176 464 176 0 8.0E-5 0.6610256500586136 l 272 176 272 256 0 0.00151 0.030771262133821843 c 400 176 400 256 0 3.3199999999999996E-6 5.438742670954392 r 464 176 464 256 0 8.0 g 272 256 272 272 0 g 400 256 400 272 0 g 464 256 464 272 0 w 208 176 208 320 0 c 208 320 304 320 0 2.37E-6 4.767372700629853 c 304 320 400 320 0 7.099999999999999E-6 -0.16235412775659708 l 304 320 304 400 0 1.5E-4 0.09052584171628873 g 304 400 304 416 0 r 400 320 400 400 0 5.6 g 400 400 400 416 0 o 4 8 0 50 5.1 1.6 0 -1 low o 14 4 0 50 10.0 0.8 1 -1 mid o 23 4 0 50 5.1 0.8 2 -1 high ================================================ FILE: src/circuits/cube.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 50 r 224 144 384 144 0 100.0 r 384 144 384 304 0 100.0 r 384 304 224 304 0 100.0 r 224 304 224 144 0 100.0 r 224 144 288 80 0 100.0 r 384 144 448 80 0 100.0 r 448 80 288 80 0 100.0 r 448 80 448 240 0 100.0 r 448 240 384 304 0 100.0 r 224 304 288 240 0 100.0 r 288 240 448 240 0 100.0 r 288 240 288 80 0 100.0 82 448 80 448 32 0 0 40.0 5.0 0.0 0.0 0.5 g 224 304 224 336 0 ================================================ FILE: src/circuits/currentsrc.txt ================================================ $ 1 5.0E-6 10.391409633455755 58 10.0 50 t 192 224 256 224 0 1 0.25888403915739877 0.5839501020424223 100.0 r 256 240 256 288 0 1000.0 g 256 288 256 320 0 w 256 208 256 160 1 w 256 160 304 160 0 w 256 64 304 64 0 R 256 64 256 16 0 0 40.0 10.0 0.0 0.0 0.5 s 304 64 304 160 0 1 false r 256 64 256 160 0 6000.0 w 256 64 192 64 0 w 192 288 256 288 0 r 192 224 192 288 0 2000.0 r 192 224 192 64 0 8000.0 ================================================ FILE: src/circuits/currentsrcelm.txt ================================================ $ 1 5.0E-6 10 50 5.0 w 112 32 208 32 0 w 208 32 304 32 0 w 304 32 400 32 0 s 208 32 208 112 0 false false s 304 32 304 112 0 true false r 208 112 208 176 0 100.0 r 304 112 304 176 0 400.0 r 400 112 400 176 0 4000.0 w 208 176 304 176 0 w 304 176 400 176 0 w 304 208 304 176 0 w 304 208 400 208 0 w 304 208 208 208 0 s 304 208 304 288 0 false false r 208 288 208 352 0 600.0 r 304 288 304 352 0 200.0 s 400 208 400 352 0 false false w 112 352 208 352 0 w 208 352 304 352 0 w 304 352 400 352 0 i 112 352 112 32 0 g 112 352 112 384 0 w 400 32 400 112 0 w 208 208 208 288 0 o 20 32 0 3 5.0 0.05 ================================================ FILE: src/circuits/currentsrcramp.txt ================================================ $ 1 5.0E-6 15 53 10.0 t 176 256 240 256 0 1 0.6557323083416877 0.6568475020864442 r 240 272 240 320 0 100.0 g 240 320 240 352 0 R 176 256 128 256 0 0 40.0 2.0 0.0 w 240 240 240 192 0 w 240 192 336 192 0 w 240 96 336 96 0 R 240 96 240 48 0 0 40.0 10.0 0.0 c 240 96 240 192 0 4.9999999999999996E-5 0 r 336 96 336 192 0 10000.0 w 240 96 192 96 0 w 240 192 192 192 0 s 192 96 192 192 0 true true o 9 128 0 2 10.0 7.8125E-4 ================================================ FILE: src/circuits/dac.txt ================================================ $ 1 5.0E-6 10 50 5.0 w 208 128 208 192 0 w 320 208 320 128 0 r 208 128 320 128 0 160.6 g 208 288 208 320 0 w 208 192 176 192 0 w 176 192 176 160 0 r 176 160 112 160 0 200.0 r 112 224 176 224 0 400.0 L 112 160 80 160 0 true false 5.0 0.0 L 112 224 80 224 0 false false 5.0 0.0 w 176 160 176 96 0 r 112 288 176 288 0 800.0 r 112 96 176 96 0 100.0 L 112 96 80 96 0 true false 5.0 0.0 L 112 288 80 288 0 false false 5.0 0.0 a 208 208 320 208 0 15.0 -15.0 O 320 208 368 208 1 w 208 224 208 288 0 w 176 288 176 224 0 w 176 224 176 192 0 ================================================ FILE: src/circuits/darlington.txt ================================================ $ 1 5.0E-6 10.20027730826997 56 5.0 50 t 368 288 400 288 0 1 -4.687537934791563 0.09853954519174213 100.0 r 304 112 304 208 0 2000000.0 s 304 208 304 288 0 1 false w 304 112 448 112 0 r 448 112 448 224 0 300.0 w 448 320 448 384 1 t 400 304 448 304 0 1 -4.786077479983305 0.2139223639566944 100.0 w 400 272 400 224 0 w 400 224 448 224 0 w 448 224 448 288 0 w 368 288 304 288 1 R 304 112 240 112 0 0 40.0 5.0 0.0 0.0 0.5 g 448 384 448 400 0 ================================================ FILE: src/circuits/dcrestoration.txt ================================================ $ 1 1.0E-6 7 59 5.0 R 160 144 96 144 0 1 500.0 5.0 0.0 c 160 144 272 144 0 5.0E-6 -3.0584720734913993 d 272 256 272 144 0 g 272 256 272 288 0 w 272 144 352 144 0 r 352 144 352 256 0 5000.0 g 352 256 352 288 0 O 352 144 416 144 0 o 7 32 0 2 10.0 9.765625E-5 ================================================ FILE: src/circuits/deccounter.txt ================================================ $ 3 5.0E-6 13 50 5.0 156 72 248 128 248 0 5.0 156 208 248 240 248 0 0.0 156 336 248 368 248 0 0.0 156 464 248 480 248 0 0.0 w 448 312 464 312 0 w 320 312 336 312 0 w 320 312 320 248 0 w 320 248 336 248 0 w 72 248 56 248 0 w 56 248 56 312 0 w 56 312 72 312 0 w 432 248 432 88 0 M 560 64 592 64 2 2.5 R 56 248 24 248 0 0 40.0 5.0 0.0 R 72 360 24 360 1 2 200.0 2.5 2.5 w 72 280 72 360 0 w 72 360 208 360 0 w 208 360 208 280 0 w 336 280 336 360 0 w 336 360 208 360 0 w 336 360 464 360 0 w 464 360 464 280 0 150 336 176 336 248 1 2 0.0 w 304 248 304 112 0 w 304 112 328 112 0 w 328 112 328 176 0 w 344 136 344 176 0 w 168 136 344 136 0 150 464 176 464 248 1 3 0.0 w 344 136 472 136 0 w 472 136 472 176 0 w 328 112 464 112 0 w 464 112 464 176 0 w 432 88 456 88 0 w 456 88 456 176 0 M 464 112 592 112 2 2.5 M 456 88 592 88 2 2.5 150 192 176 240 176 1 2 5.0 w 240 176 240 216 0 w 208 216 208 248 0 w 208 216 240 216 0 w 168 248 168 168 0 w 168 168 192 168 0 w 168 136 168 168 0 w 560 312 560 384 0 w 560 384 184 384 0 w 184 384 184 184 0 w 184 184 192 184 0 w 200 248 208 248 0 w 200 248 200 312 0 w 200 312 208 312 0 150 512 160 512 208 1 2 0.0 w 472 136 504 136 0 w 504 136 504 160 0 w 560 64 560 160 0 w 560 160 520 160 0 w 560 160 560 248 0 w 512 208 584 208 0 w 584 208 584 344 0 w 584 344 448 344 0 w 448 344 448 312 0 M 504 136 592 136 2 2.5 o 12 64 0 6 5.0 9.765625E-5 0 o 36 64 0 6 5.0 9.765625E-5 0 o 35 64 0 6 5.0 9.765625E-5 0 o 61 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/decoder.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 150 416 128 512 128 0 2 0.0 150 416 192 512 192 0 2 0.0 150 416 256 512 256 0 2 0.0 150 416 320 512 320 0 2 5.0 w 416 112 352 112 0 w 352 112 352 176 0 w 352 176 416 176 0 w 416 240 352 240 0 w 352 240 352 304 0 w 352 304 416 304 0 w 416 144 384 144 0 w 384 144 384 272 0 w 384 272 416 272 0 w 416 208 320 208 0 w 320 208 320 336 0 w 320 336 416 336 0 w 144 112 352 112 0 w 352 240 144 240 0 I 144 112 144 240 0 L 144 112 64 112 2 true false 5.0 0.0 w 384 272 144 272 0 w 320 336 144 336 0 L 144 272 64 272 2 true false 5.0 0.0 I 144 272 144 336 0 M 512 128 560 128 0 2.5 M 512 192 560 192 0 2.5 M 512 256 560 256 0 2.5 M 512 320 560 320 0 2.5 ================================================ FILE: src/circuits/delayrc.txt ================================================ $ 1 5.0E-9 10 54 5.0 f 144 144 208 144 1 f 144 240 208 240 0 w 208 160 208 192 0 w 208 192 208 224 0 w 144 144 144 192 0 w 144 192 144 240 0 L 144 192 96 192 0 false false R 208 128 208 80 0 0 40.0 5.0 0.0 g 208 256 208 288 0 r 208 192 288 192 0 1500.0 c 288 192 288 256 0 1.0E-8 4.973779073596618 g 288 256 288 288 0 w 288 192 336 192 0 w 336 192 336 144 0 w 336 192 336 240 0 f 336 144 400 144 1 f 336 240 400 240 0 w 400 160 400 192 0 w 400 192 400 224 0 M 400 192 448 192 0 g 400 256 400 288 0 R 400 128 400 80 0 0 40.0 5.0 0.0 o 6 64 0 6 5.0 9.765625E-5 0 o 19 64 0 6 5.0 9.765625E-5 0 h 2 9 10 ================================================ FILE: src/circuits/deltasigma.txt ================================================ $ 3 5.0E-6 12.185319768402522 50 5.0 50 a 144 248 224 248 0 15.0 -15.0 w 144 232 144 200 0 c 144 200 224 200 0 1.4999999999999999E-5 14.45469914811517 w 224 200 224 248 0 w 144 232 128 232 0 160 112 104 112 168 0 w 128 168 128 232 0 g 96 168 96 184 0 r 128 232 64 232 0 1600.0 i 112 56 112 104 0 0.01 82 112 56 64 56 0 0 40.0 20.0 0.0 0.0 0.5 a 224 264 312 264 0 5.0 0.0 g 224 280 224 296 0 155 312 264 376 264 1 0.0 w 312 280 312 360 0 w 376 312 376 360 0 w 376 360 312 360 0 82 312 360 288 360 1 2 600.0 2.5 2.5 0.0 0.5 w 128 136 376 136 0 w 376 136 376 296 0 164 432 304 480 304 1 4 0.0 0.0 0.0 0.0 82 432 400 376 400 0 2 20.0 2.5 2.5 -0.17453292519943295 0.9 82 144 264 112 264 0 0 40.0 15.0 0.0 0.0 0.5 w 360 296 376 296 0 168 480 304 512 304 1 4 M 528 304 560 304 0 2.5 M 528 320 576 320 0 2.5 M 528 336 592 336 0 2.5 M 528 352 608 352 0 2.5 w 480 368 480 400 0 w 432 352 432 400 0 82 480 400 480 432 0 2 20.0 2.5 2.5 -3.141592653589793 0.5 82 64 232 40 232 0 4 1.0 7.5 7.5 0.0 0.5 153 376 304 432 304 1 2 0.0 o 32 64 0 34 10.0 0.00625 0 -1 o 25 64 0 34 7.62939453125E-5 9.765625E-5 1 -1 o 26 64 0 34 5.0 9.765625E-5 1 -1 o 27 64 0 34 5.0 9.765625E-5 1 -1 o 28 64 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/diff.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 160 288 160 144 0 2 40.0 5.0 0.0 c 160 144 352 144 0 9.0E-6 4.999340978003125 r 352 144 352 288 0 120.0 w 160 288 352 288 0 o 0 64 0 2 10.0 9.765625E-5 0 o 2 64 0 3 20.0 0.2 0 h 2 2 1 ================================================ FILE: src/circuits/digcompare.txt ================================================ $ 3 5.0E-6 1.5 50 5.0 L 64 88 64 56 2 true false 5.0 0.0 w 64 88 88 88 0 I 88 88 88 144 0 L 112 88 112 56 2 true false 5.0 0.0 L 200 88 200 56 2 true false 5.0 0.0 L 248 88 248 56 2 true false 5.0 0.0 w 112 88 136 88 0 I 136 88 136 144 0 154 304 176 360 176 1 2 0.0 w 64 88 64 168 0 w 64 168 304 168 0 w 200 88 200 184 0 w 200 184 304 184 0 154 304 216 360 216 1 2 0.0 w 112 88 112 208 0 w 112 208 304 208 0 w 248 88 248 224 0 w 248 224 304 224 0 151 304 256 360 256 1 2 5.0 w 200 184 200 264 0 w 200 264 304 264 0 w 360 216 360 192 0 w 416 280 304 280 0 151 328 312 400 312 1 3 5.0 w 88 304 328 304 0 w 136 312 328 312 0 w 304 280 304 320 0 w 304 320 328 320 0 151 328 352 400 352 1 3 5.0 w 304 320 304 360 0 w 304 360 328 360 0 w 416 184 416 280 0 151 432 312 504 312 1 3 0.0 w 360 256 432 256 0 w 432 256 432 304 0 w 400 312 432 312 0 w 400 352 432 352 0 w 432 352 432 320 0 152 360 184 416 184 1 2 0.0 w 200 344 328 344 0 w 200 264 200 344 0 w 248 224 248 352 0 w 248 352 328 352 0 I 416 184 512 184 0 M 504 312 600 312 0 2.5 M 512 184 600 184 0 2.5 x 81 37 97 37 0 24 A x 219 38 235 38 0 24 B x 545 169 561 169 0 16 A=B w 512 184 512 392 0 w 504 312 504 408 0 153 512 400 576 400 1 2 0.0 w 504 408 512 408 0 M 576 400 600 400 0 2.5 x 546 298 562 298 0 16 AB w 88 144 88 248 0 w 88 248 88 304 0 w 88 248 304 248 0 w 136 144 136 312 0 ================================================ FILE: src/circuits/digsine.txt ================================================ $ 3 5.0E-6 10 69 5.0 155 80 224 88 224 1 5.0 155 144 224 152 224 1 5.0 155 208 224 216 224 1 0.0 155 272 224 280 224 1 0.0 155 336 224 344 224 1 0.0 155 400 224 416 224 1 0.0 155 464 224 480 224 1 0.0 155 528 224 544 224 1 0.0 w 128 224 144 224 0 w 192 224 208 224 0 w 256 224 272 224 0 w 320 224 336 224 0 w 384 224 400 224 0 w 448 224 464 224 0 w 512 224 528 224 0 w 576 256 576 280 0 w 576 280 64 280 0 w 64 280 64 224 0 w 64 224 80 224 0 w 80 240 72 240 0 w 72 240 72 304 0 w 144 240 136 240 0 w 136 240 136 304 0 w 208 240 200 240 0 w 200 240 200 304 0 w 272 240 264 240 0 w 264 240 264 304 0 w 336 240 328 240 0 w 328 240 328 304 0 w 400 240 392 240 0 w 392 240 392 304 0 w 464 240 456 240 0 w 456 240 456 304 0 w 528 240 520 240 0 w 520 240 520 304 0 w 520 304 456 304 0 w 456 304 392 304 0 w 392 304 328 304 0 w 328 304 264 304 0 w 264 304 200 304 0 w 200 304 136 304 0 w 136 304 72 304 0 R 72 304 32 304 1 2 800.0 2.5 2.5 r 128 224 128 96 0 57600.0 r 192 224 192 96 0 30900.0 r 256 224 256 96 0 23700.0 r 320 224 320 96 0 22100.0 r 384 224 384 96 0 23700.0 r 448 224 448 96 0 30900.0 r 512 224 512 96 0 57600.0 w 128 96 192 96 0 w 192 96 256 96 0 w 256 96 320 96 0 w 320 96 384 96 0 w 384 96 448 96 0 w 448 96 512 96 0 w 512 96 552 96 0 c 552 96 552 176 0 3.0E-7 0.33745879726352607 O 552 96 600 96 0 g 552 176 552 184 0 o 58 64 0 2 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/diodeclip.txt ================================================ $ 1 5.0E-6 11.251013186076355 58 5.0 50 r 272 160 320 160 0 200.0 r 320 160 320 240 0 100.0 d 320 240 320 288 0 R 320 288 320 320 0 0 40.0 5.0 0.0 0.0 0.5 O 320 160 384 160 0 R 272 160 240 160 0 3 40.0 10.0 0.0 0.0 0.5 o 5 64 0 35 10.0 0.1 0 -1 o 4 64 0 34 10.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/diodecurve.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 2.0 50 R 288 208 288 160 0 3 50.0 0.65 0.25 0.0 0.5 d 288 208 288 288 0 g 288 288 288 320 0 o 1 64 0 34 1.25 25.6 0 -1 o 1 64 0 33 0.625 51.2 0 -1 o 1 64 0 99 1.25 51.2 1 -1 I vs V ================================================ FILE: src/circuits/diodelimit.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 176 288 176 144 0 1 40.0 5.0 0.0 r 176 144 272 144 0 110.0 w 272 144 272 192 0 w 272 192 304 192 0 w 272 192 240 192 0 w 176 288 240 288 0 w 240 288 304 288 0 d 240 192 240 288 0 d 304 288 304 192 0 O 272 144 368 144 0 o 0 32 0 3 5.0 0.05 o 9 64 0 2 1.25 2.44140625E-5 ================================================ FILE: src/circuits/diodevar.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 1.0 50 172 336 176 336 128 0 6 0.72 0.77 -1.0 0.0 0.5 Voltage w 336 304 336 336 1 g 336 336 336 352 0 d 336 176 336 304 0 ================================================ FILE: src/circuits/divideby2.txt ================================================ $ 1 5.0E-6 10 50 5.0 155 272 96 320 96 0 0.0 R 272 128 208 128 1 2 100.0 2.5 2.5 w 368 160 368 64 0 w 368 64 272 64 0 w 272 64 272 96 0 M 368 96 448 96 0 o 1 64 0 14 5.0 9.765625E-5 0 o 5 64 0 14 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/divideby3.txt ================================================ $ 1 5.0E-6 10 50 5.0 155 112 192 144 192 0 0.0 155 304 192 352 192 0 0.0 w 304 176 304 192 0 w 304 224 304 304 0 w 112 224 112 304 0 w 112 304 304 304 0 w 112 192 112 128 0 w 400 128 400 192 0 w 112 128 208 128 0 w 208 128 208 160 0 w 208 128 400 128 0 R 112 224 48 224 1 2 150.1 2.5 2.5 M 400 192 464 192 0 153 208 176 304 176 0 2 0.0 o 11 32 0 14 5.0 9.765625E-5 0 o 12 32 0 14 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/dram.txt ================================================ $ 3 5.0E-6 5 86 5.0 50 w 400 16 424 16 0 c 424 16 424 48 0 1.0E-8 0 w 368 16 344 16 0 g 424 48 424 56 0 f 384 72 384 16 4 w 400 88 424 88 0 c 424 88 424 120 0 1.0E-8 5 w 368 88 344 88 0 g 424 120 424 128 0 f 384 144 384 88 4 w 344 16 344 88 0 w 400 160 424 160 0 c 424 160 424 192 0 1.0E-8 0 w 368 160 344 160 0 g 424 192 424 200 0 f 384 216 384 160 4 w 400 232 424 232 0 c 424 232 424 264 0 1.0E-8 5 w 368 232 344 232 0 f 384 288 384 232 4 w 344 160 344 232 0 w 344 88 344 160 0 w 384 72 320 72 0 w 384 144 320 144 0 w 384 216 320 216 0 w 384 288 320 288 0 150 280 72 320 72 1 2 0.0 150 280 144 320 144 1 2 0.0 150 280 216 320 216 1 2 5.0 150 280 288 320 288 1 2 0.0 w 232 64 280 64 0 w 232 64 232 136 0 w 232 136 280 136 0 w 232 136 232 152 0 w 280 208 232 208 0 I 232 152 232 208 0 0.5 w 232 208 232 280 0 w 232 280 280 280 0 w 280 80 264 80 0 w 264 80 264 224 0 w 264 224 280 224 0 w 280 152 256 152 0 I 208 224 208 296 0 0.5 w 208 224 264 224 0 w 256 152 256 296 0 w 208 296 256 296 0 w 256 296 280 296 0 L 208 224 160 224 2 false false 5.0 0.0 L 232 152 160 152 2 true false 5.0 0.0 w 344 304 408 304 0 a 408 312 456 312 3 5.0 0.0 R 408 320 376 320 0 0 40.0 2.5 0.0 w 456 312 456 352 0 159 344 352 456 352 0 159 280 352 344 352 0 x 84 195 100 195 0 12 row select g 424 264 424 272 0 w 344 232 344 304 0 w 344 304 344 352 0 w 280 352 280 392 0 L 280 392 160 392 0 false false 5.0 0.0 L 208 360 160 360 0 true true 5.0 0.0 w 208 360 208 376 0 w 312 376 312 368 0 w 400 376 400 368 0 w 208 376 312 376 0 x 96 365 112 365 0 12 write x 89 430 105 430 0 12 refresh x 96 398 112 398 0 12 data M 456 312 536 312 0 2.5 w 400 376 400 424 0 L 400 424 160 424 0 true true 5.0 0.0 ================================================ FILE: src/circuits/dtlinverter.txt ================================================ $ 1 5.0E-6 10 54 5.0 g 320 272 320 320 0 r 224 176 224 96 0 4700.0 r 320 96 320 176 0 1000.0 w 320 176 320 240 0 M 320 176 416 176 0 w 224 96 320 96 0 t 272 256 320 256 0 1 0.5852076661116874 0.622416726973117 d 224 256 272 256 0 d 224 256 176 256 0 w 224 176 224 256 0 L 176 256 128 256 0 false false R 224 96 128 96 0 0 40.0 5.0 0.0 ================================================ FILE: src/circuits/dtlnand.txt ================================================ $ 1 5.0E-6 10 54 5.0 g 336 272 336 320 0 r 240 176 240 96 0 4700.0 r 336 96 336 176 0 1000.0 w 336 176 336 240 0 M 336 176 432 176 0 w 240 96 336 96 0 t 288 256 336 256 0 1 0.585207666112351 0.6224167269732703 d 240 256 288 256 0 d 240 256 192 256 0 L 192 256 144 256 0 false false R 240 96 144 96 0 0 40.0 5.0 0.0 d 240 224 192 224 0 d 240 288 192 288 0 w 240 176 240 224 0 w 240 224 240 256 0 w 240 256 240 288 0 L 192 224 144 224 0 false false L 192 288 144 288 0 false false ================================================ FILE: src/circuits/dtlnor.txt ================================================ $ 1 5.0E-6 10 54 5.0 t 160 240 208 240 0 1 0.5852076661116881 0.6224167269731172 r 128 160 128 80 0 4700.0 R 128 80 64 80 0 0 40.0 5.0 0.0 w 128 80 208 80 0 t 320 240 368 240 0 1 0.5852076661116883 0.6224167269731175 r 288 80 288 160 0 4700.0 w 208 80 288 80 0 w 288 80 368 80 0 r 368 80 368 160 0 1000.0 w 368 160 416 160 0 M 416 160 480 160 0 r 208 80 208 160 0 1000.0 w 208 160 208 192 0 w 368 160 368 224 0 w 208 192 416 192 0 w 416 192 416 160 0 w 208 192 208 224 0 d 128 240 160 240 0 d 128 240 96 240 0 d 288 240 320 240 0 d 288 240 256 240 0 w 128 160 128 240 0 w 288 160 288 240 0 L 256 240 256 288 0 false false g 208 256 208 320 0 g 368 256 368 320 0 L 96 240 96 288 0 false false ================================================ FILE: src/circuits/eclnor.txt ================================================ $ 1 5.0E-6 2.2188692582893284 54 1.5 58 t 48 240 96 240 0 1 -1.3934257822325842 0.1535491976387855 100.0 t 128 240 176 240 0 1 -1.3934257822325842 0.1535491976387855 100.0 w 96 224 96 192 0 w 96 192 176 192 0 w 176 192 176 224 0 w 96 256 96 288 0 w 96 288 176 288 0 w 176 288 176 256 0 r 208 288 208 384 0 1180.0 w 176 288 208 288 0 w 208 288 240 288 0 t 288 240 240 240 0 1 -0.20927369468138468 0.6038522693256799 100.0 w 240 256 240 288 0 w 240 224 240 144 0 w 176 192 176 112 0 r 176 112 176 48 0 217.0 r 240 48 240 112 0 240.0 w 240 112 240 144 0 t 336 192 288 192 0 1 -0.3644785302182464 0.5852183980948591 100.0 w 288 208 288 240 0 w 288 176 288 48 0 w 336 192 336 112 0 r 336 48 336 112 0 250.0 w 416 48 336 48 0 w 336 48 288 48 0 w 288 48 240 48 0 w 240 48 176 48 0 d 336 192 336 240 0 d 336 240 336 288 0 r 336 288 336 384 0 2460.0 w 240 144 384 144 0 w 176 112 448 112 0 t 384 144 416 144 0 1 -0.7404232336317208 0.5992782584002211 100.0 w 416 160 416 240 0 w 416 128 416 48 0 t 448 112 480 112 0 1 -0.00657421776741567 0.6036056663680556 100.0 w 416 48 480 48 0 w 480 48 480 96 0 w 480 128 480 208 0 r 416 288 416 384 0 1500.0 r 480 288 480 384 0 1500.0 w 480 384 416 384 0 w 416 384 336 384 0 r 288 288 288 384 0 2960.0 w 208 384 288 384 0 w 288 384 336 384 0 R 208 384 160 384 0 0 40.0 -5.2 0.0 0.0 0.5 w 176 48 128 48 0 g 128 48 128 80 0 L 48 240 48 144 0 0 false -0.7 -1.4 L 128 240 128 144 0 0 false -0.7 -1.4 M 480 208 528 208 0 -1.0 M 416 272 528 272 0 -1.0 x 515 191 541 194 0 12 NOR x 518 255 535 258 0 12 OR w 416 240 416 272 0 w 288 288 288 240 0 w 416 288 416 272 0 w 480 208 480 288 0 x 59 278 81 282 0 16 Q1 x 146 278 168 281 0 16 Q2 x 212 246 234 250 0 16 Q3 ================================================ FILE: src/circuits/eclosc.txt ================================================ $ 1 5.0E-6 8.63434833026695 49 1.0 50 l 128 192 128 256 0 0.1 0.009389546443369765 c 192 192 192 256 0 4.9999999999999996E-5 0.39860877318423565 t 160 144 208 144 0 1 0.39860877318423565 0.6730719429761438 100.0 t 352 144 304 144 0 1 -0.39860877318423565 0.2744631697919081 100.0 w 208 128 208 96 0 w 208 96 240 96 0 g 240 96 240 112 0 w 208 160 208 176 0 w 208 176 256 176 0 w 256 176 304 176 0 w 304 176 304 160 0 r 256 176 256 240 0 100.0 R 256 240 256 272 0 0 40.0 -5.2 0.0 0.0 0.5 w 304 128 304 64 0 w 304 64 160 64 0 w 160 64 160 144 0 w 160 144 160 192 0 w 160 192 128 192 0 w 160 192 192 192 0 w 128 256 160 256 0 w 160 256 192 256 0 g 160 256 160 272 0 g 352 144 352 160 0 O 304 64 368 64 0 x 213 150 235 154 0 16 Q1 x 279 150 301 154 0 16 Q2 o 23 32 0 42 1.25 2.44140625E-5 0 -1 ================================================ FILE: src/circuits/edgedff.txt ================================================ $ 1 5.0E-6 10 50 5.0 151 320 272 432 272 0 2 -0.0 151 320 144 432 144 0 2 5.0 w 432 144 432 176 0 w 432 176 320 240 0 w 432 272 432 240 0 w 432 240 320 176 0 w 320 176 320 160 0 w 320 240 320 256 0 151 160 144 272 144 0 2 5.0 151 160 48 272 48 0 2 5.0 151 160 272 272 272 0 3 5.0 151 160 368 272 368 0 2 -0.0 w 160 64 160 80 0 w 160 80 272 112 0 w 160 128 160 112 0 w 160 112 272 80 0 w 272 80 272 48 0 w 160 288 160 304 0 w 160 304 272 336 0 w 272 336 272 368 0 w 160 352 160 336 0 w 160 336 272 304 0 w 272 128 320 128 0 w 272 288 320 288 0 w 272 176 160 240 0 w 160 32 128 32 0 w 128 416 272 416 0 w 160 272 96 272 0 w 96 160 160 160 0 w 160 384 96 384 0 L 96 384 32 384 0 false false R 96 272 32 272 1 2 100.0 2.5 2.5 M 432 144 496 144 0 M 432 272 496 272 0 w 96 160 96 272 0 w 160 256 160 240 0 w 272 144 272 176 0 w 272 368 272 416 0 w 128 416 128 32 0 w 272 112 272 128 0 w 272 128 272 144 0 w 272 272 272 288 0 w 272 288 272 304 0 o 30 64 0 6 5.0 9.765625E-5 0 D o 32 64 0 6 5.0 9.765625E-5 0 Q o 31 64 0 6 5.0 9.765625E-5 0 clk ================================================ FILE: src/circuits/filt-hipass-l.txt ================================================ $ 1 5.0E-6 6.499443210467817 50 5.0 50 O 400 160 512 160 0 g 400 288 400 320 0 r 240 160 400 160 0 187.0 l 400 160 400 288 0 0.06545 0 170 240 160 208 160 3 20.0 1000.0 5.0 0.1 o 4 16 0 34 5.0 9.765625E-5 0 -1 o 0 16 0 34 5.0 9.765625E-5 1 -1 h 5 2 5 ================================================ FILE: src/circuits/filt-hipass.txt ================================================ $ 1 5.0E-6 6.499443210467817 50 5.0 50 c 240 160 400 160 0 1.0E-5 0 r 400 160 400 288 0 35.0 O 400 160 512 160 0 g 400 288 400 320 0 170 240 160 208 160 3 20.0 1000.0 5.0 0.1 o 4 16 0 34 5.0 9.765625E-5 0 -1 in o 2 16 0 34 2.5 9.765625E-5 1 -1 out h 3 1 0 ================================================ FILE: src/circuits/filt-lopass-l.txt ================================================ $ 1 5.0E-6 6.499443210467817 50 5.0 50 r 400 160 400 288 0 35.0 O 400 160 512 160 0 g 400 288 400 320 0 l 240 160 400 160 0 0.06545 0 170 240 160 208 160 3 20.0 1000.0 5.0 0.1 o 4 32 0 34 5.0 9.765625E-5 0 -1 o 1 32 0 34 5.0 9.765625E-5 1 -1 h 5 0 5 ================================================ FILE: src/circuits/filt-lopass.txt ================================================ $ 1 5.0E-6 6.499443210467817 50 5.0 50 O 400 160 512 160 0 g 400 288 400 320 0 r 240 160 400 160 0 187.0 c 400 160 400 288 0 1.0E-5 0 170 240 160 208 160 3 20.0 1000.0 5.0 0.1 o 4 32 0 34 5.0 9.765625E-5 0 -1 o 0 32 0 34 5.0 9.765625E-5 1 -1 h 3 2 3 ================================================ FILE: src/circuits/filt-vcvs-hipass.txt ================================================ $ 1 5.0E-6 10.812258501325767 65 5.0 50 r 464 192 464 256 0 5860.0 r 464 256 464 320 0 10000.0 g 464 320 464 336 0 w 224 128 224 176 0 g 304 256 304 272 0 w 304 176 352 176 0 a 352 192 464 192 1 15.0 -15.0 w 352 208 352 256 0 w 352 256 464 256 0 w 464 192 480 192 0 w 480 192 480 128 0 O 480 192 544 192 0 p 144 176 144 256 0 g 144 256 144 272 0 c 144 176 224 176 0 5.3E-8 -0.956532193261995 c 224 176 304 176 0 5.3E-8 2.2055312375929486 r 304 176 304 256 0 10000.0 r 224 128 480 128 0 10000.0 170 144 176 112 176 3 20.0 800.0 5.0 0.2 o 12 32 0 34 5.0 9.765625E-5 0 -1 o 11 32 0 34 2.5 2.44140625E-5 1 -1 ================================================ FILE: src/circuits/filt-vcvs-lopass.txt ================================================ $ 1 5.0E-6 10.391409633455755 65 5.0 50 r 160 176 240 176 0 10000.0 r 240 176 320 176 0 10000.0 r 480 192 480 256 0 5860.0 r 480 256 480 320 0 10000.0 g 480 320 480 336 0 w 240 128 240 176 0 c 320 176 320 256 0 1.59E-7 0.00526783980718932 g 320 256 320 272 0 w 320 176 368 176 0 a 368 192 480 192 1 15.0 -15.0 w 368 208 368 256 0 w 368 256 480 256 0 w 480 192 496 192 0 w 496 192 496 128 0 c 496 128 240 128 0 1.59E-7 3.118399353779175 O 496 192 560 192 0 p 160 176 160 256 0 g 160 256 160 272 0 170 160 176 128 176 3 20.0 800.0 5.0 0.2 o 16 64 0 34 10.0 9.765625E-5 0 -1 o 15 64 0 34 10.0 4.8828125E-5 1 -1 ================================================ FILE: src/circuits/flashadc.txt ================================================ $ 3 5.0E-6 6.75 58 7.0 a 104 64 176 64 2 5.0 0.0 a 104 112 176 112 2 5.0 0.0 a 104 160 176 160 2 5.0 0.0 a 104 208 176 208 2 5.0 0.0 a 104 256 176 256 2 5.0 0.0 a 104 304 176 304 2 5.0 0.0 a 104 352 176 352 2 5.0 0.0 r 72 8 72 56 0 500.0 r 72 56 72 104 0 1000.0 r 72 104 72 152 0 1000.0 r 72 152 72 200 0 1000.0 r 72 200 72 248 0 1000.0 r 72 248 72 296 0 1000.0 r 72 296 72 344 0 1000.0 r 72 344 72 392 0 500.0 R 72 8 32 8 0 0 40.0 7.0 0.0 w 72 56 104 56 0 w 72 104 104 104 0 w 72 152 104 152 0 w 72 200 104 200 0 w 72 248 104 248 0 w 72 296 104 296 0 w 72 344 104 344 0 w 104 72 104 120 0 w 104 120 104 168 0 w 104 168 104 216 0 w 104 216 104 264 0 w 104 264 104 312 0 w 104 312 104 360 0 w 104 72 104 24 0 R 104 24 184 24 0 4 50.0 3.5 3.5 g 72 392 72 400 0 154 288 368 352 368 1 7 5.0 w 176 352 176 392 0 w 176 392 288 392 0 w 176 304 184 304 0 w 184 304 184 384 0 w 184 384 288 384 0 w 176 256 192 256 0 w 192 256 192 376 0 w 192 376 288 376 0 w 176 208 200 208 0 w 200 208 200 368 0 w 200 368 288 368 0 w 176 160 208 160 0 w 208 160 208 360 0 w 208 360 288 360 0 w 176 112 216 112 0 w 216 112 216 352 0 w 216 352 288 352 0 w 176 64 224 64 0 w 224 64 224 344 0 w 224 344 288 344 0 154 280 296 352 296 1 3 5.0 w 184 304 280 304 0 w 280 296 248 296 0 w 280 288 256 288 0 w 248 296 248 208 0 w 248 208 200 208 0 w 256 288 256 112 0 w 256 112 216 112 0 w 248 208 352 208 0 w 352 368 352 328 0 w 352 208 352 264 0 M 352 328 472 328 0 M 352 296 472 296 0 M 352 264 472 264 0 o 30 32 0 2 10.0 9.765625E-5 0 o 66 32 0 22 6.0 2.44140625E-5 1 o 65 32 0 22 6.0 9.765625E-5 1 o 64 32 0 22 6.0 9.765625E-5 1 ================================================ FILE: src/circuits/follower.txt ================================================ $ 1 5.0E-6 10 50 5.0 w 256 96 352 96 0 r 256 96 256 192 0 800.0 r 256 192 256 304 0 800.0 t 256 192 352 192 0 1 -3.439010340565611 0.6536862364091407 w 352 96 352 176 0 r 352 208 352 304 0 40.0 w 256 304 352 304 0 c 208 192 256 192 0 3.0E-6 1.5823558905147017 R 208 192 160 192 0 1 40.0 5.0 0.0 g 256 304 256 336 0 R 256 96 160 96 0 0 40.0 5.0 0.0 O 352 208 416 208 0 o 2 64 0 2 5.0 0.0015625 o 11 64 0 2 5.0 9.765625E-5 ================================================ FILE: src/circuits/freqdouble.txt ================================================ $ 1 5.0E-6 6.75 61 5.0 158 416 192 448 192 0 c 512 192 512 224 0 1.0E-7 0 r 512 256 576 256 0 3000.0 r 512 288 576 288 0 100000.0 w 576 256 576 288 0 g 576 288 576 320 0 R 128 144 64 144 0 2 300.0 2.5 2.5 g 304 224 304 256 0 w 416 160 416 192 0 a 336 96 416 96 1 15.0 -15.0 w 304 80 336 80 0 w 336 112 336 160 0 w 336 160 416 160 0 w 416 160 416 96 0 161 128 144 176 144 0 r 224 144 304 144 0 2000.0 w 304 80 304 144 0 c 304 144 304 176 0 9.999999999999999E-6 0 155 128 240 144 240 0 5.0 w 224 240 224 208 0 w 224 208 128 208 0 w 128 208 128 176 0 w 224 304 224 336 0 w 224 336 96 336 0 w 96 336 96 240 0 w 96 240 128 240 0 w 128 272 64 272 0 w 64 272 64 352 0 w 64 352 416 352 0 w 416 352 416 288 0 O 416 352 480 352 0 r 304 176 304 224 0 1000.0 o 6 8 0 14 5.0 4.8828125E-5 0 o 30 8 0 14 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/fulladd.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 154 144 272 272 272 0 2 -0.0 154 336 256 464 256 0 2 -0.0 w 272 272 304 272 0 w 304 272 336 272 0 w 336 160 272 160 0 w 336 240 272 240 0 w 272 240 272 224 0 w 272 224 144 224 0 w 272 160 272 224 0 w 288 128 464 128 0 M 592 160 624 160 2 w 112 288 144 288 0 w 144 112 80 112 0 w 80 112 80 256 0 w 80 256 144 256 0 L 80 256 48 256 2 true false L 112 288 48 288 2 true false L 144 224 48 224 2 true false w 144 144 112 144 0 w 112 144 112 288 0 w 464 128 464 144 0 w 336 192 304 192 0 w 304 192 304 272 0 w 464 256 576 256 0 w 576 256 576 208 0 M 576 208 624 208 2 150 144 128 288 128 0 2 0.0 150 336 176 464 176 0 2 0.0 152 464 160 592 160 0 2 0.0 ================================================ FILE: src/circuits/fullrect.txt ================================================ $ 1 5.0E-6 10 53 5.0 50 v 160 352 160 64 0 1 40.0 5.0 0.0 w 160 64 304 64 0 w 304 64 304 128 0 d 304 128 368 192 0 d 304 256 368 192 0 d 240 192 304 128 0 d 240 192 304 256 0 w 304 256 304 352 0 w 304 352 160 352 0 w 240 192 240 288 0 w 368 192 416 192 0 w 240 288 416 288 0 r 416 192 416 288 0 100.0 x 463 248 479 248 0 20 load o 0 64 0 3 5.0 0.05 0 o 12 64 0 3 5.0 0.05 1 ================================================ FILE: src/circuits/fullrectf.txt ================================================ $ 1 5.0E-6 10 50 5.0 48 v 96 336 96 48 0 1 40.0 5.0 0.0 w 96 48 224 48 0 w 224 48 224 112 0 d 224 112 288 176 0 d 224 240 288 176 0 d 160 176 224 112 0 d 160 176 224 240 0 w 224 240 224 336 0 w 224 336 96 336 0 w 160 176 160 272 0 w 288 176 336 176 0 w 160 272 336 272 0 c 336 176 336 272 0 1.02E-4 3.2105610440835166 w 336 176 416 176 0 w 336 272 416 272 0 r 416 176 416 272 0 430.0 x 451 232 457 232 0 16 load o 0 32 0 2 5.0 9.765625E-5 o 15 32 0 3 5.0 0.0125 ================================================ FILE: src/circuits/graycode.txt ================================================ $ 3 5.0E-6 23 50 5.0 50 R 144 152 104 152 1 2 200.0 2.5 2.5 154 304 152 432 152 0 2 0.0 154 304 224 432 224 0 2 5.0 154 304 296 432 296 0 2 0.0 w 240 312 304 312 0 w 304 240 304 280 0 w 240 96 304 96 0 w 304 96 304 136 0 w 304 96 432 96 0 M 432 96 472 96 0 2.5 M 432 152 472 152 0 2.5 M 432 224 472 224 0 2.5 M 432 296 472 296 0 2.5 164 144 152 224 152 0 4 0.0 5.0 0.0 0.0 w 240 96 240 152 0 w 240 184 304 184 0 w 304 184 304 168 0 w 304 184 304 208 0 w 240 248 240 312 0 w 240 216 264 216 0 w 264 216 264 240 0 w 264 240 304 240 0 R 144 248 104 248 0 0 40.0 5.0 0.0 o 9 64 0 6 5.0 9.765625E-5 0 o 10 64 0 6 5.0 9.765625E-5 0 o 11 64 0 6 5.0 9.765625E-5 0 o 12 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/grid.txt ================================================ $ 17 5.0E-6 2 46 5.0 42 R 272 64 272 16 0 g 272 352 272 384 0 r 176 64 176 112 0 5 r 176 112 176 160 0 5 r 176 160 176 208 0 5 r 176 208 176 256 0 5 r 176 256 176 304 0 5 r 176 304 176 352 0 5 r 224 64 224 112 0 5 r 224 112 224 160 0 5 r 224 160 224 208 0 5 r 224 208 224 256 0 5 r 224 256 224 304 0 5 r 224 304 224 352 0 5 r 272 64 272 112 0 5 r 272 112 272 160 0 5 r 272 160 272 208 0 5 r 272 208 272 256 0 5 r 272 256 272 304 0 5 r 272 304 272 352 0 5 r 320 64 320 112 0 5 r 320 112 320 160 0 5 r 320 160 320 208 0 5 r 320 208 320 256 0 5 r 320 256 320 304 0 5 r 320 304 320 352 0 5 r 368 64 368 112 0 5 r 368 112 368 160 0 5 r 368 160 368 208 0 5 r 368 208 368 256 0 5 r 368 256 368 304 0 5 r 368 304 368 352 0 5 r 176 64 224 64 0 5 r 176 112 224 112 0 5 r 176 160 224 160 0 5 r 176 208 224 208 0 5 r 176 256 224 256 0 5 r 176 304 224 304 0 5 r 176 352 224 352 0 5 r 224 64 272 64 0 5 r 224 112 272 112 0 5 r 224 160 272 160 0 5 r 224 208 272 208 0 5 r 224 256 272 256 0 5 r 224 304 272 304 0 5 r 224 352 272 352 0 5 r 272 64 320 64 0 5 r 272 112 320 112 0 5 r 272 160 320 160 0 5 r 272 208 320 208 0 5 r 272 256 320 256 0 5 r 272 304 320 304 0 5 r 272 352 320 352 0 5 r 320 64 368 64 0 5 r 320 112 368 112 0 5 r 320 160 368 160 0 5 r 320 208 368 208 0 5 r 320 256 368 256 0 5 r 320 304 368 304 0 5 r 320 352 368 352 0 5 ================================================ FILE: src/circuits/grid2.txt ================================================ $ 17 5.0E-6 2 46 5.0 v 272 256 272 208 0 0 r 32 64 32 112 0 10 r 32 112 32 160 0 10 r 32 160 32 208 0 10 r 32 208 32 256 0 10 r 32 256 32 304 0 10 r 32 304 32 352 0 10 r 32 352 32 400 0 10 r 80 64 80 112 0 10 r 80 112 80 160 0 10 r 80 160 80 208 0 10 r 80 208 80 256 0 10 r 80 256 80 304 0 10 r 80 304 80 352 0 10 r 80 352 80 400 0 10 r 128 64 128 112 0 10 r 128 112 128 160 0 10 r 128 160 128 208 0 10 r 128 208 128 256 0 10 r 128 256 128 304 0 10 r 128 304 128 352 0 10 r 128 352 128 400 0 10 r 176 64 176 112 0 10 r 176 112 176 160 0 10 r 176 160 176 208 0 10 r 176 208 176 256 0 10 r 176 256 176 304 0 10 r 176 304 176 352 0 10 r 176 352 176 400 0 10 r 224 64 224 112 0 10 r 224 112 224 160 0 10 r 224 160 224 208 0 10 r 224 208 224 256 0 10 r 224 256 224 304 0 10 r 224 304 224 352 0 10 r 224 352 224 400 0 10 r 272 64 272 112 0 10 r 272 112 272 160 0 10 r 272 160 272 208 0 10 r 272 256 272 304 0 10 r 272 304 272 352 0 10 r 272 352 272 400 0 10 r 320 64 320 112 0 10 r 320 112 320 160 0 10 r 320 160 320 208 0 10 r 320 208 320 256 0 10 r 320 256 320 304 0 10 r 320 304 320 352 0 10 r 320 352 320 400 0 10 r 368 64 368 112 0 10 r 368 112 368 160 0 10 r 368 160 368 208 0 10 r 368 208 368 256 0 10 r 368 256 368 304 0 10 r 368 304 368 352 0 10 r 368 352 368 400 0 10 r 416 64 416 112 0 10 r 416 112 416 160 0 10 r 416 160 416 208 0 10 r 416 208 416 256 0 10 r 416 256 416 304 0 10 r 416 304 416 352 0 10 r 416 352 416 400 0 10 r 464 64 464 112 0 10 r 464 112 464 160 0 10 r 464 160 464 208 0 10 r 464 208 464 256 0 10 r 464 256 464 304 0 10 r 464 304 464 352 0 10 r 464 352 464 400 0 10 r 512 64 512 112 0 10 r 512 112 512 160 0 10 r 512 160 512 208 0 10 r 512 208 512 256 0 10 r 512 256 512 304 0 10 r 512 304 512 352 0 10 r 512 352 512 400 0 10 r 32 64 80 64 0 10 r 32 112 80 112 0 10 r 32 160 80 160 0 10 r 32 208 80 208 0 10 r 32 256 80 256 0 10 r 32 304 80 304 0 10 r 32 352 80 352 0 10 r 32 400 80 400 0 10 r 80 64 128 64 0 10 r 80 112 128 112 0 10 r 80 160 128 160 0 10 r 80 208 128 208 0 10 r 80 256 128 256 0 10 r 80 304 128 304 0 10 r 80 352 128 352 0 10 r 80 400 128 400 0 10 r 128 64 176 64 0 10 r 128 112 176 112 0 10 r 128 160 176 160 0 10 r 128 208 176 208 0 10 r 128 256 176 256 0 10 r 128 304 176 304 0 10 r 128 352 176 352 0 10 r 128 400 176 400 0 10 r 176 64 224 64 0 10 r 176 112 224 112 0 10 r 176 160 224 160 0 10 r 176 208 224 208 0 10 r 176 256 224 256 0 10 r 176 304 224 304 0 10 r 176 352 224 352 0 10 r 176 400 224 400 0 10 r 224 64 272 64 0 10 r 224 112 272 112 0 10 r 224 160 272 160 0 10 r 224 208 272 208 0 10 r 224 256 272 256 0 10 r 224 304 272 304 0 10 r 224 352 272 352 0 10 r 224 400 272 400 0 10 r 272 64 320 64 0 10 r 272 112 320 112 0 10 r 272 160 320 160 0 10 r 272 208 320 208 0 10 r 272 256 320 256 0 10 r 272 304 320 304 0 10 r 272 352 320 352 0 10 r 272 400 320 400 0 10 r 320 64 368 64 0 10 r 320 112 368 112 0 10 r 320 160 368 160 0 10 r 320 208 368 208 0 10 r 320 256 368 256 0 10 r 320 304 368 304 0 10 r 320 352 368 352 0 10 r 320 400 368 400 0 10 r 368 64 416 64 0 10 r 368 112 416 112 0 10 r 368 160 416 160 0 10 r 368 208 416 208 0 10 r 368 256 416 256 0 10 r 368 304 416 304 0 10 r 368 352 416 352 0 10 r 368 400 416 400 0 10 r 416 64 464 64 0 10 r 416 112 464 112 0 10 r 416 160 464 160 0 10 r 416 208 464 208 0 10 r 416 256 464 256 0 10 r 416 304 464 304 0 10 r 416 352 464 352 0 10 r 416 400 464 400 0 10 r 464 64 512 64 0 10 r 464 112 512 112 0 10 r 464 160 512 160 0 10 r 464 208 512 208 0 10 r 464 256 512 256 0 10 r 464 304 512 304 0 10 r 464 352 512 352 0 10 r 464 400 512 400 0 10 ================================================ FILE: src/circuits/gyrator.txt ================================================ $ 1 5.0E-6 10.634267539816555 57 5.0 50 a 368 128 480 128 0 15.0 -15.0 1000000.0 w 480 128 480 80 0 w 480 80 368 80 0 w 368 80 368 112 0 r 368 144 368 240 0 20000.0 r 368 112 272 112 0 1000.0 c 272 144 368 144 0 2.5E-7 -1.9401381307764982 w 272 144 272 128 0 w 272 112 272 128 0 R 272 128 208 128 0 2 20.0 5.0 0.0 0.0 0.5 g 368 240 368 272 0 R 272 320 208 320 0 2 20.0 5.0 0.0 0.0 0.5 l 368 320 368 384 0 5.0 -0.0019401381307769976 g 368 384 368 400 0 r 368 320 272 320 0 1000.0 o 9 64 0 35 9.353610478917778 0.005846006549323612 0 -1 o 11 64 0 35 9.353610478917778 0.005846006549323612 1 -1 ================================================ FILE: src/circuits/halfadd.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 154 224 240 368 240 0 2 0.0 150 224 144 368 144 0 2 0.0 L 128 160 80 160 2 true false L 128 224 80 224 2 true false w 128 224 160 224 0 w 160 224 160 128 0 w 160 128 224 128 0 w 160 224 224 224 0 w 128 160 192 160 0 w 192 160 192 256 0 w 192 256 224 256 0 w 192 160 224 160 0 M 368 144 416 144 2 M 368 240 416 240 2 ================================================ FILE: src/circuits/hartley.txt ================================================ $ 1 5.0E-6 3.333936307694169 54 5.0 50 t 256 128 304 128 0 1 -5.22517933037985 -0.6454813682869913 100.0 w 80 304 192 304 0 w 80 128 192 128 0 w 192 128 256 128 0 w 192 224 304 224 0 w 304 144 304 224 0 w 304 112 352 112 0 r 352 112 352 304 0 1000.0 w 192 304 352 304 0 r 304 112 304 48 0 100.0 R 304 48 256 48 0 0 40.0 5.0 0.0 0.0 0.5 g 304 224 304 256 0 O 352 112 432 112 0 l 192 128 192 224 0 1.5 -0.001126760367703781 l 192 224 192 304 0 0.5 -0.005329780746696711 c 80 128 80 304 0 6.33E-7 -1.0221589514366398 x 157 182 176 186 0 16 L1 x 157 273 176 277 0 16 L2 o 12 32 0 42 5.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/hfadc.txt ================================================ $ 3 5.0E-6 11.251013186076355 50 5.0 50 166 360 112 384 112 1 4 R 408 160 448 160 0 0 40.0 25.5 0.0 w 408 112 488 112 0 w 488 112 488 184 0 a 160 272 224 272 2 15.0 -15.0 r 160 240 224 240 0 100000.0 w 224 240 224 272 0 w 488 184 160 184 0 r 160 184 160 240 0 100000.0 w 160 240 160 264 0 w 120 112 120 280 0 R 120 112 80 112 0 4 5.0 12.8 12.8 r 120 280 160 280 0 100000.0 g 160 352 160 368 0 r 160 280 160 352 0 100000.0 167 272 112 280 112 1 4 w 120 112 272 112 0 R 272 160 232 160 0 0 40.0 25.5 0.0 167 272 272 296 272 1 4 w 224 272 272 272 0 R 272 320 232 320 0 0 40.0 1.5 0.0 w 320 112 352 112 0 w 320 128 344 128 0 w 320 144 336 144 0 w 320 160 328 160 0 w 328 160 360 160 0 w 336 144 360 144 0 w 344 128 360 128 0 w 328 160 328 256 0 w 336 144 336 240 0 w 344 128 344 224 0 w 352 112 352 208 0 w 352 112 360 112 0 M 352 208 440 208 0 2.5 M 344 224 456 224 0 2.5 M 336 240 472 240 0 2.5 M 328 256 488 256 0 2.5 M 320 272 504 272 0 2.5 M 320 288 520 288 0 2.5 M 320 304 536 304 0 2.5 M 320 320 552 320 0 2.5 o 33 64 0 6 5.0 9.765625E-5 0 o 34 64 0 6 5.0 9.765625E-5 0 o 35 64 0 6 5.0 9.765625E-5 0 o 36 64 0 6 5.0 9.765625E-5 0 o 37 64 0 6 5.0 9.765625E-5 0 o 38 64 0 6 5.0 9.765625E-5 0 o 39 64 0 6 5.0 9.765625E-5 0 o 40 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/howland.txt ================================================ $ 1 5.0E-6 10.391409633455755 58 5.0 50 a 256 160 368 160 0 15.0 -15.0 w 368 160 368 96 0 w 368 160 368 224 0 r 256 224 368 224 0 3000.0 r 256 96 368 96 0 5000.0 r 256 96 144 96 0 5000.0 r 144 224 256 224 0 3000.0 w 256 176 256 224 0 R 144 96 144 48 0 0 40.0 -5.0 0.0 0.0 0.5 g 144 224 144 256 0 w 256 96 256 144 0 w 256 224 256 272 0 r 256 272 256 352 0 2000.0 s 304 272 304 352 0 1 false w 256 352 304 352 0 g 256 352 256 384 0 w 256 272 304 272 0 x 187 67 217 74 0 24 R1 x 300 67 330 73 0 24 R2 x 185 259 215 265 0 24 R3 x 298 259 328 265 0 24 R4 x 184 320 234 326 0 24 load o 11 64 0 33 2.5 0.003125 0 -1 ================================================ FILE: src/circuits/impedance.txt ================================================ $ 1 5.0E-6 4.798788906309526 54 5.0 48 v 240 176 240 112 0 1 80.0 5.0 0.0 1.5707963267948966 0.5 r 240 112 400 112 0 100.0 w 240 176 400 176 0 v 240 368 240 304 0 1 80.0 5.0 0.0 1.5707963267948966 0.5 w 240 368 400 368 0 r 240 304 400 304 0 100.0 l 400 112 400 176 0 0.34458 3.979221357045121E-4 c 400 304 400 368 0 1.1486E-5 2.224479357247581 w 240 272 400 272 0 v 240 272 240 208 0 1 80.0 5.0 0.0 1.5707963267948966 0.5 w 240 208 400 208 0 r 400 208 400 272 0 200.0 o 6 32 0 49 5.0 0.051 0 -1 o 11 32 0 49 5.0 0.051 0 -1 o 7 32 0 49 5.0 0.051 0 -1 ================================================ FILE: src/circuits/indmultfreq.txt ================================================ $ 1 5.0E-6 10 53 5.0 46 v 176 96 176 32 2 1 30.0 5.0 0.0 r 176 32 336 32 0 200.0 w 176 96 336 96 0 v 176 192 176 128 2 1 80.0 5.0 0.0 r 176 128 336 128 0 200.0 w 176 192 336 192 0 v 176 288 176 224 2 1 200.0 5.0 0.0 w 176 288 336 288 0 r 176 224 336 224 0 200.0 l 336 32 336 96 0 0.4 0.012667996353689499 l 336 128 336 192 0 0.4 0.005302775030447975 l 336 224 336 288 0 0.4 0.009241480515348987 o 9 64 0 17 2.5 0.025 o 10 64 0 17 5.0 0.025 o 11 64 0 17 5.0 0.025 ================================================ FILE: src/circuits/indmultind.txt ================================================ $ 1 5.0E-6 10 53 5.0 46 v 224 144 224 80 2 1 80.0 5.0 0.0 r 224 80 384 80 0 100.0 w 224 144 384 144 0 v 224 240 224 176 2 1 80.0 5.0 0.0 r 224 176 384 176 0 100.0 w 224 240 384 240 0 v 224 336 224 272 2 1 80.0 5.0 0.0 w 224 336 384 336 0 r 224 272 384 272 0 100.0 l 384 80 384 144 0 1.0 0 l 384 176 384 240 0 0.4 0 l 384 272 384 336 0 0.02 0 o 9 64 0 17 10.0 0.05 0 o 10 64 0 17 5.0 0.05 1 o 11 64 0 17 5.0 0.05 2 ================================================ FILE: src/circuits/indpar.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 48 336 48 64 0 0 40.0 5.0 0.0 S 144 144 144 64 0 false false 1 w 240 64 240 336 0 r 48 336 144 336 0 100.0 r 144 336 240 336 0 100.0 w 48 64 128 64 0 w 160 64 240 64 0 r 288 336 384 336 0 100.0 r 384 336 480 336 0 100.0 w 480 64 480 336 0 S 384 144 384 64 0 false false 1 w 288 64 368 64 0 w 400 64 480 64 0 v 288 336 288 64 0 0 40.0 5.0 0.0 w 144 144 144 192 0 w 144 336 144 288 0 w 144 288 96 288 0 w 96 192 144 192 0 w 144 192 192 192 0 l 96 192 96 288 0 1.0 0 l 192 192 192 288 0 5.0 0 l 384 144 384 336 0 .8333 0 w 144 288 192 288 0 ================================================ FILE: src/circuits/indseries.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 48 336 48 64 0 0 40.0 5.0 0.0 S 144 144 144 64 0 false false 1 w 240 64 240 336 0 r 48 336 144 336 0 100.0 r 144 336 240 336 0 100.0 w 48 64 128 64 0 w 160 64 240 64 0 r 288 336 384 336 0 100.0 r 384 336 480 336 0 100.0 w 480 64 480 336 0 S 384 144 384 64 0 false false 1 w 288 64 368 64 0 w 400 64 480 64 0 v 288 336 288 64 0 0 40.0 5.0 0.0 l 384 144 384 336 0 1.0 0 l 144 144 144 240 0 0.1 0 l 144 240 144 336 0 0.9 0 ================================================ FILE: src/circuits/induct.txt ================================================ $ 1 5.0E-6 16 50 5.0 v 96 336 96 64 0 0 40.0 5.0 0.0 S 256 144 256 64 0 false false 0 w 96 64 240 64 0 r 96 336 256 336 0 140.0 r 256 336 400 336 0 140.0 w 272 64 400 64 0 w 400 64 400 336 0 l 256 144 256 336 0 3.0 0 o 7 128 0 3 5.0 0.05 ================================================ FILE: src/circuits/inductac.txt ================================================ $ 1 5.0E-6 14.3 55 5.0 v 176 256 176 80 0 1 40.0 5.0 0.0 r 176 80 336 80 0 180.0 w 176 256 336 256 0 l 336 80 336 256 0 1.0 -0.01522759374043248 o 3 64 0 3 10.0 0.025 ================================================ FILE: src/circuits/inductkick-block.txt ================================================ $ 1 5.0E-6 10 50 5.0 42 v 176 304 176 128 0 0 40.0 5.0 0.0 w 176 304 224 304 0 w 336 304 288 304 0 s 224 304 288 304 0 false false w 288 304 288 336 0 w 224 304 224 336 0 c 224 336 288 336 0 5.0E-10 -0.0 l 176 128 336 128 0 1.0 0 r 336 128 336 304 0 100.0 w 176 128 176 80 0 w 336 128 336 80 0 d 336 80 176 80 0 ================================================ FILE: src/circuits/inductkick-snub.txt ================================================ $ 1 5.0E-6 10 50 5.0 42 v 176 304 176 128 0 0 40.0 5.0 0.0 w 176 304 224 304 0 w 336 304 288 304 0 s 224 304 288 304 0 false false w 288 304 288 336 0 w 224 304 224 336 0 c 224 336 288 336 0 5.0E-10 -0.0 l 176 128 336 128 0 1.0 0 r 336 128 336 304 0 100.0 w 176 128 176 80 0 w 336 128 336 80 0 r 256 80 176 80 0 100.0 c 256 80 336 80 0 9.999999999999999E-6 0.04169291603818248 o 7 64 0 3 5.0 0.05 ================================================ FILE: src/circuits/inductkick.txt ================================================ $ 1 5.0E-6 10 50 5.0 42 v 176 256 176 80 0 0 40.0 5.0 0.0 w 176 256 224 256 0 w 336 256 288 256 0 s 224 256 288 256 0 false false w 288 256 288 288 0 w 224 256 224 288 0 c 224 288 288 288 0 5.0E-10 -0.0 l 176 80 336 80 0 1.0 0 r 336 80 336 256 0 100.0 o 7 4 0 3 1.52587890625E-4 0.05 o 8 4 0 3 5.0 0.05 o 6 4 0 3 7.62939453125E-5 9.765625E-5 ================================================ FILE: src/circuits/inv-osc.txt ================================================ $ 1 5.0E-6 73 50 5.0 50 I 272 208 352 208 0 0.5 c 352 208 352 128 0 3.9999999999999996E-5 0.3979592824367497 r 192 128 192 208 0 4000.0 I 192 208 272 208 0 2.0E-4 p 192 208 192 272 0 g 192 272 192 288 0 w 272 128 352 128 0 r 272 128 272 208 0 400.0 w 192 128 272 128 0 O 352 208 432 208 0 o 9 128 0 10 10.0 9.765625E-5 0 ================================================ FILE: src/circuits/invertamp.txt ================================================ $ 1 5.0E-6 10 53 5.0 f 272 176 336 176 1 f 272 272 336 272 0 w 336 192 336 224 0 w 336 224 336 256 0 w 272 176 272 224 0 w 272 224 272 272 0 R 336 160 336 112 0 0 40.0 5.0 0.0 g 336 288 336 320 0 c 272 224 208 224 0 1.0E-7 2 R 208 224 160 224 0 1 250.0 0.01 0.0 w 336 224 416 224 0 w 416 224 416 64 0 r 416 64 272 64 0 1000000.0 w 272 64 272 176 0 O 416 224 496 224 0 o 9 32 0 2 0.01953125 1.220703125E-5 o 14 32 0 2 5.0 9.765625E-5 ================================================ FILE: src/circuits/itov.txt ================================================ $ 1 5.0E-6 10 59 5.0 r 272 112 384 112 0 1001.0 w 272 112 272 160 0 g 272 192 272 288 0 S 192 240 192 160 0 true false 0 S 192 80 192 160 0 true false 0 w 112 80 112 160 0 w 112 160 112 240 0 r 112 160 176 160 0 1000.0 i 192 80 112 80 0 0.0010 i 192 240 112 240 0 0.0020 a 272 176 384 176 0 w 384 112 384 176 0 O 384 176 448 176 1 R 112 240 112 280 0 0 40 -5 0 0 .5 w 272 160 208 160 1 o 14 64 0 1 7.62939453125E-5 0.003125 o 12 64 0 2 5.0 9.765625E-5 ================================================ FILE: src/circuits/jfetamp.txt ================================================ $ 1 5.0E-6 32 60 5.0 53 r 272 224 272 320 0 1675.0 j 224 208 272 208 0 R 224 208 176 208 0 1 40.0 0.1 0.0 R 272 80 224 80 0 0 40.0 10.0 0.0 r 272 80 272 192 0 1675.0 c 272 192 384 192 0 1.0E-6 7.557166811906079 r 384 192 384 320 0 50000.0 g 384 320 384 352 0 O 384 192 448 192 0 w 272 224 320 224 0 c 320 224 320 320 0 9.999999999999999E-5 2.459186829842572 w 272 320 320 320 0 g 272 320 272 352 0 o 2 128 0 2 0.15625 9.765625E-5 0 o 8 128 0 2 0.625 1.220703125E-5 1 ================================================ FILE: src/circuits/jfetcurrentsrc.txt ================================================ $ 1 5.0E-6 10 58 10.0 g 256 336 256 368 0 w 256 224 256 176 0 w 256 176 304 176 0 w 256 80 304 80 0 R 256 80 256 32 0 0 40.0 10.0 0.0 s 304 80 304 176 0 true false r 256 80 256 176 0 1500.0 j 208 240 256 240 0 w 208 240 208 336 0 w 208 336 256 336 0 r 256 256 256 336 0 1000.0 o 4 64 0 1 5.0 0.00625 ================================================ FILE: src/circuits/jfetfollower-nooff.txt ================================================ $ 1 5.0E-6 10 50 5.0 r 256 128 256 224 0 1100.0 j 208 112 256 112 0 R 208 112 160 112 0 1 40.0 2.0 0.0 j 208 240 256 240 0 r 256 256 256 320 0 1100.0 w 208 240 208 320 0 w 208 320 256 320 0 R 256 320 256 384 0 0 40.0 -10.0 0.0 O 256 224 352 224 0 R 256 96 256 32 0 0 40.0 10.0 0.0 o 2 64 0 2 2.5 9.765625E-5 o 8 64 0 2 2.5 1.220703125E-5 ================================================ FILE: src/circuits/jfetfollower.txt ================================================ $ 1 5.0E-6 10 60 5.0 58 w 288 80 288 160 0 r 288 192 288 288 0 10000.0 O 288 192 336 192 0 j 240 176 288 176 0 R 240 176 192 176 0 1 40.0 2.0 0.0 g 288 288 288 320 0 R 288 80 240 80 0 0 40.0 10.0 0.0 o 4 64 0 2 2.5 9.765625E-5 o 2 64 0 2 10.0 9.765625E-5 ================================================ FILE: src/circuits/jkff.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 151 432 144 528 144 0 2 0.0 151 432 256 528 256 0 2 5.0 w 432 224 432 240 0 w 432 160 432 176 0 w 528 224 528 256 0 w 528 224 432 176 0 w 528 144 528 176 0 w 528 176 432 224 0 151 320 128 432 128 0 2 5.0 151 320 272 432 272 0 2 0.0 w 320 144 320 256 0 w 320 256 320 336 0 151 192 144 288 144 0 2 0.0 151 192 256 288 256 0 2 5.0 w 320 112 288 112 0 w 288 112 288 144 0 w 288 256 288 288 0 w 288 288 320 288 0 w 192 160 192 176 0 w 192 240 192 224 0 w 288 224 288 256 0 w 288 224 192 176 0 w 288 176 288 144 0 w 288 176 192 224 0 151 80 128 192 128 0 3 5.0 I 64 336 320 336 0 0.5 M 528 144 592 144 0 2.5 M 528 256 592 256 0 2.5 x 518 117 537 123 0 24 Q x 520 305 539 311 2 24 Q w 32 112 80 112 0 x 30 47 37 53 0 24 J R 64 336 32 336 1 2 120.0 2.5 2.5 0.0 0.5 151 80 272 192 272 0 3 5.0 w 432 160 432 64 0 w 432 64 80 64 0 w 80 64 80 128 0 L 32 256 32 224 0 1 false 5.0 0.0 x 24 193 40 199 0 24 K w 64 336 64 256 0 w 64 256 80 256 0 w 80 144 64 144 0 w 64 144 64 256 0 w 32 288 32 256 0 w 32 288 80 288 0 w 432 240 432 368 0 w 432 368 80 368 0 w 80 368 80 272 0 L 32 112 32 80 0 1 false 5.0 0.0 o 48 64 0 38 7.62939453125E-5 9.765625E-5 0 -1 J o 37 64 0 38 5.0 9.765625E-5 0 -1 K o 26 64 0 38 7.62939453125E-5 9.765625E-5 0 -1 Q o 32 64 0 38 5.0 9.765625E-5 0 -1 clk ================================================ FILE: src/circuits/johnsonctr.txt ================================================ $ 3 5.0E-6 10.391409633455755 50 5.0 50 155 88 360 104 360 1 5.0 155 168 360 184 360 1 5.0 155 248 360 256 360 1 5.0 155 328 360 344 360 1 5.0 155 408 360 424 360 1 5.0 w 456 392 456 416 0 w 456 416 64 416 0 w 64 416 64 360 0 w 64 360 88 360 0 w 88 376 80 376 0 w 80 376 80 440 0 w 168 376 160 376 0 w 160 376 160 440 0 w 248 376 240 376 0 w 240 376 240 440 0 w 328 376 320 376 0 w 320 376 320 440 0 w 408 376 400 376 0 w 400 376 400 440 0 w 80 440 160 440 0 w 160 440 240 440 0 w 240 440 320 440 0 w 320 440 400 440 0 R 80 440 24 440 1 2 300.0 2.5 2.5 0.0 0.5 150 128 312 128 256 1 2 5.0 150 168 312 168 256 1 2 0.0 150 208 312 208 256 1 2 0.0 150 248 312 248 256 1 2 0.0 150 288 312 288 256 1 2 0.0 150 328 312 328 256 1 2 0.0 150 368 312 368 256 1 2 0.0 150 408 312 408 256 1 2 0.0 150 448 312 448 256 1 2 0.0 150 88 312 88 256 1 2 0.0 w 64 360 64 312 0 w 64 312 80 312 0 w 136 392 136 344 0 w 136 344 96 344 0 w 96 344 96 312 0 w 120 312 120 320 0 w 120 320 456 320 0 w 456 320 456 312 0 w 136 312 160 312 0 w 160 312 160 360 0 w 160 360 168 360 0 w 456 320 456 360 0 w 216 360 216 312 0 w 216 312 240 312 0 w 216 392 224 392 0 w 224 392 224 336 0 w 224 336 176 336 0 w 176 336 176 312 0 w 280 312 280 336 0 w 280 336 224 336 0 w 296 360 296 312 0 w 296 312 320 312 0 w 376 360 376 312 0 w 376 312 400 312 0 w 200 312 200 344 0 w 200 344 136 344 0 w 360 312 360 328 0 w 256 328 256 312 0 w 296 392 304 392 0 w 256 328 304 328 0 w 304 328 304 392 0 w 304 328 360 328 0 w 336 312 336 336 0 w 336 336 384 336 0 w 384 336 440 336 0 w 440 336 440 312 0 w 384 336 384 392 0 w 384 392 376 392 0 w 416 312 416 328 0 w 416 328 464 328 0 w 464 328 464 392 0 w 464 392 456 392 0 w 88 256 88 40 0 w 88 40 456 40 0 w 168 256 168 64 0 w 168 64 456 64 0 w 248 256 248 88 0 w 248 88 456 88 0 M 456 40 488 40 0 2.5 M 456 64 488 64 0 2.5 M 456 88 488 88 0 2.5 w 328 256 328 112 0 w 328 112 456 112 0 w 408 256 408 136 0 w 408 136 456 136 0 M 456 112 488 112 0 2.5 M 456 136 488 136 0 2.5 w 456 160 128 160 0 w 456 184 208 184 0 w 456 208 288 208 0 w 456 232 368 232 0 w 456 256 448 256 0 w 128 160 128 256 0 w 208 184 208 256 0 w 288 208 288 256 0 w 368 232 368 256 0 M 456 160 488 160 0 2.5 M 456 184 488 184 0 2.5 M 456 208 488 208 0 2.5 M 456 232 488 232 0 2.5 M 456 256 488 256 0 2.5 w 136 360 144 360 0 w 144 360 144 448 0 w 144 360 160 360 0 w 216 360 232 360 0 w 232 360 232 448 0 w 232 360 248 360 0 w 296 360 312 360 0 w 312 360 328 360 0 w 312 360 312 448 0 w 376 360 392 360 0 w 392 360 392 448 0 w 392 360 408 360 0 w 456 360 472 360 0 w 472 360 472 448 0 M 144 448 144 464 0 2.5 M 232 448 232 464 0 2.5 M 312 448 312 464 0 2.5 M 392 448 392 464 0 2.5 M 472 448 472 464 0 2.5 ================================================ FILE: src/circuits/ladder.txt ================================================ $ 17 5.0E-6 3 44 5.0 35 v 64 128 64 48 0 5 40.0 5.0 0.0 w 64 128 112 128 0 l 64 48 112 48 0 0.01 0.0 l 112 48 160 48 0 0.01 0.0 l 160 48 208 48 0 0.01 0.0 l 208 48 256 48 0 0.01 0.0 l 256 48 304 48 0 0.01 0.0 l 304 48 352 48 0 0.01 0.0 l 352 48 400 48 0 0.01 0.0 c 112 48 112 128 0 1.0E-4 0.0 c 160 48 160 128 0 1.0E-4 0.0 c 208 48 208 128 0 1.0E-4 0.0 c 256 48 256 128 0 1.0E-4 0.0 c 304 48 304 128 0 1.0E-4 0.0 c 352 48 352 128 0 1.0E-4 0.0 c 400 48 400 128 0 1.0E-4 0.0 w 112 128 160 128 0 w 160 128 208 128 0 w 208 128 256 128 0 w 256 128 304 128 0 w 304 128 352 128 0 w 352 128 400 128 0 l 400 48 448 48 0 0.01 0.0 w 448 48 448 160 0 w 400 128 432 128 0 w 448 160 400 160 0 c 400 160 400 240 0 1.0E-4 0.0 l 400 160 352 160 0 0.01 0.0 l 352 160 304 160 0 0.01 0.0 l 304 160 256 160 0 0.01 0.0 l 256 160 208 160 0 0.01 0.0 l 208 160 160 160 0 0.01 0.0 l 160 160 112 160 0 0.01 0.0 c 352 160 352 240 0 1.0E-4 0.0 c 304 160 304 240 0 1.0E-4 0.0 c 256 160 256 240 0 1.0E-4 0.0 c 208 160 208 240 0 1.0E-4 0.0 c 160 160 160 240 0 1.0E-4 0.0 c 112 160 112 240 0 1.0E-4 0.0 w 432 128 432 240 0 w 432 240 400 240 0 w 400 240 352 240 0 w 352 240 304 240 0 w 304 240 256 240 0 w 256 240 208 240 0 w 208 240 160 240 0 w 160 240 112 240 0 l 112 160 64 160 0 0.01 0.0 w 64 160 64 272 0 w 112 240 80 240 0 w 64 272 112 272 0 c 112 272 112 352 0 1.0E-4 0.0 w 80 240 80 352 0 w 80 352 112 352 0 l 112 272 160 272 0 0.01 0.0 l 160 272 208 272 0 0.01 0.0 l 208 272 256 272 0 0.01 0.0 l 256 272 304 272 0 0.01 0.0 l 304 272 352 272 0 0.01 0.0 l 352 272 400 272 0 0.01 0.0 c 160 272 160 352 0 1.0E-4 0.0 c 208 272 208 352 0 1.0E-4 0.0 c 256 272 256 352 0 1.0E-4 0.0 c 304 272 304 352 0 1.0E-4 0.0 c 352 272 352 352 0 1.0E-4 0.0 w 112 352 160 352 0 w 160 352 208 352 0 w 208 352 256 352 0 w 256 352 304 352 0 w 304 352 352 352 0 w 352 352 400 352 0 c 400 272 400 352 0 1.0E-4 0.0 w 400 272 432 272 0 w 432 352 400 352 0 r 432 272 432 352 0 10.0 g 432 352 432 384 0 o 0 64 0 3 10.0 0.8 o 74 64 0 3 10.0 0.8 ================================================ FILE: src/circuits/leadingedge.txt ================================================ $ 1 4.0E-9 4 54 5.0 f 160 144 208 144 1 f 160 240 208 240 0 w 208 160 208 192 0 w 208 192 208 224 0 R 208 128 208 80 0 0 40.0 5.0 0.0 g 208 256 208 288 0 g 288 256 288 288 0 w 288 192 320 192 0 w 320 192 320 144 0 w 320 192 320 240 0 f 320 144 368 144 1 f 320 240 368 240 0 w 368 160 368 192 0 w 368 192 368 224 0 g 368 256 368 288 0 R 368 128 368 80 0 0 40.0 5.0 0.0 c 208 192 288 192 0 1.0E-9 0.22165573446504094 r 288 192 288 256 0 1000.0 w 160 144 160 192 0 w 160 240 160 192 0 w 160 192 128 192 0 w 128 192 128 160 0 w 128 192 128 224 0 f 80 240 128 240 0 f 80 144 128 144 1 w 80 144 80 192 0 w 80 192 80 240 0 R 128 128 128 80 0 0 40.0 5.0 0.0 g 128 256 128 288 0 w 368 192 400 192 0 w 400 192 400 144 0 w 400 192 400 240 0 f 400 240 448 240 0 f 400 144 448 144 1 w 448 160 448 192 0 w 448 192 448 224 0 g 448 256 448 288 0 R 448 128 448 80 0 0 40.0 5.0 0.0 M 448 192 496 192 0 R 80 192 32 192 0 2 200000.0 2.5 2.5 o 39 32 0 2 5.0 9.765625E-5 0 o 38 32 0 2 5.0 9.765625E-5 0 h 2 17 16 ================================================ FILE: src/circuits/ledflasher.txt ================================================ $ 17 5.0E-6 2.183 50 5.0 50 163 160 272 208 272 0 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 5.0 0.0 L 480 336 480 368 0 false false 5.0 0.0 R 160 304 112 304 1 2 1000.0 2.5 2.5 w 192 240 192 112 0 162 192 112 192 64 0 1.0 0.0 0.0 r 192 64 112 64 0 250.0 g 112 64 112 112 0 162 224 112 224 64 0 1.0 0.0 0.0 162 256 112 256 64 0 1.0 0.0 0.0 162 288 112 288 64 0 1.0 0.0 0.0 162 320 112 320 64 0 1.0 0.0 0.0 w 192 64 224 64 0 w 224 64 256 64 0 w 256 64 288 64 0 w 288 64 320 64 0 w 352 240 352 112 0 d 224 240 224 208 0 d 256 240 256 208 0 d 288 240 288 208 0 d 320 240 320 208 0 162 352 112 352 64 0 1.0 0.0 0.0 w 352 64 320 64 0 d 384 240 384 208 0 d 416 240 416 208 0 d 448 240 448 208 0 d 480 240 480 208 0 w 384 192 384 208 0 w 416 176 416 208 0 w 448 160 448 208 0 w 320 208 320 192 0 w 320 192 384 192 0 w 416 176 288 176 0 w 288 176 288 208 0 w 448 160 256 160 0 w 256 160 256 208 0 w 224 208 224 144 0 w 224 144 480 144 0 w 480 144 480 208 0 w 224 112 224 144 0 w 256 112 256 160 0 w 288 112 288 176 0 w 320 112 320 192 0 ================================================ FILE: src/circuits/lissa.txt ================================================ $ 1 5.0E-6 52.86996988945491 50 5.0 50 118 160 208 160 80 0 1 100.0 5.0 0.0 0.0 0.5 118 160 400 160 256 0 1 104.0 5.0 0.0 0.0 0.5 w 160 80 208 80 0 w 160 208 208 208 0 w 160 256 208 256 0 w 160 400 208 400 0 p 208 80 208 208 0 p 208 256 208 400 0 118 288 208 288 80 0 1 40.0 5.0 0.0 0.0 0.5 118 288 400 288 256 0 1 101.0 5.0 0.0 0.0 0.5 w 288 80 336 80 0 w 288 208 336 208 0 w 288 256 336 256 0 w 288 400 336 400 0 w 416 256 464 256 0 w 416 80 464 80 0 w 416 208 464 208 0 w 416 400 464 400 0 118 416 208 416 80 0 1 91.0 5.0 0.0 0.0 0.5 118 416 400 416 256 0 1 30.0 5.0 0.0 0.0 0.5 p 336 80 336 208 0 p 336 256 336 400 0 p 464 80 464 208 0 p 464 256 464 400 0 o 6 64 0 226 5.0 6.4 0 7 o 20 64 0 226 5.0 6.4 1 21 o 22 64 0 226 5.0 6.4 2 23 ================================================ FILE: src/circuits/logconvert.txt ================================================ $ 1 5.0E-6 12.185319768402522 54 5.0 50 a 208 240 304 240 0 15.0 -15.0 d 304 112 208 112 0 w 208 144 208 112 0 c 208 80 304 80 0 1.0E-6 0.6555203584434989 w 304 80 304 112 0 w 208 80 208 112 0 w 208 144 208 224 0 r 208 224 128 224 0 1000.0 R 128 224 96 224 0 1 40.0 3.0 3.0 0.0 0.5 g 208 256 208 272 0 t 320 272 320 240 0 1 0.0 0.6332109005736126 w 336 240 352 240 0 w 352 240 352 272 0 w 352 272 320 272 0 w 352 240 384 240 0 i 384 176 384 240 0 0.01 R 384 176 384 144 0 0 40.0 10.0 0.0 0.0 0.5 a 384 256 480 256 1 15.0 -15.0 r 384 320 480 320 0 15000.0 r 384 320 384 384 0 1000.0 w 384 272 384 320 0 w 480 256 480 320 0 g 384 384 384 400 0 O 480 256 528 256 0 p 128 224 128 288 0 g 128 288 128 304 0 t 256 176 256 144 1 1 -6.5551380330546585E-6 0.6555138033054658 w 208 144 240 144 0 w 272 144 304 144 0 w 304 112 304 144 0 w 304 144 304 240 0 g 256 176 256 192 0 o 8 64 0 34 10.0 0.05 0 -1 in o 23 64 0 34 2.5 2.44140625E-5 1 -1 out o 24 64 0 226 10.0 1.6 2 23 out vs in ================================================ FILE: src/circuits/longdist.txt ================================================ $ 1 5.0E-6 9.001713130052181 39 120.0 42 v 64 208 64 80 0 1 60.0 120.0 0.0 0.0 0.5 w 240 160 240 208 1 T 160 128 240 128 0 0.5 1000.0 -1.0023486497286795 6.35743697744416E-4 w 160 128 160 80 2 w 160 160 160 208 1 r 160 80 64 80 0 10.0 w 64 208 160 208 0 w 240 128 240 80 2 r 240 80 432 80 0 500.0 r 240 208 432 208 0 500.0 w 432 80 432 128 0 w 432 208 432 160 0 T 432 128 496 128 0 1000000.0 0.0010 -6.357436977444156E-4 0.45338545557553267 w 496 128 496 80 2 w 496 80 560 80 0 w 496 160 496 208 1 w 496 208 560 208 0 r 560 80 560 208 0 200.0 v 64 384 64 256 0 1 60.0 120.0 0.0 0.0 0.5 r 64 256 160 256 0 10.0 r 160 256 512 256 0 500.0 r 160 384 512 384 0 500.0 w 64 384 160 384 0 w 512 256 560 256 0 w 512 384 560 384 0 r 560 256 560 384 0 200.0 g 432 208 432 224 0 g 560 208 560 224 0 o 17 64 1 35 80.0 9.765625E-5 0 -1 o 25 64 1 35 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/lrc-critical.txt ================================================ $ 1 5.0E-6 10 50 5.0 r 176 80 384 80 0 516.4 s 384 80 448 80 0 true false w 176 80 176 352 0 c 176 352 384 352 0 1.4999999999999999E-5 -9.860041921625609 l 384 80 384 352 0 1.0 0.03019234785322575 v 448 352 448 80 0 0 40.0 5.0 0.0 r 384 352 448 352 0 100.0 o 4 64 0 3 20.0 0.05 o 3 64 0 3 10.0 0.05 o 0 64 0 3 0.625 0.05 h 1 4 3 ================================================ FILE: src/circuits/lrc.txt ================================================ $ 1 5.0E-6 10 50 5.0 43 r 176 80 384 80 0 10 s 384 80 448 80 0 true false w 176 80 176 352 0 c 176 352 384 352 0 1.4999999999999999E-5 -9.860041921625609 l 384 80 384 352 0 1.0 0.03019234785322575 v 448 352 448 80 0 0 40.0 5.0 0.0 r 384 352 448 352 0 100.0 o 4 64 0 3 20.0 0.05 o 3 64 0 3 10.0 0.05 o 0 64 0 3 0.625 0.05 h 1 4 3 ================================================ FILE: src/circuits/majority.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 L 128 144 64 144 0 true false L 128 208 64 208 0 true false L 128 272 64 272 0 false false w 128 208 128 176 0 w 128 176 192 176 0 w 128 144 144 144 0 w 144 144 192 144 0 w 128 208 128 224 0 w 128 224 192 224 0 w 144 144 144 304 0 w 144 304 192 304 0 w 128 272 128 256 0 w 128 256 192 256 0 w 128 272 128 336 0 w 128 336 192 336 0 151 320 240 480 240 0 3 0.0 w 320 160 320 224 0 w 320 256 320 320 0 151 192 160 320 160 0 2 5.0 151 192 240 320 240 0 2 5.0 151 192 320 320 320 0 2 5.0 M 480 240 544 240 0 ================================================ FILE: src/circuits/masterslaveff.txt ================================================ $ 1 5.0E-6 10 50 5.0 151 432 160 528 160 0 2 5.0 151 432 272 528 272 0 2 0.0 w 432 240 432 256 0 w 432 176 432 192 0 w 528 240 528 272 0 w 528 240 432 192 0 w 528 160 528 192 0 w 528 192 432 240 0 151 320 144 432 144 0 2 5.0 151 320 288 432 288 0 2 5.0 w 320 160 320 272 0 w 320 272 320 352 0 151 192 160 288 160 0 2 5.0 151 192 272 288 272 0 2 0.0 w 320 128 288 128 0 w 288 128 288 160 0 w 288 272 288 304 0 w 288 304 320 304 0 w 192 176 192 192 0 w 192 256 192 240 0 w 288 240 288 272 0 w 288 240 192 192 0 w 288 192 288 160 0 w 288 192 192 240 0 151 80 144 192 144 0 2 0.0 151 80 288 192 288 0 2 5.0 I 80 352 320 352 0 M 528 160 592 160 0 M 528 272 592 272 0 x 518 133 534 133 0 24 Q x 520 321 536 321 2 24 Q x 153 79 169 79 0 24 master x 399 81 415 81 0 24 slave w 80 160 80 304 0 w 80 304 80 352 0 I 48 128 48 272 0 w 48 128 80 128 0 w 48 272 80 272 0 L 48 128 48 96 0 false false x 39 62 55 62 0 24 D R 80 352 48 352 1 2 120.0 2.5 2.5 o 38 64 0 6 5.0 9.765625E-5 0 D o 27 64 0 6 5.0 9.765625E-5 0 Q o 40 64 0 6 5.0 9.765625E-5 0 clk ================================================ FILE: src/circuits/mirror.txt ================================================ $ 1 5.0E-6 11.708435524800691 50 5.0 50 t 256 112 192 112 0 -1 0.0 -0.625292103755946 1000.0 t 256 112 320 112 0 -1 2.5545208310942042 -0.6252921037557799 1000.0 w 256 112 256 160 0 w 192 128 192 160 0 w 192 160 256 160 0 r 192 96 192 32 0 100.0 r 320 96 320 32 0 100.0 w 192 32 320 32 0 R 192 32 128 32 0 0 40.0 5.0 0.0 0.0 0.5 r 192 160 192 224 0 500.0 r 320 128 320 224 0 150.0 w 192 160 128 160 0 s 128 160 128 224 0 1 false r 128 224 192 224 0 200.0 w 320 128 384 128 0 s 384 128 384 224 0 1 false r 320 224 384 224 0 10.0 w 192 224 192 288 1 w 320 224 320 288 1 g 192 288 192 304 0 g 320 288 320 304 0 x 159 112 181 116 0 16 Q1 x 332 113 354 117 0 16 Q2 ================================================ FILE: src/circuits/moscurrentramp.txt ================================================ $ 1 5.0E-6 15.50424758475255 55 10.0 50 r 320 304 320 352 0 10.0 g 320 352 320 384 0 R 256 288 208 288 0 0 40.0 2.5 0.0 0.0 0.5 w 320 272 320 224 0 w 320 224 416 224 0 w 320 128 416 128 0 R 320 128 320 80 0 0 40.0 10.0 0.0 0.0 0.5 c 320 128 320 224 0 4.9999999999999996E-5 0 r 416 128 416 224 0 10000.0 w 320 128 272 128 0 w 320 224 272 224 0 s 272 128 272 224 0 1 true f 256 288 320 288 0 1.5 o 8 128 0 34 10.0 7.8125E-4 0 -1 ================================================ FILE: src/circuits/moscurrentsrc.txt ================================================ $ 1 5.0E-6 11.708435524800691 50 10.0 50 f 352 288 400 288 0 1.5 w 400 304 400 352 1 g 400 352 400 384 0 R 400 112 400 80 0 0 40.0 10.0 0.0 0.0 0.5 w 400 272 400 240 0 r 400 112 400 240 0 300.0 w 400 112 448 112 0 w 400 240 448 240 0 s 448 112 448 240 0 1 false R 352 288 320 288 0 0 40.0 3.0 0.0 0.0 0.5 ================================================ FILE: src/circuits/mosfetamp.txt ================================================ $ 1 5.0E-6 42.05934401203833 60 5.0 53 r 208 176 208 272 0 4000.0 R 160 160 112 160 0 1 40.0 0.05 0.0 0.0 0.5 R 208 32 160 32 0 0 40.0 10.0 0.0 0.0 0.5 r 208 32 208 144 0 4000.0 c 208 144 320 144 0 1.0E-6 1.938598649739942 r 320 144 320 272 0 50000.0 g 320 272 320 304 0 O 320 144 384 144 0 w 208 176 256 176 0 c 256 176 256 272 0 9.999999999999999E-5 8.054803335508433 w 208 272 256 272 0 f 160 160 208 160 0 1.5 R 208 272 208 304 0 0 40.0 -10.0 0.0 0.0 0.5 o 1 128 0 34 0.078125 4.8828125E-5 0 -1 o 7 128 0 34 2.5 3.0517578125E-6 1 -1 ================================================ FILE: src/circuits/mosfollower.txt ================================================ $ 1 5.0E-6 11.251013186076355 54 5.0 50 R 208 144 176 144 0 1 40.0 5.0 0.0 0.0 0.5 O 256 160 320 160 0 f 208 144 256 144 0 1.5 r 256 48 256 128 0 500.0 R 256 48 208 48 0 0 40.0 15.0 0.0 0.0 0.5 R 256 256 256 288 0 0 40.0 -15.0 0.0 0.0 0.5 i 256 160 256 256 0 0.0050 o 1 64 0 34 12.0 1.220703125E-5 0 -1 ================================================ FILE: src/circuits/mosmirror.txt ================================================ $ 1 5.0E-6 11.251013186076355 50 5.0 50 f 320 288 240 288 0 1.5 f 320 288 400 288 0 1.5 w 320 288 320 240 0 w 320 240 240 240 0 w 240 240 240 272 0 w 240 304 240 352 1 w 240 352 320 352 0 w 400 304 400 352 1 w 400 352 320 352 0 g 320 352 320 384 0 R 240 112 240 80 0 0 40.0 5.0 0.0 0.0 0.5 R 400 112 400 80 0 0 40.0 5.0 0.0 0.0 0.5 w 400 272 400 240 0 r 400 112 400 240 0 100.0 w 400 112 448 112 0 w 400 240 448 240 0 s 448 112 448 240 0 1 false w 240 240 192 240 0 w 240 112 192 112 0 r 240 112 240 240 0 500.0 r 192 112 192 176 0 100.0 s 192 176 192 240 0 1 false ================================================ FILE: src/circuits/mosswitch.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 s 288 224 288 304 0 1 false w 288 128 400 128 0 r 400 128 400 288 0 300.0 w 400 320 400 336 0 f 288 304 400 304 0 1.5 w 288 128 288 224 0 R 288 128 240 128 0 0 40.0 5.0 0.0 0.0 0.5 g 400 336 400 352 0 ================================================ FILE: src/circuits/mr-crossbar.txt ================================================ $ 1 5.0E-9 5.023272298708815 52 1.0 50 m 208 128 256 80 0 100.0 250000.0 0 1.0E-8 1.0E-10 m 288 128 336 80 0 100.0 250000.0 0 1.0E-8 1.0E-10 m 208 240 256 192 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10 m 288 240 336 192 0 100.0 250000.0 0 1.0E-8 1.0E-10 w 208 128 288 128 0 w 208 240 288 240 0 w 256 80 256 192 0 w 336 80 336 192 0 w 256 192 256 304 0 w 336 192 336 304 0 w 288 240 368 240 0 w 368 240 448 240 0 w 288 128 368 128 0 w 368 128 448 128 0 m 368 128 416 80 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10 m 448 128 496 80 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10 m 368 240 416 192 0 100.0 250000.0 1.0e-8 1.0E-8 1.0E-10 m 448 240 496 192 0 100.0 250000.0 0 1.0E-8 1.0E-10 w 416 80 416 192 0 w 416 192 416 304 0 w 496 80 496 192 0 w 496 192 496 304 0 S 96 176 208 176 0 0 false 0 false 0 w 208 128 208 160 0 w 208 192 208 240 0 R 96 176 48 176 0 1 500000.0 1.0 0.0 0.0 0.5 r 256 304 256 368 0 10000.0 r 336 304 336 368 0 10000.0 r 416 304 416 368 0 10000.0 r 496 304 496 368 0 10000.0 g 256 368 256 384 0 g 336 368 336 384 0 g 416 368 416 384 0 g 496 368 496 384 0 w 448 128 512 128 0 w 448 240 512 240 0 r 512 128 576 128 0 1000.0 r 512 240 576 240 0 1000.0 g 576 240 576 272 0 g 576 128 576 160 0 o 26 32 0 54 1.1 9.765625E-5 0 -1 o 27 32 0 54 1.1 9.765625E-5 0 -1 o 28 32 0 54 1.1 9.765625E-5 0 -1 o 29 32 0 54 1.1 9.765625E-5 0 -1 ================================================ FILE: src/circuits/mr-sine.txt ================================================ $ 1 5.0E-8 9.78399845368213 72 1.0 50 g 320 304 320 320 0 m 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10 R 320 192 320 160 0 1 4000.0 1.0 0.0 0.0 0.5 o 1 64 0 35 1.25 1.953125E-4 0 -1 o 1 64 2 35 20480.0 9.765625E-5 1 -1 o 1 64 0 99 2.5 1.953125E-4 2 -1 ================================================ FILE: src/circuits/mr-sine2.txt ================================================ $ 1 5.0E-8 9.78399845368213 72 1.0 50 g 320 304 320 320 0 m 320 192 320 304 0 100.0 12500.0 0.0 1.0E-8 1.0E-10 R 320 192 320 160 0 1 5000.0 1.0 0.0 0.0 0.5 o 1 64 0 35 1.25 0.003125 0 -1 o 1 64 2 35 20480.0 9.765625E-5 1 -1 o 1 64 0 99 1.25 0.003125 2 -1 ================================================ FILE: src/circuits/mr-sine3.txt ================================================ $ 1 5.0E-8 9.78399845368213 72 1.0 50 g 320 304 320 320 0 m 320 192 320 304 0 100.0 5000.0 3.865479277469485E-9 1.0E-8 1.0E-10 R 320 192 320 160 0 1 8000.0 2.0 0.0 0.0 0.5 o 1 64 0 35 2.5 0.025 0 -1 o 1 64 2 35 5120.0 2.44140625E-5 1 -1 o 1 64 0 99 2.5 0.025 2 -1 ================================================ FILE: src/circuits/mr-square.txt ================================================ $ 1 5.0E-8 9.78399845368213 72 1.0 50 g 320 304 320 320 0 m 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10 R 320 192 320 160 0 2 6300.0 1.0 0.0 0.0 0.5 o 1 64 0 35 1.25 7.8125E-4 0 -1 o 1 64 2 35 20480.0 9.765625E-5 1 -1 o 1 64 0 99 1.25 7.8125E-4 2 -1 ================================================ FILE: src/circuits/mr-triangle.txt ================================================ $ 1 5.0E-8 9.78399845368213 72 1.0 50 g 320 304 320 320 0 m 320 192 320 304 0 100.0 16000.0 0 1.0E-8 1.0E-10 R 320 192 320 160 0 3 3200.0 1.0 0.0 0.0 0.5 o 1 64 0 35 1.25 9.765625E-5 0 -1 o 1 64 2 35 20480.0 9.765625E-5 1 -1 o 1 64 0 99 1.25 9.765625E-5 2 -1 ================================================ FILE: src/circuits/mr.txt ================================================ $ 1 2.0E-8 1.3804574186067096 52 5.0 50 m 256 144 256 288 0 100.0 16000.0 0 1.0E-8 1.0E-10 g 256 320 256 336 0 w 256 288 256 320 1 172 256 144 256 112 0 6 5.0 5.0 -5.0 0.0 0.5 Voltage o 0 8 0 35 5.0 0.05 0 -1 o 0 8 2 35 640.0 9.765625E-5 1 -1 resistance ================================================ FILE: src/circuits/multivib-a.txt ================================================ $ 1 5.0E-6 8.203437568215378 50 5.0 50 w 128 48 208 48 0 w 208 48 288 48 0 w 288 48 368 48 0 r 128 48 128 176 0 330.0 r 208 48 208 176 0 1020.0 r 288 48 288 176 0 1020.0 r 368 48 368 176 0 320.0 c 128 176 208 176 0 1.8E-5 -0.1960622475177095 c 288 176 368 176 0 1.8E-5 -3.536074488299442 w 368 176 368 240 0 t 288 256 368 256 0 1 0.6643052625017931 0.6776743289781562 100.0 w 208 176 288 256 0 w 288 176 208 256 0 t 208 256 128 256 0 1 -4.004317503283525 -3.522705421823079 100.0 w 128 176 128 240 0 R 128 48 80 48 0 0 40.0 5.0 0.0 0.0 0.5 g 128 272 128 304 0 g 368 272 368 304 0 x 159 212 180 216 0 16 C1 x 317 213 338 217 0 16 C2 x 96 260 118 264 0 16 Q1 x 382 262 404 266 0 16 Q2 o 13 64 6 35 5.0 9.765625E-5 0 -1 o 10 64 6 35 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/multivib-bi.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 50 r 144 32 144 128 0 100.0 r 384 32 384 128 0 100.0 w 384 128 384 192 0 t 304 208 384 208 0 1 0.617227886429507 0.6759235619928714 100.0 w 224 128 304 208 0 w 304 128 224 208 0 t 224 208 144 208 0 1 -4.584864481423058 0.029057265154527386 100.0 w 144 128 144 192 0 r 304 128 384 128 0 1020.0 r 144 128 224 128 0 1020.0 M 384 128 448 128 0 2.5 w 144 32 384 32 0 M 144 128 80 128 0 2.5 R 144 32 80 32 0 0 40.0 5.0 0.0 0.0 0.5 r 224 208 224 304 0 1000.0 r 304 208 304 304 0 1000.0 L 224 304 80 304 0 0 true 5.0 0.0 L 304 304 448 304 0 0 true 5.0 0.0 x 54 105 106 109 2 16 output x 422 100 474 104 0 16 output x 70 278 93 282 0 16 set x 429 277 468 281 0 16 reset g 144 224 144 256 0 g 384 224 384 256 0 x 106 212 128 216 0 16 Q1 x 400 213 422 217 0 16 Q2 ================================================ FILE: src/circuits/multivib-mono.txt ================================================ $ 1 5.0E-6 8.6 50 5.0 50 w 192 32 272 32 0 r 192 32 192 160 0 330.0 r 272 32 272 160 0 1020.0 r 432 32 432 160 0 320.0 c 192 160 272 160 0 1.8E-5 4.3449566448532755 w 432 160 432 224 0 t 352 240 432 240 0 1 0.6277842747260773 0.6549145378729839 100.0 w 272 160 352 240 0 w 352 160 272 240 0 t 272 240 192 240 0 1 -4.972740919574546 0.027130263151713234 100.0 w 192 160 192 224 0 r 352 160 432 160 0 100.0 t 128 240 192 240 0 1 -4.901331660083208 0.09853952264305138 100.0 w 128 32 192 32 0 r 128 32 128 144 0 100.0 s 128 144 128 240 0 1 true w 272 32 432 32 0 R 128 32 64 32 0 0 40.0 5.0 0.0 0.0 0.5 g 192 256 192 304 0 g 432 256 432 304 0 x 444 247 466 251 0 16 Q1 o 6 64 6 35 2.5 9.765625E-5 0 -1 ================================================ FILE: src/circuits/mux.txt ================================================ $ 1 5.0E-6 19.765835257097933 58 5.0 50 f 256 112 256 64 0 1.5 f 256 288 256 224 0 1.5 f 256 176 256 224 1 1.5 f 256 16 256 64 1 1.5 w 256 288 192 288 0 w 256 16 192 16 0 R 240 64 64 64 0 1 80.0 2.5 2.5 0.0 0.5 R 240 224 64 224 0 3 40.0 2.5 2.5 0.0 0.5 w 272 64 368 64 0 w 272 224 368 224 0 w 368 64 368 224 0 r 368 224 368 304 0 1000.0 g 368 304 368 336 0 O 368 224 432 224 0 w 256 112 256 176 0 w 192 288 192 176 0 w 192 176 192 16 0 I 192 176 256 176 0 0.5 L 192 288 64 288 0 1 false 5.0 0.0 x 43 319 88 323 0 16 select o 13 64 0 34 5.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/mux3state.txt ================================================ $ 0 5.0E-6 1.5 50 5.0 151 112 160 208 160 0 2 5.0 150 112 288 208 288 0 2 5.0 f 208 288 272 288 4 f 208 160 272 160 5 w 272 176 272 224 0 w 272 224 272 272 0 g 272 304 272 336 0 R 272 144 272 112 0 0 40.0 5.0 0.0 L 112 176 48 176 0 true false 5.0 0.0 w 112 144 80 144 0 w 80 144 80 304 0 w 80 304 112 304 0 w 272 224 320 224 0 w 320 224 368 224 0 w 368 224 368 272 0 w 368 224 368 176 0 f 432 288 368 288 4 f 432 160 368 160 5 R 368 144 368 112 0 0 40.0 5.0 0.0 g 368 304 368 336 0 150 528 288 432 288 0 2 0.0 151 528 160 432 160 0 2 5.0 w 576 144 528 144 0 w 80 144 80 48 0 w 576 48 576 144 0 w 576 144 576 304 0 w 576 304 528 304 0 M 320 224 320 384 0 2.5 I 528 176 528 272 0 L 528 176 608 176 0 true false 5.0 0.0 x 32 155 48 155 0 16 in 1 x 506 358 522 358 0 16 select x 593 157 609 157 0 16 in 2 x 145 95 161 95 0 16 tri-state buffer x 382 94 398 94 0 16 tri-state buffer L 576 304 576 352 0 true false 5.0 0.0 I 576 48 80 48 0 I 112 176 112 272 0 ================================================ FILE: src/circuits/nandff.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 50 151 256 160 368 160 0 2 0.0 151 256 288 368 288 0 2 5.0 w 368 160 368 192 0 w 368 192 256 256 0 w 368 288 368 256 0 w 368 256 256 192 0 w 256 192 256 176 0 w 256 256 256 272 0 L 256 304 176 304 0 false true 5.0 0.0 L 256 144 176 144 0 false true 5.0 0.0 M 368 160 448 160 0 2.5 M 368 288 448 288 0 2.5 x 159 120 175 120 0 24 set x 438 138 454 138 0 24 Q x 147 281 163 281 0 24 reset x 438 266 454 266 2 24 Q ================================================ FILE: src/circuits/nic-r.txt ================================================ $ 1 5.0E-6 10 50 5.0 a 128 144 256 144 1 w 128 128 128 80 0 r 128 80 256 80 0 100.0 w 256 80 256 144 0 w 128 160 128 208 0 r 128 208 256 208 0 100.0 w 256 144 256 208 0 g 128 288 128 320 0 R 128 128 48 128 0 1 100.0 5.0 0.0 R 416 128 336 128 0 1 100.0 5.0 0.0 g 416 288 416 320 0 r 128 208 128 288 0 150.0 r 416 208 416 288 0 150.0 w 416 128 416 208 0 o 8 64 0 35 5.0 0.1 0 -1 nic o 8 64 0 99 5.0 0.1 1 -1 nic I/V o 9 64 0 35 5.0 0.1 2 -1 normal o 9 64 0 99 5.0 0.1 3 -1 normal I/V ================================================ FILE: src/circuits/nmosfet.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 50 f 304 240 352 240 0 1.5 172 304 240 272 240 0 6 3.5 5.0 0.0 0.0 0.5 Gate Voltage w 352 256 352 304 0 w 352 224 352 176 1 172 352 176 352 144 0 6 5.0 5.0 0.0 0.0 0.5 Drain Voltage g 352 304 352 320 0 o 0 64 0 35 5.0 0.2 0 -1 ================================================ FILE: src/circuits/nmosinverter.txt ================================================ $ 1 5.0E-6 10 54 5.0 R 272 128 208 128 0 0 40.0 5.0 0.0 g 272 288 272 320 0 L 224 224 176 224 0 false false r 272 128 272 208 0 5000.0 M 272 208 352 208 0 f 224 224 272 224 4 w 272 240 272 288 0 ================================================ FILE: src/circuits/nmosinverter2.txt ================================================ $ 1 5.0E-6 11.251013186076355 50 5.0 50 f 320 208 384 208 6 3.5 f 320 288 384 288 6 1.5 R 256 144 208 144 0 0 40.0 5.0 0.0 0.0 0.5 w 256 144 320 144 0 w 320 144 320 208 0 w 320 144 384 144 0 w 384 144 384 192 0 w 384 224 384 272 0 g 384 304 384 336 0 L 320 288 272 288 0 1 false 5.0 0.0 M 384 224 432 224 0 2.5 ================================================ FILE: src/circuits/nmosnand.txt ================================================ $ 1 5.0E-6 10 54 5.0 f 272 224 336 224 4 w 336 144 336 176 0 w 336 176 336 208 0 M 336 176 400 176 0 f 272 288 336 288 4 w 336 240 336 272 0 g 336 304 336 336 0 w 240 80 336 80 0 w 336 80 336 112 0 R 240 80 176 80 0 0 40.0 5.0 0.0 w 176 288 272 288 0 L 272 224 112 224 0 false false L 176 288 112 288 0 false false r 336 112 336 144 0 5000.0 ================================================ FILE: src/circuits/norton.txt ================================================ $ 17 5.0E-6 10.8 50 5.0 r 112 160 208 112 0 100.0 r 208 112 224 208 0 100.0 r 224 208 320 160 0 200.0 r 208 112 288 128 0 100.0 r 304 64 288 128 0 100.0 v 288 128 384 112 0 0 40.0 5.0 0.0 v 320 160 320 240 0 0 40.0 5.0 0.0 v 112 160 128 224 0 0 40.0 5.0 0.0 v 304 64 224 48 0 0 40.0 5.0 0.0 v 224 208 224 272 0 0 40.0 5.0 0.0 r 224 272 304 288 0 200.0 r 128 224 64 272 0 400.0 r 384 112 448 176 0 100.0 r 320 240 384 256 0 100.0 r 224 48 112 64 0 1000.0 v 112 64 208 112 0 0 40.0 5.0 0.0 v 64 272 224 272 0 0 40.0 2.0 0.0 v 304 288 384 256 0 0 40.0 5.0 0.0 r 448 176 384 256 0 100.0 r 320 160 384 112 0 100.0 r 112 64 112 160 0 100.0 w 64 272 64 16 0 w 448 16 448 176 0 g 448 176 448 240 0 g 384 384 384 400 0 r 128 384 384 384 0 117.784267 i 128 352 384 352 0 0.02383663 w 384 320 384 352 0 w 384 352 384 384 0 w 128 352 128 384 0 w 128 320 128 352 0 v 64 16 448 16 0 1 40.0 5.0 0.0 v 128 320 384 320 0 1 40.0 5.0 0.0 o 31 64 0 3 5.0 0.1 o 32 64 0 3 5.0 0.1 ================================================ FILE: src/circuits/notch.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 40 l 368 128 368 224 0 0.5 0 c 368 224 368 320 0 3.17E-5 0 r 256 128 368 128 0 100.0 O 368 128 432 128 0 g 368 320 368 352 0 170 256 128 224 128 3 20.0 60.0 5.0 0.5 o 5 64 0 34 5.0 9.765625E-5 0 -1 in o 3 64 0 34 5.0 9.765625E-5 1 -1 out o 0 64 0 34 10.0 0.025 2 -1 inductor o 1 64 0 34 10.0 0.025 2 -1 cap h 1 0 1 ================================================ FILE: src/circuits/npn.txt ================================================ $ 1 5.0E-6 10.812258501325767 43 2.0 50 172 240 240 208 240 0 6 0.705 0.75 0.5 0.0 0.5 Base Voltage w 352 256 352 304 1 w 352 224 352 176 1 172 352 176 352 144 0 6 2.0 2.0 0.0 0.0 0.5 Collector Voltage g 352 304 352 320 0 t 304 240 352 240 0 1 -4.295 0.7049999999999998 100.0 w 240 240 304 240 1 ================================================ FILE: src/circuits/ohms.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 50 r 256 176 256 304 0 100.0 172 304 176 304 128 0 6 5.0 5.0 0.0 0.0 0.5 Voltage g 256 336 256 352 0 w 256 304 256 336 1 r 352 176 352 304 0 1000.0 w 352 304 352 336 1 g 352 336 352 352 0 w 304 176 352 176 0 w 256 176 304 176 0 ================================================ FILE: src/circuits/opamp-regulator.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 r 192 160 192 208 0 10000.0 g 192 272 192 288 0 a 240 224 336 224 1 15.0 -15.0 1000000.0 w 240 208 192 208 0 w 192 160 320 160 0 w 336 192 336 224 0 w 352 160 416 160 1 w 240 240 240 272 0 w 240 272 416 272 0 r 416 160 416 272 0 470.0 r 416 272 416 336 0 470.0 g 416 336 416 352 0 w 416 160 544 160 2 t 336 192 336 160 1 1 0.47225771069311584 0.6621194688210963 100.0 v 560 240 560 176 0 5 60.0 6.0 2.5 0.0 0.5 w 560 240 560 272 1 g 560 272 560 288 0 z 192 272 192 208 1 0.805904783 6.14 x 502 319 631 323 0 18 Simulated load x 519 332 614 335 0 12 Variable Current x 436 142 518 145 0 12 Stable Voltage R 80 160 80 256 0 3 120.0 2.0 16.0 0.0 0.5 x 40 294 142 298 0 18 Variable V/I 174 544 160 576 176 0 1000.0 0.5 Load Current r 80 160 192 160 0 100.0 o 21 64 0 35 20.0 0.05 0 -1 input o 12 64 0 35 20.0 0.025 1 -1 regulated o 14 64 0 35 10.0 0.025 2 -1 load ================================================ FILE: src/circuits/opamp.txt ================================================ $ 1 5.0E-6 10.812258501325767 50 5.0 50 a 256 240 384 240 0 15.0 -15.0 172 256 224 208 224 0 6 3.0 5.0 0.0 0.0 0.5 - Voltage 172 256 256 208 256 0 6 4.0 5.0 0.0 0.0 0.5 + Voltage O 384 240 432 240 1 ================================================ FILE: src/circuits/opampfeedback.txt ================================================ $ 1 5.0E-6 11.251013186076355 50 5.0 50 a 192 176 320 176 0 15.0 -15.0 172 192 192 144 192 0 6 3.3 5.0 0.0 0.0 0.5 + Voltage O 320 176 368 176 1 w 320 176 320 112 0 w 192 112 192 160 0 w 192 112 320 112 0 ================================================ FILE: src/circuits/opint-current.txt ================================================ $ 1 1.0E-5 1.5642631884188172 54 15.0 66 t 64 160 96 160 0 1 -14.524416831323471 0.45874279140993174 100.0 t 128 224 96 224 0 -1 13.155478365585369 -0.45874279140993174 100.0 t 96 288 144 288 0 1 -29.07296394840523 0.45933099081733353 100.0 t 144 352 96 352 0 1 -0.45933099081733353 0.45848552057607606 100.0 r 96 368 96 448 0 1000.0 r 144 352 144 448 0 50000.0 w 144 304 144 352 0 w 96 288 96 336 0 w 96 288 96 240 0 w 96 176 96 208 0 t 240 160 208 160 0 1 -14.524389782067212 0.458756316038061 100.0 t 176 224 208 224 0 -1 13.001245413909114 -0.4587563160380609 100.0 w 208 176 208 208 0 w 128 224 176 224 0 w 176 224 176 256 0 w 208 240 208 288 0 t 144 352 208 352 0 1 -0.6135639424935881 0.4584855205760743 100.0 w 208 288 208 336 0 r 208 368 208 448 0 1000.0 w 96 448 144 448 0 w 144 448 208 448 0 R 96 448 48 448 0 0 40.0 -15.0 0.0 0.0 0.5 t 208 96 160 96 0 -1 0.0 -0.47558316867652906 100.0 t 208 96 304 96 0 -1 15.441902414143334 -0.47558316867652906 100.0 w 208 144 160 144 0 w 96 144 160 144 0 w 160 112 160 144 0 w 208 96 208 144 0 w 304 112 304 256 0 w 304 256 176 256 0 w 160 80 160 64 0 w 160 64 304 64 0 w 304 64 304 80 0 w 144 272 144 64 0 w 144 64 160 64 0 R 144 64 48 64 0 0 40.0 15.0 0.0 0.0 0.5 t 336 352 304 352 0 1 -13.514398472585153 0.4758368768112078 100.0 t 336 352 368 352 0 1 0.0 0.5681159445949842 100.0 w 304 256 304 336 0 r 304 368 304 448 0 5000.0 w 208 448 304 448 0 w 304 448 368 448 0 w 368 448 368 368 0 w 336 352 336 304 0 w 336 304 368 304 0 w 368 304 368 336 0 r 368 304 368 144 0 39000.0 t 432 96 368 96 0 -1 0.0 -0.5678758104275285 100.0 t 432 96 512 96 0 -1 14.673938034545353 -0.5678758104275285 100.0 w 368 112 368 144 0 w 432 96 432 144 0 w 432 144 368 144 0 w 304 64 368 64 0 w 368 64 368 80 0 w 368 64 512 64 0 w 512 64 512 80 0 w 512 112 512 144 0 w 512 144 544 144 0 t 544 144 592 144 0 1 -15.241813844972881 0.2605204218142353 100.0 t 592 192 544 192 0 1 -0.2605204218142353 8.387701844192463E-8 100.0 w 544 144 544 176 0 w 592 160 592 192 0 w 592 128 592 64 0 w 592 64 512 64 0 w 544 208 544 256 0 r 592 192 592 256 0 25.0 w 544 256 592 256 0 r 592 256 592 336 0 50.0 w 512 144 512 192 0 w 592 368 592 448 0 t 480 256 512 256 0 1 -0.3678986750643859 0.5648836713483172 100.0 r 480 256 480 192 0 4500.0 r 480 256 480 320 0 7500.0 w 480 320 512 320 0 w 512 320 512 272 0 w 512 240 512 192 0 w 512 192 480 192 0 t 512 352 592 352 0 -1 13.825403808614416 -0.5885347729781805 100.0 w 512 320 512 352 0 t 480 368 512 368 0 1 -13.221109797257107 0.5677848077046654 100.0 t 512 400 432 400 0 1 -1.0447597996183795 0.03650920365264376 100.0 r 512 400 512 448 0 50.0 w 480 368 480 416 0 r 480 416 480 448 0 50000.0 w 480 448 512 448 0 w 512 448 592 448 0 w 480 448 432 448 0 w 432 448 432 416 0 w 368 448 432 448 0 w 512 384 512 400 0 t 432 336 480 336 0 1 -12.744134805343393 0.47697499191371406 100.0 w 432 336 432 384 0 w 480 352 480 368 0 w 208 288 432 288 0 w 432 288 432 336 0 w 480 192 432 192 0 c 432 192 432 288 0 3.0E-11 13.676917151756095 O 624 256 656 256 0 g 64 160 64 208 0 w 240 160 240 32 0 r 240 32 624 32 0 300.0 w 624 32 624 256 1 w 624 256 592 256 0 r 240 32 144 32 0 150.0 R 144 32 96 32 0 1 40.0 5.0 0.0 0.0 0.5 x 29 167 48 173 0 24 + x 241 195 255 201 0 24 - o 97 16 0 34 20.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/opint-invert-amp.txt ================================================ $ 1 10.0E-6 1.5642631884188172 54 15.0 66 t 48 176 80 176 0 1 -14.524416831323471 0.45873235809238094 100.0 t 112 240 80 240 0 -1 13.155514603842647 -0.45873235809238094 100.0 t 80 304 128 304 0 1 -29.072979320027407 0.45933003350349466 100.0 t 128 368 80 368 0 1 -0.45933003350349466 0.4584749892202993 100.0 r 80 384 80 464 0 1000.0 r 128 368 128 464 0 50000.0 w 128 320 128 368 0 w 80 304 80 352 0 w 80 304 80 256 0 w 80 192 80 224 0 t 224 176 192 176 0 1 -14.524348068778691 0.45876673936477075 100.0 t 160 240 192 240 0 -1 13.003077911256218 -0.4587667393647708 100.0 w 192 192 192 224 0 w 112 240 160 240 0 w 160 240 160 272 0 w 192 256 192 304 0 t 128 368 192 368 0 1 -0.6117667260899236 0.4584749892202975 100.0 w 192 304 192 352 0 r 192 384 192 464 0 1000.0 w 80 464 128 464 0 w 128 464 192 464 0 R 80 464 32 464 0 0 40.0 -15.0 0.0 0.0 0.5 t 192 112 144 112 0 -1 0.0 -0.47558316867652906 100.0 t 192 112 288 112 0 -1 15.441881547508233 -0.47558316867652906 100.0 w 192 160 144 160 0 w 80 160 144 160 0 w 144 128 144 160 0 w 192 112 192 160 0 w 288 128 288 272 0 w 288 272 160 272 0 w 144 96 144 80 0 w 144 80 288 80 0 w 288 80 288 96 0 w 128 288 128 80 0 w 128 80 144 80 0 R 128 80 32 80 0 0 40.0 15.0 0.0 0.0 0.5 t 320 368 288 368 0 1 -13.514419339220254 0.4758368768112078 100.0 t 320 368 352 368 0 1 0.0 0.5681159445949842 100.0 w 288 272 288 352 0 r 288 384 288 464 0 5000.0 w 192 464 288 464 0 w 288 464 352 464 0 w 352 464 352 384 0 w 320 368 320 320 0 w 320 320 352 320 0 w 352 320 352 352 0 r 352 320 352 160 0 39000.0 t 416 112 352 112 0 -1 0.0 -0.5678758104275303 100.0 t 416 112 496 112 0 -1 13.570461032205355 -0.5678758104275303 100.0 w 352 128 352 160 0 w 416 112 416 160 0 w 416 160 352 160 0 w 288 80 352 80 0 w 352 80 352 96 0 w 352 80 496 80 0 w 496 80 496 96 0 w 496 128 496 160 0 w 496 160 528 160 0 t 528 160 576 160 0 1 -14.138336842632885 0.5304968797079701 100.0 t 576 208 528 208 0 1 -0.5304968797079701 0.004107850119627776 100.0 w 528 160 528 192 0 w 576 176 576 208 0 w 576 144 576 80 0 w 576 80 496 80 0 w 528 224 528 272 0 r 576 208 576 272 0 25.0 w 528 272 576 272 0 r 576 272 576 352 0 50.0 w 496 160 496 208 0 w 576 384 576 464 0 t 464 272 496 272 0 1 -0.36778983388140857 0.5648217349170979 100.0 r 464 272 464 208 0 4500.0 r 464 272 464 336 0 7500.0 w 464 336 496 336 0 w 496 336 496 288 0 w 496 256 496 208 0 w 496 208 464 208 0 t 496 368 576 368 0 -1 14.929051588568608 -0.3979658803531285 100.0 w 496 336 496 368 0 t 464 384 496 384 0 1 -14.326295192093617 0.5671551878197238 100.0 t 496 416 416 416 0 1 -1.0438561639037527 0.03560120865526706 100.0 r 496 416 496 464 0 50.0 w 464 384 464 432 0 r 464 432 464 464 0 50000.0 w 464 464 496 464 0 w 496 464 576 464 0 w 464 464 416 464 0 w 416 464 416 432 0 w 352 464 416 464 0 w 496 400 496 416 0 t 416 352 464 352 0 1 -13.849594216009589 0.47670097608402884 100.0 w 416 352 416 400 0 w 464 368 464 384 0 w 192 304 416 304 0 w 416 304 416 352 0 w 464 208 416 208 0 c 416 208 416 304 0 3.0E-11 14.782205784808095 O 608 272 640 272 0 g 48 176 48 224 0 w 224 176 224 48 0 r 224 48 608 48 0 2000.0 w 608 48 608 272 0 w 608 272 576 272 0 r 224 48 128 48 0 1000.0 R 128 48 80 48 0 1 40.0 5.0 0.0 0.0 0.5 x 13 183 32 189 0 24 + x 225 211 239 217 0 24 - o 97 16 0 34 20.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/opint-slew.txt ================================================ $ 1 2.0E-7 1.0751013186076355 58 15.0 66 t 64 160 96 160 0 1 -14.524416831323471 -2.506758109063678 100.0 t 128 224 96 224 0 -1 19.913739554792024 2.5067581090636915 100.0 t 96 288 144 288 0 1 -29.900223336664652 0.09977639416092643 100.0 t 144 352 96 352 0 1 -0.09977639416092643 2.691253317976816E-7 100.0 r 96 368 96 448 0 1000.0 r 144 352 144 448 0 50000.0 w 144 304 144 352 0 w 96 288 96 336 0 w 96 288 96 240 0 w 96 176 96 208 0 t 240 160 208 160 0 1 -8.558744145161098 0.4760782340175016 100.0 t 176 224 208 224 0 -1 18.933020836280406 -0.4760782340175016 100.0 w 208 176 208 208 0 w 128 224 176 224 0 w 176 224 176 256 0 w 208 240 208 288 0 t 144 352 208 352 0 1 -1.0804951126725442 2.69124420526623E-7 100.0 w 208 288 208 336 0 r 208 368 208 448 0 1000.0 w 96 448 144 448 0 w 144 448 208 448 0 R 96 448 48 448 0 0 40.0 -15.0 0.0 0.0 0.5 t 208 96 160 96 0 -1 0.0 -0.47558316867652906 100.0 t 208 96 304 96 0 -1 9.510900613196101 -0.47558316867652906 100.0 w 208 144 160 144 0 w 96 144 160 144 0 w 160 112 160 144 0 w 208 96 208 144 0 w 304 112 304 256 0 w 304 256 176 256 0 w 160 80 160 64 0 w 160 64 304 64 0 w 304 64 304 80 0 w 144 272 144 64 0 w 144 64 160 64 0 R 144 64 48 64 0 0 40.0 15.0 0.0 0.0 0.5 t 336 352 304 352 0 1 -19.445400273532385 0.475836876811206 100.0 t 336 352 368 352 0 1 0.0 0.5681159445949842 100.0 w 304 256 304 336 0 r 304 368 304 448 0 5000.0 w 208 448 304 448 0 w 304 448 368 448 0 w 368 448 368 368 0 w 336 352 336 304 0 w 336 304 368 304 0 w 368 304 368 336 0 r 368 304 368 144 0 39000.0 t 432 96 368 96 0 -1 0.0 -0.5678758104275303 100.0 t 432 96 512 96 0 -1 5.935809575255384 -0.5678758104275303 100.0 w 368 112 368 144 0 w 432 96 432 144 0 w 432 144 368 144 0 w 304 64 368 64 0 w 368 64 368 80 0 w 368 64 512 64 0 w 512 64 512 80 0 w 512 112 512 144 0 w 512 144 544 144 0 t 544 144 592 144 0 1 -6.503685385682914 0.5747794839304037 100.0 t 592 192 544 192 0 1 -0.5747794839304037 0.024148064987379314 100.0 w 544 144 544 176 0 w 592 160 592 192 0 w 592 128 592 64 0 w 592 64 512 64 0 w 544 208 544 256 0 r 592 192 592 256 0 25.0 w 544 256 592 256 0 r 592 256 592 336 0 50.0 w 512 144 512 192 0 w 592 368 592 448 0 t 480 256 512 256 0 1 -0.3684886259495066 0.5652176348585964 100.0 r 480 256 480 192 0 4500.0 r 480 256 480 320 0 7500.0 w 480 320 512 320 0 w 512 320 512 272 0 w 512 240 512 192 0 w 512 192 480 192 0 t 512 352 592 352 0 -1 22.562608353508985 -0.33477544138584836 100.0 w 512 320 512 352 0 t 480 368 512 368 0 1 -21.958971011928803 0.5675170607198208 100.0 t 512 400 432 400 0 1 -1.0443751009866045 0.03612028086036112 100.0 r 512 400 512 448 0 50.0 w 480 368 480 416 0 r 480 416 480 448 0 50000.0 w 480 448 512 448 0 w 512 448 592 448 0 w 480 448 432 448 0 w 432 448 432 416 0 w 368 448 432 448 0 w 512 384 512 400 0 t 432 336 480 336 0 1 -21.48211297166202 0.4768580402667837 100.0 w 432 336 432 384 0 w 480 352 480 368 0 w 208 288 432 288 0 w 432 288 432 336 0 w 480 192 432 192 0 c 432 192 432 288 0 3.0E-11 22.41581923247012 O 624 256 656 256 0 g 64 160 64 208 0 w 240 160 240 32 0 r 240 32 624 32 0 2000.0 w 624 32 624 256 0 w 624 256 592 256 0 r 240 32 144 32 0 1000.0 R 144 32 96 32 0 2 12000.0 5.0 0.0 0.0 0.5 x 29 167 48 173 0 24 + x 241 195 255 201 0 24 - o 104 4 0 34 5.0 0.003125 0 -1 in o 97 2 0 290 20.0 9.765625E-5 1 -1 out ================================================ FILE: src/circuits/opint.txt ================================================ $ 1 4.9999999999999996E-6 1.5642631884188172 60 15.0 66 t 64 128 96 128 0 1 -14.46038257128449 0.4699505311909224 100.0 t 128 192 96 192 0 -1 13.167263810426565 -0.46995053119092234 100.0 t 96 256 144 256 0 1 -29.043132450831923 0.4727778362899038 100.0 t 144 320 96 320 0 1 -0.4727778362899038 0.46966901844007936 100.0 r 96 336 96 432 0 1000.0 r 144 320 144 432 0 50000.0 w 144 272 144 320 0 w 96 256 96 304 0 w 96 256 96 208 0 w 96 144 96 176 0 t 240 128 208 128 0 1 -14.524414993260976 0.43793432020267864 100.0 t 176 192 208 192 0 -1 14.106489865918032 -0.43793432020267853 100.0 w 208 144 208 176 0 w 128 192 176 192 0 w 176 192 176 224 0 w 208 208 208 256 0 t 144 320 208 320 0 1 0.4664482192015633 0.4735715003080774 100.0 w 208 256 208 304 0 r 208 336 208 432 0 1000.0 w 96 432 144 432 0 w 144 432 208 432 0 R 96 432 48 432 0 0 40.0 -15.0 0.0 0.0 0.5 t 208 64 160 64 0 -1 0.0 -0.47558500673902415 100.0 t 208 64 304 64 0 -1 15.400283633666334 -0.47558500673902415 100.0 w 208 112 160 112 0 w 96 112 160 112 0 w 160 80 160 112 0 w 208 64 208 112 0 w 304 80 304 224 0 w 304 224 176 224 0 w 160 48 160 32 0 w 160 32 304 32 0 w 304 32 304 48 0 w 144 240 144 32 0 w 144 32 160 32 0 R 144 32 48 32 0 0 40.0 15.0 0.0 0.0 0.5 t 336 320 304 320 0 1 -13.556006792099927 0.4758387148737153 100.0 t 336 320 368 320 0 1 0.0 0.5681245674947153 100.0 w 304 224 304 304 0 r 304 336 304 432 0 5000.0 w 208 432 304 432 0 w 304 432 368 432 0 w 368 432 368 336 0 w 336 320 336 272 0 w 336 272 368 272 0 w 368 272 368 304 0 r 368 272 368 112 0 39000.0 t 432 64 368 64 0 -1 0.0 -0.5579117469270845 100.0 t 432 64 512 64 0 -1 -0.5576629644457523 -0.5579117469270845 100.0 w 368 80 368 112 0 w 432 64 432 112 0 w 432 112 368 112 0 w 304 32 368 32 0 w 368 32 368 48 0 w 368 32 512 32 0 w 512 32 512 48 0 w 512 80 512 112 0 w 512 112 544 112 0 t 544 112 592 112 0 1 -2.4878248133219927E-4 0.006121869393414414 100.0 t 592 160 544 160 0 1 -0.006121869393414414 9.769962616701378E-13 100.0 w 544 112 544 144 0 w 592 128 592 160 0 w 592 96 592 32 0 w 592 32 512 32 0 w 544 176 544 224 0 r 592 160 592 224 0 25.0 w 544 224 592 224 0 r 592 224 592 304 0 50.0 w 512 112 512 160 0 w 592 336 592 432 0 t 480 224 512 224 0 1 -1.58176582942815E-9 2.636269869071839E-9 100.0 r 480 224 480 160 0 4500.0 r 480 224 480 288 0 7500.0 w 480 288 512 288 0 w 512 288 512 240 0 w 512 208 512 160 0 w 512 160 480 160 0 t 512 320 592 320 0 -1 29.999751213300634 0.006121865178858599 100.0 w 512 288 512 320 0 t 480 336 512 336 0 1 -29.999751203174743 1.0122121807398798E-8 100.0 t 512 368 432 368 0 1 -0.0176414936728424 3.767652856367931E-12 100.0 r 512 368 512 432 0 50.0 w 480 336 480 384 0 r 480 384 480 432 0 50000.0 w 480 432 512 432 0 w 512 432 592 432 0 w 480 432 432 432 0 w 432 432 432 384 0 w 368 432 432 432 0 w 512 352 512 368 0 t 432 304 480 304 0 1 -29.98210971962402 0.017641483550720594 100.0 w 432 304 432 352 0 w 480 320 480 336 0 w 208 256 432 256 0 w 432 256 432 304 0 w 480 160 432 160 0 c 432 160 432 256 0 3.0E-11 29.982109723842058 O 592 224 624 224 0 R 64 128 64 176 0 1 120.0 0.1 0.0 0.0 0.5 g 240 128 240 176 0 x 245 105 259 111 0 24 - x 41 105 60 111 0 24 + o 98 64 0 34 0.625 9.765625E-5 0 -1 o 97 16 0 34 20.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/peak-detect.txt ================================================ $ 1 5.0E-6 10 50 5.0 a 128 144 256 144 1 a 304 160 432 160 1 d 256 144 272 144 0 w 272 144 304 144 0 w 304 176 304 208 0 w 304 208 432 208 0 w 432 208 432 160 0 w 128 160 128 192 0 w 272 144 272 192 0 c 272 192 272 288 0 1.0E-5 0.0026623988117427983 g 272 288 272 320 0 g 32 288 32 320 0 w 128 64 128 128 0 v 32 288 32 176 0 1 40.0 5.0 0.0 v 32 176 32 64 0 1 110.0 3.0 0.0 w 128 192 224 192 0 w 224 192 272 192 0 s 224 192 224 288 0 true true r 224 288 272 288 0 10.0 w 32 64 80 64 0 w 80 64 128 64 0 p 80 64 80 288 0 w 32 288 80 288 0 O 432 160 480 160 0 x 161 247 177 247 0 20 reset o 21 32 0 2 10.0 9.765625E-5 0 input o 23 64 0 2 10.0 9.765625E-5 1 peak ================================================ FILE: src/circuits/phasecomp.txt ================================================ $ 1 5.0E-6 10 53 5.0 R 272 176 208 176 0 2 105.0 2.5 2.5 R 272 272 208 272 0 2 100.0 2.5 2.5 w 272 176 272 208 0 161 272 208 304 208 0 w 368 208 416 208 0 r 416 208 416 112 0 1000.0 r 416 208 416 304 0 1000.0 O 416 208 480 208 0 R 416 112 368 112 0 0 40.0 5.0 0.0 g 416 304 416 320 0 w 272 240 272 272 0 o 0 64 0 6 5.0 9.765625E-5 0 o 1 64 0 6 5.0 9.765625E-5 0 o 7 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/phasecompint.txt ================================================ $ 1 5.0E-6 10 53 5.0 155 128 96 144 96 2 0.0 155 128 256 160 256 2 0.0 w 224 96 400 96 0 w 400 96 400 192 0 w 224 256 400 256 0 w 400 256 400 224 0 f 400 256 464 256 4 f 416 160 464 160 5 w 224 160 416 160 0 w 464 176 464 208 0 w 464 208 464 240 0 g 464 272 464 320 0 R 464 144 464 80 0 0 40.0 5.0 0.0 R 128 128 48 128 0 2 120.0 2.5 2.5 R 128 288 48 288 0 2 115.0 2.5 2.5 R 128 96 96 96 0 0 40.0 5.0 0.0 R 128 256 96 256 0 0 40.0 5.0 0.0 w 128 208 128 160 0 w 304 208 304 352 0 w 304 352 128 352 0 w 128 352 128 320 0 w 464 208 528 208 0 r 528 208 528 144 0 1000.0 r 528 208 528 272 0 1000.0 R 528 144 528 80 0 0 40.0 5.0 0.0 g 528 272 528 320 0 O 528 208 576 208 0 w 128 208 304 208 0 150 400 208 304 208 0 2 0.0 o 13 64 0 6 5.0 9.765625E-5 0 o 14 64 0 6 5.0 9.765625E-5 0 o 26 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/phaseseq.txt ================================================ $ 1 2.0E-5 6.7 50 5.0 r 112 96 176 96 0 100.0 r 176 96 240 96 0 100.0 r 240 96 304 96 0 100.0 r 304 96 368 96 0 100.0 c 176 96 112 160 0 3.9999999999999996E-5 -0.10741100884462906 c 240 96 176 160 0 1.9999999999999998E-5 1.1133615569674231 c 304 96 240 160 0 9.999999999999999E-6 -0.7647587214948204 c 368 96 304 160 0 4.9999999999999996E-6 -2.06464071412291 r 112 160 176 160 0 100.0 r 176 160 240 160 0 100.0 r 240 160 304 160 0 100.0 r 304 160 368 160 0 100.0 c 176 160 112 224 0 3.9999999999999996E-5 -2.8808489197362044 c 240 160 176 224 0 1.9999999999999998E-5 -1.9733158385444027 c 304 160 240 224 0 1.0E-5 -2.770585096178578 c 368 160 304 224 0 4.9999999999999996E-6 -3.3745823741490737 c 176 224 112 288 0 3.9999999999999996E-5 0.10741100884465973 c 240 224 176 288 0 1.9999999999999998E-5 -1.1133615569673985 c 304 224 240 288 0 1.0E-5 0.7647587214948486 c 368 224 304 288 0 4.9999999999999996E-6 2.064640714122932 r 112 224 176 224 0 100.0 r 176 224 240 224 0 100.0 r 240 224 304 224 0 100.0 r 304 224 368 224 0 100.0 r 368 288 304 288 0 100.0 r 304 288 240 288 0 100.0 r 240 288 176 288 0 100.0 r 176 288 112 288 0 100.0 c 176 288 112 352 0 3.9999999999999996E-5 2.880848919736184 c 240 288 176 352 0 1.9999999999999998E-5 1.9733158385443441 c 304 288 240 352 0 1.0E-5 2.770585096178546 c 368 288 304 352 0 4.9999999999999996E-6 3.3745823741490497 w 304 352 384 352 0 w 384 352 384 80 0 w 384 80 304 80 0 w 304 80 304 96 0 w 240 352 240 368 0 w 240 368 400 368 0 w 400 368 400 64 0 w 400 64 240 64 0 w 240 64 240 96 0 w 176 352 176 384 0 w 176 384 416 384 0 w 416 384 416 48 0 w 416 48 176 48 0 w 176 48 176 96 0 w 112 352 112 400 0 w 112 400 432 400 0 w 432 400 432 32 0 w 432 32 112 32 0 w 112 32 112 96 0 w 368 96 448 96 0 w 368 160 448 160 0 w 368 224 448 224 0 w 368 288 448 288 0 O 448 96 496 96 0 O 448 160 496 160 0 O 448 224 496 224 0 O 448 288 496 288 0 w 112 96 112 128 0 w 112 128 112 160 0 w 112 224 112 256 0 w 112 256 112 288 0 v 48 192 48 128 0 1 40.0 5.0 0.0 v 48 256 48 192 0 1 40.0 5.0 0.0 w 48 128 112 128 0 w 48 256 112 256 0 o 55 32 0 6 5.0 9.765625E-5 0 o 56 32 0 6 5.0 9.765625E-5 0 o 57 32 0 6 5.0 9.765625E-5 0 o 58 32 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/phaseshiftosc.txt ================================================ $ 1 5.0E-6 13.097415321081861 58 5.0 50 c 128 224 192 224 0 5.0E-7 11.800776695055955 c 192 224 256 224 0 5.0E-7 2.013884192737342 c 256 224 320 224 0 5.0E-7 -0.3404389620445001 r 320 224 384 224 0 1000.0 r 192 224 192 304 0 1000.0 r 256 224 256 304 0 1000.0 g 192 304 192 320 0 g 256 304 256 320 0 a 384 240 480 240 0 15.0 -15.0 1000000.0 w 384 224 384 176 0 r 384 176 480 176 0 29000.0 w 480 176 480 240 0 w 480 240 496 240 0 w 496 240 496 144 0 w 496 144 128 144 0 w 128 144 128 224 0 O 496 240 544 240 0 g 384 256 384 304 0 o 3 64 0 34 0.625 0.0015625 0 -1 o 16 64 0 42 20.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/phasesplit.txt ================================================ $ 1 5.0E-6 18 64 10.0 53 w 192 96 288 96 0 r 192 96 192 192 0 150000.0 r 192 192 192 304 0 56000.0 t 192 192 288 192 0 1 -9.442348352812836 0.5777055611167752 r 288 208 288 304 0 4700.0 w 192 304 288 304 0 c 144 192 192 192 0 3.0E-6 -4.905240822514835 R 144 192 96 192 0 1 40.0 3.0 0.0 g 192 304 192 336 0 R 192 96 96 96 0 0 40.0 20.0 0.0 r 288 96 288 176 0 4700.0 c 288 208 352 208 0 3.0E-6 4.826735289331256 r 352 208 352 304 0 10000.0 w 288 304 352 304 0 c 288 176 384 176 0 3.0E-6 15.221446280055797 r 384 176 384 304 0 10000.0 w 352 304 384 304 0 O 384 176 448 176 0 O 352 208 448 208 0 o 17 64 0 6 5.0 9.765625E-5 0 o 18 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/pll.txt ================================================ $ 1 5.0E-6 16.13108636308289 65 5.0 50 158 432 224 464 224 0 c 528 224 528 256 0 1.0E-6 0 r 528 288 592 288 0 4000.0 r 528 320 592 320 0 100000.0 w 592 288 592 320 0 g 592 320 592 352 0 154 144 192 256 192 0 2 0.0 R 144 176 80 176 0 2 60.0 2.5 2.5 0.0 0.5 w 144 208 144 320 0 w 144 320 432 320 0 r 256 192 320 192 0 5000.0 c 320 192 320 224 0 9.0E-6 0 w 432 192 432 224 0 O 144 320 96 320 0 a 352 128 432 128 1 15.0 -15.0 1000000.0 w 320 192 320 112 0 w 320 112 352 112 0 w 352 144 352 192 0 w 352 192 432 192 0 w 432 192 432 128 0 r 320 224 320 272 0 1000.0 g 320 272 320 288 0 o 7 64 0 46 5.0 9.765625E-5 0 -1 o 13 64 0 46 5.0 9.765625E-5 0 -1 o 11 64 0 35 1.1692013098647223 0.001461501637330903 1 -1 ================================================ FILE: src/circuits/pll2.txt ================================================ $ 1 5.0E-6 15.5 60 5.0 158 416 208 448 208 0 c 512 208 512 240 0 9.999999999999999E-7 0 r 512 272 576 272 0 3000.0 r 512 304 576 304 0 100000.0 w 576 272 576 304 0 g 576 304 576 336 0 R 128 160 64 160 0 2 120.0 2.5 2.5 w 128 192 128 304 0 w 128 304 416 304 0 w 416 176 416 208 0 O 128 304 80 304 0 a 336 112 416 112 1 15.0 -15.0 w 304 96 336 96 0 w 336 128 336 176 0 w 336 176 416 176 0 w 416 176 416 112 0 161 128 160 176 160 0 r 224 160 304 160 0 500.0 w 304 96 304 160 0 c 304 160 304 208 0 9.0E-5 0 r 304 208 304 256 0 1000.0 g 304 256 304 272 0 o 6 64 0 14 5.0 9.765625E-5 0 o 10 64 0 14 5.0 9.765625E-5 0 o 19 64 0 3 0.15625 0.05 1 ================================================ FILE: src/circuits/pll2a.txt ================================================ $ 1 5.0E-6 15 64 5.0 158 416 208 448 208 0 c 512 208 512 240 0 1.0E-8 0 r 512 272 576 272 0 30000.0 r 512 304 576 304 0 1000000.0 w 576 272 576 304 0 g 576 304 576 336 0 R 128 160 64 160 0 2 970.0 2.5 2.5 w 128 192 128 304 0 w 128 304 416 304 0 g 304 240 304 272 0 w 416 176 416 208 0 O 128 304 80 304 0 a 336 112 416 112 1 15.0 -15.0 w 304 96 336 96 0 w 336 128 336 176 0 w 336 176 416 176 0 w 416 176 416 112 0 161 128 160 176 160 0 r 224 160 304 160 0 2000.0 w 304 96 304 160 0 c 304 160 304 192 0 9.999999999999999E-6 0 r 304 192 304 240 0 1000.0 o 6 16 0 14 5.0 4.8828125E-5 0 o 11 16 0 14 5.0 9.765625E-5 0 o 20 64 0 3 5.0 0.0025 1 ================================================ FILE: src/circuits/pmosfet.txt ================================================ $ 1 5.0E-6 12.185319768402522 50 5.0 50 172 304 240 272 240 0 6 2.5 5.0 0.0 0.0 0.5 Gate Voltage w 352 256 352 304 0 w 352 224 352 176 1 f 304 240 352 240 1 1.5 172 352 304 352 320 0 6 3.0 5.0 0.0 0.0 0.5 Drain Voltage R 352 176 352 160 0 0 40.0 5.0 0.0 0.0 0.5 o 3 64 0 35 2.5 0.1 0 -1 ================================================ FILE: src/circuits/pnp.txt ================================================ $ 1 5.0E-6 11.251013186076355 43 2.0 50 172 208 176 176 176 0 6 1.2975 1.5 1.25 0.0 0.5 Base Voltage w 320 192 320 240 1 w 320 160 320 112 1 w 208 176 272 176 1 t 272 176 320 176 0 -1 1.2975 -0.7024999999999999 100.0 R 320 112 320 80 0 0 40.0 2.0 0.0 0.0 0.5 172 320 240 320 272 0 6 0.0 2.0 0.0 0.0 0.5 Collector Voltage ================================================ FILE: src/circuits/pot.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 v 208 320 208 160 0 0 40.0 5.0 0.0 0.0 0.5 v 432 320 432 160 0 0 40.0 5.0 0.0 0.0 0.5 w 320 224 320 160 0 w 320 160 208 160 0 w 320 160 432 160 0 174 208 320 432 224 0 1000.0 0.5 Resistance ================================================ FILE: src/circuits/potdivide.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 174 320 352 384 96 0 1000.0 0.5 Resistance v 240 352 240 96 0 0 40.0 5.0 0.0 0.0 0.5 w 240 96 320 96 0 w 240 352 320 352 0 O 320 96 432 96 1 O 384 224 432 224 1 O 320 352 432 352 1 ================================================ FILE: src/circuits/powerfactor1.txt ================================================ $ 13 5.0E-6 10 47 120.0 28 v 176 304 176 128 2 1 60.0 120.0 0.0 r 304 128 448 128 0 10.0 w 176 304 304 304 0 l 448 128 448 304 0 5.0 0 w 304 304 448 304 0 r 176 128 304 128 0 50.0 o 5 64 1 3 0.3125 9.765625E-5 0 o 1 64 1 3 0.078125 2.44140625E-5 1 o 3 64 1 3 5.0 9.765625E-5 2 ================================================ FILE: src/circuits/powerfactor2.txt ================================================ $ 13 5.0E-6 10 50 120.0 28 v 176 304 176 128 2 1 60.0 120.0 0.0 r 304 128 448 128 0 10.0 w 176 304 304 304 0 l 448 128 448 304 0 5.0 0 w 304 304 448 304 0 r 176 128 304 128 0 50.0 c 304 128 304 304 0 1.4E-6 0 o 5 64 1 3 0.3125 9.765625E-5 0 o 1 64 1 3 0.078125 2.44140625E-5 1 o 3 64 1 3 5.0 9.765625E-5 2 ================================================ FILE: src/circuits/pushpull.txt ================================================ $ 1 5.0E-6 10.391409633455755 43 10.0 42 t 256 192 320 192 0 1 -13.466578126476486 0.7195904601612297 t 256 288 320 288 0 -1 5.091136762641694 -0.72269465072059 w 320 208 320 240 0 w 320 240 320 272 0 w 320 304 320 352 0 r 256 288 256 352 0 220.0 r 256 192 256 128 0 220.0 d 256 240 256 288 0 R 256 240 192 240 0 1 40.0 5.0 0.0 0.0 0.5 w 256 352 320 352 0 w 256 128 320 128 0 w 320 128 320 176 0 R 256 128 256 80 0 0 40.0 10.0 0.0 0.0 0.5 R 256 352 256 400 0 0 40.0 -10.0 0.0 0.0 0.5 d 256 192 256 240 0 w 320 240 400 240 0 r 400 240 400 352 0 10.0 g 400 352 400 384 0 O 400 240 448 240 0 o 8 64 0 34 6.0 0.025 0 -1 o 18 64 0 34 6.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/pushpullxover.txt ================================================ $ 1 5.0E-6 10.812258501325767 43 10.0 42 t 256 192 320 192 0 1 -12.21942316756332 -0.7012139808257767 t 256 288 320 288 0 -1 7.780576832436679 -0.7012139808257767 w 320 208 320 240 0 w 320 240 320 272 0 w 320 304 320 352 0 R 256 240 192 240 0 1 40.0 5.0 0.0 0.0 0.5 w 320 128 320 176 0 R 320 128 320 80 0 0 40.0 10.0 0.0 0.0 0.5 R 320 352 320 400 0 0 40.0 -10.0 0.0 0.0 0.5 w 320 240 400 240 0 r 400 240 400 352 0 10.0 g 400 352 400 384 0 O 400 240 448 240 0 w 256 240 256 288 0 w 256 192 256 240 0 o 5 64 0 34 6.0 0.003125 0 -1 o 12 64 0 34 6.0 4.8828125E-5 1 -1 ================================================ FILE: src/circuits/r2rladder.txt ================================================ $ 1 5.0E-6 10 64 5.0 160 160 144 160 240 0 160 240 144 240 240 0 160 320 144 320 240 0 g 144 240 144 288 0 g 224 240 224 288 0 g 304 240 304 288 0 w 176 192 192 192 0 w 176 240 176 256 0 w 176 256 256 256 0 w 256 256 256 240 0 w 256 256 336 256 0 w 336 256 336 240 0 w 192 192 192 320 0 w 256 192 272 192 0 w 272 192 272 320 0 w 336 192 352 192 0 w 352 192 352 320 0 L 192 320 192 352 0 false false L 272 320 272 352 0 false false L 352 320 352 352 0 true false r 160 144 160 80 0 100000.0 r 240 144 240 80 0 100000.0 r 320 144 320 80 0 100000.0 r 160 80 240 80 0 50000.0 r 240 80 320 80 0 50000.0 r 320 80 400 80 0 100000.0 g 400 80 400 112 0 w 416 256 416 224 0 w 528 224 528 272 0 O 528 272 592 272 1 w 336 256 416 256 0 r 416 224 528 224 0 50100.0 g 416 288 416 320 0 a 416 272 528 272 0 20.0 -20.0 r 160 80 80 80 0 50000.0 r 80 80 80 144 0 100000.0 160 80 144 80 240 0 w 96 192 112 192 0 w 112 192 112 320 0 g 64 240 64 288 0 L 112 320 112 352 0 true false R 80 80 32 80 0 0 40.0 16.0 0.0 w 96 240 96 256 0 w 96 256 176 256 0 ================================================ FILE: src/circuits/rectify.txt ================================================ $ 1 5.0E-6 13.2 55 5.0 v 112 320 112 96 0 1 40.0 5.0 0.0 r 416 96 416 320 0 640.0 d 112 96 416 96 0 w 112 320 416 320 0 o 0 64 0 3 5.0 0.0125 o 1 64 0 3 5.0 0.0125 ================================================ FILE: src/circuits/relaxosc.txt ================================================ $ 1 5.0E-6 10.20027730826997 61 10.0 50 a 288 224 416 224 0 15.0 -15.0 1000000.0 w 288 208 288 160 0 r 288 160 416 160 0 10000.0 w 416 160 416 224 0 w 416 224 416 288 0 r 416 288 288 288 0 100000.0 w 288 240 288 288 0 r 288 288 192 288 0 100000.0 g 192 288 192 320 0 c 288 160 192 160 0 9.999999999999999E-7 6.154634481752644 g 192 160 192 192 0 O 416 224 480 224 0 o 9 64 0 35 10.0 0.025 0 -1 o 11 64 0 42 20.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/relay.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 178 240 176 384 176 0 1 0.2 0.04166643702749262 0.05 1000000.0 0.02 20.0 172 240 208 176 208 0 6 5.0 5.0 0.0 0.0 0.5 Coil Voltage g 240 288 240 304 0 R 240 176 240 112 0 0 40.0 5.0 0.0 0.0 0.5 r 384 160 464 160 0 100.0 r 384 192 464 192 0 100.0 r 240 224 240 288 0 100.0 w 464 160 464 192 0 w 464 192 464 288 0 g 464 288 464 304 0 ================================================ FILE: src/circuits/relayand.txt ================================================ $ 1 5.0E-6 10.20027730826997 44 5.0 50 178 160 176 240 176 0 1 0.1 8.400979594570726E-14 0.05 1000000.0 0.02 50.0 178 304 176 384 176 0 1 0.1 2.3377800273993248E-7 0.05 1000000.0 0.02 50.0 178 448 176 528 176 0 1 0.1 1.5717284793725733E-19 0.05 1000000.0 0.02 50.0 R 160 176 112 176 0 0 40.0 5.0 0.0 0.0 0.5 w 240 192 304 192 0 w 304 176 304 192 0 w 384 192 448 192 0 w 448 176 448 192 0 g 160 224 160 256 0 g 304 224 304 256 0 g 448 224 448 256 0 w 160 208 128 208 0 w 304 208 272 208 0 w 448 208 416 208 0 L 128 208 128 288 0 0 false 5.0 0.0 L 272 208 272 288 0 0 false 5.0 0.0 L 416 208 416 288 0 0 false 5.0 0.0 M 528 192 576 192 0 2.5 r 528 192 528 272 0 100.0 g 528 272 528 288 0 ================================================ FILE: src/circuits/relayctr.txt ================================================ $ 1 1.0E-4 0.37936678946831776 42 5.0 50 178 112 352 176 352 0 3 0.02 -0.246374098463728 0.05 1000000.0 0.02 20.0 178 112 128 176 128 0 2 0.02 0.008998074798403165 0.05 1000000.0 0.02 20.0 R 176 64 208 64 0 0 40.0 6.0 0.0 0.0 0.5 w 176 112 192 112 0 w 192 112 192 368 0 w 192 368 176 368 0 w 176 96 208 96 0 g 208 96 208 112 0 w 176 144 176 192 0 w 176 192 112 192 0 w 112 192 112 176 0 w 112 160 96 160 0 w 96 256 112 256 0 w 176 368 176 416 0 w 176 416 112 416 0 w 112 416 112 400 0 w 112 384 80 384 0 g 80 432 80 448 0 w 112 304 80 304 0 w 80 304 80 48 0 w 80 48 240 48 0 w 240 48 240 80 0 w 112 192 64 192 0 w 64 192 64 352 0 w 64 352 112 352 0 w 240 128 240 320 0 w 176 320 240 320 0 w 176 272 224 272 0 162 224 384 224 432 1 2.1024259 1.0 0.0 0.0 g 224 432 224 448 0 R 112 256 112 288 0 0 40.0 6.0 0.0 0.0 0.5 w 224 272 224 304 0 r 224 304 224 384 0 100.0 r 432 304 432 384 0 100.0 w 432 272 432 304 0 R 320 256 320 288 0 0 40.0 6.0 0.0 0.0 0.5 g 432 432 432 448 0 162 432 384 432 432 1 2.1024259 1.0 0.0 0.0 w 384 272 432 272 0 w 384 320 448 320 0 w 448 128 448 320 0 w 496 128 448 128 0 w 272 352 320 352 0 w 272 192 272 352 0 w 320 192 272 192 0 w 496 48 496 80 0 w 288 48 496 48 0 w 288 304 288 48 0 w 320 304 288 304 0 g 288 432 288 448 0 w 320 384 288 384 0 w 320 416 320 400 0 w 384 416 320 416 0 w 384 368 384 416 0 w 304 256 320 256 0 w 320 160 304 160 0 w 320 192 320 176 0 w 384 192 320 192 0 w 384 144 384 192 0 g 416 96 416 112 0 w 384 96 416 96 0 w 400 368 384 368 0 w 400 112 400 368 0 w 384 112 400 112 0 R 384 64 416 64 0 0 40.0 6.0 0.0 0.0 0.5 178 320 128 384 128 0 2 0.02 0.0012317989769374195 0.05 1000000.0 0.02 20.0 178 320 352 384 352 0 3 0.02 -0.24971375659971373 0.05 1000000.0 0.02 20.0 w 240 80 320 80 0 w 240 128 320 128 0 r 656 304 656 384 0 100.0 w 656 272 656 304 0 R 544 256 544 288 0 0 40.0 6.0 0.0 0.0 0.5 g 656 432 656 448 0 162 656 384 656 432 1 2.1024259 1.0 0.0 0.0 w 608 272 656 272 0 w 496 352 544 352 0 w 496 192 496 352 0 w 544 192 496 192 0 w 544 304 512 304 0 g 512 432 512 448 0 w 544 384 512 384 0 w 544 416 544 400 0 w 608 416 544 416 0 w 608 368 608 416 0 w 528 256 544 256 0 w 544 160 528 160 0 w 544 192 544 176 0 w 608 192 544 192 0 w 608 144 608 192 0 g 640 96 640 112 0 w 608 96 640 96 0 w 624 368 608 368 0 w 624 112 624 368 0 w 608 112 624 112 0 R 608 64 640 64 0 0 40.0 6.0 0.0 0.0 0.5 178 544 128 608 128 0 2 0.02 0.001168923898353853 0.05 1000000.0 0.02 20.0 178 544 352 608 352 0 3 0.02 -0.24487149798797075 0.05 1000000.0 0.02 20.0 w 496 80 544 80 0 w 496 128 544 128 0 w 112 80 112 64 0 w 112 64 48 64 0 w 112 128 48 128 0 159 48 64 48 128 0 1.0 1.0E10 R 32 96 32 16 1 2 25.0 2.5 2.5 0.0 0.5 w 96 160 96 256 0 w 304 160 304 256 0 w 528 160 528 256 0 w 80 384 80 432 0 w 288 384 288 432 0 w 512 384 512 432 0 o 73 8 0 37 2.3384026197294445 0.046768052394588894 0 -1 o 37 8 0 37 2.187250724783012 0.04374501449566024 0 -1 o 28 8 0 37 2.3384026197294445 0.046768052394588894 0 -1 ================================================ FILE: src/circuits/relayff.txt ================================================ $ 1 5.0E-6 10.20027730826997 45 5.0 50 178 224 192 336 192 1 1 0.2 0.21813393565127673 0.05 1000000.0 0.02 20.0 178 528 192 400 192 1 1 0.2 4.99990000199996E-6 0.05 1000000.0 0.02 20.0 w 352 176 384 224 0 w 352 224 384 176 0 w 224 192 224 144 0 w 224 144 528 144 0 w 528 144 528 192 0 R 224 144 160 144 0 0 40.0 5.0 0.0 0.0 0.5 s 336 240 336 320 0 0 true s 400 240 400 320 0 0 true g 336 320 336 336 0 g 400 320 400 336 0 x 247 286 317 290 0 16 set/reset w 336 176 352 176 0 w 336 224 352 224 0 w 384 224 400 224 0 w 384 176 400 176 0 ================================================ FILE: src/circuits/relaymux.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 178 128 160 208 160 0 1 0.1 0.24999999999997224 0.05 1000000.0 0.02 50.0 178 256 192 336 192 0 2 0.1 0.24999710044544057 0.05 1000000.0 0.02 50.0 178 384 224 464 224 0 4 0.1 0.24999999999997224 0.05 1000000.0 0.02 50.0 g 128 208 128 240 0 g 256 240 256 272 0 g 384 272 384 288 0 w 128 192 96 192 0 w 256 224 224 224 0 w 384 256 352 256 0 L 96 192 96 352 0 1 false 5.0 0.0 L 224 224 224 352 0 1 false 5.0 0.0 L 352 256 352 352 0 1 false 5.0 0.0 R 128 160 96 160 0 0 40.0 5.0 0.0 0.0 0.5 w 208 144 256 144 0 w 208 176 208 192 0 w 208 192 256 192 0 w 336 128 336 80 0 w 336 80 384 80 0 w 336 160 384 160 0 w 384 160 384 128 0 w 336 176 384 176 0 w 336 208 384 208 0 w 384 208 384 224 0 M 464 64 512 64 4 2.5 M 464 96 512 96 4 2.5 M 464 112 512 112 4 2.5 M 464 144 512 144 4 2.5 M 464 160 512 160 4 2.5 M 464 192 512 192 4 2.5 M 464 208 512 208 4 2.5 M 464 240 512 240 4 2.5 ================================================ FILE: src/circuits/relayor.txt ================================================ $ 1 5.0E-6 10.20027730826997 44 5.0 50 178 112 176 192 176 0 1 0.1 1.4393787726652385E-9 0.05 1000000.0 0.02 50.0 178 304 176 384 176 0 1 0.1 7.78801831882807E-17 0.05 1000000.0 0.02 50.0 178 480 176 560 176 0 1 0.1 1.8053432778617287E-13 0.05 1000000.0 0.02 50.0 R 112 176 80 176 0 0 40.0 5.0 0.0 0.0 0.5 g 112 224 112 256 0 g 304 224 304 256 0 g 480 224 480 256 0 w 112 208 80 208 0 w 304 208 272 208 0 w 480 208 448 208 0 L 80 208 80 288 0 0 false 5.0 0.0 L 272 208 272 288 0 0 false 5.0 0.0 L 448 208 448 288 0 0 false 5.0 0.0 M 592 192 640 192 0 2.5 r 592 192 592 272 0 100.0 g 592 272 592 288 0 R 304 176 272 176 0 0 40.0 5.0 0.0 0.0 0.5 R 480 176 448 176 0 0 40.0 5.0 0.0 0.0 0.5 w 192 192 224 192 0 w 224 192 224 128 0 w 224 128 416 128 0 w 416 128 416 192 0 w 416 192 384 192 0 w 416 128 592 128 0 w 592 128 592 192 0 w 560 192 592 192 0 ================================================ FILE: src/circuits/relaytff.txt ================================================ $ 1 1.0E-5 18.278915558614752 50 5.0 50 178 496 224 592 224 1 1 0.1 9.996201113724626E-6 0.05 1000000.0 0.02 20.0 R 112 208 64 208 0 0 40.0 5.0 0.0 0.0 0.5 w 176 208 176 368 0 w 368 304 448 304 0 w 176 368 368 368 0 w 368 272 400 272 0 w 400 320 400 368 0 w 400 368 368 368 0 w 368 176 624 176 0 w 624 176 624 240 0 w 624 240 592 240 0 s 208 144 288 144 0 1 false w 288 288 208 288 0 r 112 208 176 208 0 100.0 178 288 288 368 288 1 2 0.1 9.996201118876302E-6 0.05 1000000.0 0.02 20.0 w 208 288 208 144 0 w 368 256 416 256 0 w 416 256 416 224 0 w 448 224 496 224 0 w 368 224 368 176 0 w 416 336 416 256 0 g 448 304 448 336 0 w 416 224 448 224 0 w 288 144 288 240 0 x 225 97 275 101 0 16 toggle w 368 336 416 336 0 w 368 320 400 320 0 w 400 272 400 320 0 w 592 256 624 256 0 w 624 240 624 256 0 g 592 272 592 336 0 ================================================ FILE: src/circuits/relayxor.txt ================================================ $ 1 5.0E-6 10.20027730826997 47 5.0 50 178 176 192 272 192 0 1 0.1 4.3921117436851676E-10 0.05 1000000.0 0.02 50.0 178 400 192 304 192 0 1 0.1 1.9184076606594825E-6 0.05 1000000.0 0.02 50.0 w 272 176 304 208 0 w 272 208 304 176 0 R 176 192 144 192 0 0 40.0 5.0 0.0 0.0 0.5 g 176 240 176 256 0 g 400 240 400 256 0 w 176 224 144 224 0 w 400 224 432 224 0 L 144 224 144 304 0 0 false 5.0 0.0 L 432 224 432 304 0 0 false 5.0 0.0 w 400 192 480 192 0 r 480 192 480 272 0 100.0 g 480 272 480 288 0 M 480 192 528 192 0 2.5 ================================================ FILE: src/circuits/res-par.txt ================================================ $ 1 5.0E-6 15 53 5.0 v 64 240 64 160 0 1 41.09 5.0 0.0 c 448 160 448 240 0 1.4999999999999999E-5 2.5658496700882356 w 64 160 192 160 0 w 192 160 320 160 0 w 320 160 448 160 0 l 320 160 320 240 0 1.0 -0.016508821800832994 r 192 160 192 240 0 2000.0 w 192 240 320 240 0 w 320 240 448 240 0 r 64 240 192 240 0 100.0 v 64 128 64 48 0 1 30.0 5.0 0.0 c 448 48 448 128 0 1.4999999999999999E-5 -4.290086412851864 w 64 48 192 48 0 w 192 48 320 48 0 w 320 48 448 48 0 l 320 48 320 128 0 1.0 0.01334973082855116 r 192 48 192 128 0 2000.0 w 192 128 320 128 0 w 320 128 448 128 0 r 64 128 192 128 0 100.0 v 64 352 64 272 0 1 50.0 5.0 0.0 c 448 272 448 352 0 1.4999999999999999E-5 2.9322583665440085 w 64 272 192 272 0 w 192 272 320 272 0 w 320 272 448 272 0 l 320 272 320 352 0 1.0 -0.01279067133991683 r 192 272 192 352 0 2000.0 w 192 352 320 352 0 w 320 352 448 352 0 r 64 352 192 352 0 100.0 h 1 5 1 o 10 64 0 1 2.5 0.025 o 0 64 0 1 2.5 0.003125 o 20 64 0 1 2.5 0.0125 ================================================ FILE: src/circuits/res-series.txt ================================================ $ 1 5.0E-6 15 48 5.0 v 80 112 80 32 0 1 35.0 5.0 0.0 v 80 224 80 144 0 1 41.09 5.0 0.0 v 80 336 80 256 0 1 45.0 5.0 0.0 r 80 32 432 32 0 10.0 c 432 32 432 112 0 1.5E-5 0 l 80 112 432 112 0 1.0 0 r 80 144 432 144 0 10.0 c 432 144 432 224 0 1.5E-5 0 l 80 224 432 224 0 1.0 0 r 80 256 432 256 0 10.0 c 432 256 432 336 0 1.5E-5 0 l 80 336 432 336 0 1.0 0 h 1 5 4 o 4 64 0 3 20.0 0.1 o 7 64 0 3 160.0 0.8 o 10 64 0 3 40.0 0.2 ================================================ FILE: src/circuits/resistors.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 96 368 96 48 0 0 40.0 5.0 0.0 w 96 48 192 48 1 w 192 48 288 48 0 w 288 48 384 48 0 s 192 48 192 128 0 false false s 288 48 288 128 0 true false s 384 48 384 128 0 false false r 192 128 192 192 0 100.0 r 288 128 288 192 0 400.0 r 384 128 384 192 0 800.0 w 192 192 288 192 0 w 288 192 384 192 0 w 288 224 288 192 0 w 288 224 384 224 0 w 288 224 192 224 0 s 288 224 288 304 0 false false s 192 224 192 304 0 true false r 192 304 192 368 0 600.0 r 288 304 288 368 0 200.0 s 384 224 384 368 0 true false w 96 368 192 368 0 w 192 368 288 368 0 w 288 368 384 368 0 ================================================ FILE: src/circuits/ringing.txt ================================================ $ 1 5.0E-6 4.621633621589249 50 5.0 46 w 368 128 368 192 0 w 368 272 368 320 0 w 320 272 368 272 0 w 368 272 416 272 0 w 320 192 368 192 0 w 368 192 416 192 0 l 320 192 320 272 0 0.0020 0.07708318720316419 c 416 192 416 272 0 1.264E-5 -0.22352804367929519 r 256 128 368 128 0 100.0 O 368 128 464 128 0 g 368 320 368 336 0 R 256 128 224 128 0 2 100.0 5.0 0.0 0.0 0.5 o 9 16 0 34 2.5 4.8828125E-5 0 -1 ================================================ FILE: src/circuits/ringmod.txt ================================================ $ 17 5.0E-6 1.7725424121461644 41 3.0 50 d 272 176 320 128 1 0.805904783 d 320 128 368 176 1 0.805904783 d 368 176 320 224 1 0.805904783 d 320 224 272 176 1 0.805904783 169 144 144 208 144 0 0.1 1.0 0.36188085234266 -0.10938222138187827 w 208 144 208 128 0 169 496 208 432 208 0 0.1 1.0 -0.33106614006595897 0.01591880270109881 w 368 144 368 176 0 w 432 208 432 256 0 w 272 256 272 176 0 w 272 256 432 256 0 w 432 144 368 144 0 w 208 128 320 128 0 w 208 208 208 224 0 w 208 224 320 224 0 w 208 176 240 176 0 w 240 176 240 288 0 w 240 288 288 288 0 w 432 176 400 176 0 w 400 176 400 288 0 w 400 288 336 288 0 v 528 144 528 208 0 1 300.0 2.4 0.0 0.0 0.5 v 112 144 112 208 0 1 200.0 2.0 0.0 0.0 0.5 w 288 288 288 336 0 w 336 288 336 336 0 r 288 336 336 336 0 1.0 w 496 208 528 208 0 w 496 144 528 144 0 w 112 208 144 208 0 w 112 144 144 144 0 r 400 288 432 256 0 1000.0 g 528 208 528 224 0 g 112 208 112 224 0 g 208 224 208 240 0 o 21 8 0 38 2.5 0.4 0 -1 o 22 8 0 38 2.5 0.4 0 -1 o 25 8 0 38 1.0229345649675443 0.6546781215792284 1 -1 ================================================ FILE: src/circuits/rossler.txt ================================================ $ 3 5.0E-6 2.898875293967098 66 5.0 50 a 360 304 408 304 2 15.0 -15.0 r 360 272 408 272 0 5000000.0 c 360 240 408 240 0 1.0E-9 3.0635621976420984 w 408 240 408 272 0 w 408 272 408 304 0 w 360 272 360 296 0 w 360 272 360 240 0 g 360 312 360 328 0 c 360 360 408 360 0 1.0E-9 -0.0028565435358697752 r 360 392 408 392 0 100000.0 a 360 424 408 424 2 15.0 -15.0 w 408 360 408 392 0 w 408 392 408 424 0 w 360 416 360 392 0 w 360 392 360 360 0 g 360 432 360 448 0 w 408 240 408 200 0 a 352 120 408 120 2 15.0 -15.0 g 352 128 352 144 0 r 352 88 408 88 0 2000000.0 c 352 56 408 56 0 1.0E-9 0.6880284746244376 w 352 56 352 88 0 w 352 88 352 112 0 w 408 88 408 120 0 w 408 56 408 88 0 r 352 112 304 112 0 100000.0 w 304 112 304 168 0 w 304 168 520 168 0 w 408 200 280 200 0 w 280 200 280 144 0 w 408 56 408 16 0 a 144 304 192 304 2 15.0 -15.0 a 144 424 192 424 2 15.0 -15.0 w 192 416 192 424 0 r 192 416 360 416 0 100000.0 r 192 296 360 296 0 100000.0 w 192 296 192 304 0 w 144 296 144 256 0 r 144 256 192 256 0 10000.0 w 192 256 192 296 0 r 144 296 48 296 0 10000.0 d 96 416 144 416 0 r 96 416 96 360 0 10000.0 r 96 416 96 472 0 68000.0 w 96 360 48 360 0 w 48 360 48 296 0 w 48 296 48 16 0 w 48 16 408 16 0 r 280 56 352 56 0 200000.0 w 280 56 280 144 0 r 280 144 144 144 0 75000.0 w 144 144 144 256 0 g 144 312 144 328 0 g 144 432 144 448 0 r 144 384 192 384 0 150000.0 w 144 384 144 416 0 w 192 384 192 416 0 w 520 168 520 392 0 w 520 392 408 392 0 R 96 472 40 472 0 0 40.0 -15.0 0.0 0.0 0.5 p 408 304 480 304 0 p 408 424 480 424 0 p 408 120 480 120 0 g 480 120 480 136 0 g 480 304 480 320 0 g 480 424 480 440 0 o 60 64 0 226 5.0 3.2 0 61 z vs y o 62 64 0 226 5.0 6.4 1 60 y vs x ================================================ FILE: src/circuits/rtlinverter.txt ================================================ $ 1 5.0E-6 10 52 5.0 r 240 224 320 224 0 470.0 t 320 224 368 224 0 1 0.6381869044881298 0.6478945398933037 r 368 208 368 112 0 640.0 w 368 240 368 288 0 L 240 224 192 224 0 false false 3.6 0.0 R 368 112 320 112 0 0 40.0 3.6 0.0 M 368 208 432 208 0 g 368 288 368 320 0 ================================================ FILE: src/circuits/rtlnand.txt ================================================ $ 1 5.0E-6 10 52 5.0 R 368 64 320 64 0 0 40.0 3.6 0.0 g 368 336 368 368 0 t 320 208 368 208 0 1 0.6378429407740765 0.6475693325578884 w 368 160 368 192 0 r 368 160 368 64 0 640.0 t 320 256 368 256 0 1 0.6376732762947126 0.6550300979283231 t 320 304 368 304 0 1 0.6375679404402763 0.6608122760347422 w 368 224 368 240 0 w 368 272 368 288 0 w 368 320 368 336 0 r 320 208 240 208 0 470.0 r 240 256 320 256 0 470.0 r 240 304 320 304 0 470.0 L 240 208 208 208 0 false false 3.6 0.0 L 240 256 208 256 0 false false 3.6 0.0 L 240 304 208 304 0 false false 3.6 0.0 M 368 160 432 160 0 ================================================ FILE: src/circuits/rtlnor.txt ================================================ $ 1 5.0E-6 10 52 5.0 t 176 208 224 208 0 1 0.638186904488133 0.6478945398932158 t 272 208 320 208 0 1 -0.00970763539752057 7.562178340717264E-12 t 368 208 416 208 0 1 -0.00970763539752057 7.562178340717264E-12 w 224 160 224 192 0 w 320 160 320 192 0 w 224 160 320 160 0 w 320 160 416 160 0 w 416 160 416 192 0 r 176 208 176 272 0 470.0 r 272 208 272 272 0 470.0 r 368 208 368 272 0 470.0 L 176 272 176 304 0 false false 3.6 0.0 L 272 272 272 304 0 true false 3.6 0.0 L 368 272 368 304 0 true false 3.6 0.0 w 224 224 224 336 0 w 320 224 320 336 0 w 416 224 416 336 0 w 416 336 320 336 0 w 320 336 224 336 0 r 416 160 416 64 0 640.0 g 416 336 416 368 0 R 416 64 352 64 0 0 40.0 3.6 0.0 M 416 160 464 160 0 ================================================ FILE: src/circuits/samplenhold.txt ================================================ $ 1 5.0E-6 10 74 5.0 81 f 192 112 192 160 1 f 192 224 192 160 0 w 192 112 256 112 0 w 256 112 256 224 0 I 192 224 256 224 0 0.5 L 192 224 192 304 0 true true 5.0 0.0 w 208 160 304 160 0 c 304 160 304 256 0 1.0E-7 1.9962454782690886 g 304 256 304 304 0 a 352 160 464 160 1 15.0 -15.0 w 304 160 304 144 0 w 304 144 352 144 0 w 352 176 352 224 0 w 352 224 464 224 0 w 464 224 464 160 0 O 464 160 512 160 0 R 144 160 96 160 0 1 40.0 2.5 2.5 w 144 160 176 160 0 x 157 341 173 341 0 20 sample o 16 64 0 2 6.0 9.765625E-5 0 o 15 64 0 2 6.0 9.765625E-5 1 ================================================ FILE: src/circuits/sawtooth.txt ================================================ $ 1 5.0E-6 10.634267539816555 63 5.0 50 a 160 224 272 224 0 15.0 -15.0 1000000.0 w 160 240 160 304 0 w 160 304 272 304 0 r 272 224 272 304 0 100000.0 a 384 240 496 240 0 15.0 -15.0 1000000.0 r 272 304 352 304 0 40000.0 w 352 304 496 304 0 w 496 304 496 240 0 w 496 240 496 176 0 c 384 176 496 176 0 5.0E-7 4.758165877822716 w 384 176 384 224 0 g 384 256 384 272 0 O 496 240 560 240 0 w 160 208 128 208 0 g 128 208 128 240 0 r 384 176 320 176 0 5000.0 r 384 224 320 224 0 40000.0 d 272 176 320 176 1 0.805904783 d 320 224 272 224 1 0.805904783 w 272 176 272 224 0 o 12 64 0 42 10.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/schmitt.txt ================================================ $ 1 5.0E-6 16.13 50 5.0 50 r 192 32 192 96 0 500.0 r 192 96 336 96 0 100.0 w 336 96 336 144 0 t 336 144 416 144 0 1 0.5820470981894252 0.631962165475968 100.0 t 128 144 192 144 0 1 -1.8901554514017818 -0.6779682779383932 100.0 w 192 96 192 128 0 w 416 128 416 96 0 w 192 32 416 32 0 r 416 32 416 96 0 500.0 w 192 160 192 192 0 w 192 192 416 192 0 w 416 160 416 192 0 w 336 144 336 208 0 r 336 208 336 272 0 300.0 r 192 192 192 272 0 100.0 w 192 272 336 272 0 R 192 32 128 32 0 0 40.0 5.0 0.0 0.0 0.5 g 192 272 192 320 0 R 64 144 32 144 0 1 2000.0 0.2 0.0 0.0 0.5 p 128 144 128 272 0 w 128 272 192 272 0 v 64 144 128 144 0 1 40.0 2.0 2.0 0.0 0.5 O 416 96 464 96 0 x 201 151 223 155 0 16 Q1 x 425 151 447 155 0 16 Q2 o 19 64 0 38 5.0 9.765625E-5 0 -1 in o 22 64 0 34 5.0 9.765625E-5 1 -1 out o 19 64 0 226 5.0 6.4 2 22 out vs in ================================================ FILE: src/circuits/scr.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 r 384 160 384 96 0 100.0 R 384 96 384 80 0 0 40.0 5.0 0.0 0.0 0.5 s 384 288 384 368 0 1 false s 352 256 256 256 0 1 false r 256 176 256 256 0 100.0 R 256 176 256 128 0 0 40.0 5.0 0.0 0.0 0.5 g 384 368 384 384 0 177 384 160 368 288 0 0.0 0.0 ================================================ FILE: src/circuits/scractrig.txt ================================================ $ 1 5.0E-6 10.20027730826997 49 5.0 50 177 256 176 256 352 0 -15.051976407130628 -15.051976407130628 r 256 176 256 112 0 50.0 R 256 112 256 80 0 1 40.0 20.0 0.0 0.0 0.5 d 368 288 288 288 1 0.805904783 g 256 352 256 384 0 w 256 176 304 176 0 w 368 208 368 288 0 174 368 208 304 144 0 1800.0 0.8069000000000001 Trigger Voltage o 2 64 0 33 10.0 0.2 0 -1 ================================================ FILE: src/circuits/sine.txt ================================================ $ 1 5.0E-6 10.812258501325767 53 15.0 50 a 80 128 192 128 0 15.0 -15.0 w 80 112 32 112 0 w 80 144 80 208 0 a 304 144 416 144 0 15.0 -15.0 w 416 208 416 144 0 w 416 144 416 80 0 c 304 80 416 80 0 2.0E-6 -9.423018815839887 w 304 80 304 128 0 r 192 128 304 128 0 1000.0 g 304 160 304 176 0 O 416 144 480 144 0 w 80 112 80 48 0 c 80 48 192 48 0 2.0E-6 10.648649139047 w 192 48 192 128 0 r 80 208 192 208 0 1000.0 w 192 208 416 208 0 c 80 208 80 272 0 2.0E-6 -1.201945379750099 g 80 272 80 304 0 r 32 112 32 192 0 996.0 g 32 192 32 224 0 O 192 48 256 48 0 o 20 64 0 42 20.0 9.765625E-5 0 -1 o 10 64 0 34 20.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/sinediode.txt ================================================ $ 1 5.0E-6 3.58 58 5.0 59 d 96 320 96 224 0 d 112 224 112 272 0 w 80 272 112 272 0 r 80 272 32 272 0 100.0 r 16 320 96 320 0 100.0 r 112 272 160 272 0 33.0 r 96 320 176 320 0 33.0 w 160 272 192 272 0 d 176 320 176 224 0 d 192 224 192 272 0 d 256 320 256 224 0 d 272 224 272 272 0 w 272 272 240 272 0 r 176 320 256 320 0 82.0 r 192 272 240 272 0 82.0 r 256 320 336 320 0 47.0 d 336 320 336 224 0 d 352 224 352 272 0 w 352 272 320 272 0 r 272 272 320 272 0 47.0 r 336 320 416 320 0 30.0 r 416 320 496 320 0 39.0 d 416 320 416 224 0 d 496 320 496 224 0 d 432 224 432 272 0 d 512 224 512 272 0 w 400 272 432 272 0 w 480 272 512 272 0 r 352 272 400 272 0 30.0 r 432 272 480 272 0 39.0 R 512 272 560 272 0 0 40.0 2.4 0.0 R 496 320 560 320 0 0 40.0 -2.4 0.0 w 96 224 112 224 0 w 176 224 192 224 0 w 256 224 272 224 0 w 336 224 352 224 0 w 416 224 432 224 0 w 496 224 512 224 0 r 112 224 112 144 0 2000.0 r 192 224 192 144 0 1000.0 r 272 224 272 144 0 470.0 r 352 224 352 144 0 330.0 r 432 224 432 144 0 120.0 w 112 144 192 144 0 w 192 144 272 144 0 w 272 144 352 144 0 w 352 144 432 144 0 w 432 144 512 144 0 r 112 144 64 144 0 200.0 R 64 144 32 144 0 3 80.0 5.0 0.0 O 512 144 560 144 0 w 512 144 512 224 0 w 16 320 16 272 0 w 16 272 32 272 0 o 49 32 0 35 5.0 0.025 0 0 o 50 32 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/spark-marx.txt ================================================ $ 1 1.9999999999999998E-5 13.097415321081861 66 2000.0 50 r 160 144 256 144 0 4000000.0 c 256 144 256 256 0 2.4E-8 0 r 256 144 352 144 0 1000000.0 r 256 256 352 256 0 1000000.0 c 352 256 352 144 0 2.4E-8 0 r 352 144 448 144 0 1000000.0 r 352 256 448 256 0 1000000.0 c 448 256 448 144 0 2.4E-8 0 187 256 144 352 256 0 1000.0 1.0E9 4000.0 0.0015 187 352 144 448 256 0 1000.0 1.0E9 4000.0 0.0010 187 704 144 704 208 0 1000.0 1.0E9 11000.0 0.0010 g 704 288 704 320 0 R 160 144 128 144 0 0 40.0 5000.0 0.0 0.0 0.5 w 256 256 208 256 0 g 208 256 208 320 0 c 352 256 352 304 2 1.0E-11 0 c 448 256 448 304 2 1.0E-11 0 g 352 304 352 320 0 g 448 304 448 320 0 g 640 304 640 320 0 g 544 304 544 320 0 c 640 256 640 304 2 1.0E-11 0 c 544 256 544 304 2 1.0E-11 0 187 544 144 640 256 0 1000.0 1.0E9 4000.0 0.0010 187 448 144 544 256 0 1000.0 1.0E9 4000.0 0.0010 c 640 256 640 144 0 2.4E-8 0 r 544 256 640 256 0 1000000.0 r 544 144 640 144 0 1000000.0 c 544 256 544 144 0 2.4E-8 0 r 448 256 544 256 0 1000000.0 r 448 144 544 144 0 1000000.0 w 640 144 704 144 0 r 704 208 704 288 0 2000000.0 o 8 64 0 35 5120.0 9.765625E-5 0 -1 o 9 64 0 35 10240.0 9.765625E-5 1 -1 o 24 64 0 35 5120.0 9.765625E-5 2 -1 o 23 64 0 35 10240.0 9.765625E-5 3 -1 o 32 64 0 35 40.0 9.765625E-5 4 -1 ================================================ FILE: src/circuits/spark-sawtooth.txt ================================================ $ 1 1.0E-6 43.84883893407173 66 2000.0 50 R 320 160 320 128 0 0 40.0 2000.0 0.0 0.0 0.5 r 320 160 320 240 0 2000000.0 187 320 240 320 336 0 10000.0 1.0E9 1000.0 0.0010 g 320 336 320 352 0 c 352 240 352 336 0 1.0E-8 954.6107492378424 w 352 336 320 336 0 w 320 240 352 240 0 o 4 128 0 35 1280.0 0.1 0 -1 ================================================ FILE: src/circuits/spikegen.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 112 288 112 144 0 2 40.0 5.0 0.0 r 240 144 240 288 0 110.0 d 240 144 368 144 0 w 112 288 240 288 0 c 112 144 240 144 0 1.0E-5 4.9868403762557465 O 368 144 432 144 0 r 368 144 368 288 0 100.0 w 240 288 368 288 0 o 5 64 0 3 10.0 9.765625E-5 ================================================ FILE: src/circuits/switchedcap.txt ================================================ $ 1 5.0E-6 17.50203994009402 50 5.0 50 159 160 176 256 176 0 159 256 176 352 176 0 c 352 176 352 240 0 4.876999999999999E-6 0 w 352 176 416 176 0 a 416 192 512 192 1 15.0 -15.0 w 416 208 416 240 0 w 416 240 512 240 0 w 512 240 512 192 0 O 512 192 576 192 0 g 256 240 256 256 0 g 352 240 352 256 0 w 304 192 304 288 0 I 208 288 304 288 0 0.5 w 208 192 208 288 0 R 208 288 112 288 1 2 2000.0 2.5 2.5 0.0 0.5 c 256 240 256 176 0 9.5123E-5 0 p 160 176 160 240 0 g 160 240 160 256 0 170 160 176 112 176 3 10.0 400.0 5.0 0.2 o 16 64 0 34 5.0 9.765625E-5 0 -1 o 8 64 0 34 5.0 4.8828125E-5 1 -1 ================================================ FILE: src/circuits/switchfilter.txt ================================================ $ 1 1.2E-5 14 57 5.0 f 240 176 176 176 1 f 128 176 176 176 0 r 176 96 176 160 0 50.0 r 304 96 304 160 0 350.0 w 176 192 176 224 0 w 176 224 304 224 0 w 304 192 304 224 0 w 304 96 304 64 0 w 304 64 176 64 0 w 176 64 176 96 0 w 304 224 416 224 0 c 416 224 416 288 0 1.0E-5 0.4780517576155351 g 416 288 416 320 0 O 416 224 480 224 0 w 240 176 240 256 0 I 240 320 240 256 0 w 128 176 128 320 0 w 128 320 240 320 0 w 240 320 352 320 0 L 128 320 80 320 0 true false v 176 64 112 64 0 1 500.0 1.0 0.0 w 304 64 416 64 0 p 416 64 416 112 0 g 416 112 416 144 0 R 112 64 80 64 0 1 40.0 1.0 2.5 f 240 176 304 176 0 f 352 176 304 176 1 w 352 176 352 320 0 o 22 32 0 2 5.0 2.44140625E-5 o 13 32 0 2 1.25 2.44140625E-5 ================================================ FILE: src/circuits/swtreedac.txt ================================================ $ 3 5.0E-6 10.391409633455755 50 5.0 50 160 312 192 248 192 1 160 312 272 248 272 1 160 312 352 248 352 1 160 312 112 248 112 1 160 376 152 312 152 1 160 376 312 312 312 1 160 440 232 376 232 1 w 376 152 376 216 0 w 376 248 376 312 0 w 312 272 312 296 0 w 312 328 312 352 0 w 312 168 312 192 0 w 312 112 312 136 0 O 440 232 496 232 1 r 168 208 168 256 0 100.0 r 168 256 168 304 0 100.0 r 168 304 168 352 0 100.0 r 168 352 168 400 0 100.0 r 168 208 168 160 0 100.0 r 168 160 168 112 0 100.0 r 168 112 168 64 0 100.0 w 168 64 248 64 0 w 248 64 248 96 0 w 168 112 216 112 0 w 168 160 248 160 0 w 248 160 248 176 0 w 168 208 248 208 0 w 168 256 248 256 0 w 168 304 248 304 0 w 248 304 248 288 0 w 168 352 208 352 0 w 208 352 208 336 0 w 208 336 248 336 0 w 168 400 248 400 0 w 248 400 248 368 0 w 216 112 216 128 0 w 216 128 248 128 0 82 168 64 168 32 0 0 40.0 7.001 0.0 0.0 0.5 g 168 400 168 424 0 w 280 128 280 208 0 w 280 208 280 288 0 w 280 288 280 368 0 w 344 168 344 328 0 w 408 248 408 368 0 w 344 328 344 368 0 L 408 368 464 368 0 false false 5.0 0.0 w 344 368 344 400 0 L 344 400 464 400 0 false false 5.0 0.0 w 280 368 280 432 0 L 280 432 464 432 0 false false 5.0 0.0 ================================================ FILE: src/circuits/synccounter.txt ================================================ $ 3 5.0E-6 10 50 5.0 156 80 272 128 272 0 0.0 156 208 272 240 272 0 5.0 156 336 272 368 272 0 0.0 156 464 272 480 272 0 5.0 w 464 272 448 272 0 w 448 272 448 336 0 w 448 336 464 336 0 w 320 336 336 336 0 w 320 336 320 272 0 w 320 272 336 272 0 w 208 272 192 272 0 w 192 272 192 336 0 w 192 336 208 336 0 w 80 272 64 272 0 w 64 272 64 336 0 w 64 336 80 336 0 w 560 272 560 88 0 w 432 272 432 112 0 w 176 272 176 160 0 M 560 88 592 88 2 2.5 R 64 272 32 272 0 0 40.0 5.0 0.0 R 80 384 32 384 1 2 200.0 2.5 2.5 w 80 304 80 384 0 w 176 272 192 272 0 w 80 384 208 384 0 w 208 384 208 304 0 w 336 304 336 384 0 w 336 384 208 384 0 w 336 384 464 384 0 w 464 384 464 304 0 150 336 200 336 272 1 2 0.0 w 304 272 304 136 0 w 304 136 328 136 0 w 328 136 328 200 0 w 344 160 344 200 0 w 176 160 344 160 0 150 464 200 464 272 1 3 0.0 w 344 160 472 160 0 w 472 160 472 200 0 w 328 136 464 136 0 w 464 136 464 200 0 w 432 112 456 112 0 w 456 112 456 200 0 M 472 160 592 160 2 2.5 M 464 136 592 136 2 2.5 M 456 112 592 112 2 2.5 ================================================ FILE: src/circuits/tdiode.txt ================================================ $ 1 5.0E-6 10.634267539816555 56 2.0 50 R 320 208 320 160 0 3 50.0 0.28 0.26 0.0 0.5 g 320 288 320 320 0 175 320 208 320 288 0 o 2 32 0 35 0.625 0.0125 0 -1 o 2 64 0 99 0.625 0.0125 1 -1 ================================================ FILE: src/circuits/tdosc.txt ================================================ $ 1 5.0E-6 10.20027730826997 54 1.5 50 R 160 176 128 176 0 0 40.0 1.5 0.0 0.0 0.5 r 160 176 240 176 0 80.0 r 240 176 240 288 0 24.0 175 240 176 320 176 0 r 320 176 320 288 0 75.0 l 448 176 448 288 0 0.2 0.0014801805180037042 O 448 176 512 176 0 g 240 288 240 304 0 g 320 288 320 304 0 g 448 288 448 304 0 w 320 176 384 176 0 c 384 176 384 288 0 3.9999999999999996E-5 -0.0973586411333848 w 384 176 448 176 0 g 384 288 384 304 0 o 3 64 0 35 0.625 0.0125 0 -1 diode o 3 64 0 99 0.625 0.00625 1 -1 o 6 64 0 34 0.3125 4.8828125E-5 2 -1 output ================================================ FILE: src/circuits/tdrelax.txt ================================================ $ 1 5.0E-6 10.20027730826997 54 1.5 50 R 176 176 144 176 0 0 40.0 1.5 0.0 0.0 0.5 r 176 176 256 176 0 80.0 r 256 176 256 288 0 24.0 175 256 176 336 176 0 l 336 176 336 288 0 0.7 0.002697977898647033 O 336 176 384 176 0 g 256 288 256 304 0 g 336 288 336 304 0 o 3 64 0 35 0.0390625 0.00625 0 -1 diode o 3 64 0 99 0.625 0.00625 1 -1 o 5 64 0 34 0.625 4.8828125E-5 2 -1 output ================================================ FILE: src/circuits/tesla.txt ================================================ $ 1 1.0E-8 12.235633750745258 30 120.0 50 g 240 304 240 336 0 r 240 256 176 256 0 10.0 R 176 256 144 256 0 1 60.0 120.0 0.0 0.0 0.5 T 240 256 320 304 2 10.0 100.0 4.437258653736118 -0.04413717098860063 0.999 c 384 224 464 224 0 2.0E-8 9788.947578396032 w 320 304 320 336 0 w 384 336 464 336 0 w 320 224 320 256 0 g 320 336 320 368 0 w 320 224 384 224 2 w 320 336 384 336 0 w 464 224 464 256 0 w 464 304 464 336 0 c 528 256 528 144 0 2.5E-11 -0.002896435768521405 r 528 304 528 352 0 0.1 g 528 352 528 368 0 T 464 256 528 304 2 3.16628E-5 28.28427 0.04412738203720486 1.4084140624744444E-8 0.1 187 384 224 384 336 0 1.0 1.0E9 10000.0 0.0010 w 528 144 592 144 0 g 592 144 592 368 0 o 17 64 0 35 10240.0 9.765625E-5 0 -1 o 13 32 0 34 0.0048828125 9.765625E-5 0 -1 ================================================ FILE: src/circuits/thevenin.txt ================================================ $ 17 5.0E-6 10.8 50 5.0 r 112 176 208 128 0 100.0 r 208 128 224 224 0 100.0 r 224 224 320 176 0 200.0 r 208 128 288 144 0 100.0 r 304 80 288 144 0 100.0 v 288 144 384 128 0 0 40.0 5.0 0.0 v 320 176 320 256 0 0 40.0 5.0 0.0 v 112 176 128 240 0 0 40.0 5.0 0.0 v 304 80 224 64 0 0 40.0 5.0 0.0 v 224 224 224 288 0 0 40.0 5.0 0.0 r 224 288 304 304 0 200.0 r 128 240 64 288 0 400.0 r 384 128 448 192 0 100.0 r 320 256 384 272 0 100.0 r 224 64 112 80 0 1000.0 v 112 80 208 128 0 0 40.0 5.0 0.0 v 64 288 224 288 0 0 40.0 2.0 0.0 v 304 304 384 272 0 0 40.0 5.0 0.0 r 448 192 384 272 0 100.0 r 320 176 384 128 0 100.0 r 112 80 112 176 0 100.0 w 64 288 64 16 0 w 448 16 448 192 0 r 272 384 128 384 0 117.784267 w 128 384 128 336 0 w 384 336 384 384 0 v 272 384 384 384 0 0 40.0 2.80758 0.0 v 64 16 448 16 0 1 40.0 5.0 0.0 v 128 336 384 336 0 1 40.0 5.0 0.0 g 448 192 448 256 0 g 384 384 384 400 0 o 27 64 0 3 5.0 0.1 o 28 64 0 3 5.0 0.1 ================================================ FILE: src/circuits/tl.txt ================================================ $ 1 5.0E-12 10.391409633455755 50 5.0 50 171 176 240 496 240 0 0.00000003 75.0 80 0.0 w 176 240 128 240 0 w 128 320 176 320 0 w 496 240 544 240 0 w 496 320 544 320 0 r 544 240 544 320 0 75.0 v 128 320 128 240 0 1 40000000.0 5.0 0.0 0.0 0.5 ================================================ FILE: src/circuits/tlfreq.txt ================================================ $ 1 5.0E-12 13.200821376227164 50 5.0 50 w 496 112 544 112 0 w 496 176 544 176 0 170 128 112 96 112 2 1.0E8 5.0E8 5.0 4.0E-7 g 176 176 176 192 0 r 128 112 176 112 0 75.0 g 544 176 544 192 0 p 544 112 544 176 0 170 128 272 96 272 2 1.0E8 5.0E8 5.0 4.0E-7 r 128 272 176 272 0 75.0 w 496 272 544 272 0 w 496 336 544 336 0 w 544 272 544 336 0 171 176 272 496 272 0 5.0E-9 75.0 64 0.0 171 176 112 496 112 0 5.0E-9 75.0 64 0.0 g 176 336 176 352 0 g 544 336 544 352 0 o 4 64 0 34 5.1 0.05 0 -1 o 8 64 0 34 5.1 0.05 1 -1 ================================================ FILE: src/circuits/tllight.txt ================================================ $ 1 1.0E-11 25.237822143832553 37 120.0 50 171 128 176 384 176 0 6.000000000000001E-8 300.0 64 0.0 r 128 176 80 176 0 10.0 w 80 240 128 240 0 w 512 176 544 176 0 w 512 240 544 240 0 r 544 176 544 240 0 70.0 v 80 240 80 176 0 1 60.0 120.0 0.0 1.5707963267948966 0.03 g 384 240 384 256 0 g 432 240 432 256 0 g 512 240 512 256 0 171 432 176 512 176 0 1.0E-8 300.0 64 0.0 s 384 176 432 176 0 0 false o 6 256 0 35 160.0 1.6 0 -1 o 5 256 0 35 160.0 1.6 1 -1 ================================================ FILE: src/circuits/tllopass.txt ================================================ $ 1 5.0E-13 11.708435524800691 50 5.0 50 170 64 80 32 80 2 2.0E9 8.0E9 5.0 1.0E-8 171 144 176 256 176 0 3.125E-11 64.9 48 0.0 171 144 80 256 80 0 3.125E-11 217.5 48 0.0 w 128 128 128 224 0 w 128 224 144 224 0 w 128 128 144 128 0 171 304 80 400 80 0 3.125E-11 217.5 48 0.0 171 304 176 400 176 0 3.125E-11 70.3 48 0.0 171 448 176 544 176 0 3.125E-11 64.9 48 0.0 w 256 80 272 80 0 w 272 80 272 176 0 w 272 176 304 176 0 w 256 128 288 128 0 w 288 128 288 224 0 w 288 224 304 224 0 w 272 80 304 80 0 w 288 128 304 128 0 w 400 80 416 80 0 w 416 80 416 176 0 w 416 176 448 176 0 w 400 128 432 128 0 w 432 128 432 224 0 w 432 224 448 224 0 g 256 224 256 240 0 g 400 224 400 240 0 g 544 224 544 240 0 w 416 80 464 80 0 w 432 128 464 128 0 r 464 80 464 128 0 50.0 g 256 128 256 144 0 g 144 224 144 240 0 r 64 80 112 80 0 50.0 w 112 80 112 176 0 w 112 176 144 176 0 w 112 80 144 80 0 o 28 64 0 35 5.0 0.1 0 -1 ================================================ FILE: src/circuits/tlmatch1.txt ================================================ $ 1 1.0E-11 25.237822143832553 52 4.0 50 171 128 128 256 128 0 2.0E-8 75.0 64 0.0 171 400 128 528 128 0 2.0E-8 300.0 64 0.0 r 128 128 80 128 0 75.0 w 80 192 128 192 0 w 528 128 560 128 0 w 528 192 560 192 0 r 560 128 560 192 0 300.0 v 80 192 80 128 0 1 9.0E7 5.0 0.0 0.0 0.03 g 256 192 256 208 0 g 400 192 400 208 0 g 528 192 528 208 0 l 256 128 336 128 0 2.5E-7 -0.00932931614162717 c 336 128 336 192 0 1.06E-11 -4.843602086224591 w 336 192 400 192 0 w 336 128 400 128 0 v 80 256 80 320 0 1 9.0E7 5.0 0.0 0.0 0.5 r 80 256 128 256 0 75.0 w 80 320 128 320 0 171 128 256 256 256 0 2.0E-8 75.0 64 0.0 171 400 256 528 256 0 2.0E-8 300.0 64 0.0 w 256 256 400 256 0 w 256 320 400 320 0 w 528 256 560 256 0 w 528 320 560 320 0 g 256 320 256 336 0 g 528 320 528 336 0 g 128 192 128 208 0 g 128 320 128 336 0 r 560 256 560 320 0 300.0 o 6 64 1 51 0.15625 1.220703125E-5 0 -1 matched o 28 64 1 51 0.15625 2.44140625E-5 1 -1 mismatched ================================================ FILE: src/circuits/tlmatch2.txt ================================================ $ 1 1.0E-11 12.682493960703473 52 4.0 50 171 48 112 192 112 0 1.0E-8 75.0 64 0.0 r 48 112 0 112 0 75.0 w 0 176 48 176 0 w 464 112 496 112 0 w 464 176 496 176 0 r 496 112 496 176 0 300.0 v 0 176 0 112 0 1 1.0E8 5.0 0.0 0.0 0.03 g 192 176 192 192 0 v 0 240 0 304 0 1 1.0E8 5.0 0.0 0.0 0.5 r 0 240 48 240 0 75.0 w 0 304 48 304 0 171 48 240 192 240 0 1.17621E-8 75.0 64 0.0 w 464 240 496 240 0 w 464 304 496 304 0 g 192 304 192 320 0 g 48 176 48 192 0 g 48 304 48 320 0 r 496 240 496 304 0 300.0 w 192 112 192 32 0 w 192 32 208 32 0 w 192 176 208 176 0 w 208 176 208 96 0 w 192 112 224 112 0 w 208 176 224 176 0 g 336 96 336 112 0 171 224 112 288 112 0 1.7621000000000001E-9 75.0 64 0.0 g 288 176 288 192 0 171 208 32 336 32 0 3.4358E-9 75.0 64 0.0 171 304 112 464 112 0 1.0E-8 300.0 64 0.0 171 304 240 464 240 0 1.0E-8 300.0 64 0.0 w 288 176 304 176 0 w 288 112 304 112 0 w 192 240 304 240 0 w 192 304 304 304 0 g 464 304 464 320 0 g 464 176 464 192 0 o 5 64 1 51 0.15625 1.220703125E-5 0 -1 matched o 17 64 1 51 0.15625 2.44140625E-5 1 -1 mismatched ================================================ FILE: src/circuits/tlmis1.txt ================================================ $ 0 5.0E-12 23.25989509352673 50 5.0 50 171 128 192 304 192 0 1.0E-8 75.0 64 0.0 r 128 192 80 192 0 75.0 w 80 256 128 256 0 w 512 192 544 192 0 w 512 256 544 256 0 r 544 192 544 256 0 500.0 v 80 256 80 192 0 1 1.87E8 5.0 0.0 0.0 0.03 g 304 256 304 272 0 g 336 256 336 272 0 g 512 256 512 272 0 171 336 192 512 192 0 1.0E-8 500.0 64 0.0 w 304 192 336 192 0 o 1 64 0 34 4.0 0.025 0 -1 o 5 64 0 34 5.0 0.00625 1 -1 ================================================ FILE: src/circuits/tlmismatch.txt ================================================ $ 1 5.0E-12 12.682493960703473 50 5.0 50 171 112 192 256 192 0 1.0E-8 75.0 64 0.0 171 256 192 384 192 0 1.0E-8 500.0 64 0.0 171 384 192 512 192 0 1.0E-8 75.0 64 0.0 r 112 192 64 192 0 75.0 w 64 256 112 256 0 w 512 192 544 192 0 w 512 256 544 256 0 r 544 192 544 256 0 75.0 v 64 256 64 192 0 2 1.0E7 2.5 2.5 0.0 0.03 g 256 256 256 272 0 g 384 256 384 272 0 g 512 256 512 272 0 ================================================ FILE: src/circuits/tlstand.txt ================================================ $ 1 1.0E-12 2.7070718156067044 50 5.0 50 171 176 192 496 192 0 0.0000000020 300.0 80 0.0 w 128 272 176 272 0 w 496 192 544 192 0 w 496 272 544 272 0 r 128 192 176 192 0 300.0 g 544 272 544 288 0 g 128 272 128 288 0 R 128 192 96 192 0 1 1500000000.0 5.0 0.0 0.0 0.5 w 544 192 544 272 0 o 4 16 0 34 5.0 0.025 0 -1 ================================================ FILE: src/circuits/tlterm.txt ================================================ $ 1 5.0E-12 14.304574186067095 50 5.0 50 171 112 32 528 32 0 1.0E-8 75.0 64 0.0 r 112 32 64 32 0 75.0 w 64 96 112 96 0 w 528 32 560 32 0 w 528 96 560 96 0 r 560 32 560 96 0 75.0 v 64 96 64 32 0 2 1.0E7 2.5 2.5 0.0 0.03 g 528 96 528 112 0 171 112 144 528 144 0 1.0E-8 75.0 64 0.0 r 112 144 64 144 0 75.0 w 64 208 112 208 0 w 528 144 560 144 0 w 528 208 560 208 0 r 560 144 560 208 0 10000.0 v 64 208 64 144 0 2 1.0E7 2.5 2.5 0.0 0.03 g 528 208 528 224 0 171 112 256 528 256 0 1.0E-8 75.0 64 0.0 r 112 256 64 256 0 75.0 w 64 320 112 320 0 w 528 256 560 256 0 w 528 320 560 320 0 r 560 256 560 320 0 10.0 v 64 320 64 256 0 2 1.0E7 2.5 2.5 0.0 0.03 g 528 320 528 336 0 171 112 368 528 368 0 1.0E-8 75.0 64 0.0 r 112 368 64 368 0 10.0 w 64 432 112 432 0 w 528 368 560 368 0 w 528 432 560 432 0 r 560 368 560 432 0 10000.0 v 64 432 64 368 0 2 1.0E7 2.5 2.5 0.0 0.03 g 528 432 528 448 0 ================================================ FILE: src/circuits/traffic.txt ================================================ $ 3 0.0012 3.84 50 5.0 50 163 296 336 320 336 1 10 0.0 0.0 0.0 0.0 0.0 0.0 5.0 0.0 0.0 0.0 R 456 368 456 392 0 0 40.0 5.0 0.0 152 336 296 336 232 1 4 0.0 w 320 296 312 296 0 w 312 296 312 320 0 w 328 296 328 320 0 w 344 296 344 320 0 w 352 296 360 296 0 w 360 296 360 320 0 w 408 296 408 320 0 w 424 296 424 320 0 w 400 296 392 296 0 w 392 296 392 320 0 w 432 296 440 296 0 w 440 296 440 320 0 152 416 296 416 232 1 4 5.0 162 480 88 528 88 0 1.0 0.0 0.0 162 480 120 528 120 0 1.0 1.0 0.0 162 480 152 528 152 0 0.0 1.0 0.0 w 376 320 376 216 0 162 304 88 256 88 0 1.0 0.0 0.0 162 304 120 256 120 0 1.0 1.0 0.0 162 304 152 256 152 0 0.0 1.0 0.0 w 336 232 336 152 0 w 456 320 456 120 0 w 456 120 480 120 0 w 416 232 416 152 0 w 416 152 480 152 0 w 416 96 416 152 0 w 416 80 432 80 0 w 432 80 432 120 0 w 432 120 456 120 0 w 336 152 336 40 0 w 360 88 304 88 0 w 376 216 352 216 0 w 336 152 304 152 0 w 352 216 352 120 0 w 352 120 304 120 0 w 352 120 352 56 0 152 352 48 480 48 1 2 0.0 w 336 40 352 40 0 w 480 48 480 88 0 w 528 88 528 120 0 w 528 120 528 152 0 w 256 88 256 120 0 w 256 120 256 152 0 r 528 152 528 216 0 200.0 r 256 152 256 216 0 200.0 g 256 216 256 232 0 g 528 216 528 232 0 152 416 88 360 88 1 2 5.0 R 152 176 152 136 0 0 40.0 5.0 0.0 w 152 176 64 176 0 r 64 240 64 304 0 47000.0 r 64 176 64 240 0 10000.0 w 216 272 216 352 0 w 216 352 296 352 0 165 88 208 152 208 0 0.0 w 64 304 64 336 0 c 64 336 64 368 0 9.999999999999999E-6 2.4856719240739658 g 64 368 64 384 0 w 64 240 88 240 0 w 64 304 88 304 0 w 64 336 88 336 0 ================================================ FILE: src/circuits/trans-diffamp-common.txt ================================================ $ 1 5.0E-6 5.6 68 15.0 60 t 176 224 208 224 0 1 -15.316178939790538 0.5164877485159067 t 400 224 336 224 0 1 -8.349791529425255 0.516487748515907 w 208 240 208 272 0 w 336 240 336 272 0 r 208 272 272 272 0 1000.0 r 272 272 336 272 0 1000.0 r 272 272 272 352 0 75000.0 r 336 144 336 64 0 75000.0 w 208 64 336 64 0 R 208 64 176 64 0 0 40.0 15.0 0.0 R 272 352 208 352 0 0 40.0 -15.0 0.0 R 176 224 128 224 0 1 40.0 1.0 0.0 R 400 224 432 224 0 1 40.0 1.0 0.0 p 400 224 400 288 0 g 400 288 400 320 0 w 336 144 336 208 0 w 208 64 208 208 0 O 336 144 416 144 0 x 154 206 170 206 0 14 in 1 x 377 207 393 207 0 14 in 2 o 11 32 0 2 0.15625 9.765625E-5 0 o 13 32 0 2 0.3125 9.765625E-5 0 o 17 32 0 2 20.0 9.765625E-5 1 output ================================================ FILE: src/circuits/trans-diffamp-cursrc.txt ================================================ $ 1 5.0E-6 5.6 60 15.0 52 t 208 192 240 192 0 1 -12.552345476990716 0.5746836796974437 t 432 192 368 192 0 1 -5.407801804527631 0.5746836796974437 w 240 208 240 240 0 w 368 208 368 240 0 r 368 128 368 48 0 7500.0 w 240 48 368 48 0 R 240 48 208 48 0 0 40.0 15.0 0.0 R 208 192 160 192 0 1 40.0 4.0 0.0 R 496 192 528 192 0 1 40.0 4.0 0.0 p 432 192 432 256 0 g 432 256 432 288 0 w 368 128 368 176 0 w 240 48 240 176 0 O 368 128 448 128 0 x 186 174 202 174 0 14 in 1 x 409 175 425 175 0 14 in 2 w 240 240 304 240 0 w 304 240 368 240 0 t 256 288 304 288 0 1 -14.336812066191886 0.5922636176064682 w 304 240 304 272 1 w 304 368 256 368 0 r 256 288 256 368 0 2700.0 r 304 304 304 368 0 1000.0 r 256 288 176 288 0 13000.0 g 176 288 176 304 0 R 256 368 176 368 0 0 40.0 -15.0 0.0 v 432 192 496 192 0 5 300.0 0.4 0.0 o 7 32 0 2 0.15625 9.765625E-5 0 o 9 32 0 2 0.3125 9.765625E-5 0 o 13 32 0 2 20.0 9.765625E-5 1 ================================================ FILE: src/circuits/trans-diffamp.txt ================================================ $ 1 5.0E-6 5.6 68 15.0 60 t 144 208 176 208 0 1 -15.095449051751599 0.5174493144866628 t 368 208 304 208 0 1 -8.193950382547882 0.5162742583726527 w 176 224 176 256 0 w 304 224 304 256 0 r 176 256 240 256 0 1000.0 r 240 256 304 256 0 1000.0 r 240 256 240 336 0 75000.0 r 304 128 304 48 0 75000.0 w 176 48 304 48 0 R 176 48 144 48 0 0 40.0 15.0 0.0 R 240 336 176 336 0 0 40.0 -15.0 0.0 R 144 208 96 208 0 1 40.0 0.1 0.0 v 368 208 432 208 0 1 40.0 -0.1 0.0 R 432 208 464 208 0 1 200.0 0.1 0.0 p 368 208 368 272 0 g 368 272 368 304 0 w 304 128 304 192 0 w 176 48 176 192 0 O 304 128 384 128 0 x 122 190 138 190 0 14 in 1 x 345 191 361 191 0 14 in 2 o 11 32 0 2 0.15625 9.765625E-5 0 o 14 32 0 2 0.3125 9.765625E-5 0 o 18 32 0 2 12.0 9.765625E-5 1 output ================================================ FILE: src/circuits/transformer.txt ================================================ $ 1 5.0E-6 9 54 5.0 v 176 272 176 144 0 1 60.0 10.0 0.0 w 352 224 352 272 0 T 272 192 352 192 0 100.0 1.0 -0.003935272598777283 0.004618353276268098 w 272 192 272 144 0 w 272 224 272 272 0 r 272 144 176 144 0 0.1 w 176 272 272 272 0 w 352 272 448 272 0 w 352 144 448 144 0 r 448 144 448 272 0 1000.0 w 352 192 352 144 0 o 0 64 0 3 10.0 0.0125 2 o 9 64 0 3 10.0 0.0125 1 ================================================ FILE: src/circuits/transformerdc.txt ================================================ $ 1 5.0E-6 10 50 5.0 42 v 176 272 176 144 0 0 60.0 10.0 0.0 w 352 224 352 272 0 T 272 192 352 192 0 10.0 1.0 0 0 w 272 192 272 144 0 w 272 224 272 272 0 r 272 144 176 144 0 100.0 w 176 272 272 272 0 w 352 272 448 272 0 w 352 144 448 144 0 r 448 144 448 272 0 300.0 w 352 192 352 144 0 o 0 64 0 3 10.0 0.1 0 o 9 64 0 3 10.0 0.025 1 ================================================ FILE: src/circuits/transformerdown.txt ================================================ $ 1 5.0E-6 9 47 5.0 30 v 176 272 176 144 2 1 60.0 120.0 0.0 w 352 224 352 272 0 T 272 192 352 192 0 1000.0 0.1 0 0 w 272 192 272 144 1 w 272 224 272 272 0 r 272 144 176 144 0 20.0 w 176 272 272 272 0 w 352 272 448 272 0 w 352 144 448 144 0 r 448 144 448 272 0 300.0 w 352 192 352 144 1 o 0 64 0 3 160.0 0.4 0 o 9 64 0 3 20.0 0.05 1 ================================================ FILE: src/circuits/transformerup.txt ================================================ $ 1 5.0E-6 9 43 5.0 42 v 176 272 176 144 0 1 60.0 10.0 0.0 w 352 224 352 272 0 T 272 192 352 192 0 1.0 10.0 0.14177509724862508 -0.008963174444486828 w 272 192 272 144 1 w 272 224 272 272 0 r 272 144 176 144 0 0.1 w 176 272 272 272 0 w 352 272 448 272 0 w 352 144 448 144 0 r 448 144 448 272 0 2000.0 w 352 192 352 144 1 o 0 64 0 3 10.0 0.8 0 o 9 64 0 3 160.0 0.05 1 ================================================ FILE: src/circuits/transswitch.txt ================================================ $ 1 5.0E-6 10 50 5.0 v 144 352 144 80 0 0 40.0 5.0 0.0 w 144 80 256 80 0 t 256 256 368 256 0 1 0.5597337598267538 0.646589672025579 r 256 80 256 176 0 10000.0 s 256 176 256 256 0 true false w 256 80 368 80 0 r 368 80 368 240 0 300.0 w 368 272 368 352 0 w 368 352 144 352 0 ================================================ FILE: src/circuits/triangle.txt ================================================ $ 1 4.9999999999999996E-6 10.20027730826997 60 6.0 50 a 160 224 272 224 0 15.0 -15.0 1000000.0 w 160 240 160 304 0 w 160 304 272 304 0 r 272 224 272 304 0 10000.0 a 384 240 496 240 0 15.0 -15.0 1000000.0 r 272 304 352 304 0 4000.0 w 352 304 496 304 0 w 496 304 496 240 0 w 496 240 496 176 0 c 384 176 496 176 0 1.0E-6 4.7736574744107685 w 384 176 384 224 0 r 272 224 384 224 0 10000.0 g 384 256 384 272 0 O 496 240 560 240 0 w 160 208 128 208 0 g 128 208 128 240 0 o 13 64 0 42 10.0 9.765625E-5 0 -1 ================================================ FILE: src/circuits/triode.txt ================================================ $ 1 5.0E-6 10.20027730826997 50 5.0 50 172 304 240 272 240 0 6 0.0 0.0 -8.0 0.0 0.5 Grid Voltage w 352 272 352 320 0 w 368 208 368 160 1 172 368 160 368 128 0 6 500.0 500.0 0.0 0.0 0.5 Plate Voltage g 352 320 352 336 0 173 304 240 368 240 0 93.0 680.0 o 3 64 0 35 640.0 0.1 0 -1 ================================================ FILE: src/circuits/triodeamp.txt ================================================ $ 1 5.0E-6 11.086722712598126 60 3.0 53 w 272 64 368 64 0 r 272 224 272 368 0 10000.0 w 272 368 352 368 0 g 272 368 272 400 0 R 272 64 176 64 0 0 40.0 160.0 0.0 0.0 0.5 r 368 64 368 192 0 10000.0 r 352 256 352 368 0 3000.0 c 272 224 192 224 0 4.9999999999999996E-6 -0.011918466765635682 R 192 224 144 224 0 1 80.0 0.5 0.0 0.0 0.5 c 368 192 448 192 0 4.9999999999999996E-6 156.41283175374522 O 448 192 496 192 0 r 448 192 448 288 0 100000.0 g 448 288 448 320 0 173 272 224 368 224 0 93.0 1360.0 w 352 256 400 256 0 c 400 256 400 368 0 4.9999999999999996E-6 1.2120701747074232 w 352 368 400 368 0 o 8 64 0 34 0.625 9.765625E-5 0 -1 o 10 64 0 34 5.0 2.44140625E-5 1 -1 ================================================ FILE: src/circuits/ttlinverter.txt ================================================ $ 1 5.0E-6 10 54 5.0 t 224 192 224 272 0 1 0.5875584150944089 -3.7844516501481884 t 240 272 320 272 0 1 0.6035944264912844 0.6279899347574025 g 320 288 320 336 0 L 208 272 144 272 0 false false r 224 192 224 112 0 4700.0 r 320 112 320 192 0 1000.0 w 320 192 320 256 0 M 320 192 416 192 0 R 224 112 144 112 0 0 40.0 5.0 0.0 w 224 112 320 112 0 ================================================ FILE: src/circuits/ttlnand.txt ================================================ $ 1 5.0E-6 10 54 5.0 R 192 112 112 112 0 0 40.0 5.0 0.0 r 352 112 352 192 0 1000.0 w 352 192 352 224 0 t 192 192 192 240 0 1 0.5735476679612052 -4.40887239412782 t 240 192 240 288 0 1 0.5735476679612052 0.5911276058721799 t 288 240 352 240 0 1 -4.982420061888025 0.01757993791097478 w 208 240 288 240 0 w 256 288 288 288 0 w 288 288 288 240 0 w 192 192 240 192 0 L 176 240 128 240 0 false false L 224 288 128 288 0 true false g 352 256 352 336 0 w 192 112 352 112 0 r 192 112 192 192 0 4700.0 M 352 192 416 192 0 ================================================ FILE: src/circuits/ttlnor.txt ================================================ $ 1 5.0E-6 10 54 5.0 t 144 192 144 272 0 1 0.5874809043486446 -3.7727363939084873 t 160 272 208 272 0 1 0.602697396937354 0.6397827017428683 L 128 272 64 272 0 false false r 144 192 144 112 0 4700.0 R 144 112 64 112 0 0 40.0 5.0 0.0 w 144 112 208 112 0 t 304 192 304 272 0 1 0.5908763474738555 0.5911276058707033 t 320 272 368 272 0 1 -0.03683404640866654 2.512583968477912E-4 r 304 112 304 192 0 4700.0 w 208 112 304 112 0 w 304 112 368 112 0 r 368 112 368 192 0 1000.0 w 368 192 432 192 0 M 432 192 480 192 0 L 288 272 240 272 0 true false r 208 112 208 192 0 1000.0 w 208 192 208 224 0 w 368 192 368 256 0 w 208 224 432 224 0 w 432 224 432 192 0 w 208 224 208 256 0 g 208 288 208 320 0 g 368 288 368 320 0 ================================================ FILE: src/circuits/twint.txt ================================================ $ 1 5.0E-6 10.391409633455755 50 5.0 50 r 192 112 304 112 0 100.0 r 304 112 416 112 0 100.0 c 192 272 304 272 0 2.6524999999999998E-5 0 c 304 272 416 272 0 2.6524999999999998E-5 0 c 304 112 304 176 0 5.3049999999999995E-5 0 g 304 176 304 208 0 r 304 272 304 336 0 50.0 g 304 336 304 368 0 w 416 112 416 192 0 w 416 192 416 272 0 w 192 112 192 192 0 w 192 192 192 272 0 O 416 192 480 192 0 170 192 192 144 192 3 40.0 80.0 5.0 0.5 o 13 32 0 34 5.0 0.025 0 -1 o 12 32 0 34 5.0 9.765625E-5 1 -1 ================================================ FILE: src/circuits/vco.txt ================================================ $ 1 5.0E-6 8.872897488127265 75 5.0 50 a 176 160 272 160 0 5.0 0.0 a 368 176 464 176 0 5.0 0.0 w 272 160 304 160 0 w 304 160 368 160 0 w 368 192 368 224 0 w 464 176 464 224 0 r 368 224 464 224 0 100000.0 r 368 224 368 288 0 100000.0 g 368 288 368 304 0 r 176 176 176 240 0 49900.0 g 176 240 176 256 0 w 176 144 176 96 0 w 176 144 144 144 0 r 144 144 64 144 0 100000.0 w 64 144 64 160 0 w 64 160 64 176 0 r 64 176 160 176 0 49900.0 w 160 176 176 176 0 w 144 144 144 272 0 r 144 272 144 320 0 49900.0 g 144 352 144 368 0 f 192 336 144 336 0 w 192 336 464 336 0 w 464 336 464 224 0 c 176 96 272 96 0 1.0E-8 -2.248578405619046 w 272 96 272 160 0 w 368 192 368 128 0 r 368 128 368 80 0 100000.0 R 368 80 416 80 0 0 40.0 5.0 0.0 R 64 160 32 160 0 4 10.0 2.0 3.0 O 464 176 512 176 0 O 304 160 304 48 0 o 29 64 0 2 5.0 9.765625E-5 0 control o 30 32 0 2 10.0 4.8828125E-5 1 o 31 32 0 2 5.0 9.765625E-5 2 ================================================ FILE: src/circuits/voltdivide.txt ================================================ $ 1 5.0E-6 10 63 10.0 62 v 112 368 112 48 0 0 40.0 10.0 0.0 w 112 48 240 48 0 r 240 48 240 208 0 10000 r 240 208 240 368 0 10000 w 112 368 240 368 0 O 240 208 304 208 1 w 240 48 432 48 0 w 240 368 432 368 0 r 432 48 432 128 0 10000 r 432 128 432 208 0 10000 r 432 208 432 288 0 10000 r 432 288 432 368 0 10000 O 432 128 496 128 1 O 432 208 496 208 1 O 432 288 496 288 1 ================================================ FILE: src/circuits/voltdouble.txt ================================================ $ 1 5.0E-6 10 53 15.0 45 v 160 208 160 112 0 1 40.0 15.0 0.0 w 160 112 224 112 0 d 224 112 336 112 0 c 336 112 336 208 0 9.999999999999999E-5 0 c 336 208 336 304 0 9.999999999999999E-5 0 w 160 208 336 208 0 w 224 112 224 304 0 d 336 304 224 304 0 w 336 112 432 112 0 w 336 304 432 304 0 r 432 112 432 304 0 10000.0 o 0 64 0 3 5.0 0.2 o 10 64 0 2 10.0 7.8125E-4 ================================================ FILE: src/circuits/voltdouble2.txt ================================================ $ 1 5.0E-6 10 50 15.0 45 R 224 176 192 176 0 1 40.0 15.0 0.0 c 224 176 304 176 0 9.999999999999999E-5 0 d 304 288 304 176 0 d 304 176 400 176 0 c 400 176 400 288 0 9.999999999999999E-5 0 g 304 288 304 304 0 g 400 288 400 304 0 w 400 176 464 176 0 r 464 176 464 288 0 20000.0 g 464 288 464 304 0 o 0 64 0 3 20.0 0.4 o 8 64 0 3 40.0 0.025 ================================================ FILE: src/circuits/voltinvert.txt ================================================ $ 1 5.0E-6 3.5 62 5.0 159 176 112 272 112 0 159 272 112 368 112 0 c 272 112 272 208 0 1.0E-5 0 159 176 208 272 208 0 159 272 208 368 208 0 g 368 112 368 144 0 c 368 208 368 304 0 1.0E-5 0 g 368 304 368 320 0 g 176 208 176 240 0 R 176 112 128 112 0 0 40.0 5.0 0.0 w 224 128 224 224 0 w 320 128 320 224 0 w 224 224 224 288 0 w 320 224 320 288 0 I 224 288 320 288 0 R 224 288 128 288 1 2 400.0 2.5 2.5 w 368 208 432 208 0 r 432 208 432 304 0 30000.0 g 432 304 432 320 0 O 432 208 496 208 1 ================================================ FILE: src/circuits/voltquad.txt ================================================ $ 1 5.0E-6 10 53 15.0 45 d 208 256 288 256 0 c 208 160 288 160 0 9.999999999999999E-5 0 d 288 160 368 160 0 c 368 160 368 336 0 9.999999999999999E-5 0 w 368 160 432 160 0 r 432 160 432 336 0 50000.0 g 208 336 208 352 0 g 368 336 368 352 0 g 432 336 432 352 0 R 208 160 160 160 0 1 120.0 15.0 0.0 d 208 336 208 256 0 d 288 256 288 160 0 c 288 256 288 336 0 9.999999999999999E-5 0 g 288 336 288 352 0 c 208 160 208 256 0 9.999999999999999E-5 0 o 9 64 0 3 80.0 0.00625 o 5 64 0 3 80.0 0.00625 ================================================ FILE: src/circuits/volttriple.txt ================================================ $ 1 5.0E-6 10 53 15.0 45 d 208 160 208 256 0 d 208 256 288 256 0 w 288 256 288 160 0 c 208 160 288 160 0 9.999999999999999E-5 0 c 208 256 208 336 0 9.999999999999999E-5 0 d 288 160 368 160 0 c 368 160 368 336 0 9.999999999999999E-5 0 w 368 160 432 160 0 r 432 160 432 336 0 40000.0 g 208 336 208 352 0 g 368 336 368 352 0 g 432 336 432 352 0 R 208 160 160 160 0 1 120.0 15.0 0.0 o 12 64 0 3 80.0 0.00625 o 8 64 0 3 80.0 0.00625 ================================================ FILE: src/circuits/volume.txt ================================================ $ 1 5.0E-6 10 67 5.0 64 j 304 240 352 240 0 r 304 240 304 176 0 100000.0 r 304 240 240 240 0 100000.0 w 304 176 352 176 0 w 352 176 352 224 0 g 352 256 352 304 0 w 352 176 352 128 0 r 352 128 240 128 0 6000.0 O 352 128 416 128 0 R 240 128 192 128 0 1 200.0 5.0 0.0 R 240 240 192 240 0 3 10.0 3.0 -8.0 o 10 64 0 6 20.0 9.765625E-5 0 o 8 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/wheatstone.txt ================================================ v 176 352 176 64 0 0 40.0 5.0 0.0 w 320 64 320 128 0 w 320 256 320 352 0 w 320 352 176 352 0 r 256 192 320 128 0 200.0 r 320 128 384 192 0 400.0 r 256 192 320 256 0 100.0 r 320 256 384 192 0 200.0 w 176 64 320 64 0 w 256 192 384 192 0 ================================================ FILE: src/circuits/xor.txt ================================================ $ 1 5.0E-6 1.5 50 5.0 151 96 240 208 240 0 2 0 151 208 192 320 192 0 2 0 151 208 288 320 288 0 2 0 w 208 240 208 272 0 w 208 240 208 208 0 151 320 240 432 240 0 2 0 w 320 192 320 224 0 w 320 256 320 288 0 w 96 176 96 224 0 w 96 176 208 176 0 w 96 256 96 304 0 w 96 304 208 304 0 M 432 240 480 240 0 L 96 176 48 176 0 true false L 96 304 48 304 0 true false ================================================ FILE: src/circuits/xorphasedet.txt ================================================ $ 1 5.0E-6 10 50 5.0 R 192 128 128 128 0 2 100.0 2.5 2.5 R 192 224 128 224 0 2 105.0 2.5 2.5 154 192 176 336 176 0 2 0.0 O 336 176 416 176 0 w 192 128 192 160 0 w 192 192 192 224 0 o 0 64 0 6 5.0 9.765625E-5 0 o 1 64 0 6 5.0 9.765625E-5 0 o 3 64 0 6 5.0 9.765625E-5 0 ================================================ FILE: src/circuits/zeneriv.txt ================================================ $ 1 5.0E-6 10.634267539816555 40 2.0 50 R 320 208 320 160 0 3 50.0 3.55 -2.56 0.0 0.5 g 320 288 320 320 0 z 320 208 320 288 1 0.805904783 5.6 o 2 64 0 99 10.0 25.6 0 -1 o 2 64 0 35 10.0 25.6 1 -1 ================================================ FILE: src/circuits/zenerref.txt ================================================ $ 1 5.0E-6 10.20027730826997 54 5.0 50 R 272 160 224 160 0 1 40.0 1.0 6.7 0.0 0.5 z 336 288 336 160 1 0.805904783 5.6 g 336 288 336 304 0 w 336 160 416 160 0 r 416 160 416 288 0 10000.0 g 416 288 416 304 0 r 272 160 336 160 0 500.0 o 0 64 0 34 10.0 0.003125 0 -1 in o 4 64 0 34 10.0 3.90625E-4 1 -1 out o 1 64 0 35 10.0 0.00625 2 -1 zener ================================================ FILE: src/circuits/zenerreffollow.txt ================================================ $ 1 5.0E-6 10.20027730826997 56 5.0 50 R 240 128 192 128 0 1 40.0 2.0 8.8 0.0 0.5 w 240 128 320 128 0 r 320 128 320 208 0 10000.0 t 320 208 400 208 0 1 -3.046294556431631 0.6320971159170448 100.0 r 400 128 400 192 0 100.0 w 320 128 400 128 0 z 320 320 320 208 1 0.805904783 5.6 w 400 224 400 256 0 w 400 256 448 256 0 r 448 256 448 320 0 500.0 g 448 320 448 336 0 g 320 320 320 336 0 o 0 64 0 34 12.0 0.00625 0 -1 in o 9 64 0 35 5.0 0.0125 1 -1 out o 6 64 0 35 10.0 7.8125E-4 2 -1 zener ================================================ FILE: src/setuplist.txt ================================================ ### setuplist.txt first line must be a comment +Basics ohms.txt Ohm's Law resistors.txt Resistors cap.txt Capacitor induct.txt Inductor >lrc.txt LRC Circuit voltdivide.txt Voltage Divider pot.txt Potentiometer potdivide.txt Potentiometer Divider thevenin.txt Thevenin's Theorem norton.txt Norton's Theorem - +A/C Circuits capac.txt Capacitor inductac.txt Inductor capmultcaps.txt Caps of Various Capacitances capmultfreq.txt Caps w/ Various Frequencies indmultind.txt Inductors of Various Inductances indmultfreq.txt Inductors w/ Various Frequencies impedance.txt Impedances of Same Magnitude res-series.txt Series Resonance res-par.txt Parallel Resonance - +Passive Filters filt-hipass.txt High-Pass Filter (RC) filt-lopass.txt Low-Pass Filter (RC) filt-hipass-l.txt High-Pass Filter (RL) filt-lopass-l.txt Low-Pass Filter (RL) bandpass.txt Band-pass Filter notch.txt Notch Filter twint.txt Twin-T Filter crossover.txt Crossover butter10lo.txt Butterworth Low-Pass (10 pole) besselbutter.txt Bessel vs Butterworth ringing.txt Band-pass with Ringing - +Other Passive Circuits +Series/Parallel indseries.txt Inductors in Series indpar.txt Inductors in Parallel capseries.txt Caps in Series cappar.txt Caps in Parallel - +Transformers transformer.txt Transformer transformerdc.txt Transformer w/ DC transformerup.txt Step-Up Transformer transformerdown.txt Step-Down Transformer longdist.txt Long-Distance Power Transmission - +Relays relay.txt Relay relayand.txt Relay AND relayor.txt Relay OR relayxor.txt Relay XOR relaymux.txt Relay Mux relayff.txt Relay Flip-Flop relaytff.txt Relay Toggle Flip-Flop relayctr.txt Relay Counter - 3way.txt 3-Way Light Switches 4way.txt 3- and 4-Way Light Switches diff.txt Differentiator wheatstone.txt Wheatstone Bridge lrc-critical.txt Critically Damped LRC currentsrcelm.txt Current Source inductkick.txt Inductive Kickback inductkick-snub.txt Blocking Inductive Kickback powerfactor1.txt Power Factor powerfactor2.txt Power Factor Correction grid.txt Resistor Grid grid2.txt Resistor Grid 2 cube.txt Resistor Cube +Coupled LC's coupled1.txt LC Modes (2) coupled2.txt Weak Coupling coupled3.txt LC Modes (3) ladder.txt LC Ladder - phaseseq.txt Phase-Sequence Network lissa.txt Lissajous Figures - +Diodes diodevar.txt Diode diodecurve.txt Diode I/V Curve rectify.txt Half-Wave Rectifier fullrect.txt Full-Wave Rectifier fullrectf.txt Full-Wave Rectifier w/ Filter diodelimit.txt Diode Limiter +Zener Diodes zeneriv.txt I/V Curve zenerref.txt Voltage Reference zenerreffollow.txt Voltage Reference w/ Follower - dcrestoration.txt DC Restoration inductkick-block.txt Blocking Inductive Kickback spikegen.txt Spike Generator +Voltage Multipliers voltdouble.txt Voltage Doubler voltdouble2.txt Voltage Doubler 2 volttriple.txt Voltage Tripler voltquad.txt Voltage Quadrupler - amdetect.txt AM Detector diodeclip.txt Waveform Clipper sinediode.txt Triangle-to-Sine Converter ringmod.txt Ring Modulator - +Op-Amps opamp.txt Op-Amp opampfeedback.txt Op-Amp Feedback +Amplifiers amp-invert.txt Inverting Amplifier amp-noninvert.txt Noninverting Amplifier amp-follower.txt Follower amp-diff.txt Differential Amplifier amp-sum.txt Summing Amplifier logconvert.txt Log Amplifier classd.txt Class-D Amplifier - +Oscillators relaxosc.txt Relaxation Oscillator phaseshiftosc.txt Phase-Shift Oscillator triangle.txt Triangle Wave Generator sine.txt Sine Wave Generator sawtooth.txt Sawtooth Wave Generator vco.txt Voltage-Controlled Oscillator rossler.txt Rossler Circuit - amp-rect.txt Half-Wave Rectifier (inverting) amp-fullrect.txt Full-Wave Rectifier peak-detect.txt Peak Detector amp-integ.txt Integrator amp-dfdx.txt Differentiator amp-schmitt.txt Schmitt Trigger nic-r.txt Negative Impedance Converter gyrator.txt Gyrator capmult.txt Capacitance Multiplier howland.txt Howland Current Source itov.txt I-to-V Converter opamp-regulator.txt Voltage Regulator opint.txt 741 Internals opint-invert-amp.txt 741 (inverting amplifier) opint-slew.txt 741 Slew Rate opint-current.txt 741 Current Limits - +Transistors npn.txt NPN Transistor pnp.txt PNP Transistor transswitch.txt Switch follower.txt Emitter Follower +Multivibrators multivib-a.txt Astable Multivib multivib-bi.txt Bistable Multivib (Flip-Flop) multivib-mono.txt Monostable Multivib (One-Shot) - ceamp.txt Common-Emitter Amplifier phasesplit.txt Unity-Gain Phase Splitter schmitt.txt Schmitt Trigger currentsrc.txt Current Source currentsrcramp.txt Current Source Ramp mirror.txt Current Mirror darlington.txt Darlington Pair +Differential Amplifiers trans-diffamp.txt Differential Input trans-diffamp-common.txt Common-Mode Input trans-diffamp-cursrc.txt Common-Mode w/Current Source - +Push-Pull Follower pushpullxover.txt Simple, with distortion pushpull.txt Improved - +Oscillators colpitts.txt Colpitts Oscillator hartley.txt Hartley Oscillator eclosc.txt Emitter-Coupled LC Oscillator - - +MOSFETs nmosfet.txt n-MOSFET pmosfet.txt p-MOSFET mosswitch.txt Switch mosfollower.txt Source Follower moscurrentsrc.txt Current Source moscurrentramp.txt Current Ramp mosmirror.txt Current Mirror mosfetamp.txt Common-Source Amplifier cmosinverter.txt CMOS Inverter cmosinvertercap.txt CMOS Inverter (w/capacitance) cmosinverterslow.txt CMOS Inverter (slow transition) cmostransgate.txt CMOS Transmission Gate mux.txt CMOS Multiplexer samplenhold.txt Sample-and-Hold delayrc.txt Delayed Buffer leadingedge.txt Leading-Edge Detector switchfilter.txt Switchable Filter voltinvert.txt Voltage Inverter invertamp.txt Inverter Amplifier inv-osc.txt Inverter Oscillator - +555 Timer Chip 555square.txt Square Wave Generator 555int.txt Internals 555saw.txt Sawtooth Oscillator 555lowduty.txt Low-duty-cycle Oscillator 555monostable.txt Monostable Multivibrator 555pulsemod.txt Pulse Width Modulator 555sequencer.txt Pulse Sequencer 555schmitt.txt Schmitt Trigger (inverting) 555missing.txt Missing Pulse Detector - +Active Filters filt-vcvs-lopass.txt VCVS Low-Pass Filter filt-vcvs-hipass.txt VCVS High-Pass Filter switchedcap.txt Switched-Capacitor Filter allpass1.txt Allpass allpass2.txt Allpass w/ Square - +Logic Families +RTL rtlinverter.txt RTL Inverter rtlnor.txt RTL NOR rtlnand.txt RTL NAND - +DTL dtlinverter.txt DTL Inverter dtlnand.txt DTL NAND dtlnor.txt DTL NOR - +TTL ttlinverter.txt TTL Inverter ttlnand.txt TTL NAND ttlnor.txt TTL NOR - +NMOS nmosinverter.txt NMOS Inverter nmosinverter2.txt NMOS Inverter 2 nmosnand.txt NMOS NAND - +CMOS cmosinverter.txt CMOS Inverter cmosnand.txt CMOS NAND cmosnor.txt CMOS NOR cmosxor.txt CMOS XOR cmosff.txt CMOS Flip-Flop cmosmsff.txt CMOS Master-Slave Flip-Flop - +ECL eclnor.txt ECL NOR/OR - +Ternary 3-cgand.txt CGAND 3-cgor.txt CGOR 3-invert.txt Complement (F210) 3-f211.txt F211 3-f220.txt F220 3-f221.txt F221 - - +Combinational Logic xor.txt Exclusive OR halfadd.txt Half Adder fulladd.txt Full Adder decoder.txt 1-of-4 Decoder mux3state.txt 2-to-1 Mux majority.txt Majority Logic digcompare.txt 2-Bit Comparator 7segdecoder.txt 7-Segment LED Decoder - +Sequential Logic +Flip-Flops nandff.txt SR Flip-Flop clockedsrff.txt Clocked SR Flip-Flop masterslaveff.txt Master-Slave Flip-Flop edgedff.txt Edge-Triggered D Flip-Flop jkff.txt JK Flip-Flop - +Counters counter.txt 4-Bit Ripple Counter counter8.txt 8-Bit Ripple Counter synccounter.txt Synchronous Counter deccounter.txt Decimal Counter graycode.txt Gray Code Counter johnsonctr.txt Johnson Counter - divideby2.txt Divide-by-2 divideby3.txt Divide-by-3 ledflasher.txt LED Flasher traffic.txt Traffic Light dram.txt Dynamic RAM - +Analog/Digital flashadc.txt Flash ADC deltasigma.txt Delta-Sigma ADC hfadc.txt Half-Flash (Subranging) ADC dac.txt Binary-Weighted DAC r2rladder.txt R-2R Ladder DAC swtreedac.txt Switch-Tree DAC digsine.txt Digital Sine Wave - +Phase-Locked Loops xorphasedet.txt XOR Phase Detector pll.txt Type I PLL phasecomp.txt Phase Comparator (Type II) phasecompint.txt Phase Comparator Internals pll2.txt Type II PLL pll2a.txt Type II PLL (fast) freqdouble.txt Frequency Doubler - +Transmission Lines tl.txt Simple TL tlstand.txt Standing Wave tlterm.txt Termination tlmismatch.txt Mismatched lines (Pulse) tlmis1.txt Mismatched lines (Standing Wave) tlmatch1.txt Impedance Matching (L-Section) tlmatch2.txt Impedance Matching (Shunt Stub) tlfreq.txt Stub Frequency Response tllopass.txt Low-Pass Filter tllight.txt Light Switch - +Misc Devices +JFETs jfetcurrentsrc.txt JFET Current Source jfetfollower.txt JFET Follower jfetfollower-nooff.txt JFET Follower w/zero offset jfetamp.txt Common-Source Amplifier volume.txt Volume Control - +Tunnel Diodes tdiode.txt I/V Curve tdosc.txt LC Oscillator tdrelax.txt Relaxation Oscillator - +Memristors mr.txt Memristor mr-sine.txt Sine Wave mr-square.txt Square Wave mr-triangle.txt Triangle Wave mr-sine2.txt Hard-Switching 1 mr-sine3.txt Hard-Switching 2 mr-crossbar.txt Crossbar Memory - +Triodes triode.txt Triode triodeamp.txt Amplifier - +Silicon-Controlled Rectifiers scr.txt SCR scractrig.txt AC Trigger - +Current Conveyor cc2.txt CCII+ cc2n.txt CCII- ccinductor.txt Inductor Simulator cc2imp.txt CCII+ Implementation cc2impn.txt CCII- Implementation cciamp.txt Current Amplifier ccvccs.txt VCCS ccdiff.txt Current Differentiator ccint.txt Current Integrator ccitov.txt Current-Controlled Voltage Source - +Spark Gap spark-sawtooth.txt Sawtooth Generator tesla.txt Tesla Coil spark-marx.txt Marx Generator - - blank.txt Blank Circuit