├── examples ├── clean ├── requirements.txt ├── Golden │ ├── Makefile │ ├── feedback.svg │ ├── inverting.svg │ ├── inverter.svg │ └── noninverting.svg ├── makeall ├── feedback.py ├── inverting.py ├── noninverting.py ├── inverter.py ├── oscillator.py ├── charge-pump.py ├── network-map.py ├── mfed.py ├── pipeline-adc.py ├── buck.py └── receiver.py ├── rlc.png ├── doc ├── images │ ├── clean │ ├── diode.py │ ├── gate.py │ ├── inductor.py │ ├── resistor.py │ ├── capacitor.py │ ├── bjt.py │ ├── pin.py │ ├── ground.py │ ├── crossing.py │ ├── switch.py │ ├── label.py │ ├── mos.py │ ├── ground.svg │ ├── Golden │ │ ├── ground.svg │ │ ├── resistor.svg │ │ ├── gate.svg │ │ ├── inductor.svg │ │ ├── diode.svg │ │ ├── capacitor.svg │ │ ├── rlc1b.svg │ │ ├── rlc.svg │ │ ├── rlc1a.svg │ │ ├── rlc2.svg │ │ ├── pin.svg │ │ ├── label.svg │ │ ├── rlc3.svg │ │ ├── tile2.svg │ │ ├── bjt.svg │ │ ├── crossing.svg │ │ ├── switch.svg │ │ ├── mos.svg │ │ └── wires.svg │ ├── makeall │ ├── orient.py │ ├── lpf.py │ ├── box.py │ ├── wires.py │ ├── resistor.svg │ ├── gate.svg │ ├── rlc.py │ ├── inductor.svg │ ├── diode.svg │ ├── capacitor.svg │ ├── tile.py │ ├── rlc1b.svg │ ├── source.py │ ├── rlc.svg │ ├── rlc1a.svg │ ├── rlc2.svg │ ├── pin.svg │ ├── label.svg │ ├── rlc3.svg │ ├── tile2.svg │ ├── box.svg │ ├── bjt.svg │ ├── amp.py │ ├── crossing.svg │ ├── switch.svg │ ├── mos.svg │ └── wires.svg ├── requirements.txt ├── releases.rst ├── index.rst ├── examples.rst └── Makefile ├── .gitignore ├── .bump.cfg.nt ├── clean ├── .readthedocs.yml ├── .github └── workflows │ └── build.yaml ├── pyproject.toml └── README.rst /examples/clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set nonomatch 4 | rm -f *.svg 5 | -------------------------------------------------------------------------------- /examples/requirements.txt: -------------------------------------------------------------------------------- 1 | shlib>=1.4 2 | inform>=1.26 3 | quantiphy>=2.16 4 | -------------------------------------------------------------------------------- /rlc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KenKundert/svg_schematic/HEAD/rlc.png -------------------------------------------------------------------------------- /doc/images/clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set nonomatch 4 | rm -f *.svg 5 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | docutils!=0.18 2 | # There is an incompatibility between Sphinx and docutils version 0.18. 3 | sphinx_rtd_theme 4 | -------------------------------------------------------------------------------- /examples/Golden/Makefile: -------------------------------------------------------------------------------- 1 | DRAWINGS = \ 2 | charge-pump \ 3 | inverter \ 4 | oscillator \ 5 | pipeline-adc \ 6 | receiver \ 7 | schematic 8 | 9 | SVG_FILES=$(DRAWINGS:=.svg) 10 | PNG_FILES=$(DRAWINGS:=.png) 11 | 12 | .PHONY: default clean 13 | 14 | default: $(PNG_FILES) 15 | 16 | clean: 17 | @rm -rf $(PNG_FILES) 18 | 19 | %.png: %.svg 20 | convert $< $@ 21 | 22 | -------------------------------------------------------------------------------- /doc/images/diode.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Diode, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'diode.svg'): 6 | d = Diode(name='D1') 7 | Label(C=d.c, name='c', loc='e', kind='dot', color='blue') 8 | Label(C=d.a, name='a', loc='w', kind='dot', color='blue') 9 | except Error as e: 10 | e.report() 11 | except OSError as e: 12 | error(os_error(e)) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[co] 2 | .*.swp 3 | install.out 4 | 5 | # Packages 6 | *.egg 7 | *.egg-info 8 | dist 9 | build 10 | eggs 11 | parts 12 | bin 13 | var 14 | sdist 15 | develop-eggs 16 | .installed.cfg 17 | images/*.svg 18 | examples/*.svg 19 | doc/.build 20 | 21 | # Installer logs 22 | pip-log.txt 23 | 24 | # Unit test / coverage reports 25 | .coverage 26 | .tox 27 | .test*.sum 28 | 29 | #Translations 30 | *.mo 31 | 32 | #Mr Developer 33 | .mr.developer.cfg 34 | 35 | -------------------------------------------------------------------------------- /doc/images/gate.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Gate, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'gate.svg'): 6 | u = Gate(kind='inv', name='U') 7 | Label(C=u.i, name='i', loc='w', kind='dot', color='blue', w=2) 8 | Label(C=u.o, name='o', loc='e', kind='dot', color='blue', w=2) 9 | 10 | except Error as e: 11 | e.report() 12 | except OSError as e: 13 | error(os_error(e)) 14 | -------------------------------------------------------------------------------- /doc/images/inductor.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Inductor, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'inductor.svg'): 6 | l = Inductor(name='L1', value='1μH') 7 | Label(C=l.p, name='p', loc='e', kind='dot', color='blue') 8 | Label(C=l.n, name='n', loc='w', kind='dot', color='blue') 9 | except Error as e: 10 | e.report() 11 | except OSError as e: 12 | error(os_error(e)) 13 | -------------------------------------------------------------------------------- /doc/images/resistor.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Resistor, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'resistor.svg'): 6 | r = Resistor(name='Rs', value='50Ω') 7 | Label(C=r.p, name='p', loc='e', kind='dot', color='blue') 8 | Label(C=r.n, name='n', loc='w', kind='dot', color='blue') 9 | except Error as e: 10 | e.report() 11 | except OSError as e: 12 | error(os_error(e)) 13 | -------------------------------------------------------------------------------- /doc/images/capacitor.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Capacitor, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'capacitor.svg'): 6 | c = Capacitor(name='C1', value='1.2pF') 7 | Label(C=c.p, name='p', loc='n', kind='dot', color='blue') 8 | Label(C=c.n, name='n', loc='s', kind='dot', color='blue') 9 | except Error as e: 10 | e.report() 11 | except OSError as e: 12 | error(os_error(e)) 13 | -------------------------------------------------------------------------------- /.bump.cfg.nt: -------------------------------------------------------------------------------- 1 | major: 1 2 | minor: 3 3 | patch: 0 4 | revision: 0 5 | type: release 6 | files: 7 | pyproject.toml: 8 | version: version 9 | svg_schematic.py: 10 | version: __version__ 11 | date: __released__ 12 | README.rst: 13 | version: Version 14 | date: Released 15 | doc/index.rst: 16 | version: Version 17 | date: Released 18 | doc/releases.rst: 19 | version: Version 20 | date: Released 21 | doc/conf.py: 22 | version: release 23 | style: python 24 | -------------------------------------------------------------------------------- /clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set nonomatch 4 | rm -f *.svg 5 | rm -f examples/*.svg 6 | 7 | # the rest is common to all python directories 8 | rm -f *.pyc *.pyo .test*.sum expected result install.out 9 | rm -rf build *.egg-info dist __pycache__ .coverage .coverage-html htmlcov .tox 10 | rm -rf doc/.build 11 | 12 | for i in */clean 13 | do 14 | if [[ "$i" == '*/clean' ]] 15 | then 16 | break 17 | fi 18 | #echo $i 19 | ( cd ${i%/*}; ./clean ) 20 | done 21 | for i in */Makefile 22 | do 23 | if [[ "$i" == '*/Makefile' ]] 24 | then 25 | break 26 | fi 27 | #echo $i 28 | ( cd ${i%/*}; make clean ) 29 | done 30 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | 13 | # Build documentation in the doc/ directory with Sphinx 14 | sphinx: 15 | configuration: doc/conf.py 16 | 17 | # Optionally build your docs in additional formats such as PDF and ePub 18 | formats: all 19 | 20 | # Optionally set the version of Python and requirements required to build your docs 21 | python: 22 | install: 23 | - requirements: doc/requirements.txt 24 | - method: pip 25 | path: . 26 | -------------------------------------------------------------------------------- /doc/images/bjt.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, BJT, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'bjt.svg'): 6 | q = BJT(kind='npn', name='Qn') 7 | Label(C=q.c, name='c', loc='n', kind='dot', color='blue') 8 | Label(C=q.b, name='b', loc='w', kind='dot', color='blue') 9 | Label(C=q.e, name='e', loc='s', kind='dot', color='blue') 10 | 11 | q = BJT(kind='pnp', name='Qp', C=q.C, xoff=150) 12 | Label(C=q.e, name='e', loc='n', kind='dot', color='blue') 13 | Label(C=q.b, name='b', loc='w', kind='dot', color='blue') 14 | Label(C=q.c, name='c', loc='s', kind='dot', color='blue') 15 | except Error as e: 16 | e.report() 17 | except OSError as e: 18 | error(os_error(e)) 19 | -------------------------------------------------------------------------------- /examples/makeall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | try: 4 | from shlib import lsf, Run, set_prefs, to_path 5 | from inform import Error 6 | set_prefs(use_inform=True) 7 | except ImportError: 8 | print( 9 | 'Run `pip install --user -r requirements.txt`', 10 | 'to install missing packages.' 11 | ) 12 | raise SystemExit 13 | 14 | golden = to_path('Golden') 15 | 16 | for py_file in lsf(select='*.py'): 17 | print(str(py_file)) 18 | cmd = ['python3', py_file] 19 | try: 20 | Run(cmd, 'soEW') 21 | except Error as e: 22 | e.report() 23 | 24 | if golden.exists(): 25 | for svg_file in lsf(select='*.svg'): 26 | cmd = ['cmp', svg_file, golden / svg_file] 27 | try: 28 | Run(cmd, 'soEW') 29 | except Error as e: 30 | e.report() 31 | -------------------------------------------------------------------------------- /doc/images/pin.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Pin, Wire, shift_x, shift_y 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'pin.svg'): 6 | Wire([(0, -25), (0,175)], color='cyan') 7 | p = Pin(kind='none', name='none', value='none value', w=5) 8 | Wire([shift_x(p.C, -50), shift_x(p.C, 50)]) 9 | p = Pin(kind='dot', name='dot', C=p.C, yoff=50, value='dot value', w=5) 10 | Wire([shift_x(p.C, -50), shift_x(p.C, 50)]) 11 | Wire([shift_y(p.C, -25), shift_y(p.C, 25)]) 12 | p = Pin(kind='in', name='in', C=p.C, yoff=50, w=5) 13 | Wire([p.C, shift_x(p.C, 25)]) 14 | p = Pin(kind='out', name='out', C=p.C, yoff=50, w=5) 15 | Wire([p.C, shift_x(p.C, -50)]) 16 | except Error as e: 17 | e.report() 18 | except OSError as e: 19 | error(os_error(e)) 20 | -------------------------------------------------------------------------------- /doc/images/ground.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Ground, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'ground.svg'): 6 | g = Ground() 7 | Label(C=g.t, name='t', loc='n', kind='dot', color='blue') 8 | # Label(C=g.N, name='N', loc='n', kind='dot', color='blue') 9 | # Label(C=g.NE, name='NE', loc='ne', kind='dot', color='blue') 10 | # Label(C=g.E, name='E', loc='e', kind='dot', color='blue') 11 | # Label(C=g.SE, name='SE', loc='se', kind='dot', color='blue') 12 | # Label(C=g.S, name='S', loc='s', kind='dot', color='blue') 13 | # Label(C=g.SW, name='SW', loc='sw', kind='dot', color='blue') 14 | # Label(C=g.W, name='W', loc='w', kind='dot', color='blue') 15 | # Label(C=g.NW, name='NW', loc='nw', kind='dot', color='blue') 16 | except Error as e: 17 | e.report() 18 | except OSError as e: 19 | error(os_error(e)) 20 | -------------------------------------------------------------------------------- /doc/images/crossing.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Crossing, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'crossing.svg'): 6 | c = Crossing() 7 | Label(C=c.pi, name='pi', loc='w', kind='dot', color='blue', w=3) 8 | Label(C=c.ni, name='ni', loc='w', kind='dot', color='blue', w=3) 9 | Label(C=c.po, name='po', loc='e', kind='dot', color='blue', w=3) 10 | Label(C=c.no, name='no', loc='e', kind='dot', color='blue', w=3) 11 | 12 | c = Crossing(C=c.C, w=2, h=2, xoff=150) 13 | Label(C=c.pi, name='pi', loc='w', kind='dot', color='blue', w=3) 14 | Label(C=c.ni, name='ni', loc='w', kind='dot', color='blue', w=3) 15 | Label(C=c.po, name='po', loc='e', kind='dot', color='blue', w=3) 16 | Label(C=c.no, name='no', loc='e', kind='dot', color='blue', w=3) 17 | 18 | except Error as e: 19 | e.report() 20 | except OSError as e: 21 | error(os_error(e)) 22 | -------------------------------------------------------------------------------- /doc/images/switch.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Switch, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'switch.svg'): 6 | s = Switch(kind='spst', name='φ₁') 7 | Label(C=s.i, name='i', loc='w', kind='dot', color='blue', w=2) 8 | Label(C=s.ot, name='ot', loc='e', kind='dot', color='blue', w=2) 9 | Label(C=s.o, name='o', loc='e', kind='dot', color='blue', w=2) 10 | Label(C=s.ob, name='ob', loc='e', kind='dot', color='blue', w=2) 11 | 12 | s = Switch(kind='spdt', name='φ₂', C=s.C, xoff=150) 13 | Label(C=s.i, name='i', loc='w', kind='dot', color='blue', w=2) 14 | Label(C=s.ot, name='ot', loc='e', kind='dot', color='blue', w=2) 15 | Label(C=s.o, name='o', loc='e', kind='dot', color='blue', w=2) 16 | Label(C=s.ob, name='ob', loc='e', kind='dot', color='blue', w=2) 17 | except Error as e: 18 | e.report() 19 | except OSError as e: 20 | error(os_error(e)) 21 | -------------------------------------------------------------------------------- /doc/images/label.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Label, Wire, shift_x, shift_y 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'label.svg'): 6 | Wire([(0, -25), (0,225)], color='cyan') 7 | l = Label(kind='plain', name='plain', loc='se', w=3) 8 | Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) 9 | l = Label(kind='arrow', name='arrow', C=l.C, yoff=50, loc='se', w=3) 10 | Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) 11 | l = Label(kind='arrow|', name='arrow|', C=l.C, yoff=50, loc='se', w=3) 12 | Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) 13 | l = Label(kind='slash', name='slash', C=l.C, yoff=50, loc='se', w=3) 14 | Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) 15 | l = Label(kind='dot', name='dot', C=l.C, yoff=50, loc='se', w=3) 16 | Wire([shift_x(l.C, -50), shift_x(l.C, 50)]) 17 | except Error as e: 18 | e.report() 19 | except OSError as e: 20 | error(os_error(e)) 21 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: AVG Schematic 2 | on: [push, pull_request] 3 | jobs: 4 | check-bats-version: 5 | runs-on: ${{ matrix.os }} 6 | strategy: 7 | matrix: 8 | os: [ubuntu-latest] 9 | python-version: ["3.6", "3.x"] 10 | max-parallel: 6 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | submodules: true 16 | - name: Set up Python ${{ matrix.python-version }} 17 | uses: actions/setup-node@v2 18 | with: 19 | python-version: ${{ matrix.python-version }} 20 | - name: Install packages 21 | run: | 22 | python -m pip install --upgrade pip 23 | pip install . 24 | pip install tox 25 | pip install coveralls 26 | - name: Run tests 27 | run: tox 28 | - name: Report test coverage 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | COVERALLS_SERVICE_NAME: github 32 | run: coveralls 33 | -------------------------------------------------------------------------------- /examples/feedback.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import Schematic, Amp, Box, Label, Pin, Source, Wire, shift_x 4 | from inform import Error, error, os_error 5 | 6 | try: 7 | with Schematic( 8 | filename = "feedback.svg", 9 | font_size=16, 10 | font_family='serif' 11 | ): 12 | 13 | summer = Source(kind='sum') 14 | amp = Amp(W=summer.E, xoff=25, name='$a$', kind='se') 15 | fb = Box(C=amp.C, yoff=100, name='$f$', h=1, orient='|') 16 | Label(C=summer.W, name='$+$', loc='nw') 17 | Label(C=summer.S, name='$-$', loc='sw') 18 | i = Pin(C=summer.W, xoff=-50, name='in', kind='in') 19 | o = Pin(C=amp.E, xoff=50, name='out', kind='out') 20 | 21 | Wire([i.C, summer.W]) 22 | Wire([summer.E, amp.i]) 23 | Wire([amp.E, o.C]) 24 | Wire([shift_x(amp.E, 25), fb.i], kind='|-') 25 | Wire([summer.S, fb.W], kind='|-') 26 | 27 | except Error as e: 28 | e.report() 29 | except OSError as e: 30 | error(os_error(e)) 31 | -------------------------------------------------------------------------------- /doc/images/mos.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, MOS, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'mos.svg'): 6 | m = MOS(kind='n', name='Mn') 7 | Label(C=m.d, name='d', loc='n', kind='dot', color='blue') 8 | Label(C=m.g, name='g', loc='w', kind='dot', color='blue') 9 | Label(C=m.s, name='s', loc='s', kind='dot', color='blue') 10 | 11 | m = MOS(kind='p', name='Mp', C=m.C, xoff=150) 12 | Label(C=m.s, name='s', loc='n', kind='dot', color='blue') 13 | Label(C=m.g, name='g', loc='w', kind='dot', color='blue') 14 | Label(C=m.d, name='d', loc='s', kind='dot', color='blue') 15 | 16 | m = MOS(kind='', name='M', C=m.C, xoff=150) 17 | Label(C=m.d, name='d', loc='n', kind='dot', color='blue') 18 | Label(C=m.g, name='g', loc='w', kind='dot', color='blue') 19 | Label(C=m.s, name='s', loc='s', kind='dot', color='blue') 20 | except Error as e: 21 | e.report() 22 | except OSError as e: 23 | error(os_error(e)) 24 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "svg_schematic" 3 | version = "1.3" 4 | description = "SVG schematic generator" 5 | readme = "README.rst" 6 | keywords = ["schematic", "SVG"] 7 | authors = [ 8 | {name = "Ken Kundert"}, 9 | {email = "svg_schematic@nurdletech.com"} 10 | ] 11 | classifiers = [ 12 | 'Development Status :: 5 - Production/Stable', 13 | 'Intended Audience :: Science/Research', 14 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', 15 | 'Natural Language :: English', 16 | 'Operating System :: POSIX :: Linux', 17 | 'Programming Language :: Python :: 3', 18 | 'Topic :: Utilities', 19 | 'Topic :: Scientific/Engineering', 20 | ] 21 | requires-python = ">=3.6" 22 | dependencies = [ 23 | 'svgwrite', 24 | 'inform', 25 | ] 26 | 27 | [project.urls] 28 | repository = "https://github.com/kenkundert/svg_schematic" 29 | documentation = "https://svg-schematic.readthedocs.io/en/latest/" 30 | 31 | [build-system] 32 | requires = ["flit_core >=2,<4"] 33 | build-backend = "flit_core.buildapi" 34 | -------------------------------------------------------------------------------- /examples/inverting.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, Amp, Dot, Ground, Label, Pin, Resistor, Source, Wire 5 | ) 6 | from inform import Error, error, os_error 7 | 8 | try: 9 | with Schematic( 10 | filename = "inverting.svg", 11 | font_size=16, 12 | font_family='serif' 13 | ): 14 | 15 | vin = Pin(kind='in', name='in', w=1.5) 16 | vout = Pin(C=vin.C, xoff=350, kind='out', name='out', w=2) 17 | Wire([vin.C, vout.C]) 18 | rin = Resistor(W=vin.C, xoff=25, name='Rin') 19 | vg = Dot(C=rin.E, xoff=25) 20 | rfb = Resistor(W=vg.C, xoff=25, name='Rfb') 21 | oj = Dot(C=rfb.E, xoff=25) 22 | amp = Amp(C=rfb.C, yoff=75, orient='-', kind='oa') 23 | Wire([oj.C, amp.o], kind='|-') 24 | gnd = Ground(C=amp.pi, xoff=-25, orient='h|') 25 | Wire([gnd.C, amp.pi]) 26 | Wire([vg.C, amp.ni], kind='|-') 27 | Label(C=vg.C, name='Vg', loc='sw') 28 | 29 | except Error as e: 30 | e.report() 31 | except OSError as e: 32 | error(os_error(e)) 33 | -------------------------------------------------------------------------------- /doc/images/ground.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | t 18 | 19 | 20 | -------------------------------------------------------------------------------- /doc/images/Golden/ground.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | t 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/noninverting.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, Amp, Dot, Ground, Label, Pin, Resistor, Source, Wire 5 | ) 6 | from inform import Error, error, os_error 7 | 8 | try: 9 | with Schematic(filename = "noninverting.svg", line_width=2): 10 | 11 | vin = Source(kind='sine') 12 | Label(C=vin.p, name='Vin', loc='n') 13 | Ground(C=vin.n) 14 | amp = Amp(pi=vin.p, xoff=100, kind='oa') 15 | Label(C=amp.ni, xoff=-25, name='Vf', loc='n') 16 | Wire([vin.p, amp.pi]) 17 | out = Pin(C=amp.o, xoff=50, name='out', w=2) 18 | Wire([amp.o, out.C]) 19 | oj = Dot(C=amp.o, xoff=25) 20 | r1 = Resistor(p=amp.ni, off=(-25, 50), name='R1', orient='v') 21 | Wire([r1.N, amp.ni], kind='|-') 22 | r2 = Resistor(C=amp.C, yoff=75, name='R2') 23 | Wire([r1.p, r2.W], kind='|-') 24 | Wire([oj.C, r2.E], kind='|-') 25 | fj = Dot(C=r2.W, xoff=-25) 26 | Ground(C=r1.n) 27 | 28 | except Error as e: 29 | e.report() 30 | except OSError as e: 31 | error(os_error(e)) 32 | -------------------------------------------------------------------------------- /doc/images/makeall: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from shlib import lsf, Run, set_prefs, to_path 4 | from inform import Error, error 5 | set_prefs(use_inform=True) 6 | 7 | golden = to_path('Golden') 8 | 9 | for py_file in lsf(select='*.py'): 10 | svg_file = py_file.with_suffix('.svg') 11 | print(str(py_file)) 12 | cmd = ['python3', py_file] 13 | try: 14 | Run(cmd, 'soEW') 15 | except Error as e: 16 | e.report() 17 | 18 | if golden.exists(): 19 | for svg_file in lsf(select='*.svg'): 20 | cmd = ['cmp', svg_file, golden / svg_file] 21 | try: 22 | Run(cmd, 'soEW') 23 | except Error as e: 24 | e.report() 25 | 26 | # sphinx puts all figures in the same directory, so make sure we do not have 27 | # figures with the same name in our two source directories 28 | 29 | examples = to_path('../../examples/Golden') 30 | local_figures = set(f.name for f in golden.iterdir()) 31 | example_figures = set(f.name for f in examples.iterdir()) 32 | dups = local_figures & example_figures 33 | if dups: 34 | error('conflicting filenames.', codicil=', '.join(dups)) 35 | -------------------------------------------------------------------------------- /doc/images/orient.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, BJT, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic( 6 | filename = 'orient.svg', 7 | background = 'none', 8 | ): 9 | q11 = BJT(orient='v') 10 | l11 = Label(N=q11.S, name="orient='v'") 11 | q12 = BJT(W=q11.E, xoff=50, orient='v|') 12 | l12 = Label(N=q12.S, name="orient='v|'") 13 | q13 = BJT(W=q12.E, xoff=50, orient='v-') 14 | l13 = Label(N=q13.S, name="orient='v-'") 15 | q14 = BJT(W=q13.E, xoff=50, orient='v|-') 16 | l14 = Label(N=q14.S, name="orient='v|-'") 17 | q21 = BJT(N=l11.S, yoff=25, orient='h') 18 | l21 = Label(N=q21.S, name="orient='h'") 19 | q22 = BJT(N=l12.S, yoff=25, orient='h|') 20 | l22 = Label(N=q22.S, name="orient='h|'") 21 | q23 = BJT(N=l13.S, yoff=25, orient='h-') 22 | l23 = Label(N=q23.S, name="orient='h-'") 23 | q24 = BJT(N=l14.S, yoff=25, orient='h|-') 24 | l24 = Label(N=q24.S, name="orient='h|-'") 25 | except Error as e: 26 | e.report() 27 | except OSError as e: 28 | error(os_error(e)) 29 | -------------------------------------------------------------------------------- /doc/releases.rst: -------------------------------------------------------------------------------- 1 | Releases 2 | -------- 3 | 4 | **Latest development release**: 5 | | Version: 1.3 6 | | Released: 2025-07-04 7 | 8 | - added Crossing symbols 9 | - added Converter symbols. 10 | 11 | **1.0 (2020-04-16)**: 12 | - reorganized documentation into a formal manual. 13 | 14 | **0.7 (2020-03-02)**: 15 | 16 | Moves almost fully to relative placement of components. 17 | 18 | - add ability to place a component by specifying location of its pins or principle coordinates. 19 | - add ability to add offsets when placing components. 20 | 21 | *This version is incompatible with previous versions.* 22 | 23 | - location of component must be specified with named argument. 24 | - ``orientation`` arguments have been renamed to ``orient``. 25 | - terminal array (``t``) has been removed 26 | 27 | You can upgrade previous schematics to this version by: 28 | 29 | - adding ``C=`` to leading argument of all components. 30 | - replacing ``orientation`` with ``orient`` in the argument lists of all components. 31 | - replacing use of ``t`` with the actual names of the pins. 32 | 33 | 34 | **0.6 (2019-09-03)**: 35 | -------------------------------------------------------------------------------- /examples/inverter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import Schematic, MOS, Ground, Gate, Label, Pin, Wire, midpoint 4 | from inform import Error, error, os_error 5 | 6 | try: 7 | with Schematic(filename = 'inverter.svg', line_width=2, background='none'): 8 | 9 | # transistor version 10 | mp = MOS(kind='p') 11 | mn = MOS(N=mp.S, kind='n') 12 | vin = Pin(C=midpoint(mp.g, mn.g), xoff=-50, kind='in', name=r'$V_{\rm in}$', w=2) 13 | vout = Pin(C=midpoint(mp.d, mn.d), xoff=50, kind='out', name=r'$V_{\rm out}$', w=2) 14 | Label(C=mp.s, loc='n', name=r'$V_{\rm dd}$') 15 | Ground(C=mn.s) 16 | Wire([vin.t, mp.g], kind='-|') 17 | Wire([vin.t, mn.g], kind='-|') 18 | Wire([vout.t, mp.d], kind='-|') 19 | Wire([vout.t, mn.d], kind='-|') 20 | 21 | # gate version 22 | inv = Gate(N=mn.S, yoff=25, kind='inv') 23 | vin = Pin(t=inv.i, xoff=-25, kind='in', name=r'$V_{\rm in}$', w=2) 24 | vout = Pin(t=inv.o, xoff=25, kind='out', name=r'$V_{\rm out}$', w=2) 25 | Wire([inv.o, vout.t]) 26 | Wire([inv.i, vin.t]) 27 | 28 | except Error as e: 29 | e.report() 30 | except OSError as e: 31 | error(os_error(e)) 32 | -------------------------------------------------------------------------------- /doc/images/lpf.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import ( 2 | Schematic, Capacitor, Ground, Inductor, Resistor, Pin, Source, Wire 3 | ) 4 | from inform import Error, error, os_error 5 | 6 | try: 7 | with Schematic( 8 | filename = 'lpf.svg', 9 | background = 'none', 10 | ): 11 | vin = Source(name='Vin', value='1 V', kind='sine') 12 | Ground(C=vin.n) 13 | rs = Resistor(name='Rs', value='50 Ω', n=vin.p, xoff=25) 14 | Wire([vin.p, rs.n]) 15 | c1 = Capacitor(name='C1', value='864 pF', p=rs.p, xoff=25) 16 | Ground(C=c1.n) 17 | l2 = Inductor(name='L2', value='5.12 μH', n=c1.p, xoff=25) 18 | Wire([rs.p, l2.n]) 19 | c3 = Capacitor(name='C3', value='2.83 nF', p=l2.p, xoff=25) 20 | Ground(C=c3.n) 21 | l4 = Inductor(name='L4', value='8.78 μH', n=c3.p, xoff=25) 22 | Wire([l2.p, l4.n]) 23 | c5 = Capacitor(name='C5', value='7.28 nF', p=l4.p, xoff=25) 24 | Ground(C=c5.n) 25 | rl = Resistor(name='Rl', value='50 Ω', p=c5.p, xoff=100, orient='v') 26 | Ground(C=rl.n) 27 | out = Pin(name='out', C=rl.p, xoff=50, w=2) 28 | Wire([l4.p, out.t]) 29 | except Error as e: 30 | e.report() 31 | except OSError as e: 32 | error(os_error(e)) 33 | 34 | -------------------------------------------------------------------------------- /examples/oscillator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, Capacitor, MOS, Inductor, Label, Source, Wire, Crossing, 5 | midpoint, shift, shift_y, 6 | ) 7 | from inform import Error, error, os_error 8 | 9 | try: 10 | with Schematic(filename = "oscillator.svg", background='none', line_width=2): 11 | 12 | # resonator 13 | vdd = Label(loc='n', nudge=10, name=r'$V_{\rm dd}$') 14 | Wire([vdd.C, shift_y(vdd.C, 25)]) 15 | ll = Inductor(p=shift(vdd.C, -125, 25), orient='v', name=r'$\frac{1}{2} L$') 16 | lr = Inductor(p=shift(vdd.C, 125, 25), orient='v|', name=r'$\frac{1}{2} L$') 17 | c = Capacitor(C=midpoint(ll.n, lr.n), orient='h', name='$C$') 18 | Wire([ll.p, lr.p]) 19 | Wire([ll.n, c.p]) 20 | Wire([lr.n, c.n]) 21 | 22 | # gain stage 23 | ml = MOS(d=ll.n, yoff=75, orient='|') 24 | mr = MOS(d=lr.n, yoff=75, orient='') 25 | Wire([ll.n, ml.d]) 26 | Wire([lr.n, mr.d]) 27 | cross = Crossing(C=midpoint(ml.g, mr.g), yoff=-50, orient='v', pass_under='white') 28 | Wire([ml.g, cross.pi], kind='-|') 29 | Wire([mr.g, cross.ni], kind='-|') 30 | Wire([lr.n, cross.po], kind='|-') 31 | Wire([ll.n, cross.no], kind='|-') 32 | Wire([ml.s, shift_y(ml.s, 12), shift_y(mr.s, 12), mr.s]) 33 | Source(p=midpoint(ml.s, mr.s), yoff=12, kind='idc', value=r'$I_{\rm ss}$') 34 | 35 | except Error as e: 36 | e.report() 37 | except OSError as e: 38 | error(os_error(e)) 39 | -------------------------------------------------------------------------------- /doc/images/box.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Box, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'box.svg'): 6 | b = Box(name='4 bit', value='Flash') 7 | Label(C=b.pi, name='pi', loc='w', kind='dot', color='blue') 8 | Label(C=b.i, name='i', loc='w', kind='dot', color='blue') 9 | Label(C=b.ni, name='ni', loc='w', kind='dot', color='blue') 10 | Label(C=b.po, name='po', loc='e', kind='dot', color='blue') 11 | Label(C=b.o, name='o', loc='e', kind='dot', color='blue') 12 | Label(C=b.no, name='no', loc='e', kind='dot', color='blue') 13 | 14 | b = Box(name='𝘻⁻¹', w=1, h=1, C=b.C, xoff=150) 15 | Label(C=b.i, name='i', loc='w', kind='dot', color='blue') 16 | Label(C=b.o, name='o', loc='e', kind='dot', color='blue') 17 | 18 | s = Box(name='4 bit', value='Flash', yoff=150) 19 | Label(C=s.N, name='N', loc='n', kind='dot', color='blue', w=2) 20 | Label(C=s.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) 21 | Label(C=s.E, name='E', loc='e', kind='dot', color='blue', w=2) 22 | Label(C=s.SE, name='SE', loc='se', kind='dot', color='blue', w=2) 23 | Label(C=s.S, name='S', loc='s', kind='dot', color='blue', w=2) 24 | Label(C=s.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) 25 | Label(C=s.W, name='W', loc='w', kind='dot', color='blue', w=2) 26 | Label(C=s.NW, name='NW', loc='nw', kind='dot', color='blue', w=2) 27 | 28 | except Error as e: 29 | e.report() 30 | except OSError as e: 31 | error(os_error(e)) 32 | -------------------------------------------------------------------------------- /doc/images/wires.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Label, Resistor, Wire, with_x 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic( 6 | filename = 'wires.svg', 7 | background = 'none', 8 | line_width = 2, 9 | ): 10 | r11 = Resistor(orient='h') 11 | r12 = Resistor(orient='h', n=r11.p, off=(50,50)) 12 | w = Wire([r11.p, r12.n], kind='plain') 13 | c = with_x(w.m, r12.E) 14 | Label(name="kind='plain'", C=c, xoff=25, loc='e', w=5) 15 | 16 | r21 = Resistor(orient='h', C=r11.C, yoff=100) 17 | r22 = Resistor(orient='h', n=r21.p, off=(50,50)) 18 | w = Wire([r21.p, r22.n], kind='|-') 19 | c = with_x(w.m, r22.E) 20 | Label(name="kind='|-'", C=c, xoff=25, loc='e', w=5) 21 | 22 | r31 = Resistor(orient='h', C=r21.C, yoff=100) 23 | r32 = Resistor(orient='h', n=r31.p, off=(50,50)) 24 | w = Wire([r31.p, r32.n], kind='-|') 25 | c = with_x(w.m, r32.E) 26 | Label(name="kind='-|'", C=c, xoff=25, loc='e', w=5) 27 | 28 | r41 = Resistor(orient='h', C=r31.C, yoff=100) 29 | r42 = Resistor(orient='h', n=r41.p, off=(50,50)) 30 | w = Wire([r41.p, r42.n], kind='|-|') 31 | c = with_x(w.m, r42.E) 32 | Label(name="kind='|-|'", C=c, xoff=25, loc='e', w=5) 33 | 34 | r51 = Resistor(orient='h', C=r41.C, yoff=100) 35 | r52 = Resistor(orient='h', n=r51.p, off=(50,50)) 36 | w = Wire([r51.p, r52.n], kind='-|-') 37 | c = with_x(w.m, r52.E) 38 | Label(name="kind='-|-'", C=c, xoff=25, loc='e', w=5) 39 | 40 | except Error as e: 41 | e.report() 42 | except OSError as e: 43 | error(os_error(e)) 44 | 45 | -------------------------------------------------------------------------------- /doc/images/resistor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Rs 14 | 50Ω 15 | 16 | 17 | 18 | 19 | 20 | 21 | p 22 | 23 | 24 | 25 | 26 | 27 | 28 | n 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/images/Golden/resistor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Rs 14 | 50Ω 15 | 16 | 17 | 18 | 19 | 20 | 21 | p 22 | 23 | 24 | 25 | 26 | 27 | 28 | n 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/images/gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | U 16 | 17 | 18 | 19 | 20 | 21 | 22 | i 23 | 24 | 25 | 26 | 27 | 28 | 29 | o 30 | 31 | 32 | -------------------------------------------------------------------------------- /doc/images/Golden/gate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | U 16 | 17 | 18 | 19 | 20 | 21 | 22 | i 23 | 24 | 25 | 26 | 27 | 28 | 29 | o 30 | 31 | 32 | -------------------------------------------------------------------------------- /doc/images/rlc.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Resistor, Capacitor, Inductor, Wire, shift_y 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = "rlc.svg"): 6 | r = Resistor(name='R', orient='v') 7 | c = Capacitor(C=r.C, xoff=100, name='C', orient='v') 8 | l = Inductor(C=c.C, xoff=100, name='L', orient='v|') 9 | Wire([r.p, c.p, l.p], kind='-|-') 10 | Wire([r.n, c.n, l.n], kind='-|-') 11 | 12 | with Schematic(filename = "rlc1a.svg"): 13 | r = Resistor(name='R', orient='v') 14 | c = Capacitor(W=r.E, name='C', orient='v') 15 | l = Inductor(W=c.E, name='L', orient='v|') 16 | Wire([r.p, c.p, l.p], kind='-|-') 17 | Wire([r.n, c.n, l.n], kind='-|-') 18 | 19 | with Schematic(filename = "rlc1b.svg"): 20 | r = Resistor(name='R', orient='h') 21 | c = Capacitor(n=r.p, name='C', orient='h|') 22 | l = Inductor(n=c.p, name='L', orient='h') 23 | 24 | with Schematic(filename = "rlc2.svg"): 25 | r = Resistor(name='R', orient='v') 26 | c = Capacitor(C=r.C, off=(100,25), name='C', orient='v') 27 | l = Inductor(C=c.C, xoff=100, name='L', orient='v|') 28 | Wire([r.p, c.p, l.p], kind='-|-') 29 | Wire([r.n, c.n, l.n], kind='-|-') 30 | 31 | with Schematic(filename = "rlc3.svg"): 32 | r = Resistor(name='R', orient='v') 33 | c = Capacitor(C=r.C, xoff=100, name='C', orient='v') 34 | l = Inductor(C=c.C, xoff=100, name='L', orient='v|') 35 | Wire([r.p, shift_y(r.p, -12.5), shift_y(c.p, -12.5), c.p]) 36 | Wire([c.p, shift_y(c.p, -12.5), shift_y(l.p, -12.5), l.p]) 37 | Wire([r.n, shift_y(r.n, 12.5), shift_y(c.n, 12.5), c.n]) 38 | Wire([c.n, shift_y(c.n, 12.5), shift_y(l.n, 12.5), l.n]) 39 | 40 | except Error as e: 41 | e.report() 42 | except OSError as e: 43 | error(os_error(e)) 44 | -------------------------------------------------------------------------------- /examples/charge-pump.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import Schematic, Capacitor, Diode, Ground, Pin, Wire, Dot, with_x 4 | from inform import Error, error, os_error 5 | 6 | try: 7 | with Schematic( 8 | filename = "charge-pump.svg", line_width=2, background='none'): 9 | 10 | vin = Pin(kind='in', name=r'$V_{\rm in}$', w=2) 11 | p1 = Pin(C=vin.C, yoff=150, kind='in', name=r'$\phi_1$', w=2) 12 | p2 = Pin(C=p1.C, yoff=50, kind='in', name=r'$\phi_2$', w=2) 13 | d1 = Diode(a=vin.C, xoff=25, orient='h') 14 | c1 = Capacitor(p=d1.c, off=(25, 25), orient='v') 15 | d2 = Diode(a=d1.c, xoff=50, orient='h') 16 | c2 = Capacitor(p=d2.c, off=(25, 25), orient='v') 17 | d3 = Diode(a=d2.c, xoff=50, orient='h') 18 | c3 = Capacitor(p=d3.c, off=(25, 25), orient='v') 19 | d4 = Diode(a=d3.c, xoff=50, orient='h') 20 | c4 = Capacitor(p=d4.c, off=(25, 25), orient='v') 21 | d5 = Diode(a=d4.c, xoff=50, orient='h') 22 | c5 = Capacitor(p=d5.c, off=(25, 25), orient='v') 23 | vout = Pin(C=d5.c, xoff=75, kind='out', name=r'$V_{\rm out}$', w=2) 24 | Ground(t=c5.n) 25 | 26 | Wire([vin.t, d1.a]) 27 | Wire([d1.c, d2.a]) 28 | Wire([d2.c, d3.a]) 29 | Wire([d3.c, d4.a]) 30 | Wire([d4.c, d5.a]) 31 | Wire([d5.c, vout.t]) 32 | Wire([with_x(vin.t, c1.C), c1.p]) 33 | Wire([with_x(vin.t, c2.C), c2.p]) 34 | Wire([with_x(vin.t, c3.C), c3.p]) 35 | Wire([with_x(vin.t, c4.C), c4.p]) 36 | Wire([with_x(vin.t, c5.C), c5.p]) 37 | Wire([p1.t, c1.n], kind='-|') 38 | Wire([p2.t, c2.n], kind='-|') 39 | co = Dot(C=with_x(p1.C, c2.C), color='white') # wire cross over 40 | Wire([p1.t, c3.n], kind='-|') 41 | Wire([p2.t, c4.n], kind='-|') 42 | 43 | except Error as e: 44 | e.report() 45 | except OSError as e: 46 | error(os_error(e)) 47 | -------------------------------------------------------------------------------- /doc/images/inductor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | L1 14 | 1μH 15 | 16 | 17 | 18 | 19 | 20 | 21 | p 22 | 23 | 24 | 25 | 26 | 27 | 28 | n 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/images/Golden/inductor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | L1 14 | 1μH 15 | 16 | 17 | 18 | 19 | 20 | 21 | p 22 | 23 | 24 | 25 | 26 | 27 | 28 | n 29 | 30 | 31 | -------------------------------------------------------------------------------- /examples/network-map.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Box, Wire, Label, shift_x, shift_y 2 | 3 | 4 | with Schematic(filename='network-map.svg', line_width=2): 5 | # work network 6 | work = Box(w=6.5, h=4.5, stroke_dasharray="4 2") 7 | Label(C=work.SW, loc='ne', name='work') 8 | bastion = Box(S=work.S, yoff=-25, w=5.5, h=2, color='lightgray') 9 | Wire([bastion.E, shift_x(bastion.E, 75)]) 10 | Label(C=bastion.SW, loc='ne', name='bastion') 11 | www = Box(NE=bastion.N, off=(-12.5, 25), w=2, h=1, color='white', name='www') 12 | mail = Box(NW=bastion.N, off=(12.5, 25), w=2, h=1, color='white', name='mail') 13 | dump = Box(SW=bastion.NW, yoff=-25, w=2.5, h=1, name='dump') 14 | laptop = Box(SE=bastion.NE, yoff=-25, w=2.5, h=1, name='my laptop', stroke_dasharray="2 2") 15 | 16 | # home network 17 | home = Box(N=work.S, yoff=50, w=6.5, h=2, stroke_dasharray="4 2") 18 | Label(C=home.SW, loc='ne', name='home') 19 | laptop = Box(SW=home.SW, off=(25, -25), w=2.5, h=1, color='lightgray', name='my laptop', stroke_dasharray="2 2") 20 | media = Box(SE=home.SE, off=(-25, -25), w=2.5, h=1, name='media') 21 | Wire([media.E, shift_x(media.E, 75)]) 22 | 23 | # internet 24 | internet = Wire([shift_x(work.NE, 50), shift_x(home.SE, 50)], line_width=4) 25 | Label(C=internet.e, loc='s', name='internet') 26 | 27 | # external network 28 | github = Box(NW=internet.b, off=(50, 25), w=3, h=1, name='github') 29 | Wire([github.W, shift_x(github.W, -50)]) 30 | cloud = Box(N=github.S, yoff=25, w=3, h=1, name='vps') 31 | Wire([cloud.W, shift_x(cloud.W, -50)]) 32 | backups = Box(N=cloud.S, yoff=25, w=3, h=1, name='backups') 33 | Wire([backups.W, shift_x(backups.W, -50)]) 34 | hotspot = Box(N=backups.S, yoff=25, w=3, h=2, stroke_dasharray="4 2") 35 | Label(C=hotspot.SW, loc='ne', name='a wifi hotspot') 36 | laptop = Box(C=hotspot.C, w=2, h=1, name='my laptop', stroke_dasharray="2 2") 37 | -------------------------------------------------------------------------------- /doc/images/diode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | D1 17 | 18 | 19 | 20 | 21 | 22 | 23 | c 24 | 25 | 26 | 27 | 28 | 29 | 30 | a 31 | 32 | 33 | -------------------------------------------------------------------------------- /doc/images/Golden/diode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | D1 17 | 18 | 19 | 20 | 21 | 22 | 23 | c 24 | 25 | 26 | 27 | 28 | 29 | 30 | a 31 | 32 | 33 | -------------------------------------------------------------------------------- /doc/images/capacitor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | C1 17 | 1.2pF 18 | 19 | 20 | 21 | 22 | 23 | 24 | p 25 | 26 | 27 | 28 | 29 | 30 | 31 | n 32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/images/Golden/capacitor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | C1 17 | 1.2pF 18 | 19 | 20 | 21 | 22 | 23 | 24 | p 25 | 26 | 27 | 28 | 29 | 30 | 31 | n 32 | 33 | 34 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | SVG Schematic 2 | ============= 3 | 4 | :Author: Ken Kundert 5 | :Version: 1.3 6 | :Released: 2025-07-04 7 | 8 | 9 | This package allows you to create simple SVG schematics and block diagrams 10 | without a mouse. Instead, you build the schematic using Python to instantiate 11 | and place the symbols and wires. 12 | 13 | 14 | Simple Example 15 | -------------- 16 | 17 | Here is a simple example that demonstrates the package. It generates the 18 | schematic of a shunt RLC circuit: 19 | 20 | .. code-block:: python 21 | 22 | from svg_schematic import Schematic, Resistor, Capacitor, Inductor, Wire 23 | from inform import Error, error, os_error 24 | 25 | try: 26 | with Schematic(filename='rlc.svg'): 27 | r = Resistor(name='R', orient='v') 28 | c = Capacitor(W=r.E, name='C', orient='v') 29 | l = Inductor(W=c.E, name='L', orient='v|') 30 | Wire([r.p, l.p]) 31 | Wire([r.n, l.n]) 32 | except Error as e: 33 | e.report() 34 | except OSError as e: 35 | error(os_error(e)) 36 | 37 | When run, it produces the following schematic: 38 | 39 | .. image:: images/Golden/rlc.svg 40 | :width: 35 % 41 | :align: center 42 | 43 | 44 | Installation 45 | ------------ 46 | 47 | Requires Python3. Works best with Python3.6 or newer. 48 | 49 | You can download and install the latest 50 | stable version of the code from `PyPI `_ using:: 51 | 52 | pip3 install --user svg_schematic 53 | 54 | You can find the latest development version of the source code on 55 | `Github `_. 56 | 57 | 58 | Issues 59 | ------ 60 | 61 | Please ask questions or report problems on 62 | `Github Issues `_. 63 | 64 | 65 | Contributions 66 | ------------- 67 | 68 | Contributions in the form of pull requests are welcome. 69 | 70 | I tend to create symbols as I need them. If you create missing symbols, please 71 | consider contributing them back to the project. 72 | 73 | 74 | Contents 75 | -------- 76 | 77 | .. toctree:: 78 | :maxdepth: 1 79 | 80 | concepts 81 | classes 82 | examples 83 | releases 84 | 85 | * :ref:`genindex` 86 | -------------------------------------------------------------------------------- /examples/mfed.py: -------------------------------------------------------------------------------- 1 | """ 2 | Draw a 5th Order Low Pass Passive Filer with Maximally Flat Envelope Delay 3 | 4 | Use the following parameters: 5 | Fo = 1MHz — 3dB corner frequency 6 | Rref = 50Ω — termination impedance 7 | 8 | Design equations: 9 | ω0 = 2*π*Fo 10 | Lscale = Rref/ω0 11 | Cscale = 1/(Rref*ω0) 12 | 13 | Rs = 1.0000 * Rref "Ω" 14 | C1 = 0.2715 * Cscale "F" 15 | L2 = 0.6541 * Lscale "H" 16 | C3 = 0.8892 * Cscale "F" 17 | L4 = 1.1034 * Lscale "H" 18 | C5 = 2.2873 * Cscale "F" 19 | """ 20 | 21 | try: 22 | from svg_schematic import ( 23 | Schematic, Capacitor, Dot, Ground, Inductor, Label, Resistor, Pin, 24 | Source, Wire 25 | ) 26 | from inform import Error, error, os_error 27 | from quantiphy import Quantity 28 | from math import pi 29 | except ImportError: 30 | print( 31 | 'Run `pip install --user -r requirements.txt`', 32 | 'to install missing packages.' 33 | ) 34 | raise SystemExit 35 | 36 | Quantity.set_prefs(map_sf=Quantity.map_sf_to_greek, prec=2) 37 | globals().update( 38 | Quantity.extract(__doc__, predefined={'π': pi}) 39 | ) 40 | 41 | try: 42 | with Schematic(filename = 'mfed.svg', line_width=2, background = 'none'): 43 | 44 | vin = Source(kind='sine') 45 | Ground(C=vin.n) 46 | rs = Resistor(name='Rs', value=Rref, n=vin.p, xoff=25) 47 | Wire([vin.p, rs.n]) 48 | c1 = Capacitor(name='C1', value=C1, p=rs.p, xoff=25) 49 | Ground(C=c1.n) 50 | l2 = Inductor(name='L2', value=L2, n=c1.p, xoff=25) 51 | Wire([rs.p, l2.n]) 52 | c3 = Capacitor(name='C3', value=C3, p=l2.p, xoff=25) 53 | Ground(C=c3.n) 54 | l4 = Inductor(name='L4', value=L4, n=c3.p, xoff=25) 55 | Wire([l2.p, l4.n]) 56 | c5 = Capacitor(name='C5', value=C5, p=l4.p, xoff=25) 57 | Ground(C=c5.n) 58 | rl = Resistor(name='Rl', value=Rref, p=c5.p, xoff=100, orient='v') 59 | Ground(C=rl.n) 60 | out = Pin(name='out', C=rl.p, xoff=50, w=2) 61 | Wire([l4.p, out.t]) 62 | Label(S=c3.N, yoff=-50, name=f'{Fo} LPF', loc='s') 63 | Dot(C=c1.p) 64 | Dot(C=c3.p) 65 | Dot(C=c5.p) 66 | Dot(C=rl.p) 67 | 68 | except Error as e: 69 | e.report() 70 | except OSError as e: 71 | error(os_error(e)) 72 | 73 | -------------------------------------------------------------------------------- /doc/images/tile.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Resistor, Box, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic( 6 | filename = 'tile1.svg', 7 | background = 'none', 8 | ): 9 | b = Box(w=2, h=2, background='lightgray') 10 | r = Resistor(C=b.C) 11 | Label(C=r.C, name='C', loc='s', kind='dot', color='blue', w=2) 12 | Label(C=r.N, name='N', loc='n', kind='dot', color='blue', w=2) 13 | Label(C=r.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) 14 | Label(C=r.E, name='E', loc='e', kind='dot', color='blue', w=2) 15 | Label(C=r.SE, name='SE', loc='se', kind='dot', color='blue', w=2) 16 | Label(C=r.S, name='S', loc='s', kind='dot', color='blue', w=2) 17 | Label(C=r.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) 18 | Label(C=r.W, name='W', loc='w', kind='dot', color='blue', w=2) 19 | Label(C=r.NW, name='NW', loc='nw', kind='dot', color='blue', w=2) 20 | 21 | b = Box(C=b.C, xoff=200, w=2, h=2, background='lightgray') 22 | r = Resistor(C=b.C, orient='v') 23 | Label(C=r.C, name='C', loc='e', kind='dot', color='blue', w=2) 24 | Label(C=r.N, name='N', loc='n', kind='dot', color='blue', w=2) 25 | Label(C=r.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) 26 | Label(C=r.E, name='E', loc='e', kind='dot', color='blue', w=2) 27 | Label(C=r.SE, name='SE', loc='se', kind='dot', color='blue', w=2) 28 | Label(C=r.S, name='S', loc='s', kind='dot', color='blue', w=2) 29 | Label(C=r.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) 30 | Label(C=r.W, name='W', loc='w', kind='dot', color='blue', w=2) 31 | Label(C=r.NW, name='NW', loc='nw', kind='dot', color='blue', w=2) 32 | 33 | with Schematic(filename='tile2.svg', background='none'): 34 | b = Box(background='lightgray', w=2, h=2) 35 | r = Resistor(C=b.C) 36 | Label(C=r.p, name='p', loc='n', kind='dot', color='blue', w=2) 37 | Label(C=r.n, name='n', loc='s', kind='dot', color='blue', w=2) 38 | 39 | b = Box(C=b.C, xoff=200, background='lightgray', w=2, h=2) 40 | r = Resistor(C=b.C, orient='v') 41 | Label(C=r.p, name='p', loc='n', kind='dot', color='blue', w=2) 42 | Label(C=r.n, name='n', loc='s', kind='dot', color='blue', w=2) 43 | except Error as e: 44 | e.report() 45 | except OSError as e: 46 | error(os_error(e)) 47 | 48 | -------------------------------------------------------------------------------- /doc/images/rlc1b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | -------------------------------------------------------------------------------- /doc/images/Golden/rlc1b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | -------------------------------------------------------------------------------- /doc/images/source.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Source, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'source.svg'): 6 | s = Source(kind='empty', name='Ve') 7 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 8 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 9 | 10 | s = Source(kind='vdc', name='Vd', C=s.C, xoff=150) 11 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 12 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 13 | 14 | s = Source(kind='idc', name='Id', C=s.C, xoff=150) 15 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 16 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 17 | 18 | s = Source(kind='sine', name='Vs', C=s.C, xoff=150) 19 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 20 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 21 | 22 | s = Source(kind='sum', name='S', yoff=150) 23 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 24 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 25 | 26 | s = Source(kind='mult', name='M', C=s.C, xoff=150) 27 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 28 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 29 | 30 | s = Source(kind='cv', name='Vc', C=s.C, xoff=150) 31 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 32 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 33 | 34 | s = Source(kind='ci', name='Ic', C=s.C, xoff=150) 35 | Label(C=s.p, name='p', loc='w', kind='dot', color='blue', w=2) 36 | Label(C=s.n, name='n', loc='w', kind='dot', color='blue', w=2) 37 | 38 | s = Source(kind='sum', name='S', yoff=300) 39 | Label(C=s.N, name='N', loc='n', kind='dot', color='blue', w=2) 40 | Label(C=s.NE, name='NE', loc='ne', kind='dot', color='blue', w=2) 41 | Label(C=s.E, name='E', loc='e', kind='dot', color='blue', w=2) 42 | Label(C=s.SE, name='SE', loc='se', kind='dot', color='blue', w=2) 43 | Label(C=s.S, name='S', loc='s', kind='dot', color='blue', w=2) 44 | Label(C=s.SW, name='SW', loc='sw', kind='dot', color='blue', w=2) 45 | Label(C=s.W, name='W', loc='w', kind='dot', color='blue', w=2) 46 | Label(C=s.NW, name='NW', loc='nw', kind='dot', color='blue', w=2) 47 | 48 | except Error as e: 49 | e.report() 50 | except OSError as e: 51 | error(os_error(e)) 52 | -------------------------------------------------------------------------------- /examples/pipeline-adc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, Amp, Box, Label, Pin, Source, Wire, 5 | midpoint, shift_x, shift, with_x, with_y, 6 | ) 7 | from inform import Error, error, os_error 8 | 9 | try: 10 | with Schematic(filename = 'pipeline-adc.svg', line_width=2): 11 | 12 | # Stage 1 13 | i = Pin(kind='in', name='in') 14 | s1 = Box(NW=i.t, off=(25,-62.5), w=10.5, h=4.5, background='lightgray') 15 | Label(C=s1.SE, loc='nw', name='Stage 1') 16 | adc = Box(W=i.t, off=(75,100), name='2 bit', value='Flash') 17 | dac = Box(i=adc.o, xoff=50, name='2 bit', value='DAC') 18 | sh = Box(C=with_x(i.t, midpoint(adc.C, dac.C)), name='SAH') 19 | sum = Source(W=with_x(i.t, dac.E), xoff=25, kind='sum', orient='h|') 20 | Label(C=sum.W, loc='nw', name='+') 21 | Label(C=sum.S, loc='se', name='−') 22 | amp = Amp(i=sum.E, xoff=25, kind='se', name='4×') 23 | Wire([i.t, sh.i]) 24 | Wire([sh.o, sum.W]) 25 | Wire([sum.E, amp.i]) 26 | Wire([shift_x(i.t, 50), adc.i], kind='|-') 27 | Wire([adc.o, dac.i]) 28 | Wire([dac.o, sum.S], kind='-|') 29 | 30 | # Stages 2, 3, 4 31 | s2 = Box(N=dac.S, off=(25,75), name='Stage 2') 32 | s3 = Box(W=s2.E, xoff=50, name='Stage 3') 33 | s4 = Box(W=s3.E, xoff=50, name='4 bit', value='Flash') 34 | Wire([s2.o, s3.i]) 35 | Wire([s3.o, s4.i]) 36 | Wire([ 37 | amp.o, 38 | shift_x(amp.o, 50), 39 | shift(s1.SE, 25,25), 40 | shift(s2.NW, -25, -25), 41 | shift_x(s2.W, -25), 42 | s2.W, 43 | ]) 44 | 45 | # Error correction 46 | ec = Box(NW=s2.SW, off=(-75, 50), name='Digital Error Correction', w=9, h=1) 47 | out = Pin(t=shift_x(ec.o, 50), kind='out', name='out', w=2) 48 | Wire([ec.o, out.t]) 49 | Label(C=shift_x(ec.E, 25), kind='slash', loc='s', name='8') 50 | 51 | w1 = Wire([midpoint(adc.o, dac.i), with_y(midpoint(adc.o, dac.i), ec.N)]) 52 | w2 = Wire([s2.S, with_y(s2.S, ec.N)]) 53 | w3 = Wire([s3.S, with_y(s3.S, ec.N)]) 54 | w4 = Wire([s4.S, with_y(s4.S, ec.N)]) 55 | Label(C=w1.e, yoff=-25, kind='slash', loc='w', name='2', nudge=8) 56 | Label(C=w2.e, yoff=-25, kind='slash', loc='w', name='2', nudge=8) 57 | Label(C=w3.e, yoff=-25, kind='slash', loc='w', name='2', nudge=8) 58 | Label(C=w4.e, yoff=-25, kind='slash', loc='w', name='4', nudge=8) 59 | 60 | except Error as e: 61 | e.report() 62 | except OSError as e: 63 | error(os_error(e)) 64 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | SVG Schematic 2 | ============= 3 | 4 | .. image:: https://pepy.tech/badge/svg_schematic/month 5 | :target: https://pepy.tech/project/svg_schematic 6 | 7 | .. image:: https://img.shields.io/readthedocs/svg-schematic.svg 8 | :target: https://svg-schematic.readthedocs.io/en/latest/?badge=latest 9 | 10 | .. image:: https://img.shields.io/pypi/v/svg_schematic.svg 11 | :target: https://pypi.python.org/pypi/svg_schematic 12 | 13 | .. image:: https://img.shields.io/pypi/pyversions/svg_schematic.svg 14 | :target: https://pypi.python.org/pypi/svg_schematic/ 15 | 16 | 17 | :Author: Ken Kundert 18 | :Version: 1.3 19 | :Released: 2025-07-04 20 | 21 | 22 | This package allows you to create simple SVG schematics and block diagrams 23 | without a mouse. Instead, you build the schematic using Python to instantiate 24 | and place the symbols and wires. 25 | 26 | 27 | Simple Example 28 | -------------- 29 | 30 | Here is a simple example that demonstrates the package. It generates the 31 | schematic of a shunt RLC circuit:: 32 | 33 | from svg_schematic import Schematic, Resistor, Capacitor, Inductor, Wire 34 | from inform import Error, error, os_error 35 | 36 | try: 37 | with Schematic(filename='rlc.svg'): 38 | r = Resistor(name='R', orient='v') 39 | c = Capacitor(W=r.E, name='C', orient='v') 40 | l = Inductor(W=c.E, name='L', orient='v|') 41 | Wire([r.p, l.p]) 42 | Wire([r.n, l.n]) 43 | except Error as e: 44 | e.report() 45 | except OSError as e: 46 | error(os_error(e)) 47 | 48 | When run, it produces the following schematic: 49 | 50 | .. image:: doc/images/Golden/rlc.svg 51 | :width: 35 % 52 | :align: center 53 | 54 | 55 | Installation 56 | ------------ 57 | 58 | Requires Python3. Works best with Python3.6 or newer. 59 | 60 | You can download and install the latest 61 | stable version of the code from `PyPI 62 | `_ using:: 63 | 64 | pip3 install svg_schematic 65 | 66 | You can find the latest development version of the source code on 67 | `Github `_. 68 | 69 | 70 | Documentation 71 | ------------- 72 | 73 | You can find documentation at `ReadTheDocs 74 | `_. 75 | 76 | 77 | Issues 78 | ------ 79 | 80 | Please ask questions or report problems on 81 | `Github Issues `_. 82 | 83 | 84 | Contributions 85 | ------------- 86 | 87 | Contributions in the form of pull requests are welcome. 88 | 89 | I tend to create symbols as I need them. If you create missing symbols, please 90 | consider contributing them back to the project. 91 | -------------------------------------------------------------------------------- /doc/images/rlc.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/Golden/rlc.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/rlc1a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/Golden/rlc1a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/rlc2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/Golden/rlc2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /doc/images/pin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | none 15 | none value 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | dot 26 | dot value 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | in 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | out 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/images/Golden/pin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | none 15 | none value 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | dot 26 | dot value 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | in 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | out 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/images/label.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | plain 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | arrow 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | arrow| 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | slash 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | dot 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /examples/buck.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, Amp, Box, Capacitor, Converter, Dot, Ground, Inductor, Label, MOS, 5 | Pin, Resistor, Switch, Wire, shift, shift_x, shift_y, with_x, with_y, midpoint 6 | ) 7 | from inform import Error, error, os_error 8 | 9 | try: 10 | with Schematic(filename="buck.svg", line_width=2, background='none'): 11 | 12 | pvdd = Pin(kind='in', name='pvdd', w=3) 13 | avdd = Pin(C=pvdd.C, yoff=50, kind='in', name='avdd', w=3) 14 | Wire([avdd.C, shift_x(avdd.C, 50)]) 15 | 16 | lvl = Pin(C=avdd.C, yoff=90, kind='in', name='lvl', w=3) 17 | reference = Converter(i=lvl.C, xoff=75, name='ref') 18 | lvl2ref = Wire([lvl.C, reference.i]) 19 | Label(C=lvl2ref.m, kind='slash', name='6', loc='se') 20 | 21 | amp = Amp(pi=reference.o, xoff=50, kind='oa', name='amp') 22 | Wire([reference.o, amp.pi]) 23 | C1 = Capacitor(p=amp.C, off=(-12.5, 75), orient='h') 24 | R1 = Resistor(p=C1.p, xoff=12.5, orient='h') 25 | C2 = Capacitor(C=midpoint(R1.C, C1.C), yoff=50, orient='h') 26 | Wire([C1.n, with_y(C1.n, amp.o)], kind='-|') 27 | Wire([R1.n, amp.ni], kind='|-') 28 | Wire([C2.p, R1.n], kind='-|') 29 | Wire([C2.n, C1.n], kind='-|') 30 | 31 | cmp = Amp(pi=amp.o, xoff=125, kind='comp', name='cmp') 32 | Wire([amp.o, cmp.pi]) 33 | 34 | gd = Box(i=cmp.o, xoff=50, name='gate', value='drivers') 35 | Wire([cmp.o, gd.i]) 36 | 37 | pfet = MOS(g=gd.N, yoff=-50, kind='p', orient='h') 38 | Wire([pfet.g, gd.N]) 39 | Wire([pfet.s, pvdd.C]) 40 | 41 | nfet = MOS(g=gd.o, xoff=25, kind='n', orient='v') 42 | Wire([nfet.g, gd.o]) 43 | Wire([nfet.d, pfet.d], kind='|-') 44 | Ground(C=nfet.s) 45 | 46 | ind = Inductor(n=with_x(pfet.d, nfet.E), orient='h') 47 | Wire([pfet.d, ind.n]) 48 | cap = Capacitor(p=ind.p, orient='v') 49 | Ground(C=cap.n) 50 | out = Pin(C=ind.p, xoff=100, kind='out', name='out', w=3) 51 | out_wire = Wire([ind.p, out.C]) 52 | 53 | fb = shift_y(R1.n, 100) 54 | 55 | Rt = Resistor(n=with_x(fb, out_wire.m), orient='v') 56 | Rb = Resistor(p=with_x(fb, out_wire.m), orient='v') 57 | Wire([Rt.p, with_y(Rt.p, out.C)]) 58 | Ground(C=Rb.n) 59 | 60 | RG = Box(o=C1.n, yoff=175) 61 | rg2cmp = Wire([RG.o, cmp.ni], kind='-|-') 62 | Dot(C=with_y(rg2cmp.m, fb), color='white') 63 | Wire([shift_x(RG.C, -30), shift(RG.C, -25, 25), shift(RG.C, 25, -25), shift_x(RG.C, 30)]) 64 | Label(C=RG.S, loc='s', name='ramp_gen') 65 | Wire([R1.n, fb, Rt.n], kind='|-') 66 | 67 | en = Pin(C=lvl.C, yoff=250, kind='in', name='en', w=3) 68 | Wire([en.C, shift_x(en.C, 50)]) 69 | avss = Pin(C=en.C, yoff=50, kind='in', name='avss', w=3) 70 | Wire([avss.C, shift_x(avss.C, 50)]) 71 | 72 | except Error as e: 73 | e.report() 74 | except OSError as e: 75 | error(os_error(e)) 76 | -------------------------------------------------------------------------------- /doc/images/Golden/label.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | plain 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | arrow 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | arrow| 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | slash 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | dot 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /doc/images/rlc3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/images/Golden/rlc3.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | R 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | C 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | L 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /doc/images/tile2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | p 21 | 22 | 23 | 24 | 25 | 26 | 27 | n 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | p 46 | 47 | 48 | 49 | 50 | 51 | 52 | n 53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/images/Golden/tile2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | p 21 | 22 | 23 | 24 | 25 | 26 | 27 | n 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | p 46 | 47 | 48 | 49 | 50 | 51 | 52 | n 53 | 54 | 55 | -------------------------------------------------------------------------------- /examples/receiver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from svg_schematic import ( 4 | Schematic, shift_x, shift_y, Amp, Box, Ground, Label, Pin, Source, Wire 5 | ) 6 | 7 | with Schematic( 8 | filename = 'receiver.svg', 9 | font_size = 12, 10 | font_family = 'sans', 11 | outline = 'none', 12 | pad = 20, 13 | line_width = 2, 14 | ) as schematic: 15 | 16 | # Input from horn antenna 17 | rf_in = Pin(kind='in', name='L-band Horn', w=3) 18 | Label(C=rf_in.C, yoff=15, loc='w', name='fc=1420MHz', w=3.5, nudge=14) 19 | Label(C=rf_in.C, yoff=30, loc='w', name='BW=15MHz', w=3.5, nudge=14) 20 | 21 | # First preamp 22 | rf_preamp1 = Amp(i=rf_in.t, xoff=25, kind='se', name='RF Preamp1') 23 | Label(C=rf_preamp1.S, loc='s', name='A>=26dB') 24 | Wire([rf_in.t, rf_preamp1.i]) 25 | 26 | # Second preamp 27 | rf_preamp2 = Amp(i=rf_preamp1.o, xoff=25, kind='se', name='RF Preamp2') 28 | Label(C=rf_preamp2.S, loc='s', name='A>=26dB') 29 | Wire([rf_preamp1.o, rf_preamp2.i]) 30 | 31 | # RF band-pass filter 32 | rf_bpf = Box(i=rf_preamp2.o, xoff=25, name='RF BPF') 33 | l = Label(C=rf_bpf.S, loc='s', name='fc=1380MHz') 34 | Label(C=l.S, name='BW=320MHz') 35 | Wire([rf_preamp2.o, rf_bpf.i]) 36 | 37 | # First RF amplifier 38 | rf_amp1 = Amp(i=rf_bpf.o, xoff=25, kind='se', name='RF Amp1') 39 | Label(C=rf_amp1.S, loc='s', name='A<=20dB') 40 | Wire([rf_bpf.o, rf_amp1.i]) 41 | 42 | # Second RF amplifier 43 | rf_amp2 = Amp(i=rf_amp1.o, xoff=25, kind='se', name='RF Amp2') 44 | Label(C=rf_amp2.S, loc='s', name='A<=20dB') 45 | Wire([rf_amp1.o, rf_amp2.i]) 46 | 47 | # RF mixer 48 | rf_mixer = Source(W=rf_amp2.o, xoff=25, kind='mult') 49 | Label(C=rf_mixer.N, loc='n', name='DSB') 50 | Wire([rf_amp2.o, rf_mixer.W]) 51 | 52 | # RF local oscillator 53 | rf_lo = Source( 54 | p=rf_mixer.S, yoff=50, kind='sine', 55 | name='fo=1230MHz', value='P=10dBm' 56 | ) 57 | Ground(t=rf_lo.n) 58 | Wire([rf_mixer.S, rf_lo.N]) 59 | 60 | # IF band-pass filter 61 | if_bpf = Box(i=rf_mixer.E, xoff=25, name='IF BPF') 62 | l= Label(C=if_bpf.S, loc='s', name='fc=190MHz') 63 | Label(C=l.S, name='BW=22MHz') 64 | Wire([rf_mixer.E, if_bpf.i]) 65 | 66 | # IF amplifier 67 | if_amp = Amp(i=if_bpf.o, xoff=25, name='IF Amp') 68 | Label(C=if_amp.S, loc='s', name='A=20dB') 69 | Wire([if_bpf.o, if_amp.i]) 70 | 71 | # IF mixer 72 | if_mixer = Source(W=if_amp.o, xoff=20, kind='mult') 73 | Label(C=if_mixer.N, loc='n', name='SSB') 74 | Wire([if_amp.o, if_mixer.W]) 75 | 76 | # IF local oscillator 77 | if_lo = Source( 78 | p=if_mixer.S, yoff=50, kind='sine', 79 | name='fo=190MHz', value='P=10dBm' 80 | ) 81 | Ground(t=if_lo.n) 82 | Wire([if_mixer.S, if_lo.p]) 83 | 84 | # Baseband low-pass filter 85 | bb_lpf = Box(i=if_mixer.E, xoff=25, name='BB LPF') 86 | Label(C=bb_lpf.S, loc='s', name='BW=2MHz (var)') 87 | Wire([if_mixer.E, bb_lpf.i]) 88 | 89 | # Analog-to-digital converter 90 | adc = Box(i=bb_lpf.o, xoff=25, name='ADC') 91 | Label(C=adc.S, loc='s', name='Fclk=var') 92 | Wire([bb_lpf.o, adc.i]) 93 | 94 | # Output 95 | bb_out = Pin(t=adc.o, xoff=50, kind='out', name='out', w=1.5) 96 | w = Wire([adc.o, bb_out.t]) 97 | Label(C=w.m, kind='slash', loc='s', name='8') 98 | -------------------------------------------------------------------------------- /examples/Golden/feedback.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | $a$ 20 | 21 | 22 | 23 | 24 | 25 | 26 | $f$ 27 | 28 | 29 | 30 | 31 | 32 | $+$ 33 | 34 | 35 | 36 | 37 | 38 | $-$ 39 | 40 | 41 | 42 | 43 | 44 | 45 | in 46 | 47 | 48 | 49 | 50 | 51 | 52 | out 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | .. _noninverting amplifier: 5 | 6 | Non Inverting Amplifier 7 | ----------------------- 8 | 9 | Here is an example of a typical schematic with exception handling. 10 | 11 | .. include:: ../examples/noninverting.py 12 | :literal: 13 | 14 | .. image:: ../examples/Golden/noninverting.svg 15 | :width: 40% 16 | :align: center 17 | 18 | 19 | Inverting Amplifier 20 | ------------------- 21 | 22 | This schematic uses ``line_width = 1`` give the schematic a lighter look. 23 | It uses a 16 point serif font. 24 | 25 | .. include:: ../examples/inverting.py 26 | :literal: 27 | 28 | .. image:: ../examples/Golden/inverting.svg 29 | :width: 50% 30 | :align: center 31 | 32 | 33 | Charge Pump 34 | ----------- 35 | 36 | This example has a transparent background and so all wires terminate at 37 | terminals rather than passing underneath components. The labels are intended to 38 | be rendered by :ref:`Latex`. 39 | It sets ``line_width`` to 2 give the schematic a heavier look. 40 | 41 | .. include:: ../examples/charge-pump.py 42 | :literal: 43 | 44 | .. image:: ../examples/Golden/charge-pump.svg 45 | :width: 80% 46 | :align: center 47 | 48 | 49 | Inverter 50 | -------- 51 | 52 | This example has a transparent background and so all wires terminate at 53 | terminals rather than passing underneath components. The labels are intended to 54 | be rendered by :ref:`Latex`. 55 | It sets ``line_width`` to 2 give the schematic a heavier look. 56 | 57 | .. include:: ../examples/inverter.py 58 | :literal: 59 | 60 | .. image:: ../examples/Golden/inverter.svg 61 | :width: 30% 62 | :align: center 63 | 64 | 65 | Oscillator 66 | ---------- 67 | 68 | This example has a transparent background and so all wires terminate at 69 | terminals rather than passing underneath components. The labels are intended to 70 | be rendered by :ref:`Latex`. 71 | This schematic uses ``line_width = 2`` give the schematic a heavier look. 72 | 73 | .. include:: ../examples/oscillator.py 74 | :literal: 75 | 76 | .. image:: ../examples/Golden/oscillator.svg 77 | :width: 40% 78 | :align: center 79 | 80 | 81 | Passive Low Pass Filter 82 | ----------------------- 83 | 84 | This example uses `QuantiPhy 85 | `_ to compute the values 86 | for the components in a low pass filter and then constructs the schematic using 87 | those values. It sets ``line_width`` to 2 and employs dots at wire junctions to 88 | give the schematic a heavier look. 89 | 90 | .. include:: ../examples/mfed.py 91 | :literal: 92 | 93 | .. image:: ../examples/Golden/mfed.svg 94 | :width: 80% 95 | :align: center 96 | 97 | 98 | Buck Regulator 99 | -------------- 100 | 101 | This example uses a white dot as a pass-under (on the line that runs from ramp 102 | generator to the comparator. 103 | 104 | .. include:: ../examples/buck.py 105 | :literal: 106 | 107 | .. image:: ../examples/Golden/buck.svg 108 | :width: 100% 109 | :align: center 110 | 111 | 112 | Pipelined ADC 113 | ------------- 114 | 115 | This block diagram has a white background and so could route wires under 116 | components rather than wiring to terminals, but it largely does not. 117 | It uses ``line_width = 2`` give the diagram a heavier look. 118 | 119 | .. include:: ../examples/pipeline-adc.py 120 | :literal: 121 | 122 | .. image:: ../examples/Golden/pipeline-adc.svg 123 | :width: 100% 124 | :align: center 125 | 126 | 127 | Receiver 128 | -------- 129 | 130 | This block diagram has a white background and so could route the wires 131 | underneath the components, but does not. 132 | It uses ``line_width = 2`` give the diagram a heavier look. 133 | It looks small because it is quite wide, and it is scaled to fit the page. 134 | 135 | .. include:: ../examples/receiver.py 136 | :literal: 137 | 138 | .. image:: ../examples/Golden/receiver.svg 139 | :width: 100% 140 | :align: center 141 | 142 | 143 | Network Map 144 | ----------- 145 | 146 | This is another block diagram. 147 | 148 | .. include:: ../examples/network-map.py 149 | :literal: 150 | 151 | .. image:: ../examples/Golden/network-map.svg 152 | :width: 60% 153 | :align: center 154 | -------------------------------------------------------------------------------- /doc/images/box.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 4 bit 13 | Flash 14 | 15 | 16 | 17 | 18 | 19 | 20 | pi 21 | 22 | 23 | 24 | 25 | 26 | 27 | i 28 | 29 | 30 | 31 | 32 | 33 | 34 | ni 35 | 36 | 37 | 38 | 39 | 40 | 41 | po 42 | 43 | 44 | 45 | 46 | 47 | 48 | o 49 | 50 | 51 | 52 | 53 | 54 | 55 | no 56 | 57 | 58 | 59 | 60 | 61 | 62 | 𝘻⁻¹ 63 | 64 | 65 | 66 | 67 | 68 | 69 | i 70 | 71 | 72 | 73 | 74 | 75 | 76 | o 77 | 78 | 79 | -------------------------------------------------------------------------------- /doc/images/bjt.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Qn 17 | 18 | 19 | 20 | 21 | 22 | 23 | c 24 | 25 | 26 | 27 | 28 | 29 | 30 | b 31 | 32 | 33 | 34 | 35 | 36 | 37 | e 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Qp 49 | 50 | 51 | 52 | 53 | 54 | 55 | e 56 | 57 | 58 | 59 | 60 | 61 | 62 | b 63 | 64 | 65 | 66 | 67 | 68 | 69 | c 70 | 71 | 72 | -------------------------------------------------------------------------------- /doc/images/Golden/bjt.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Qn 17 | 18 | 19 | 20 | 21 | 22 | 23 | c 24 | 25 | 26 | 27 | 28 | 29 | 30 | b 31 | 32 | 33 | 34 | 35 | 36 | 37 | e 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Qp 49 | 50 | 51 | 52 | 53 | 54 | 55 | e 56 | 57 | 58 | 59 | 60 | 61 | 62 | b 63 | 64 | 65 | 66 | 67 | 68 | 69 | c 70 | 71 | 72 | -------------------------------------------------------------------------------- /doc/images/amp.py: -------------------------------------------------------------------------------- 1 | from svg_schematic import Schematic, Amp, Converter, Label 2 | from inform import Error, error, os_error 3 | 4 | try: 5 | with Schematic(filename = 'amp.svg'): 6 | origin = (0,0) 7 | a = Amp(C=origin, kind='se', name='As') 8 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 9 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 10 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 11 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 12 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 13 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 14 | 15 | a = Amp(kind='oa', name='Ao', C=a.C, xoff=200) 16 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 17 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 18 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 19 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 20 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 21 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 22 | 23 | a = Amp(kind='da', name='Ad', C=a.C, xoff=200) 24 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 25 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 26 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 27 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 28 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 29 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 30 | 31 | a = Amp(kind='comp', name='Ac', C=a.C, xoff=200) 32 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 33 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 34 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 35 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 36 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 37 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 38 | 39 | a = Converter(C=origin, yoff=150, kind='se', name='Cs') 40 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 41 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 42 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 43 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 44 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 45 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 46 | 47 | a = Converter(kind='oa', name='Co', C=a.C, xoff=200) 48 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 49 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 50 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 51 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 52 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 53 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 54 | 55 | a = Converter(kind='da', name='Cd', C=a.C, xoff=200) 56 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 57 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 58 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 59 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 60 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 61 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 62 | 63 | a = Converter(kind='comp', name='Cc', C=a.C, xoff=200) 64 | Label(C=a.pi, name='pi', loc='w', kind='dot', color='blue', w=2) 65 | Label(C=a.i, name='i', loc='w', kind='dot', color='blue', w=2) 66 | Label(C=a.ni, name='ni', loc='w', kind='dot', color='blue', w=2) 67 | Label(C=a.po, name='po', loc='e', kind='dot', color='blue', w=2) 68 | Label(C=a.o, name='o', loc='e', kind='dot', color='blue', w=2) 69 | Label(C=a.no, name='no', loc='e', kind='dot', color='blue', w=2) 70 | 71 | except Error as e: 72 | e.report() 73 | except OSError as e: 74 | error(os_error(e)) 75 | -------------------------------------------------------------------------------- /doc/images/crossing.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | pi 21 | 22 | 23 | 24 | 25 | 26 | 27 | ni 28 | 29 | 30 | 31 | 32 | 33 | 34 | po 35 | 36 | 37 | 38 | 39 | 40 | 41 | no 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | pi 57 | 58 | 59 | 60 | 61 | 62 | 63 | ni 64 | 65 | 66 | 67 | 68 | 69 | 70 | po 71 | 72 | 73 | 74 | 75 | 76 | 77 | no 78 | 79 | 80 | -------------------------------------------------------------------------------- /doc/images/Golden/crossing.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | pi 21 | 22 | 23 | 24 | 25 | 26 | 27 | ni 28 | 29 | 30 | 31 | 32 | 33 | 34 | po 35 | 36 | 37 | 38 | 39 | 40 | 41 | no 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | pi 57 | 58 | 59 | 60 | 61 | 62 | 63 | ni 64 | 65 | 66 | 67 | 68 | 69 | 70 | po 71 | 72 | 73 | 74 | 75 | 76 | 77 | no 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/Golden/inverting.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | in 13 | 14 | 15 | 16 | 17 | 18 | 19 | out 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Rin 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Rfb 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Vg 77 | 78 | 79 | -------------------------------------------------------------------------------- /doc/images/switch.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | φ₁ 16 | 17 | 18 | 19 | 20 | 21 | 22 | i 23 | 24 | 25 | 26 | 27 | 28 | 29 | ot 30 | 31 | 32 | 33 | 34 | 35 | 36 | o 37 | 38 | 39 | 40 | 41 | 42 | 43 | ob 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | φ₂ 55 | 56 | 57 | 58 | 59 | 60 | 61 | i 62 | 63 | 64 | 65 | 66 | 67 | 68 | ot 69 | 70 | 71 | 72 | 73 | 74 | 75 | o 76 | 77 | 78 | 79 | 80 | 81 | 82 | ob 83 | 84 | 85 | -------------------------------------------------------------------------------- /doc/images/Golden/switch.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | φ₁ 16 | 17 | 18 | 19 | 20 | 21 | 22 | i 23 | 24 | 25 | 26 | 27 | 28 | 29 | ot 30 | 31 | 32 | 33 | 34 | 35 | 36 | o 37 | 38 | 39 | 40 | 41 | 42 | 43 | ob 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | φ₂ 55 | 56 | 57 | 58 | 59 | 60 | 61 | i 62 | 63 | 64 | 65 | 66 | 67 | 68 | ot 69 | 70 | 71 | 72 | 73 | 74 | 75 | o 76 | 77 | 78 | 79 | 80 | 81 | 82 | ob 83 | 84 | 85 | -------------------------------------------------------------------------------- /examples/Golden/inverter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | $V_{\rm in}$ 30 | 31 | 32 | 33 | 34 | 35 | 36 | $V_{\rm out}$ 37 | 38 | 39 | 40 | 41 | 42 | $V_{\rm dd}$ 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | $V_{\rm in}$ 75 | 76 | 77 | 78 | 79 | 80 | 81 | $V_{\rm out}$ 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /examples/Golden/noninverting.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Vin 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Vf 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | out 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | R1 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | R2 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = .build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean show html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | default: html 20 | 21 | help: 22 | @echo "Please use \`make ' where is one of" 23 | @echo " html to make standalone HTML files" 24 | @echo " dirhtml to make HTML files named index.html in directories" 25 | @echo " singlehtml to make a single large HTML file" 26 | @echo " pickle to make pickle files" 27 | @echo " json to make JSON files" 28 | @echo " htmlhelp to make HTML files and a HTML help project" 29 | @echo " qthelp to make HTML files and a qthelp project" 30 | @echo " devhelp to make HTML files and a Devhelp project" 31 | @echo " epub to make an epub" 32 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 33 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 34 | @echo " text to make text files" 35 | @echo " man to make manual pages" 36 | @echo " texinfo to make Texinfo files" 37 | @echo " info to make Texinfo files and run them through makeinfo" 38 | @echo " gettext to make PO message catalogs" 39 | @echo " changes to make an overview of all changed/added/deprecated items" 40 | @echo " linkcheck to check all external links for integrity" 41 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 42 | 43 | clean: 44 | -rm -rf $(BUILDDIR)/* 45 | 46 | html: 47 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 48 | @echo 49 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 50 | 51 | show: html 52 | firefox .build/html/index.html 53 | 54 | dirhtml: 55 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 56 | @echo 57 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 58 | 59 | singlehtml: 60 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 61 | @echo 62 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 63 | 64 | pickle: 65 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 66 | @echo 67 | @echo "Build finished; now you can process the pickle files." 68 | 69 | json: 70 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 71 | @echo 72 | @echo "Build finished; now you can process the JSON files." 73 | 74 | htmlhelp: 75 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 76 | @echo 77 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 78 | ".hhp project file in $(BUILDDIR)/htmlhelp." 79 | 80 | qthelp: 81 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 82 | @echo 83 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 84 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 85 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/avendesora.qhcp" 86 | @echo "To view the help file:" 87 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/avendesora.qhc" 88 | 89 | devhelp: 90 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 91 | @echo 92 | @echo "Build finished." 93 | @echo "To view the help file:" 94 | @echo "# mkdir -p $$HOME/.local/share/devhelp/avendesora" 95 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/avendesora" 96 | @echo "# devhelp" 97 | 98 | epub: 99 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 100 | @echo 101 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 102 | 103 | latex: 104 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 105 | @echo 106 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 107 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 108 | "(use \`make latexpdf' here to do that automatically)." 109 | 110 | latexpdf: 111 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 112 | @echo "Running LaTeX files through pdflatex..." 113 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 114 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 115 | 116 | text: 117 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 118 | @echo 119 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 120 | 121 | man: 122 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 123 | @echo 124 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 125 | 126 | texinfo: 127 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 128 | @echo 129 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 130 | @echo "Run \`make' in that directory to run these through makeinfo" \ 131 | "(use \`make info' here to do that automatically)." 132 | 133 | info: 134 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 135 | @echo "Running Texinfo files through makeinfo..." 136 | make -C $(BUILDDIR)/texinfo info 137 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 138 | 139 | gettext: 140 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 141 | @echo 142 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 143 | 144 | changes: 145 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 146 | @echo 147 | @echo "The overview file is in $(BUILDDIR)/changes." 148 | 149 | linkcheck: 150 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 151 | @echo 152 | @echo "Link check complete; look for any errors in the above output " \ 153 | "or in $(BUILDDIR)/linkcheck/output.txt." 154 | 155 | doctest: 156 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 157 | @echo "Testing of doctests in the sources finished, look at the " \ 158 | "results in $(BUILDDIR)/doctest/output.txt." 159 | -------------------------------------------------------------------------------- /doc/images/mos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Mn 18 | 19 | 20 | 21 | 22 | 23 | 24 | d 25 | 26 | 27 | 28 | 29 | 30 | 31 | g 32 | 33 | 34 | 35 | 36 | 37 | 38 | s 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Mp 51 | 52 | 53 | 54 | 55 | 56 | 57 | s 58 | 59 | 60 | 61 | 62 | 63 | 64 | g 65 | 66 | 67 | 68 | 69 | 70 | 71 | d 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | M 83 | 84 | 85 | 86 | 87 | 88 | 89 | d 90 | 91 | 92 | 93 | 94 | 95 | 96 | g 97 | 98 | 99 | 100 | 101 | 102 | 103 | s 104 | 105 | 106 | -------------------------------------------------------------------------------- /doc/images/Golden/mos.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Mn 18 | 19 | 20 | 21 | 22 | 23 | 24 | d 25 | 26 | 27 | 28 | 29 | 30 | 31 | g 32 | 33 | 34 | 35 | 36 | 37 | 38 | s 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Mp 51 | 52 | 53 | 54 | 55 | 56 | 57 | s 58 | 59 | 60 | 61 | 62 | 63 | 64 | g 65 | 66 | 67 | 68 | 69 | 70 | 71 | d 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | M 83 | 84 | 85 | 86 | 87 | 88 | 89 | d 90 | 91 | 92 | 93 | 94 | 95 | 96 | g 97 | 98 | 99 | 100 | 101 | 102 | 103 | s 104 | 105 | 106 | -------------------------------------------------------------------------------- /doc/images/wires.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | kind='plain' 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | kind='|-' 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | kind='-|' 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | kind='|-|' 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | kind='-|-' 108 | 109 | 110 | -------------------------------------------------------------------------------- /doc/images/Golden/wires.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | kind='plain' 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | kind='|-' 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | kind='-|' 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | kind='|-|' 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | kind='-|-' 108 | 109 | 110 | --------------------------------------------------------------------------------