├── docsrc ├── log ├── make_apidoc ├── _source │ ├── _static │ │ └── pictures │ │ │ ├── Cython.png │ │ │ ├── Macros.png │ │ │ ├── Instance.png │ │ │ ├── Add_new_Lib.png │ │ │ └── Add_new_Lib_2.png │ ├── modules.rst │ ├── source_code │ │ ├── drcsl_source.rst │ │ ├── cleanermain_source.rst │ │ ├── cleanermaster_source.rst │ │ └── cleanerslave_source.rst │ ├── sourcecodes.rst │ ├── drc │ │ ├── cleanermain.rst │ │ ├── drc.rst │ │ ├── cleanerslave.rst │ │ ├── cleanermaster.rst │ │ └── cleaner.rst │ ├── tips.rst │ ├── index.rst │ ├── photonics │ │ ├── photonics.rst │ │ ├── ports.rst │ │ ├── first_steps.rst │ │ └── techfile.rst │ ├── introduction.rst │ └── conf.py ├── Makefile └── make.bat ├── docs ├── .nojekyll ├── _static │ ├── custom.css │ ├── file.png │ ├── minus.png │ ├── plus.png │ ├── background_b01.png │ ├── pictures │ │ ├── Cython.png │ │ ├── Macros.png │ │ ├── Instance.png │ │ ├── Add_new_Lib.png │ │ └── Add_new_Lib_2.png │ ├── documentation_options.js │ ├── bizstyle.js │ ├── pygments.css │ ├── classic.css │ └── sidebar.js ├── objects.inv ├── _images │ ├── Cython.png │ ├── Macros.png │ ├── Instance.png │ ├── Add_new_Lib.png │ ├── Add_new_Lib_2.png │ └── package_format.png ├── KLayoutPhotonicPCells.pdf ├── _sources │ ├── modules.rst.txt │ ├── source_code │ │ ├── drcsl_source.rst.txt │ │ ├── cleanermain_source.rst.txt │ │ ├── cleanermaster_source.rst.txt │ │ └── cleanerslave_source.rst.txt │ ├── sourcecodes.rst.txt │ ├── drc │ │ ├── cleanermain.rst.txt │ │ ├── drc.rst.txt │ │ ├── cleanerslave.rst.txt │ │ ├── cleanermaster.rst.txt │ │ └── cleaner.rst.txt │ ├── tips.rst.txt │ ├── index.rst.txt │ ├── photonics │ │ ├── photonics.rst.txt │ │ ├── ports.rst.txt │ │ ├── first_steps.rst.txt │ │ └── techfile.rst.txt │ └── introduction.rst.txt ├── .buildinfo ├── _modules │ └── index.html ├── search.html ├── drc │ ├── cleanermain.html │ └── cleanerslave.html ├── py-modindex.html ├── sourcecodes.html ├── modules.html ├── tips.html ├── photonics │ ├── ports.html │ └── first_steps.html ├── introduction.html └── index.html ├── .gitattributes ├── icon_128x128.png ├── cpp └── source │ ├── SignalHandler.h │ ├── SignalHandler.cpp │ ├── CleanerMaster.pxd │ ├── setup.py │ ├── setup_cc.py │ ├── cleanermaster.pyx │ ├── CleanerMain.cpp │ ├── DrcSl.pxd │ ├── CleanerMaster.h │ ├── CleanerSlave.h │ ├── slcleaner.pyx │ ├── DrcSl.h │ ├── CleanerSlave.cpp │ └── CleanerMaster.cpp ├── scripts ├── clean_compile.sh ├── clean.sh └── compile.sh ├── README.md ├── pymacros └── AddMenus.lym ├── python └── kppc │ ├── photonics │ ├── phidlpcell.py │ ├── techconstraints.py │ ├── layermaps.py │ └── dataprep.py │ └── __init__.py ├── default-settings.json └── .gitignore /docsrc/log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/_static/custom.css: -------------------------------------------------------------------------------- 1 | /* This file intentionally left blank. */ 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | docs/* linguist-documentation 2 | docsrc/* linguist-documentation 3 | -------------------------------------------------------------------------------- /docsrc/make_apidoc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sphinx-apidoc -f -o ./source/ ../python/ 4 | -------------------------------------------------------------------------------- /docs/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/objects.inv -------------------------------------------------------------------------------- /icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/icon_128x128.png -------------------------------------------------------------------------------- /docs/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/file.png -------------------------------------------------------------------------------- /docs/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/minus.png -------------------------------------------------------------------------------- /docs/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/plus.png -------------------------------------------------------------------------------- /docs/_images/Cython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/Cython.png -------------------------------------------------------------------------------- /docs/_images/Macros.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/Macros.png -------------------------------------------------------------------------------- /docs/_images/Instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/Instance.png -------------------------------------------------------------------------------- /docs/_images/Add_new_Lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/Add_new_Lib.png -------------------------------------------------------------------------------- /docs/KLayoutPhotonicPCells.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/KLayoutPhotonicPCells.pdf -------------------------------------------------------------------------------- /docs/_images/Add_new_Lib_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/Add_new_Lib_2.png -------------------------------------------------------------------------------- /docs/_images/package_format.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_images/package_format.png -------------------------------------------------------------------------------- /docs/_static/background_b01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/background_b01.png -------------------------------------------------------------------------------- /docs/_static/pictures/Cython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/pictures/Cython.png -------------------------------------------------------------------------------- /docs/_static/pictures/Macros.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/pictures/Macros.png -------------------------------------------------------------------------------- /docs/_static/pictures/Instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/pictures/Instance.png -------------------------------------------------------------------------------- /docs/_static/pictures/Add_new_Lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/pictures/Add_new_Lib.png -------------------------------------------------------------------------------- /docs/_static/pictures/Add_new_Lib_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docs/_static/pictures/Add_new_Lib_2.png -------------------------------------------------------------------------------- /docsrc/_source/_static/pictures/Cython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docsrc/_source/_static/pictures/Cython.png -------------------------------------------------------------------------------- /docsrc/_source/_static/pictures/Macros.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docsrc/_source/_static/pictures/Macros.png -------------------------------------------------------------------------------- /docsrc/_source/modules.rst: -------------------------------------------------------------------------------- 1 | Code Documentation 2 | ================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | drc/drc 8 | photonics/photonics 9 | -------------------------------------------------------------------------------- /docs/_sources/modules.rst.txt: -------------------------------------------------------------------------------- 1 | Code Documentation 2 | ================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | drc/drc 8 | photonics/photonics 9 | -------------------------------------------------------------------------------- /docsrc/_source/_static/pictures/Instance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docsrc/_source/_static/pictures/Instance.png -------------------------------------------------------------------------------- /docsrc/_source/_static/pictures/Add_new_Lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docsrc/_source/_static/pictures/Add_new_Lib.png -------------------------------------------------------------------------------- /docsrc/_source/_static/pictures/Add_new_Lib_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastian-goeldi/KLayoutPhotonicPCells-core/HEAD/docsrc/_source/_static/pictures/Add_new_Lib_2.png -------------------------------------------------------------------------------- /docs/_sources/source_code/drcsl_source.rst.txt: -------------------------------------------------------------------------------- 1 | .. _drcslsource: 2 | 3 | DrcSl Source 4 | ============ 5 | 6 | .. literalinclude:: ../../../cpp/source/DrcSl.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docsrc/_source/source_code/drcsl_source.rst: -------------------------------------------------------------------------------- 1 | .. _drcslsource: 2 | 3 | DrcSl Source 4 | ============ 5 | 6 | .. literalinclude:: ../../../cpp/source/DrcSl.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docs/_sources/source_code/cleanermain_source.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cmainsource: 2 | 3 | CleanerMain Source 4 | ^^^^^^^^^^^^^^^^^^ 5 | 6 | .. literalinclude:: ../../../cpp/source/CleanerMain.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docs/_sources/source_code/cleanermaster_source.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cmsource: 2 | 3 | CleanerMaster Source 4 | ==================== 5 | 6 | .. literalinclude:: ../../../cpp/source/DrcSl.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docs/_sources/source_code/cleanerslave_source.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cssource: 2 | 3 | CleanerSlave Source 4 | =================== 5 | 6 | .. literalinclude:: ../../../cpp/source/CleanerSlave.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docsrc/_source/source_code/cleanermain_source.rst: -------------------------------------------------------------------------------- 1 | .. _cmainsource: 2 | 3 | CleanerMain Source 4 | ^^^^^^^^^^^^^^^^^^ 5 | 6 | .. literalinclude:: ../../../cpp/source/CleanerMain.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docsrc/_source/source_code/cleanermaster_source.rst: -------------------------------------------------------------------------------- 1 | .. _cmsource: 2 | 3 | CleanerMaster Source 4 | ==================== 5 | 6 | .. literalinclude:: ../../../cpp/source/DrcSl.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docsrc/_source/source_code/cleanerslave_source.rst: -------------------------------------------------------------------------------- 1 | .. _cssource: 2 | 3 | CleanerSlave Source 4 | =================== 5 | 6 | .. literalinclude:: ../../../cpp/source/CleanerSlave.cpp 7 | :language: c++ 8 | -------------------------------------------------------------------------------- /docs/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 941b8f0505f0631368fe974c443efed3 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docsrc/_source/sourcecodes.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | C++ Source Code 3 | =============== 4 | 5 | .. toctree:: 6 | 7 | source_code/drcsl_source 8 | source_code/cleanermaster_source 9 | source_code/cleanermain_source 10 | source_code/cleanerslave_source 11 | -------------------------------------------------------------------------------- /docs/_sources/sourcecodes.rst.txt: -------------------------------------------------------------------------------- 1 | =============== 2 | C++ Source Code 3 | =============== 4 | 5 | .. toctree:: 6 | 7 | source_code/drcsl_source 8 | source_code/cleanermaster_source 9 | source_code/cleanermain_source 10 | source_code/cleanerslave_source 11 | -------------------------------------------------------------------------------- /cpp/source/SignalHandler.h: -------------------------------------------------------------------------------- 1 | class SignalHandler 2 | { 3 | public: 4 | SignalHandler(); 5 | ~SignalHandler(); 6 | 7 | bool setSignalToHandle(int sig); 8 | static bool isSignalSet(); 9 | static void setSignal(int unused); 10 | 11 | private: 12 | static bool signalSet; 13 | 14 | }; -------------------------------------------------------------------------------- /scripts/clean_compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Script that compiles the C++ scanline algorithm with cython to a python module and copies it into the current folder 4 | #If there is an __init__.py in the folder the setup script will create subfolders, so avoid that 5 | 6 | cd "$(dirname "$0")" 7 | 8 | sh ./clean 9 | sh ./compile.sh 10 | -------------------------------------------------------------------------------- /docsrc/_source/drc/cleanermain.rst: -------------------------------------------------------------------------------- 1 | .. _cmain: 2 | 3 | 4 | CleanerMain 5 | ^^^^^^^^^^^ 6 | 7 | C++ documentation of the cleanermain. This program is a simple program with a loop that processes any layers added to the shared memory. If the process receives `SIGUSER1`, it joins the threads and terminates afterwards. 8 | 9 | 10 | Source: :ref:`cmainsource` 11 | -------------------------------------------------------------------------------- /docs/_sources/drc/cleanermain.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cmain: 2 | 3 | 4 | CleanerMain 5 | ^^^^^^^^^^^ 6 | 7 | C++ documentation of the cleanermain. This program is a simple program with a loop that processes any layers added to the shared memory. If the process receives `SIGUSER1`, it joins the threads and terminates afterwards. 8 | 9 | 10 | Source: :ref:`cmainsource` 11 | -------------------------------------------------------------------------------- /docs/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '1.1.0', 4 | LANGUAGE: 'None', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | HAS_SOURCE: true, 9 | SOURCELINK_SUFFIX: '.txt', 10 | NAVIGATION_WITH_KEYS: false 11 | }; -------------------------------------------------------------------------------- /scripts/clean.sh: -------------------------------------------------------------------------------- 1 | cd "$(dirname "$0")" 2 | 3 | rm -r ../python/kppc/drc/__pycache__ 4 | rm ../python/kppc/photonics/__pycache__ 5 | rm -r ../cpp/source/build 6 | rm ../cpp/source/cleanermaster.cpp 7 | rm ../cpp/source/slcleaner.cpp 8 | rm -r ../cpp/source/build 9 | rm -r ../cpp/build 10 | rm ../python/kppc/drc/*.cpy* 11 | rm ../python/kppc/drc/slcleaner.cp* 12 | rm ../python/kppc/drc/cleanermaster.cp* 13 | -------------------------------------------------------------------------------- /docs/_sources/tips.rst.txt: -------------------------------------------------------------------------------- 1 | Tips & Tricks 2 | ============= 3 | 4 | Variable Names in KLayout Python 5 | -------------------------------- 6 | 7 | When using global variables in pymacros (scripts like cell libraries) be careful. Namespace is shared between macros. This means when for example defining the names of metal layers in two cells, one can overwrite the other one. 8 | Therefore the use of global variables is not advised and the use of a wrapper class is recommended instead. It can be defined in the same wrapper class used for defining layernames and cleaning information, for example. 9 | -------------------------------------------------------------------------------- /docsrc/_source/tips.rst: -------------------------------------------------------------------------------- 1 | Tips & Tricks 2 | ============= 3 | 4 | Variable Names in KLayout Python 5 | -------------------------------- 6 | 7 | When using global variables in pymacros (scripts like cell libraries) be careful. Namespace is shared between macros. This means when for example defining the names of metal layers in two cells, one can overwrite the other one. 8 | Therefore the use of global variables is not advised and the use of a wrapper class is recommended instead. It can be defined in the same wrapper class used for defining layernames and cleaning information, for example. 9 | -------------------------------------------------------------------------------- /cpp/source/SignalHandler.cpp: -------------------------------------------------------------------------------- 1 | #include "SignalHandler.h" 2 | #include "signal.h" 3 | 4 | using namespace std; 5 | 6 | bool SignalHandler::signalSet = false; 7 | 8 | SignalHandler::SignalHandler() 9 | { 10 | } 11 | 12 | SignalHandler::~SignalHandler() 13 | { 14 | } 15 | 16 | bool SignalHandler::setSignalToHandle(int sig) 17 | { 18 | if(signal(sig, SignalHandler::setSignal) == SIG_ERR) { 19 | return false; 20 | } 21 | return true; 22 | } 23 | 24 | void SignalHandler::setSignal(int unused) 25 | { 26 | signalSet = true; 27 | } 28 | 29 | bool SignalHandler::isSignalSet() 30 | { 31 | return signalSet; 32 | } 33 | -------------------------------------------------------------------------------- /cpp/source/CleanerMaster.pxd: -------------------------------------------------------------------------------- 1 | # distutils: language=c++ 2 | 3 | from libcpp.vector cimport vector 4 | from libcpp.pair cimport pair 5 | 6 | cdef extern from "CleanerMaster.cpp": 7 | pass 8 | 9 | cdef extern from "CleanerMaster.h" namespace "drclean": 10 | cdef cppclass CleanerMaster: 11 | CleanerMaster() except + 12 | CleanerMaster(int nlayers) except + 13 | 14 | int set_box(int layer, int datatype, int violation_width, int violation_space, int x1, int x2, int y1, int y2) 15 | void add_edge(int x1, int x2, int y1, int y2) 16 | int done() 17 | vector[vector[int]] get_layer() 18 | vector[vector[pair[int,int]]] get_polygons() 19 | -------------------------------------------------------------------------------- /docs/_sources/drc/drc.rst.txt: -------------------------------------------------------------------------------- 1 | drc Module 2 | =========== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: kppc.drc 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | Submodules 13 | ---------- 14 | 15 | .. include:: cleaner.rst 16 | 17 | 18 | Multiprocessing 19 | --------------- 20 | 21 | With version 0.1.0 multiprocessing was introduced. Multiprocessing allows to use all threads of the machine to process the DRC cleaning on all threads of the CPU in parallel. This can give a considerable speed boost if multiple layers are involved and the hardware supports it. 22 | 23 | .. include:: cleanermaster.rst 24 | .. include:: cleanermain.rst 25 | .. include:: cleanerslave.rst 26 | -------------------------------------------------------------------------------- /docsrc/_source/drc/drc.rst: -------------------------------------------------------------------------------- 1 | drc Module 2 | =========== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: kppc.drc 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | 12 | Submodules 13 | ---------- 14 | 15 | .. include:: cleaner.rst 16 | 17 | 18 | Multiprocessing 19 | --------------- 20 | 21 | With version 0.1.0 multiprocessing was introduced. Multiprocessing allows to use all threads of the machine to process the DRC cleaning on all threads of the CPU in parallel. This can give a considerable speed boost if multiple layers are involved and the hardware supports it. 22 | 23 | .. include:: cleanermaster.rst 24 | .. include:: cleanermain.rst 25 | .. include:: cleanerslave.rst 26 | -------------------------------------------------------------------------------- /scripts/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Script that compiles the C++ scanline algorithm with cython to a python module and copies it into the current folder 4 | #If there is an __init__.py in the folder the setup script will create subfolders, so avoid that 5 | cd "$(dirname "$0")"/../cpp/source 6 | echo $(pwd) 7 | mkdir -p ../build 8 | 9 | DRCDIR="../../python/kppc/drc/" 10 | 11 | python3 setup.py build_ext -b $DRCDIR & 12 | python3 setup_cc.py build_ext -b $DRCDIR & 13 | g++ CleanerMain.cpp CleanerSlave.cpp DrcSl.cpp SignalHandler.cpp -o ../build/cleanermain -isystem /usr/include/boost/ -lboost_system -pthread -lboost_thread -lrt 14 | 15 | #/usr/bin/python3 setup.py build_ext -b ./ 16 | #cp slcleaner.cpython* ../ 17 | 18 | -------------------------------------------------------------------------------- /cpp/source/setup.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # cython: language_level=3 3 | 4 | from distutils.core import setup 5 | from distutils.extension import Extension 6 | from Cython.Build import cythonize 7 | from Cython.Distutils import build_ext 8 | 9 | ext_module = cythonize([Extension('slcleaner', 10 | ['slcleaner.pyx'], 11 | extra_compile_args=["--std=c++14"], 12 | extra_link_args=["--std=c++14"], 13 | language='c++')], force=True) 14 | 15 | for e in ext_module: 16 | e.cython_directives = {'embedsignature': True} 17 | 18 | setup( 19 | name='Design Rule Cleaner based on Scanline Algorithm', 20 | cmdclass={'build_ext': build_ext}, 21 | ext_modules=ext_module 22 | ) 23 | -------------------------------------------------------------------------------- /docsrc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = PhotonicPCellLibraryExtension 8 | SOURCEDIR = _source 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | pdf: 18 | @make latexpdf 19 | @cp -a _build/latex/*.pdf ../docs 20 | @make clean 21 | github: 22 | @make html 23 | @cp -a _build/html/. ../docs 24 | @make clean 25 | # Catch-all target: route all unknown targets to Sphinx using the new 26 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 27 | %: Makefile 28 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 29 | -------------------------------------------------------------------------------- /docsrc/_source/drc/cleanerslave.rst: -------------------------------------------------------------------------------- 1 | .. _cs: 2 | 3 | CleanerSlave 4 | ^^^^^^^^^^^^ 5 | 6 | C++ Class 7 | """"""""" 8 | 9 | .. cpp:class:: CleanerSlave 10 | 11 | 12 | .. cpp:member:: void CleanerSlave() 13 | 14 | Constructor of the Class 15 | The constructor opens the shared memory and initializes the allocators for the shared memory. Initializes a boost thread_pool with as many threads as the CPU supports (one per core). 16 | 17 | 18 | .. cpp:member:: void clean() 19 | 20 | Checks if the shared memory has a cell layer added. If there is a layer to process, move the data to shared memory and schedule it for processing by the thread_pool. 21 | 22 | 23 | .. cpp:member:: void join_threads() 24 | 25 | Wait for the thread_pool to finish all jobs and return 26 | 27 | Source Code: :ref:`cssource` 28 | -------------------------------------------------------------------------------- /docs/_sources/drc/cleanerslave.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cs: 2 | 3 | CleanerSlave 4 | ^^^^^^^^^^^^ 5 | 6 | C++ Class 7 | """"""""" 8 | 9 | .. cpp:class:: CleanerSlave 10 | 11 | 12 | .. cpp:member:: void CleanerSlave() 13 | 14 | Constructor of the Class 15 | The constructor opens the shared memory and initializes the allocators for the shared memory. Initializes a boost thread_pool with as many threads as the CPU supports (one per core). 16 | 17 | 18 | .. cpp:member:: void clean() 19 | 20 | Checks if the shared memory has a cell layer added. If there is a layer to process, move the data to shared memory and schedule it for processing by the thread_pool. 21 | 22 | 23 | .. cpp:member:: void join_threads() 24 | 25 | Wait for the thread_pool to finish all jobs and return 26 | 27 | Source Code: :ref:`cssource` 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KLayoutPhotonicPCells-core 2 | KLayoutPhotonicPCells core Package 3 | 4 | This package extends KLayout with photonic PCells. Namely it provides the possibility to create ports. Ports in comparison to pins of electronics have additionally to the position also a direction and length. Furthermore, this package allows to build hierarchical PCells. These allow instantiating other PCells and connect them via ports or position them relativ to the coordinate system of the parent PCell. 5 | 6 | The full documentation is in the [docs](https://github.com/sebastian-goeldi/KLayoutPhotonicPCells-core/blob/master/docs/) folder. It is available as a sphinx html documentation at docs/index.html . A [pdf](https://github.com/sebastian-goeldi/KLayoutPhotonicPCells-core/blob/master/docs/KLayoutPhotonicPCells.pdf) version is available in the docs folder, too. 7 | 8 | Online documentation is available on [GitHub Pages](https://sebastian-goeldi.github.io/KLayoutPhotonicPCells-core/) 9 | -------------------------------------------------------------------------------- /cpp/source/setup_cc.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | # cython: language_level=3 3 | 4 | from distutils.core import setup 5 | from distutils.extension import Extension 6 | from Cython.Build import cythonize 7 | from Cython.Distutils import build_ext 8 | 9 | ext_module = cythonize([Extension('cleanermaster', 10 | ['cleanermaster.pyx'], 11 | extra_compile_args=["--std=c++14"], 12 | extra_link_args=["--std=c++14"], 13 | language='c++', 14 | libraries=['rt', 'boost_thread'], 15 | # libraries_dirs=['/lib/x86_64-linux-gnu/'] 16 | )], force=True) 17 | 18 | for e in ext_module: 19 | e.cython_directives = {'embedsignature': True} 20 | 21 | setup( 22 | name='Client to submit polygons to Engine', 23 | cmdclass={'build_ext': build_ext}, 24 | ext_modules=ext_module 25 | ) 26 | -------------------------------------------------------------------------------- /docsrc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=PhotonicPCellLibraryExtension 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /docs/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. Photonic PCell Library Extension documentation master file, created by 2 | sphinx-quickstart on Fri Sep 14 14:48:05 2018. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ============================================== 7 | Photonic PCell Library Extension Documentation 8 | ============================================== 9 | 10 | KLayout Photonic PCells introduces the concept of ports to KLayout. Ports in contrast to pins also track directions. Additionally, PCells can be built hierarchically from other PCells and new shapes. The sub-cells can be connected to each other through ports. 11 | 12 | The source code can be found on `Github `_ 13 | 14 | .. toctree:: 15 | :maxdepth: 3 16 | :caption: Contents: 17 | 18 | introduction 19 | photonics/first_steps 20 | photonics/ports 21 | photonics/techfile 22 | modules 23 | photonics/example_library 24 | tips 25 | sourcecodes 26 | 27 | Glossary: 28 | 29 | * :ref:`genindex` 30 | * :ref:`modindex` 31 | * :ref:`search` 32 | -------------------------------------------------------------------------------- /docsrc/_source/index.rst: -------------------------------------------------------------------------------- 1 | .. Photonic PCell Library Extension documentation master file, created by 2 | sphinx-quickstart on Fri Sep 14 14:48:05 2018. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ============================================== 7 | Photonic PCell Library Extension Documentation 8 | ============================================== 9 | 10 | KLayout Photonic PCells introduces the concept of ports to KLayout. Ports in contrast to pins also track directions. Additionally, PCells can be built hierarchically from other PCells and new shapes. The sub-cells can be connected to each other through ports. 11 | 12 | The source code can be found on `Github `_ 13 | 14 | .. toctree:: 15 | :maxdepth: 3 16 | :caption: Contents: 17 | 18 | introduction 19 | photonics/first_steps 20 | photonics/ports 21 | photonics/techfile 22 | modules 23 | photonics/example_library 24 | tips 25 | sourcecodes 26 | 27 | Glossary: 28 | 29 | * :ref:`genindex` 30 | * :ref:`modindex` 31 | * :ref:`search` 32 | -------------------------------------------------------------------------------- /pymacros/AddMenus.lym: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pymacros 6 | 7 | 8 | 9 | true 10 | false 11 | 12 | false 13 | 14 | 15 | python 16 | 17 | import pya 18 | from pathlib import Path 19 | import kppc.menu 20 | import kppc 21 | 22 | # Main 23 | 24 | kppc.menu.set_settings() 25 | 26 | iconpath = Path(__file__).parent.parent/"icon_128x128.png" 27 | app = pya.Application.instance() 28 | menu = app.main_window().menu() 29 | #menu.insert_menu("@toolbar.end","KPP","PhotonicPCells") 30 | open_settings = lambda : kppc.settingsdialog.Dialog(pya.Application.instance().main_window()) 31 | kppc_action = pya.Action() 32 | kppc_action.title = "KLayout Photonic PCells Settings" 33 | kppc_action.on_triggered = kppc.menu.dialog 34 | kppc_action.icon = str(iconpath) 35 | kppc_action.icon_text = "KPPC" 36 | menu.insert_item("@toolbar.end","KPPC",kppc_action) 37 | #menu.insert_item("@toolbar.KPP.end","Settings",kppc_action) 38 | 39 | -------------------------------------------------------------------------------- /cpp/source/cleanermaster.pyx: -------------------------------------------------------------------------------- 1 | # distutils: language=c++ 2 | # cython: language_level=3 3 | 4 | from CleanerMaster cimport CleanerMaster 5 | from libcpp.vector cimport vector 6 | from libcpp.pair cimport pair 7 | 8 | cdef extern from "" namespace "std" nogil: 9 | T move[T](T) 10 | 11 | cdef class PyCleanerMaster: 12 | cdef CleanerMaster c_cc 13 | 14 | def __cint__(self, nlayers : int): 15 | self.c_cc = CleanerMaster(nlayers) 16 | 17 | def set_box(self, layer : int, datatype : int, violation_width : int, violation_space : int, x1 : int, x2 : int, 18 | y1 : int, y2 : int): 19 | return self.c_cc.set_box(layer, datatype, violation_width, violation_space, x1, x2, y1, y2) 20 | 21 | def add_edge(self, x1 : int, x2 : int, y1 : int, y2 : int): 22 | self.c_cc.add_edge(x1, x2, y1, y2) 23 | 24 | def done(self): 25 | return self.c_cc.done() 26 | 27 | def get_layer(self): 28 | # arr = np.array([[]], dtype=np.int) 29 | cdef vector[vector[int]] res 30 | res = move(self.c_cc.get_layer()) 31 | return res 32 | 33 | def polygons(self): 34 | cdef vector[vector[pair[int,int]]] polygons 35 | polygons = move(self.c_cc.get_polygons()) 36 | return polygons 37 | -------------------------------------------------------------------------------- /python/kppc/photonics/phidlpcell.py: -------------------------------------------------------------------------------- 1 | from kppc.photonics import PhotDevice,PortCreation 2 | from lygadgets.cell_translation import anyCell_to_anyCell as actac 3 | 4 | class Device(PhotDevice): 5 | 6 | def __init__(self): 7 | PhotDevice.__init__(self) 8 | self.pcellinstances = [] 9 | self.dev=None 10 | 11 | def device(self): 12 | self.dev = None 13 | #raise ImplentationError('This function must be implemented by the cell and define self.device as a phild.Device') 14 | 15 | def shapes(self): 16 | self.dev = None 17 | self.pcellinstances = [] 18 | self.device() 19 | if self.dev is not None: 20 | actac(self.dev,self.cell) 21 | 22 | def create_param_inst(self): 23 | self.dev = None 24 | self.pcellinstances = [] 25 | self.device() 26 | if self.dev is not None: 27 | ports = [] 28 | for i in self.dev.ports: 29 | p = self.dev.ports[i] 30 | ports.append(PortCreation(p.midpoint[0],p.midpoint[1],int(p.orientation),p.width,name=i)) 31 | return ports,self.pcellinstances 32 | else: 33 | return self.pcellinstances 34 | 35 | def add_pcell(self,params,n=1): 36 | instance = self.add_pcell_variant(params,number=n) 37 | self.pcellinstances.append(instance) 38 | return instance -------------------------------------------------------------------------------- /docs/_static/bizstyle.js: -------------------------------------------------------------------------------- 1 | // 2 | // bizstyle.js 3 | // ~~~~~~~~~~~ 4 | // 5 | // Sphinx javascript -- for bizstyle theme. 6 | // 7 | // This theme was created by referring to 'sphinxdoc' 8 | // 9 | // :copyright: Copyright 2012-2014 by Sphinx team, see AUTHORS. 10 | // :license: BSD, see LICENSE for details. 11 | // 12 | $(document).ready(function(){ 13 | if (navigator.userAgent.indexOf('iPhone') > 0 || 14 | navigator.userAgent.indexOf('Android') > 0) { 15 | $("li.nav-item-0 a").text("Top"); 16 | } 17 | 18 | $("div.related:first ul li:not(.right) a").slice(1).each(function(i, item){ 19 | if (item.text.length > 20) { 20 | var tmpstr = item.text 21 | $(item).attr("title", tmpstr); 22 | $(item).text(tmpstr.substr(0, 17) + "..."); 23 | } 24 | }); 25 | $("div.related:last ul li:not(.right) a").slice(1).each(function(i, item){ 26 | if (item.text.length > 20) { 27 | var tmpstr = item.text 28 | $(item).attr("title", tmpstr); 29 | $(item).text(tmpstr.substr(0, 17) + "..."); 30 | } 31 | }); 32 | }); 33 | 34 | $(window).resize(function(){ 35 | if ($(window).width() <= 776) { 36 | $("li.nav-item-0 a").text("Top"); 37 | } 38 | else { 39 | $("li.nav-item-0 a").text("KLayout Photonic PCells 1.1.0 documentation"); 40 | } 41 | }); -------------------------------------------------------------------------------- /docsrc/_source/photonics/photonics.rst: -------------------------------------------------------------------------------- 1 | photonics Module 2 | ================= 3 | 4 | This package is a library extension for KLayout to provide functionalities for photonic structures. 5 | 6 | .. warning:: KLayout does not check if a loaded module has changed during runtime and thus does not reread/recompile it. 7 | This means you either must manually reload the library if you want to do it during runtime. Generally, it is easier and 8 | safer to close and reopen KLayout. 9 | 10 | If this extension is modified (or any file in a ``/python`` directory), don't forget to either reload the module or 11 | reopen KLayout. 12 | 13 | .. note:: To reload a module during runtime use the following commands in the KLayout python console (not guaranteed to work in all cases): 14 | 15 | >>> from importlib import reload 16 | >>> import 17 | >>> reload() 18 | 19 | Module contents 20 | --------------- 21 | 22 | .. automodule:: kppc.photonics 23 | :members: 24 | :undoc-members: 25 | :show-inheritance: 26 | 27 | Submodules 28 | ---------- 29 | 30 | photonics.dataprep module 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | .. automodule:: kppc.photonics.dataprep 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | photonics.layermaps module 39 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | .. automodule:: kppc.photonics.layermaps 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | -------------------------------------------------------------------------------- /docs/_sources/photonics/photonics.rst.txt: -------------------------------------------------------------------------------- 1 | photonics Module 2 | ================= 3 | 4 | This package is a library extension for KLayout to provide functionalities for photonic structures. 5 | 6 | .. warning:: KLayout does not check if a loaded module has changed during runtime and thus does not reread/recompile it. 7 | This means you either must manually reload the library if you want to do it during runtime. Generally, it is easier and 8 | safer to close and reopen KLayout. 9 | 10 | If this extension is modified (or any file in a ``/python`` directory), don't forget to either reload the module or 11 | reopen KLayout. 12 | 13 | .. note:: To reload a module during runtime use the following commands in the KLayout python console (not guaranteed to work in all cases): 14 | 15 | >>> from importlib import reload 16 | >>> import 17 | >>> reload() 18 | 19 | Module contents 20 | --------------- 21 | 22 | .. automodule:: kppc.photonics 23 | :members: 24 | :undoc-members: 25 | :show-inheritance: 26 | 27 | Submodules 28 | ---------- 29 | 30 | photonics.dataprep module 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | .. automodule:: kppc.photonics.dataprep 34 | :members: 35 | :undoc-members: 36 | :show-inheritance: 37 | 38 | photonics.layermaps module 39 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | .. automodule:: kppc.photonics.layermaps 42 | :members: 43 | :undoc-members: 44 | :show-inheritance: 45 | -------------------------------------------------------------------------------- /default-settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "General": { 3 | "Progressbar": true, 4 | "_Progressbar_DESC": "Show progressbars while calculating", 5 | "SettingsVersion": "1.0.6", 6 | "_Settings_DESC": "Version. Detect if newer default settings are available", 7 | "Debug": false, 8 | "_Debug_DESC": "Show debug information in cells, such as the portlist and transformations" 9 | }, 10 | "Multithreading": { 11 | "Enabled": true, 12 | "_Enabled_DESC": "Multi Threading (KPPC will create its own process which does the cleaning)", 13 | "Automatic": true, 14 | "_Automatic_DESC": "Automatically set number of threads to number of CPU cores", 15 | "Threads": 4, 16 | "_Threads_DESC": "Number of threads to use if Automatic is disabled", 17 | "_Threads_MIN": 1, 18 | "_Threads_MAX": 32 19 | }, 20 | "Logging": { 21 | "Enabled": true, 22 | "_Enabled_DESC": "Enable Logging to File and Stream (Console)", 23 | "_StreamLevel_DESC": "Log Level of Stream (Console)", 24 | "StreamLevel": [ 25 | 3, 26 | "DEBUG", 27 | "INFO", 28 | "WARNING", 29 | "ERROR", 30 | "CRITICAL" 31 | ], 32 | "_LogfileLevel_DESC": "Log Level for File Logging", 33 | "LogfileLevel": [ 34 | 2, 35 | "DEBUG", 36 | "INFO", 37 | "WARNING", 38 | "ERROR", 39 | "CRITICAL" 40 | ] 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /docsrc/_source/photonics/ports.rst: -------------------------------------------------------------------------------- 1 | Ports 2 | ===== 3 | 4 | Ports are a concept used in photonics. They are very similar to pins in electronics, as they both describe connections 5 | between cells. The big difference between ports and pins is ports have additional properties that are important 6 | for photonics. When connecting photonic devices it is necessary that the device connections are aligned. For example, if 7 | two waveguides are connected, the connected endings have to point on the opposite direction and the connections have to 8 | be the same size. 9 | 10 | This module implements the concept of ports into KLayout PCells. Currently ports track location, orientation and length. 11 | If two ports have a mismatch in width, they cannot be connected. New ports can be created in PCells with the 12 | :class:`kppc.photonics.PortCreation` when overriding the :meth:`kppc.photonics.PhotDevice.create_param_inst` method 13 | in the PCell Library. If any instantiated child cells in a PCell have any open ports (not connected to another port of another 14 | child cell), they are passed upwards to the cell itself and are announced as ports of this cell. 15 | This hierarchical design allows to create arbitrary Devices independent of the order when assembling them. 16 | 17 | .. note:: Make sure ports are drawn correctly. If texts in ports aren't oriented alond the width of the port, set the boolean 18 | `Transform text with cell instance` in :menuselection:`File --> Setup --> Display --> Cells` to true 19 | and make sure the text font is not set to the default font. 20 | -------------------------------------------------------------------------------- /docs/_sources/photonics/ports.rst.txt: -------------------------------------------------------------------------------- 1 | Ports 2 | ===== 3 | 4 | Ports are a concept used in photonics. They are very similar to pins in electronics, as they both describe connections 5 | between cells. The big difference between ports and pins is ports have additional properties that are important 6 | for photonics. When connecting photonic devices it is necessary that the device connections are aligned. For example, if 7 | two waveguides are connected, the connected endings have to point on the opposite direction and the connections have to 8 | be the same size. 9 | 10 | This module implements the concept of ports into KLayout PCells. Currently ports track location, orientation and length. 11 | If two ports have a mismatch in width, they cannot be connected. New ports can be created in PCells with the 12 | :class:`kppc.photonics.PortCreation` when overriding the :meth:`kppc.photonics.PhotDevice.create_param_inst` method 13 | in the PCell Library. If any instantiated child cells in a PCell have any open ports (not connected to another port of another 14 | child cell), they are passed upwards to the cell itself and are announced as ports of this cell. 15 | This hierarchical design allows to create arbitrary Devices independent of the order when assembling them. 16 | 17 | .. note:: Make sure ports are drawn correctly. If texts in ports aren't oriented alond the width of the port, set the boolean 18 | `Transform text with cell instance` in :menuselection:`File --> Setup --> Display --> Cells` to true 19 | and make sure the text font is not set to the default font. 20 | -------------------------------------------------------------------------------- /cpp/source/CleanerMain.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | // Copyright (c) 2018, Sebastian Goeldi 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | #include "CleanerSlave.h" 18 | #include 19 | 20 | int main(int argc, char* argv[]) 21 | { 22 | drclean::CleanerSlave* cs; 23 | if(argc < 2) 24 | { 25 | cs = new drclean::CleanerSlave(); 26 | } else if(argc == 2) { 27 | cs = new drclean::CleanerSlave(std::stoi(argv[1])); 28 | } 29 | 30 | 31 | if (!cs->initialized) 32 | { 33 | return -1; 34 | } 35 | 36 | SignalHandler signalHandler; 37 | signalHandler.setSignalToHandle(SIGUSR1); 38 | 39 | while(!signalHandler.isSignalSet()) 40 | { 41 | cs->clean(); 42 | } 43 | 44 | // Cleanup 45 | cs->join_threads(); 46 | delete cs; 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /docsrc/_source/introduction.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | The KLayoutPhotonicPCells`kppc` module is an extension for KLayout PCells to facilitate photonic PCells. 5 | Photonics often works with the concept of ports. 6 | Ports are defined by a coordinate and a direction. In the case of this module ports will be stored in PCell parameters in the background. 7 | They are serialized `KLayout Trans`_ objects. For an introduction on how to build your own PCell Library, have a look at 8 | how to create :doc:`Example Library `. 9 | 10 | When building PCell Libraries it is recommended to build it with three packages as shown in :numref:`p_format` 11 | 12 | .. figure:: _static/pictures/package_format.svg 13 | :name: p_format 14 | :width: 100 % 15 | :alt: The intended use for this library extension is to work with 3 packages per PCell-Library. First this one, second a technology specific 16 | package which contains techfile and import from techfile and finally the PCell Library. 17 | 18 | The recommend structure for working with the photonic PCell extension: 19 | * Photonic Library Extension: New functionalities for KLayout PCells 20 | 21 | * Ports, DR-Cleaning, DataPrep 22 | 23 | * Technology: Contains manufacturer specific data 24 | 25 | * Design rules 26 | * Layermapping from abstract to manufacturer layers 27 | 28 | * PCell-Library: 29 | 30 | * Definitions of PCells 31 | * Library specific modules if required 32 | 33 | 34 | .. _KLayout Trans: https://www.klayout.de/doc/code/class_ICplxTrans.html 35 | -------------------------------------------------------------------------------- /docs/_sources/introduction.rst.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | The KLayoutPhotonicPCells`kppc` module is an extension for KLayout PCells to facilitate photonic PCells. 5 | Photonics often works with the concept of ports. 6 | Ports are defined by a coordinate and a direction. In the case of this module ports will be stored in PCell parameters in the background. 7 | They are serialized `KLayout Trans`_ objects. For an introduction on how to build your own PCell Library, have a look at 8 | how to create :doc:`Example Library `. 9 | 10 | When building PCell Libraries it is recommended to build it with three packages as shown in :numref:`p_format` 11 | 12 | .. figure:: _static/pictures/package_format.svg 13 | :name: p_format 14 | :width: 100 % 15 | :alt: The intended use for this library extension is to work with 3 packages per PCell-Library. First this one, second a technology specific 16 | package which contains techfile and import from techfile and finally the PCell Library. 17 | 18 | The recommend structure for working with the photonic PCell extension: 19 | * Photonic Library Extension: New functionalities for KLayout PCells 20 | 21 | * Ports, DR-Cleaning, DataPrep 22 | 23 | * Technology: Contains manufacturer specific data 24 | 25 | * Design rules 26 | * Layermapping from abstract to manufacturer layers 27 | 28 | * PCell-Library: 29 | 30 | * Definitions of PCells 31 | * Library specific modules if required 32 | 33 | 34 | .. _KLayout Trans: https://www.klayout.de/doc/code/class_ICplxTrans.html 35 | -------------------------------------------------------------------------------- /cpp/source/DrcSl.pxd: -------------------------------------------------------------------------------- 1 | # This file is part of KLayoutPhotonicPcells, an extension for Photonic Layouts in KLayout. 2 | # Copyright (c) 2018, Sebastian Goeldi 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | 17 | # distutils: language=c++ 18 | from libcpp.vector cimport vector 19 | from libcpp cimport bool 20 | 21 | 22 | cdef extern from "DrcSl.cpp": 23 | pass 24 | 25 | cdef extern from "DrcSl.h" namespace "drclean": 26 | cdef cppclass DrcSl: 27 | DrcSl() except + 28 | 29 | void initialize_list(int, int, int, int, int, int) 30 | void add_data(int x1, int x2, int y1, int y2) 31 | void sortlist() 32 | void clean(int max_tries) 33 | 34 | bool list_cleaning() 35 | int clean_space() 36 | int clean_width() 37 | void switch_dimensions() 38 | void printvector(int beg, int ende) 39 | 40 | vector[int] get_vect(int ind) 41 | vector[int] get_types(int ind) 42 | vector[vector[int]] get_lines() 43 | int violation_width 44 | int violation_space 45 | int hor1 46 | int hor2 47 | int ver1 48 | int ver2 49 | int s() 50 | -------------------------------------------------------------------------------- /python/kppc/__init__.py: -------------------------------------------------------------------------------- 1 | import json 2 | from pathlib import Path 3 | import logging 4 | import logging.handlers 5 | 6 | 7 | class JSONObject: 8 | def __init__(self, dic): 9 | vars(self).update(dic) 10 | 11 | settings_path = Path(__file__).resolve().parent.parent.parent / "settings.json" 12 | defaultsettings_path = Path(__file__).resolve().parent.parent.parent / "default-settings.json" 13 | 14 | def load_settings(path): 15 | obj = None 16 | try: 17 | with open(path, 'r') as infile: 18 | obj = json.load(infile, object_hook=JSONObject) 19 | return obj 20 | except: 21 | return None 22 | 23 | default = load_settings(defaultsettings_path) 24 | settings = load_settings(settings_path) 25 | if settings is None: 26 | settings = default 27 | else: 28 | ask = False 29 | if settings.General.SettingsVersion is None: 30 | ask = True 31 | curversion = [int(x) for x in settings.General.SettingsVersion.split('.')] 32 | defversion = [int(x) for x in default.General.SettingsVersion.split('.')] 33 | for i,j in zip(curversion,defversion): 34 | if j > i: 35 | ask = True 36 | if ask: 37 | pass 38 | #ask for replacement of option 39 | 40 | 41 | logfile_path = settings_path.parent / "kppc.log" 42 | logger = logging.getLogger('KPPC') 43 | logger.setLevel(logging.DEBUG) 44 | _fh = logging.handlers.RotatingFileHandler(logfile_path, maxBytes=32768, backupCount=4) 45 | _ch = logging.StreamHandler() 46 | _fh.setLevel(logging.getLevelName(settings.Logging.LogfileLevel[1:][settings.Logging.LogfileLevel[0]])) 47 | _ch.setLevel(logging.getLevelName(settings.Logging.StreamLevel[1:][settings.Logging.StreamLevel[0]])) 48 | _formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: %(message)s') 49 | _fh.setFormatter(_formatter) 50 | _ch.setFormatter(_formatter) 51 | 52 | logger.addHandler(_fh) 53 | logger.addHandler(_ch) -------------------------------------------------------------------------------- /python/kppc/photonics/techconstraints.py: -------------------------------------------------------------------------------- 1 | # This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | # Copyright (c) 2018, Sebastian Goeldi 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | 17 | # Simple function to read the minWidth/minSpacings from the techfile 18 | 19 | import re 20 | import os 21 | 22 | 23 | def load_from_tech(techfile: str): 24 | 25 | read = False 26 | 27 | tech = {} 28 | 29 | with open(techfile, 'r') as thefile: 30 | for i, line in enumerate(thefile): 31 | if ';spacings' in line: 32 | read = False 33 | continue 34 | if 'spacings' in line: 35 | read = True 36 | continue 37 | if ';orderedSpacings' in line: 38 | read = False 39 | continue 40 | if 'orderedSpacings' in line: 41 | read = True 42 | continue 43 | 44 | if read: 45 | l = line.strip() 46 | lyst = l.split() 47 | for key in lyst[2:-2]: 48 | k = key.strip('"') 49 | if k not in tech: 50 | tech[k] = {} 51 | tech[k][lyst[1]]=float(lyst[-2]) 52 | return tech -------------------------------------------------------------------------------- /docsrc/_source/photonics/first_steps.rst: -------------------------------------------------------------------------------- 1 | First Steps 2 | =========== 3 | 4 | Prerequisites 5 | ------------- 6 | 7 | To use the library extension, make sure you have installed Cython. Part of the cleaning process relies on a C++ module that needs to be compiled first. To compile it we use pythons :doc:`Setuptools ` and :doc:`Cython `. Make sure you have these packages before starting. It is sufficient to install Cython, as setuptools is either built-in of python or installed along Cython. 8 | 9 | Installation 10 | ------------ 11 | 12 | This installation procedure is solely written for Linux. For this installation Cython is required. So get Cython either from the package manager of your distribution or through pip. The package is tested on Python 3.5+. No special python3 modules are used, therefore it should work with python 2.7, too. The Python version used should be the same KLayout uses. By default, this is the system interpreter for Python3. 13 | If you installed the package manually, move the unpackaged package into ``~/.klayout/salt`` or into the KLayout folder if you used a custom directory. This tutorial assumes default pathes. 14 | After unpacking and moving you should have a ``~/.klayout/salt/KLayouPhotonicPCells/core`` folder. If you installed the FreePDK45_Cells & FreePDK45_tech, then you should have the folders ``~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_ExampleCells`` and ``~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_tech``, too. The library extension package needs manual setup before being usable. 15 | 16 | Use a console and execute the following commands. If you are familiar with setuptools you can skip these instructions. For further information consult the :py:mod:`drc` documentation. 17 | 18 | .. code-block:: console 19 | 20 | cd ~/.klayout/salt/KLayouPhotonicPCells/cor/python/kppc/drc/ 21 | sh compile.sh 22 | 23 | .. figure:: ../_static/pictures/Cython.png 24 | :width: 100 % 25 | :alt: Compile the C++Python module with Cython 26 | 27 | Change directory to the drc folder and execute the setup script. 28 | 29 | -------------------------------------------------------------------------------- /docs/_sources/photonics/first_steps.rst.txt: -------------------------------------------------------------------------------- 1 | First Steps 2 | =========== 3 | 4 | Prerequisites 5 | ------------- 6 | 7 | To use the library extension, make sure you have installed Cython. Part of the cleaning process relies on a C++ module that needs to be compiled first. To compile it we use pythons :doc:`Setuptools ` and :doc:`Cython `. Make sure you have these packages before starting. It is sufficient to install Cython, as setuptools is either built-in of python or installed along Cython. 8 | 9 | Installation 10 | ------------ 11 | 12 | This installation procedure is solely written for Linux. For this installation Cython is required. So get Cython either from the package manager of your distribution or through pip. The package is tested on Python 3.5+. No special python3 modules are used, therefore it should work with python 2.7, too. The Python version used should be the same KLayout uses. By default, this is the system interpreter for Python3. 13 | If you installed the package manually, move the unpackaged package into ``~/.klayout/salt`` or into the KLayout folder if you used a custom directory. This tutorial assumes default pathes. 14 | After unpacking and moving you should have a ``~/.klayout/salt/KLayouPhotonicPCells/core`` folder. If you installed the FreePDK45_Cells & FreePDK45_tech, then you should have the folders ``~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_ExampleCells`` and ``~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_tech``, too. The library extension package needs manual setup before being usable. 15 | 16 | Use a console and execute the following commands. If you are familiar with setuptools you can skip these instructions. For further information consult the :py:mod:`drc` documentation. 17 | 18 | .. code-block:: console 19 | 20 | cd ~/.klayout/salt/KLayouPhotonicPCells/cor/python/kppc/drc/ 21 | sh compile.sh 22 | 23 | .. figure:: ../_static/pictures/Cython.png 24 | :width: 100 % 25 | :alt: Compile the C++Python module with Cython 26 | 27 | Change directory to the drc folder and execute the setup script. 28 | 29 | -------------------------------------------------------------------------------- /python/kppc/photonics/layermaps.py: -------------------------------------------------------------------------------- 1 | # This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | # Copyright (c) 2018, Sebastian Goeldi 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | 17 | 18 | def load(filename: 'str'): 19 | """ 20 | Simple routine to read a .layermap file into a dictionary 21 | 22 | :param filename: Filename with path 23 | :type filename: str 24 | :return: Dictionary of dictionaries in the form of {layer: {purpose1:(layer_number,purpose_number), 25 | purpose2:(layer_number1,purpose_number2)},layer2: {...} } 26 | :rtype: dict 27 | 28 | :Examples: 29 | >>> import kppc.photonics.layermaps as lm 30 | >>> lm.load(os.path.expanduser('~/.klayout/salt/zccmos/FreePDK45_tech/tech/FreePDK45.layermap')) 31 | {'pwell': {'blockage': ('109', '1'), 'drawing': ('109', '0')}, ... } 32 | """ 33 | if filename.split('.')[-1] != 'layermap': 34 | filename += '.layermap' 35 | layers = {} 36 | 37 | with open(filename, 'r') as thefile: 38 | for line in thefile: 39 | strings = line.split() 40 | if strings[0][0] == ';': 41 | continue 42 | else: 43 | if strings[0] in layers: 44 | layers[strings[0]][strings[1]] = (int(strings[2]), int(strings[3])) 45 | else: 46 | layers[strings[0]] = {strings[1]: (int(strings[2]), int(strings[3]))} 47 | return layers 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.[gG][dD][sS] 2 | *.[tT][fF] 3 | *.[lL][yY][pP] 4 | 5 | # cython 6 | slcleaner.cpp 7 | python/drc/source/build/ 8 | .idea 9 | *.o 10 | cleaner_engine 11 | cleaner_client.o 12 | cleaner_client.cpp 13 | cleanermaster.cpp 14 | cleanerslave.cpp 15 | cleanermain 16 | 17 | # From template https://github.com/github/gitignore/blob/master/Python.gitignore 18 | 19 | # Byte-compiled / optimized / DLL files 20 | __pycache__/ 21 | *.py[cod] 22 | *$py.class 23 | 24 | # C extensions 25 | *.so 26 | 27 | # Distribution / packaging 28 | .Python 29 | #build/ 30 | develop-eggs/ 31 | dist/ 32 | downloads/ 33 | eggs/ 34 | .eggs/ 35 | lib/ 36 | lib64/ 37 | parts/ 38 | sdist/ 39 | var/ 40 | wheels/ 41 | share/python-wheels/ 42 | *.egg-info/ 43 | .installed.cfg 44 | *.egg 45 | MANIFEST 46 | 47 | # PyInstaller 48 | # Usually these files are written by a python script from a template 49 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 50 | *.manifest 51 | *.spec 52 | 53 | # Installer logs 54 | pip-log.txt 55 | pip-delete-this-directory.txt 56 | 57 | # Unit test / coverage reports 58 | htmlcov/ 59 | .tox/ 60 | .nox/ 61 | .coverage 62 | .coverage.* 63 | .cache 64 | nosetests.xml 65 | coverage.xml 66 | *.cover 67 | .hypothesis/ 68 | .pytest_cache/ 69 | 70 | # Translations 71 | *.mo 72 | *.pot 73 | 74 | # Django stuff: 75 | *.log 76 | local_settings.py 77 | db.sqlite3 78 | 79 | # Flask stuff: 80 | instance/ 81 | .webassets-cache 82 | 83 | # Scrapy stuff: 84 | .scrapy 85 | 86 | # Sphinx documentation 87 | docs/_build/ 88 | 89 | # PyBuilder 90 | target/ 91 | 92 | # Jupyter Notebook 93 | .ipynb_checkpoints 94 | 95 | # IPython 96 | profile_default/ 97 | ipython_config.py 98 | 99 | # pyenv 100 | .python-version 101 | 102 | # celery beat schedule file 103 | celerybeat-schedule 104 | 105 | # SageMath parsed files 106 | *.sage.py 107 | 108 | # Environments 109 | .env 110 | .venv 111 | env/ 112 | venv/ 113 | ENV/ 114 | env.bak/ 115 | venv.bak/ 116 | 117 | # Spyder project settings 118 | .spyderproject 119 | .spyproject 120 | 121 | # Rope project settings 122 | .ropeproject 123 | 124 | # mkdocs documentation 125 | /site 126 | 127 | # mypy 128 | .mypy_cache/ 129 | .dmypy.json 130 | dmypy.json 131 | 132 | # Pyre type checker 133 | .pyre/ 134 | 135 | # KDevelop4 136 | *.kdev4 137 | 138 | # Log Files 139 | *.log 140 | *.log.* 141 | 142 | #settingfile 143 | settings.json 144 | -------------------------------------------------------------------------------- /cpp/source/CleanerMaster.h: -------------------------------------------------------------------------------- 1 | // This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | // Copyright (c) 2018, Sebastian Goeldi 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | #ifndef CC_H 18 | #define CC_H 19 | 20 | #include 21 | #include "DrcSl.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include //std::system 29 | #include 30 | #include 31 | 32 | 33 | namespace bi = boost::interprocess; 34 | 35 | typedef std::pair pi; 36 | 37 | typedef bi::allocator ShmemAllocatorInt; 38 | typedef bi::vector ShIVector; 39 | typedef bi::allocator ShmemAllocatorIVec; 40 | typedef bi::vector ShIVVector; 41 | typedef bi::allocator ShmemAllocatorPair; 42 | typedef bi::vector ShPVector; 43 | typedef bi::allocator ShmemAllocatorPVec; 44 | typedef bi::vector ShPVVector; 45 | 46 | namespace drclean 47 | { 48 | 49 | class CleanerMaster 50 | { 51 | 52 | public: 53 | CleanerMaster(); 54 | CleanerMaster(int nlayers); 55 | virtual ~CleanerMaster(); 56 | 57 | int set_box(int layer, int datatype, int violation_width, int violation_space, int x1, int x2, int y1, int y2); 58 | void add_edge(int x1, int x2, int y1, int y2); 59 | int done(); 60 | 61 | std::vector> get_layer(); 62 | bi::managed_shared_memory* segment; 63 | std::vector> get_polygons(); 64 | 65 | private: 66 | 67 | std::vector local_input; 68 | ShmemAllocatorInt* alloc_inst; 69 | ShIVector *input; 70 | ShIVector *outList; 71 | bi::named_mutex* mux_inp; 72 | bi::named_mutex* mux_out; 73 | ShPVVector *polygons; 74 | 75 | }; 76 | } 77 | 78 | #endif // CC_H 79 | -------------------------------------------------------------------------------- /cpp/source/CleanerSlave.h: -------------------------------------------------------------------------------- 1 | // This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | // Copyright (c) 2018, Sebastian Goeldi 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | #ifndef CE_H 18 | #define CE_H 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | #include 36 | #include //std::system 37 | 38 | #include 39 | 40 | #include "DrcSl.h" 41 | #include "SignalHandler.h" 42 | 43 | #include 44 | 45 | #include 46 | #include 47 | 48 | namespace bi = boost::interprocess; 49 | 50 | typedef std::pair pi; 51 | 52 | typedef bi::allocator ShmemAllocatorInt; 53 | typedef bi::vector ShIVector; 54 | 55 | typedef bi::allocator ShmemAllocatorIVec; 56 | typedef bi::vector ShIVVector; 57 | 58 | typedef bi::allocator ShmemAllocatorPair; 59 | typedef bi::vector ShPVector; 60 | typedef bi::allocator ShmemAllocatorPVec; 61 | typedef bi::vector ShPVVector; 62 | 63 | namespace drclean 64 | { 65 | 66 | class CleanerSlave 67 | { 68 | 69 | public: 70 | CleanerSlave(); 71 | CleanerSlave(int nthreads); 72 | virtual ~CleanerSlave(); 73 | bool initialized = false; 74 | void clean(); 75 | void join_threads(); 76 | 77 | private: 78 | bi::managed_shared_memory* segment; 79 | 80 | ShmemAllocatorInt* alloc_inst; 81 | ShmemAllocatorIVec* alloc_vec; 82 | ShmemAllocatorPVec* alloc_pvec; 83 | ShmemAllocatorPair* alloc_poly; 84 | 85 | ShIVector* input; 86 | ShIVector* outList; 87 | 88 | ShPVVector* polygons; 89 | 90 | bi::named_mutex* mux_inp; 91 | bi::named_mutex* mux_out; 92 | 93 | void threaded_DrcSl(std::vector *inp); 94 | 95 | boost::asio::thread_pool * pool; 96 | 97 | }; 98 | 99 | } 100 | 101 | #endif //CE_H 102 | -------------------------------------------------------------------------------- /docs/_sources/drc/cleanermaster.rst.txt: -------------------------------------------------------------------------------- 1 | .. _cm: 2 | 3 | kppc.drc.cleanermaster module 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | Wrapper Class for CleanerMaster.cpp 7 | 8 | This Class creates a managed shared memory space. Polygon data for cleaning are streamed into this memory space. A slave process (cleanermain, which is a little loop for CleanerSlave.cpp). 9 | 10 | Python Class 11 | """""""""""" 12 | 13 | .. class:: PyCleanerMaster 14 | 15 | .. method:: add_edge(self, x1 : int, x2 : int, y1 : int, y2 : int) 16 | 17 | Add an edge to the cleaner. 18 | 19 | :param x1: first x coordinate 20 | :type x1: :integers: 21 | :param x2: second x coordinate 22 | :type x2: :integers: 23 | :param y1: first y coordinate 24 | :type y1: :integers: 25 | :param y2: second y coordinate 26 | :type y2: :integers: 27 | 28 | .. method:: done(self) 29 | 30 | Indicates whether there is data still in the buffer from the last read or not. 31 | 32 | :return: false if the buffer is empty and the data has been read by the slave. 33 | :rtype: bool 34 | 35 | .. method:: get_layer(self) 36 | 37 | Read the next processed layer in the memory space and returns it in per line style (x coordinates per line (y coordinate)). This is considerably slower than returning the polygons. 38 | 39 | .. method:: polygons(self) 40 | 41 | Reads the next processed layer in the memory and assembles the line style to polygons. 42 | 43 | .. method:: set_box(self, layer : int, datatype : int, violation_width : int, violation_space : int, x1 : int, x2 : int, y1 : int, y2 : int) 44 | 45 | Allocate enough space in the shared memory to stream the cell and its polygons in. 46 | 47 | :param layer: layer number 48 | :param datatype: datatype number 49 | :type layer: :integers: 50 | :param viospace: minimum space violation in database units 51 | :type viospace: minimum space violation in database units 52 | :param viowidth: minimum width violation in database units 53 | :type viowidth: minimum width violation in database units 54 | :param x1: left bound of box 55 | :type x1: :integers: 56 | :param x2: right bound of box 57 | :type x2: :integers: 58 | :param y1: bottom bound of box 59 | :type y1: :integers: 60 | :param y2: top bound of box 61 | :type y2: :integers: 62 | 63 | C++ Class 64 | """"""""" 65 | 66 | 67 | .. cpp:class:: CleanerMaster 68 | 69 | .. cpp:function:: CleanerMaster(int nlayers) 70 | 71 | Creates the shared memory space and resizes the vectors for nlayers 72 | 73 | .. cpp:function:: void set_box(int layer, int datatype, int violation_width, int violation_space, int x1, int x2, int y1, int y2) 74 | 75 | Allocate enough space in the shared memory to stream the cell and its polygons in. 76 | 77 | .. cpp:function:: void add_edge(int x1, int x2, int y1, int y2) 78 | 79 | Add an edge to the cleaner. 80 | 81 | .. cpp:function:: bool done() 82 | 83 | Indicates whether there is data still in the buffer from the last read or not. 84 | 85 | .. cpp:function:: std::vector> get_layer() 86 | 87 | Read the next processed layer in the memory space and returns it in per line style (x coordinates per line (y coordinate)). 88 | 89 | .. cpp:function:: std::vector>> get_polygons() 90 | 91 | Reads the next processed layer in the memory and assembles the line style to polygons. 92 | 93 | 94 | 95 | C++ Source Code: :ref:`cmsource` 96 | -------------------------------------------------------------------------------- /docsrc/_source/drc/cleanermaster.rst: -------------------------------------------------------------------------------- 1 | .. _cm: 2 | 3 | kppc.drc.cleanermaster module 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | Wrapper Class for CleanerMaster.cpp 7 | 8 | This Class creates a managed shared memory space. Polygon data for cleaning are streamed into this memory space. A slave process (cleanermain, which is a little loop for CleanerSlave.cpp). 9 | 10 | Python Class 11 | """""""""""" 12 | 13 | .. class:: PyCleanerMaster 14 | 15 | .. method:: add_edge(self, x1 : int, x2 : int, y1 : int, y2 : int) 16 | 17 | Add an edge to the cleaner. 18 | 19 | :param x1: first x coordinate 20 | :type x1: :integers: 21 | :param x2: second x coordinate 22 | :type x2: :integers: 23 | :param y1: first y coordinate 24 | :type y1: :integers: 25 | :param y2: second y coordinate 26 | :type y2: :integers: 27 | 28 | .. method:: done(self) 29 | 30 | Indicates whether there is data still in the buffer from the last read or not. 31 | 32 | :return: false if the buffer is empty and the data has been read by the slave. 33 | :rtype: bool 34 | 35 | .. method:: get_layer(self) 36 | 37 | Read the next processed layer in the memory space and returns it in per line style (x coordinates per line (y coordinate)). This is considerably slower than returning the polygons. 38 | 39 | .. method:: polygons(self) 40 | 41 | Reads the next processed layer in the memory and assembles the line style to polygons. 42 | 43 | .. method:: set_box(self, layer : int, datatype : int, violation_width : int, violation_space : int, x1 : int, x2 : int, y1 : int, y2 : int) 44 | 45 | Allocate enough space in the shared memory to stream the cell and its polygons in. 46 | 47 | :param layer: layer number 48 | :param datatype: datatype number 49 | :type layer: :integers: 50 | :param viospace: minimum space violation in database units 51 | :type viospace: minimum space violation in database units 52 | :param viowidth: minimum width violation in database units 53 | :type viowidth: minimum width violation in database units 54 | :param x1: left bound of box 55 | :type x1: :integers: 56 | :param x2: right bound of box 57 | :type x2: :integers: 58 | :param y1: bottom bound of box 59 | :type y1: :integers: 60 | :param y2: top bound of box 61 | :type y2: :integers: 62 | 63 | C++ Class 64 | """"""""" 65 | 66 | 67 | .. cpp:class:: CleanerMaster 68 | 69 | .. cpp:function:: CleanerMaster(int nlayers) 70 | 71 | Creates the shared memory space and resizes the vectors for nlayers 72 | 73 | .. cpp:function:: void set_box(int layer, int datatype, int violation_width, int violation_space, int x1, int x2, int y1, int y2) 74 | 75 | Allocate enough space in the shared memory to stream the cell and its polygons in. 76 | 77 | .. cpp:function:: void add_edge(int x1, int x2, int y1, int y2) 78 | 79 | Add an edge to the cleaner. 80 | 81 | .. cpp:function:: bool done() 82 | 83 | Indicates whether there is data still in the buffer from the last read or not. 84 | 85 | .. cpp:function:: std::vector> get_layer() 86 | 87 | Read the next processed layer in the memory space and returns it in per line style (x coordinates per line (y coordinate)). 88 | 89 | .. cpp:function:: std::vector>> get_polygons() 90 | 91 | Reads the next processed layer in the memory and assembles the line style to polygons. 92 | 93 | 94 | 95 | C++ Source Code: :ref:`cmsource` 96 | -------------------------------------------------------------------------------- /docs/_modules/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Overview: module code — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 37 | 51 | 52 |
53 |
54 |
55 |
56 | 57 |

All modules for which code is available

58 | 64 | 65 |
66 |
67 |
68 |
69 |
70 | 82 | 86 | 87 | -------------------------------------------------------------------------------- /docs/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Search — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 42 | 46 | 47 |
48 |
49 |
50 |
51 | 52 |

Search

53 |
54 | 55 |

56 | Please activate JavaScript to enable the search 57 | functionality. 58 |

59 |
60 |

61 | From here you can search these documents. Enter your search 62 | words into the box below and click "search". Note that the search 63 | function will automatically search for all of the words. Pages 64 | containing fewer words won't appear in the result list. 65 |

66 |
67 | 68 | 69 | 70 |
71 | 72 |
73 | 74 |
75 | 76 |
77 |
78 |
79 |
80 |
81 | 93 | 97 | 98 | -------------------------------------------------------------------------------- /docs/drc/cleanermain.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | CleanerMain — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 37 | 58 | 59 |
60 |
61 |
62 |
63 | 64 |
65 |

CleanerMain

66 |

C++ documentation of the cleanermain. This program is a simple program with a loop that processes any layers added to the shared memory. If the process receives SIGUSER1, it joins the threads and terminates afterwards.

67 |

Source: CleanerMain Source

68 |
69 | 70 | 71 |
72 |
73 |
74 |
75 |
76 | 88 | 92 | 93 | -------------------------------------------------------------------------------- /docs/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ 8 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 9 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 10 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */ 11 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 12 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 13 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 14 | .highlight .ge { font-style: italic } /* Generic.Emph */ 15 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 16 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 17 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 18 | .highlight .go { color: #333333 } /* Generic.Output */ 19 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 20 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 21 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 22 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 23 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 24 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 25 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 26 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 27 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 28 | .highlight .kt { color: #902000 } /* Keyword.Type */ 29 | .highlight .m { color: #208050 } /* Literal.Number */ 30 | .highlight .s { color: #4070a0 } /* Literal.String */ 31 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 32 | .highlight .nb { color: #007020 } /* Name.Builtin */ 33 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 34 | .highlight .no { color: #60add5 } /* Name.Constant */ 35 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 36 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 37 | .highlight .ne { color: #007020 } /* Name.Exception */ 38 | .highlight .nf { color: #06287e } /* Name.Function */ 39 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 40 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 41 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 42 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 43 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 44 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 45 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 46 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 47 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 48 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 49 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 50 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */ 51 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 52 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 53 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ 54 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 55 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 56 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 57 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 58 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 59 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 60 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 61 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 62 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 63 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 64 | .highlight .fm { color: #06287e } /* Name.Function.Magic */ 65 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 66 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 67 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 68 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ 69 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docsrc/_source/drc/cleaner.rst: -------------------------------------------------------------------------------- 1 | .. _slcleaner: 2 | 3 | kppc.drc.slcleaner module 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | 7 | An interface to the DrcSl.cpp Class. 8 | 9 | .. class:: kppc.drc.slcleaner.PyDrcSl 10 | 11 | 12 | .. method:: def add_data(x1, x2, y1, y2) 13 | 14 | Insert data into the scanline cleaner. The data is an edge that will be manhattanized and cleaned. 15 | 16 | .. note:: Edges should be added in such a way that the 17 | outwards face is left in the direction of p1 to p2. 18 | Klayout already does this nicely. 19 | 20 | :param x1: x position of p1 of the edge 21 | :type x1: int 22 | :param x2: y position of p1 of the edge 23 | :type x2: int 24 | :param y1: x position of p2 of the edge 25 | :type y1: int 26 | :param y2: y position of p2 of the edge 27 | :type y2: int 28 | 29 | .. method:: clean(x = 10) 30 | 31 | Clean data in the vector for space and width violations. 32 | 33 | :param x: number of max tries 34 | 35 | 36 | .. method:: clean_space() 37 | 38 | Clean the current data for space violations. 39 | 40 | .. method:: clean_width() 41 | 42 | Clean the current data for width violations. 43 | 44 | .. method:: init_list(x1: int, x2: int, y1: int, y2: int, viospace: int, viowidth: int) 45 | 46 | (Re-)Initialize the Cleaner. x1,2 and y1,2 define the bounding box of the cleaner. 47 | 48 | .. warning :: 49 | 50 | If a corner or a complete edge is outside the bounding box and is added through the add_data function, a Segmentation Fault will most likely occur and the module (including Klayout) crashes. Alternatively, it will just be confined to the bounding box and the rest will be cut off. 51 | 52 | :param x1: left bound of box 53 | :type x1: int 54 | :param x2: right bound of box 55 | :type x2: int 56 | :param y1: bottom bound of box 57 | :type y1: int 58 | :param y2: top bound of box 59 | :type y2: int 60 | :param viospace: minimum space violation in database units 61 | :type viospace: minimum space violation in database units 62 | :param viowidth: minimum width violation in database units 63 | :type viowidth: minimum width violation in database units 64 | 65 | .. method:: get_row(ind: int) 66 | 67 | Get the edge data back to python from the C++ object. 68 | 69 | :param ind: index of the row to retrieve data from 70 | :type ind: int 71 | :return: numpy array of the edges 72 | 73 | .. method:: get_row_types(ind: int) 74 | 75 | Get the type of edges in that row. 76 | 77 | :param ind: index of the row 78 | :type ind: int 79 | :return: numpy array of types of edges (0 for upwards facing edge, 1 for downwards) 80 | 81 | .. method:: polygons() 82 | 83 | Returns list of crude polygons. The format is list of polygons, where a polygon is a list of tuples of (x,y) 84 | 85 | :return: polygons in the form [[(x1,y1),(x2,y2),...],...] 86 | :return_type: list 87 | 88 | .. method:: printvector(beg = -1, end = -1) 89 | 90 | Print the data of rows/columns depending on current orientation 91 | 92 | :param beg: beginning of the rows/columns that should be printed 93 | :type beg: int 94 | :param end: ending of the rows/columns that should be printed 95 | :type end: int 96 | 97 | .. method:: s() 98 | 99 | This property can be used to get the array size of the cleaner. 100 | 101 | :return: Size of the array of vectors. 102 | :rtype: int 103 | 104 | .. method:: sort() 105 | 106 | Sort the data in ascending order. This will also delete invalid edges, i.e. touching / overlapping polygons will be merged. 107 | 108 | .. method:: switch_dimensions() 109 | 110 | Switch the orientation of the data. From row oriented to column oriented and vice-versa. 111 | 112 | This wrapper is used to expose the design rule cleaner class to the python PCells of KLayout. 113 | The algorithm is pasted below. The algorithm uses a `Scanline Rendering Algorithm `_ 114 | to first convert the polygons from KLayout to manhattanized edges and then add them into an array representation 115 | of the polygon edges. 116 | 117 | 118 | Source Code: :ref:`drcslsource` 119 | -------------------------------------------------------------------------------- /docs/_sources/drc/cleaner.rst.txt: -------------------------------------------------------------------------------- 1 | .. _slcleaner: 2 | 3 | kppc.drc.slcleaner module 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | 7 | An interface to the DrcSl.cpp Class. 8 | 9 | .. class:: kppc.drc.slcleaner.PyDrcSl 10 | 11 | 12 | .. method:: def add_data(x1, x2, y1, y2) 13 | 14 | Insert data into the scanline cleaner. The data is an edge that will be manhattanized and cleaned. 15 | 16 | .. note:: Edges should be added in such a way that the 17 | outwards face is left in the direction of p1 to p2. 18 | Klayout already does this nicely. 19 | 20 | :param x1: x position of p1 of the edge 21 | :type x1: int 22 | :param x2: y position of p1 of the edge 23 | :type x2: int 24 | :param y1: x position of p2 of the edge 25 | :type y1: int 26 | :param y2: y position of p2 of the edge 27 | :type y2: int 28 | 29 | .. method:: clean(x = 10) 30 | 31 | Clean data in the vector for space and width violations. 32 | 33 | :param x: number of max tries 34 | 35 | 36 | .. method:: clean_space() 37 | 38 | Clean the current data for space violations. 39 | 40 | .. method:: clean_width() 41 | 42 | Clean the current data for width violations. 43 | 44 | .. method:: init_list(x1: int, x2: int, y1: int, y2: int, viospace: int, viowidth: int) 45 | 46 | (Re-)Initialize the Cleaner. x1,2 and y1,2 define the bounding box of the cleaner. 47 | 48 | .. warning :: 49 | 50 | If a corner or a complete edge is outside the bounding box and is added through the add_data function, a Segmentation Fault will most likely occur and the module (including Klayout) crashes. Alternatively, it will just be confined to the bounding box and the rest will be cut off. 51 | 52 | :param x1: left bound of box 53 | :type x1: int 54 | :param x2: right bound of box 55 | :type x2: int 56 | :param y1: bottom bound of box 57 | :type y1: int 58 | :param y2: top bound of box 59 | :type y2: int 60 | :param viospace: minimum space violation in database units 61 | :type viospace: minimum space violation in database units 62 | :param viowidth: minimum width violation in database units 63 | :type viowidth: minimum width violation in database units 64 | 65 | .. method:: get_row(ind: int) 66 | 67 | Get the edge data back to python from the C++ object. 68 | 69 | :param ind: index of the row to retrieve data from 70 | :type ind: int 71 | :return: numpy array of the edges 72 | 73 | .. method:: get_row_types(ind: int) 74 | 75 | Get the type of edges in that row. 76 | 77 | :param ind: index of the row 78 | :type ind: int 79 | :return: numpy array of types of edges (0 for upwards facing edge, 1 for downwards) 80 | 81 | .. method:: polygons() 82 | 83 | Returns list of crude polygons. The format is list of polygons, where a polygon is a list of tuples of (x,y) 84 | 85 | :return: polygons in the form [[(x1,y1),(x2,y2),...],...] 86 | :return_type: list 87 | 88 | .. method:: printvector(beg = -1, end = -1) 89 | 90 | Print the data of rows/columns depending on current orientation 91 | 92 | :param beg: beginning of the rows/columns that should be printed 93 | :type beg: int 94 | :param end: ending of the rows/columns that should be printed 95 | :type end: int 96 | 97 | .. method:: s() 98 | 99 | This property can be used to get the array size of the cleaner. 100 | 101 | :return: Size of the array of vectors. 102 | :rtype: int 103 | 104 | .. method:: sort() 105 | 106 | Sort the data in ascending order. This will also delete invalid edges, i.e. touching / overlapping polygons will be merged. 107 | 108 | .. method:: switch_dimensions() 109 | 110 | Switch the orientation of the data. From row oriented to column oriented and vice-versa. 111 | 112 | This wrapper is used to expose the design rule cleaner class to the python PCells of KLayout. 113 | The algorithm is pasted below. The algorithm uses a `Scanline Rendering Algorithm `_ 114 | to first convert the polygons from KLayout to manhattanized edges and then add them into an array representation 115 | of the polygon edges. 116 | 117 | 118 | Source Code: :ref:`drcslsource` 119 | -------------------------------------------------------------------------------- /cpp/source/slcleaner.pyx: -------------------------------------------------------------------------------- 1 | # This file is part of KLayoutPhotonicPcells, an extension for Photonic Layouts in KLayout. 2 | # Copyright (c) 2018, Sebastian Goeldi 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | 17 | # distutils: language=c++ 18 | # cython: language_level=3 19 | 20 | """Hello. 21 | 22 | """ 23 | 24 | 25 | from DrcSl cimport DrcSl 26 | import numpy as np 27 | 28 | # from DrcSl cimport edgecoord 29 | 30 | from libcpp cimport bool 31 | from libcpp.vector cimport vector 32 | 33 | cdef class PyDrcSl: 34 | cdef DrcSl c_sl 35 | 36 | def __cint__(self): 37 | self.c_sl = DrcSl() 38 | 39 | def add_data(self, x1: int, x2: int, y1: int, y2: int): 40 | """Insert data into the scanline cleaner. The data is an edge that will be manhattanised and cleaned. 41 | 42 | .. note :: edges should be added in such a way that the outwards face is left in the direction of p1 to p2. Klayout already does this nicely. 43 | 44 | :param x1: x position of p1 of the edge 45 | :param x2: y position of p1 of the edge 46 | :param y1: x position of p2 of the edge 47 | :param y2: y position of p2 of the edge 48 | """ 49 | self.c_sl.add_data(x1, x2, y1, y2) 50 | 51 | def init_list(self, x1: int, x2: int, y1: int, y2: int, viospace: int, viowidth: int): 52 | """(Re-)Initialize the Cleaner. x1,2 and y1,2 define the bounding box of the cleaner. 53 | 54 | .. warning :: 55 | 56 | If data outside this bounding box is added through the add_data function a Segmentation Fault will 57 | most likely occur and the module (including Klayout) crashes. 58 | 59 | :param x1: left bound of box 60 | :param x2: right bound of box 61 | :param y1: bottom bound of box 62 | :param y2: top bound of box 63 | :param viospace: minimum space violation in database units 64 | :param viowidth: minimum width violation in database units 65 | """ 66 | self.c_sl.initialize_list(x1, x2, y1, y2, viospace, viowidth) 67 | 68 | def sort(self): 69 | """Sort the data in ascending order 70 | """ 71 | self.c_sl.sortlist() 72 | 73 | def clean(self, x: int = 10): 74 | """Clean data in the vector for space and width violations 75 | 76 | :param x: number of max tries 77 | """ 78 | cdef int cx = x 79 | self.c_sl.clean(cx) 80 | 81 | def printvector(self, beg = -1, end = -1): 82 | """Print the data of rows/colums depending on current orientation 83 | 84 | :param beg: begining of the rows/columns that should be printed 85 | :param end: ending of the rows/columns that should be printed 86 | """ 87 | self.c_sl.printvector(beg, end) 88 | 89 | def get_row(self, ind: int): 90 | """Get the edge data back to python from the C++ object. 91 | 92 | :param ind: index of the row to retrieve data from 93 | :return: numpy array of the edges 94 | """ 95 | cdef vector[int] res 96 | res = self.c_sl.get_vect(ind) 97 | return np.array(res, dtype=int) 98 | 99 | def get_row_types(self, ind: int): 100 | """Get the type of edges in that row. 101 | 102 | :param ind: index of the row 103 | :return: numpy array of types of edges (0 for upwards facing edge, 1 for downwards) 104 | """ 105 | cdef vector[int] res 106 | res = self.c_sl.get_types(ind) 107 | return np.array(res, dtype=int) 108 | 109 | def clean_space(self): 110 | """Clean the current data for space violations. 111 | """ 112 | self.c_sl.clean_space() 113 | 114 | def clean_width(self): 115 | """Clean the current data for width violations. 116 | """ 117 | self.c_sl.clean_width() 118 | 119 | def switch_dimensions(self): 120 | """Switch the orientation of the data. From row oriented to column oriented and vice-versa. 121 | """ 122 | self.c_sl.switch_dimensions() 123 | 124 | @property 125 | def s(self): 126 | """This property can be used to get the array size of the cleaner. 127 | 128 | :return: Size of the array of vectors. 129 | :rtype: int 130 | """ 131 | return self.c_sl.s() 132 | @s.setter 133 | def s(self, s): 134 | raise ValueError('cannot set the dimensions. it is automatically calculated') 135 | -------------------------------------------------------------------------------- /docs/py-modindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Python Module Index — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 40 | 54 | 55 |
56 |
57 |
58 |
59 | 60 | 61 |

Python Module Index

62 | 63 |
64 | k 65 |
66 | 67 | 68 | 69 | 71 | 72 | 74 | 77 | 78 | 79 | 82 | 83 | 84 | 87 | 88 | 89 | 92 | 93 | 94 | 97 |
 
70 | k
75 | kppc 76 |
    80 | kppc.drc 81 |
    85 | kppc.photonics 86 |
    90 | kppc.photonics.dataprep 91 |
    95 | kppc.photonics.layermaps 96 |
98 | 99 | 100 |
101 |
102 |
103 |
104 |
105 | 117 | 121 | 122 | -------------------------------------------------------------------------------- /docs/_static/classic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * classic.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- classic theme. 6 | * 7 | * :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li, div.body blockquote { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | code { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning code { 241 | background: #efc2c2; 242 | } 243 | 244 | .note code { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } 257 | 258 | div.code-block-caption { 259 | color: #efefef; 260 | background-color: #1c4e63; 261 | } -------------------------------------------------------------------------------- /docs/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | // global elements used by the functions. 34 | // the 'sidebarbutton' element is defined as global after its 35 | // creation, in the add_sidebar_button function 36 | var bodywrapper = $('.bodywrapper'); 37 | var sidebar = $('.sphinxsidebar'); 38 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 39 | 40 | // for some reason, the document has no sidebar; do not run into errors 41 | if (!sidebar.length) return; 42 | 43 | // original margin-left of the bodywrapper and width of the sidebar 44 | // with the sidebar expanded 45 | var bw_margin_expanded = bodywrapper.css('margin-left'); 46 | var ssb_width_expanded = sidebar.width(); 47 | 48 | // margin-left of the bodywrapper and width of the sidebar 49 | // with the sidebar collapsed 50 | var bw_margin_collapsed = '.8em'; 51 | var ssb_width_collapsed = '.8em'; 52 | 53 | // colors used by the current theme 54 | var dark_color = $('.related').css('background-color'); 55 | var light_color = $('.document').css('background-color'); 56 | 57 | function sidebar_is_collapsed() { 58 | return sidebarwrapper.is(':not(:visible)'); 59 | } 60 | 61 | function toggle_sidebar() { 62 | if (sidebar_is_collapsed()) 63 | expand_sidebar(); 64 | else 65 | collapse_sidebar(); 66 | } 67 | 68 | function collapse_sidebar() { 69 | sidebarwrapper.hide(); 70 | sidebar.css('width', ssb_width_collapsed); 71 | bodywrapper.css('margin-left', bw_margin_collapsed); 72 | sidebarbutton.css({ 73 | 'margin-left': '0', 74 | 'height': bodywrapper.height() 75 | }); 76 | sidebarbutton.find('span').text('»'); 77 | sidebarbutton.attr('title', _('Expand sidebar')); 78 | document.cookie = 'sidebar=collapsed'; 79 | } 80 | 81 | function expand_sidebar() { 82 | bodywrapper.css('margin-left', bw_margin_expanded); 83 | sidebar.css('width', ssb_width_expanded); 84 | sidebarwrapper.show(); 85 | sidebarbutton.css({ 86 | 'margin-left': ssb_width_expanded-12, 87 | 'height': bodywrapper.height() 88 | }); 89 | sidebarbutton.find('span').text('«'); 90 | sidebarbutton.attr('title', _('Collapse sidebar')); 91 | document.cookie = 'sidebar=expanded'; 92 | } 93 | 94 | function add_sidebar_button() { 95 | sidebarwrapper.css({ 96 | 'float': 'left', 97 | 'margin-right': '0', 98 | 'width': ssb_width_expanded - 28 99 | }); 100 | // create the button 101 | sidebar.append( 102 | '
«
' 103 | ); 104 | var sidebarbutton = $('#sidebarbutton'); 105 | light_color = sidebarbutton.css('background-color'); 106 | // find the height of the viewport to center the '<<' in the page 107 | var viewport_height; 108 | if (window.innerHeight) 109 | viewport_height = window.innerHeight; 110 | else 111 | viewport_height = $(window).height(); 112 | sidebarbutton.find('span').css({ 113 | 'display': 'block', 114 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 115 | }); 116 | 117 | sidebarbutton.click(toggle_sidebar); 118 | sidebarbutton.attr('title', _('Collapse sidebar')); 119 | sidebarbutton.css({ 120 | 'color': '#FFFFFF', 121 | 'border-left': '1px solid ' + dark_color, 122 | 'font-size': '1.2em', 123 | 'cursor': 'pointer', 124 | 'height': bodywrapper.height(), 125 | 'padding-top': '1px', 126 | 'margin-left': ssb_width_expanded - 12 127 | }); 128 | 129 | sidebarbutton.hover( 130 | function () { 131 | $(this).css('background-color', dark_color); 132 | }, 133 | function () { 134 | $(this).css('background-color', light_color); 135 | } 136 | ); 137 | } 138 | 139 | function set_position_from_cookie() { 140 | if (!document.cookie) 141 | return; 142 | var items = document.cookie.split(';'); 143 | for(var k=0; k. 16 | #ifndef DRCSL_H 17 | #define DRCSL_H 18 | 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | typedef std::pair pi; 25 | 26 | 27 | 28 | namespace drclean 29 | { 30 | 31 | 32 | struct SplitPolygon 33 | { 34 | 35 | public: 36 | std::vector* left; 37 | std::vector* right; 38 | 39 | int begin; 40 | int end; 41 | int blx,brx; 42 | int elx,erx; 43 | int merge_ind; 44 | 45 | SplitPolygon():merge_ind(-1) 46 | { 47 | right = new std::vector(); 48 | left = new std::vector(); 49 | }; 50 | int can_append(int x1, int x2, int l) 51 | { 52 | if (l != end +1 ) 53 | return 0; 54 | if(x2 < left->back().first) 55 | return 1; 56 | if(x1 > right->back().second) 57 | return -1; 58 | return 2; 59 | } 60 | void destroy() 61 | { 62 | delete right; 63 | delete left; 64 | } 65 | void init(int x1, int x2, int l) 66 | { 67 | left->push_back(std::make_pair(x1,l)); 68 | left->push_back(std::make_pair(x1,l+1)); 69 | right->push_back(std::make_pair(x2,l)); 70 | right->push_back(std::make_pair(x2,l+1)); 71 | begin = l; 72 | end = l+1; 73 | blx = x1; 74 | brx = x2; 75 | elx = x1; 76 | erx = x2; 77 | } 78 | 79 | int append(int x1, int x2, int l) 80 | { 81 | if(x1 == left->back().first) 82 | { 83 | left->back().second++; 84 | } 85 | else 86 | { 87 | left->push_back(std::make_pair(x1,l)); 88 | left->push_back(std::make_pair(x1,l+1)); 89 | } 90 | 91 | if(x2 == right->back().first) 92 | { 93 | right->back().second++; 94 | } 95 | else 96 | { 97 | right->push_back(std::make_pair(x2,l)); 98 | right->push_back(std::make_pair(x2,l+1)); 99 | } 100 | end = l+1; 101 | elx = x1; 102 | erx = x2; 103 | return true; 104 | } 105 | void right_insert(std::vector* polygon) 106 | { 107 | right->insert(right->end(),polygon->begin(),polygon->end()); 108 | } 109 | void right_merge() 110 | { 111 | right->insert(right->end(),left->rbegin(),left->rend()); 112 | left->clear(); 113 | } 114 | }; 115 | 116 | typedef std::vector spv; 117 | 118 | enum orientation 119 | { 120 | hor = 0, 121 | ver = 1, 122 | }; 123 | 124 | struct edgecoord 125 | { 126 | /* 127 | ** Struct to store information about an edge and it's dimensions. 128 | ** @pos: The coordinate of an edge. 129 | ** @type:The type of an edge. 0: Polygon is in the positive coordinate direction from the edge. 130 | ** 1: Polygon is in the negative coordinate direction from the edge. 131 | */ 132 | 133 | int pos; 134 | int type; 135 | bool rem = false; 136 | edgecoord(int p, int t, bool r = false): pos(p), type(t), rem(r) {}; 137 | virtual ~edgecoord() {}; 138 | }; 139 | 140 | 141 | typedef std::vector ev; 142 | 143 | 144 | class DrcSl 145 | { 146 | public: 147 | DrcSl(); 148 | ~DrcSl(); 149 | 150 | int set_data(std::vector *horlist); 151 | void initialize_list(int hor1,int hor2, int ver1, int ver2, int violation_space, int violation_width); 152 | void sortlist(); 153 | void add_data(int hor1,int hor2, int ver1, int ver2); 154 | bool list_cleaning(); 155 | int clean_space(); 156 | int clean_width(); 157 | void switch_dimensions(); 158 | std::vector get_vect(int ind); 159 | std::vector get_types(int ind); 160 | void clean(int max_tries = 10); 161 | int violation_width; 162 | int violation_space; 163 | void printvector(int beg = -1, int ende = -1); 164 | int hor1; 165 | int hor2; 166 | int ver1; 167 | int ver2; 168 | int s(); 169 | std::vector *l; 170 | std::vector> get_lines(); 171 | std::vector> get_polygons(); 172 | 173 | protected: 174 | std::vector listdif(std::vector &l1,std::vector &l2); 175 | 176 | private: 177 | int i; 178 | bool orientation = hor; //0 -> row representation , 1 -> column representation 179 | std::vector *lhor; 180 | std::vector *lver; 181 | int shor; 182 | int sver; 183 | std::vector> polygons; 184 | std::vector splits; 185 | 186 | }; 187 | 188 | 189 | } 190 | 191 | #endif // DRCSL_H 192 | -------------------------------------------------------------------------------- /docs/sourcecodes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | C++ Source Code — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 72 | 73 |
74 |
75 |
76 |
77 | 78 |
79 |

C++ Source Code

80 | 88 |
89 | 90 | 91 |
92 |
93 |
94 |
95 |
96 | 114 | 118 | 119 | -------------------------------------------------------------------------------- /cpp/source/CleanerSlave.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | // Copyright (c) 2018, Sebastian Goeldi 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | #include "CleanerSlave.h" 18 | 19 | 20 | namespace drclean 21 | { 22 | CleanerSlave::CleanerSlave() 23 | { 24 | segment = new bi::managed_shared_memory(bi::open_only, "DRCleanEngine"); 25 | 26 | std::cout<< "Initializing" << std::endl; 27 | 28 | alloc_inst = new ShmemAllocatorInt(segment->get_segment_manager()); 29 | alloc_vec = new ShmemAllocatorIVec(segment->get_segment_manager()); 30 | alloc_pvec = new ShmemAllocatorPVec(segment->get_segment_manager()); 31 | alloc_poly = new ShmemAllocatorPair(segment->get_segment_manager()); 32 | 33 | input = segment->find("input").first; 34 | outList = segment->find("outList").first; 35 | 36 | mux_inp = new bi::named_mutex(bi::open_only, "mux_inp"); 37 | mux_out = new bi::named_mutex(bi::open_only, "mux_out"); 38 | 39 | pool = new boost::asio::thread_pool(boost::thread::hardware_concurrency()); 40 | 41 | if (input) 42 | { 43 | initialized = true; 44 | } 45 | } 46 | 47 | CleanerSlave::CleanerSlave(int nthreads) 48 | { 49 | segment = new bi::managed_shared_memory(bi::open_only, "DRCleanEngine"); 50 | 51 | std::cout<< "Initializing" << std::endl; 52 | 53 | alloc_inst = new ShmemAllocatorInt(segment->get_segment_manager()); 54 | alloc_vec = new ShmemAllocatorIVec(segment->get_segment_manager()); 55 | alloc_pvec = new ShmemAllocatorPVec(segment->get_segment_manager()); 56 | alloc_poly = new ShmemAllocatorPair(segment->get_segment_manager()); 57 | 58 | input = segment->find("input").first; 59 | outList = segment->find("outList").first; 60 | 61 | mux_inp = new bi::named_mutex(bi::open_only, "mux_inp"); 62 | mux_out = new bi::named_mutex(bi::open_only, "mux_out"); 63 | 64 | int n = nthreads; 65 | 66 | if(n < 1) 67 | { 68 | n = 1; 69 | } else if (n > boost::thread::hardware_concurrency()) { 70 | n = boost::thread::hardware_concurrency(); 71 | } 72 | 73 | pool = new boost::asio::thread_pool(n); 74 | 75 | if (input) 76 | { 77 | initialized = true; 78 | } 79 | } 80 | 81 | CleanerSlave::~CleanerSlave() 82 | { 83 | join_threads(); 84 | delete alloc_inst; 85 | delete pool; 86 | } 87 | 88 | void CleanerSlave::clean() 89 | { 90 | std::vector *inp = new std::vector(); 91 | mux_inp->lock(); 92 | if(!input->empty()) 93 | { 94 | bi::vector::iterator it; 95 | for(it = input->begin(); it != input->end(); it++) 96 | { 97 | inp->push_back(*it); 98 | } 99 | input->clear(); 100 | mux_inp->unlock(); 101 | } 102 | else 103 | { 104 | mux_inp->unlock(); 105 | delete inp; 106 | 107 | std::this_thread::sleep_for(std::chrono::milliseconds(30)); 108 | return; 109 | } 110 | 111 | boost::asio::post(*pool,boost::bind(&CleanerSlave::threaded_DrcSl,this,inp)); 112 | // threaded_DrcSl(inp); //For single thread calculation 113 | } 114 | 115 | void CleanerSlave::threaded_DrcSl(std::vector *inp) 116 | { 117 | int layer; 118 | int datatype; 119 | 120 | DrcSl sl; 121 | std::vector::iterator iter = inp->begin(); 122 | 123 | if(iter!=inp->end()) 124 | { 125 | layer = *(iter++); 126 | datatype = *(iter++); 127 | sl.initialize_list(*(iter),*(iter+1),*(iter+2),*(iter+3),*(iter+4),*(iter+5)); 128 | // The first six datapoints are size (x1,x2,y1,y2) and layer, datatype information. 129 | int count = 6; 130 | iter+=6; 131 | while(iter!=inp->end()) 132 | { 133 | count +=4; 134 | sl.add_data(*(iter),*(iter+1),*(iter+2),*(iter+3)); 135 | iter+=4; 136 | } 137 | } 138 | else 139 | { 140 | delete inp; 141 | return; 142 | } 143 | 144 | delete inp; 145 | sl.sortlist(); 146 | sl.clean(); 147 | std::string layername = std::to_string(layer) + "/" + std::to_string(datatype); 148 | 149 | std::vector> polys = sl.get_polygons(); 150 | 151 | ShPVVector* polygons = segment->construct(layername.data())(*alloc_pvec); 152 | 153 | for(auto p: polys) 154 | { 155 | ShPVector* poly = segment->construct(bi::anonymous_instance) (*alloc_poly); 156 | for(auto pit: p) 157 | { 158 | poly->push_back(pit); 159 | } 160 | polygons->push_back(boost::move(*poly)); 161 | } 162 | mux_out->lock(); 163 | outList->push_back(layer); 164 | outList->push_back(datatype); 165 | mux_out->unlock(); 166 | 167 | } 168 | 169 | void CleanerSlave::join_threads() 170 | { 171 | pool->join(); 172 | } 173 | 174 | }; 175 | -------------------------------------------------------------------------------- /cpp/source/CleanerMaster.cpp: -------------------------------------------------------------------------------- 1 | // This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | // Copyright (c) 2018, Sebastian Goeldi 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU Affero General Public License as 6 | // published by the Free Software Foundation, either version 3 of the 7 | // License, or (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU Affero General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU Affero General Public License 15 | // along with this program. If not, see . 16 | 17 | #include "CleanerMaster.h" 18 | 19 | 20 | namespace drclean 21 | { 22 | 23 | CleanerMaster::CleanerMaster() 24 | { 25 | bi::shared_memory_object::remove("DRCleanEngine"); 26 | 27 | bi::named_mutex::remove("mux_inp"); 28 | bi::named_mutex::remove("mux_out"); 29 | 30 | segment = new bi::managed_shared_memory(bi::create_only, "DRCleanEngine", 1073741824); 31 | 32 | alloc_inst = new ShmemAllocatorInt(segment->get_segment_manager()); 33 | 34 | input = segment->construct("input") (*alloc_inst); 35 | outList = segment->construct("outList") (*alloc_inst); 36 | 37 | mux_inp = new bi::named_mutex(bi::open_or_create, "mux_inp"); 38 | mux_out = new bi::named_mutex(bi::open_or_create, "mux_out"); 39 | 40 | } 41 | 42 | CleanerMaster::CleanerMaster(int nlayers) 43 | { 44 | CleanerMaster(); 45 | outList->resize(nlayers); 46 | } 47 | 48 | CleanerMaster::~CleanerMaster() 49 | { 50 | bi::shared_memory_object::remove("DRCleanEngine"); 51 | delete segment; 52 | delete alloc_inst; 53 | delete mux_out; 54 | delete mux_inp; 55 | } 56 | 57 | int CleanerMaster::set_box(int layer, int datatype, int violation_width, int violation_space, int x1, int x2, int y1, int y2) 58 | { 59 | local_input.clear(); 60 | local_input.push_back(layer); 61 | local_input.push_back(datatype); 62 | local_input.push_back(x1); 63 | local_input.push_back(x2); 64 | local_input.push_back(y1); 65 | local_input.push_back(y2); 66 | local_input.push_back(violation_space); 67 | local_input.push_back(violation_width); 68 | return 0; 69 | } 70 | 71 | void CleanerMaster::add_edge(int x1, int x2, int y1, int y2) 72 | { 73 | local_input.push_back(x1); 74 | local_input.push_back(x2); 75 | local_input.push_back(y1); 76 | local_input.push_back(y2); 77 | } 78 | 79 | int CleanerMaster::done() 80 | { 81 | mux_inp->lock(); 82 | if(!input->empty()) 83 | { 84 | mux_inp->unlock(); 85 | return 1; 86 | } 87 | 88 | for(auto iter = local_input.begin(); iter!=local_input.end(); iter++) 89 | { 90 | input->push_back(*iter); 91 | } 92 | 93 | mux_inp->unlock(); 94 | 95 | return 0; 96 | } 97 | 98 | std::vector> CleanerMaster::get_layer() 99 | { 100 | std::vector> lines; 101 | mux_out->lock(); 102 | int layer; 103 | int datatype; 104 | if(!outList->empty()) 105 | { 106 | datatype = outList->back(); 107 | outList->pop_back(); 108 | layer = outList->back(); 109 | outList->pop_back(); 110 | mux_out->unlock(); 111 | } 112 | else 113 | { 114 | mux_out->unlock(); 115 | std::vector ld(2,-1); 116 | lines.push_back(ld); 117 | return lines; 118 | } 119 | std::vector ld{layer,datatype}; 120 | lines.push_back(ld); 121 | std::string layername = std::to_string(layer) + "/" + std::to_string(datatype); 122 | ShIVVector* linesVect = segment->find(layername.data()).first; 123 | 124 | for(ShIVVector::iterator iter = linesVect->begin(); iter != linesVect->end(); iter++) 125 | { 126 | std::vector poly; 127 | for(ShIVector::iterator iterint = iter->begin(); iterint != iter->end(); iterint++) 128 | { 129 | poly.push_back(*iterint); 130 | } 131 | lines.push_back(std::move(poly)); 132 | 133 | } 134 | return lines; 135 | } 136 | 137 | std::vector> CleanerMaster::get_polygons() 138 | { 139 | std::vector> polys; 140 | 141 | mux_out->lock(); 142 | int layer; 143 | int datatype; 144 | if(!outList->empty()) 145 | { 146 | datatype = outList->back(); 147 | outList->pop_back(); 148 | layer = outList->back(); 149 | outList->pop_back(); 150 | mux_out->unlock(); 151 | } 152 | else 153 | { 154 | mux_out->unlock(); 155 | std::vector ld; 156 | ld.push_back(std::make_pair(-1,-1)); 157 | polys.push_back(ld); 158 | return polys; 159 | } 160 | std::vector ld; 161 | ld.push_back(std::make_pair(layer,datatype)); 162 | polys.push_back(ld); 163 | std::string layername = std::to_string(layer) + "/" + std::to_string(datatype); 164 | ShPVVector* polygons = segment->find(layername.data()).first; 165 | 166 | for(ShPVVector::iterator iter = polygons->begin(); iter != polygons->end(); iter++) 167 | { 168 | std::vector poly; 169 | for(ShPVector::iterator piter = iter->begin(); piter != iter->end(); piter++) 170 | { 171 | poly.push_back(*piter); 172 | } 173 | polys.push_back(std::move(poly)); 174 | } 175 | mux_out->unlock(); 176 | return polys; 177 | 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /docs/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Code Documentation — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 72 | 73 |
74 |
75 |
76 |
77 | 78 |
79 |

Code Documentation

80 |
81 | 94 |
95 |
96 | 97 | 98 |
99 |
100 |
101 |
102 |
103 | 121 | 125 | 126 | -------------------------------------------------------------------------------- /docs/tips.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Tips & Tricks — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 80 | 81 |
82 |
83 |
84 |
85 | 86 |
87 |

Tips & Tricks

88 |
89 |

Variable Names in KLayout Python

90 |

When using global variables in pymacros (scripts like cell libraries) be careful. Namespace is shared between macros. This means when for example defining the names of metal layers in two cells, one can overwrite the other one. 91 | Therefore the use of global variables is not advised and the use of a wrapper class is recommended instead. It can be defined in the same wrapper class used for defining layernames and cleaning information, for example.

92 |
93 |
94 | 95 | 96 |
97 |
98 |
99 |
100 |
101 | 119 | 123 | 124 | -------------------------------------------------------------------------------- /docs/drc/cleanerslave.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | CleanerSlave — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 37 | 66 | 67 |
68 |
69 |
70 |
71 | 72 |
73 |

CleanerSlave

74 |
75 |

C++ Class

76 |
77 |
78 | class CleanerSlave
79 |
80 |
81 | void CleanerSlave()
82 |

Constructor of the Class 83 | The constructor opens the shared memory and initializes the allocators for the shared memory. Initializes a boost thread_pool with as many threads as the CPU supports (one per core).

84 |
85 | 86 |
87 |
88 | void clean()
89 |

Checks if the shared memory has a cell layer added. If there is a layer to process, move the data to shared memory and schedule it for processing by the thread_pool.

90 |
91 | 92 |
93 |
94 | void join_threads()
95 |

Wait for the thread_pool to finish all jobs and return

96 |
97 | 98 |
99 | 100 |

Source Code: CleanerSlave Source

101 |
102 |
103 | 104 | 105 |
106 |
107 |
108 |
109 |
110 | 122 | 126 | 127 | -------------------------------------------------------------------------------- /docs/photonics/ports.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Ports — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 72 | 73 |
74 |
75 |
76 |
77 | 78 |
79 |

Ports

80 |

Ports are a concept used in photonics. They are very similar to pins in electronics, as they both describe connections 81 | between cells. The big difference between ports and pins is ports have additional properties that are important 82 | for photonics. When connecting photonic devices it is necessary that the device connections are aligned. For example, if 83 | two waveguides are connected, the connected endings have to point on the opposite direction and the connections have to 84 | be the same size.

85 |

This module implements the concept of ports into KLayout PCells. Currently ports track location, orientation and length. 86 | If two ports have a mismatch in width, they cannot be connected. New ports can be created in PCells with the 87 | kppc.photonics.PortCreation when overriding the kppc.photonics.PhotDevice.create_param_inst() method 88 | in the PCell Library. If any instantiated child cells in a PCell have any open ports (not connected to another port of another 89 | child cell), they are passed upwards to the cell itself and are announced as ports of this cell. 90 | This hierarchical design allows to create arbitrary Devices independent of the order when assembling them.

91 |
92 |

Note

93 |

Make sure ports are drawn correctly. If texts in ports aren’t oriented alond the width of the port, set the boolean 94 | Transform text with cell instance in File ‣ Setup ‣ Display ‣ Cells to true 95 | and make sure the text font is not set to the default font.

96 |
97 |
98 | 99 | 100 |
101 |
102 |
103 |
104 |
105 | 123 | 127 | 128 | -------------------------------------------------------------------------------- /docs/_sources/photonics/techfile.rst.txt: -------------------------------------------------------------------------------- 1 | Technology Import 2 | ================= 3 | 4 | To use KLayout and the Photonics-extension efficiently, it is recommended to create a KLayout technology. This chapter explains how to import a technology. 5 | 6 | To use a new technology either create a new technology from the technology manager :menuselection:`Tools --> Manage Technologies` or create a new package 7 | :menuselection:`Tools --> Manage Packages` for the technology. 8 | 9 | Import Techfile & Creation of LayerProperties 10 | --------------------------------------------- 11 | 12 | KLayout provides an import script for Cadence techfiles. This import creats the Layer Properties automatically for the defined layers. 13 | 14 | The script can be found in :menuselection:`File --> Import Cadence Techfile` 15 | 16 | After importing, the properties can be saved via :menuselection:`File --> Save Layer Properties`. Recommended location for the file is in the technology folder in `~/.klayout/tech//` or if using a package 17 | `~/.klayout/salt//tech/` 18 | 19 | .. note:: 20 | Suggested filename for easy use with the sample cells: FreePDK45.tf / FreePDK45.lyp 21 | 22 | In order to use the additional abstract layers in the sample cells paste the following xml snippets into the <>.lyp file: 23 | 24 | .. code-block:: xml 25 | 26 | 27 | #01ff6b 28 | #01ff6b 29 | 0 30 | 0 31 | I3 32 | I6 33 | true 34 | true 35 | false 36 | 1 37 | false 38 | false 39 | 0 40 | phot_silicon.drawing 41 | 400/0@1 42 | 43 | 44 | #808080 45 | #808080 46 | 0 47 | 0 48 | I2 49 | I0 50 | true 51 | true 52 | false 53 | 1 54 | false 55 | false 56 | 0 57 | phot_poly.drawing 58 | 410/0@1 59 | 60 | 61 | #ff0000 62 | #ff0000 63 | 0 64 | 0 65 | I9 66 | 67 | true 68 | true 69 | false 70 | 1 71 | false 72 | false 73 | 0 74 | phot_pwell.drawing 75 | 420/0@1 76 | 77 | 78 | #0000ff 79 | #0000ff 80 | 0 81 | 0 82 | I5 83 | 84 | true 85 | true 86 | false 87 | 1 88 | false 89 | false 90 | 0 91 | phot_nwell.drawing 92 | 430/0@1 93 | 94 | 95 | #ff0000 96 | #ff0000 97 | 0 98 | 0 99 | I11 100 | 101 | true 102 | true 103 | false 104 | 1 105 | false 106 | false 107 | 0 108 | phot_pimplant.drawing 109 | 440/0@1 110 | 111 | 112 | #0000ff 113 | #0000ff 114 | 0 115 | 0 116 | I7 117 | 118 | true 119 | true 120 | false 121 | 1 122 | false 123 | false 124 | 0 125 | phot_nimplant.drawing 126 | 450/0@1 127 | 128 | 129 | Put this block between the last properties block but befor the end of the name block. 130 | 131 | Import of example Vias 132 | ---------------------- 133 | 134 | Importing a .LEF will create the layerproperties. The layerproperties are the layer-purpose-pairs of KLayout. When using the lef import script built into 135 | KLayout, it will automatically load example vias into a new layout. Unfortunately, the layers are not the correct layers from the technology files. 136 | The layers can be edited by selecting a layer in the layers sub-window and then editing the layer via :menuselection:`Edit --> Layer --> Edit Layer Specification`. 137 | Recommended place is in the `~/.klayout/tech/libraries` or if using a package: `~/.klayout/salt//tech/libraries`. These will automatically be loaded and are available as static cells for insert or in PCells. 138 | 139 | Layermap 140 | -------- 141 | 142 | The .layermap file is usually supplied by the foundry. This file can be used in the pcell_lib_ext to use layernames instead of layer numbers in the PCell Library. 143 | It contains layername | layernumber | layerdatatype on each line for each layer. They have to be separated by white spaces. Afterwards, they can by used by the `self.add_layer(str varname, str layername)` 144 | function during the `__init__` of a new class of a PCell. Later the layer is accessible as `self.varname`. 145 | 146 | Recommended place is again in the tech folder. 147 | -------------------------------------------------------------------------------- /docsrc/_source/photonics/techfile.rst: -------------------------------------------------------------------------------- 1 | Technology Import 2 | ================= 3 | 4 | To use KLayout and the Photonics-extension efficiently, it is recommended to create a KLayout technology. This chapter explains how to import a technology. 5 | 6 | To use a new technology either create a new technology from the technology manager :menuselection:`Tools --> Manage Technologies` or create a new package 7 | :menuselection:`Tools --> Manage Packages` for the technology. 8 | 9 | Import Techfile & Creation of LayerProperties 10 | --------------------------------------------- 11 | 12 | KLayout provides an import script for Cadence techfiles. This import creats the Layer Properties automatically for the defined layers. 13 | 14 | The script can be found in :menuselection:`File --> Import Cadence Techfile` 15 | 16 | After importing, the properties can be saved via :menuselection:`File --> Save Layer Properties`. Recommended location for the file is in the technology folder in `~/.klayout/tech//` or if using a package 17 | `~/.klayout/salt//tech/` 18 | 19 | .. note:: 20 | Suggested filename for easy use with the sample cells: FreePDK45.tf / FreePDK45.lyp 21 | 22 | In order to use the additional abstract layers in the sample cells paste the following xml snippets into the <>.lyp file: 23 | 24 | .. code-block:: xml 25 | 26 | 27 | #01ff6b 28 | #01ff6b 29 | 0 30 | 0 31 | I3 32 | I6 33 | true 34 | true 35 | false 36 | 1 37 | false 38 | false 39 | 0 40 | phot_silicon.drawing 41 | 400/0@1 42 | 43 | 44 | #808080 45 | #808080 46 | 0 47 | 0 48 | I2 49 | I0 50 | true 51 | true 52 | false 53 | 1 54 | false 55 | false 56 | 0 57 | phot_poly.drawing 58 | 410/0@1 59 | 60 | 61 | #ff0000 62 | #ff0000 63 | 0 64 | 0 65 | I9 66 | 67 | true 68 | true 69 | false 70 | 1 71 | false 72 | false 73 | 0 74 | phot_pwell.drawing 75 | 420/0@1 76 | 77 | 78 | #0000ff 79 | #0000ff 80 | 0 81 | 0 82 | I5 83 | 84 | true 85 | true 86 | false 87 | 1 88 | false 89 | false 90 | 0 91 | phot_nwell.drawing 92 | 430/0@1 93 | 94 | 95 | #ff0000 96 | #ff0000 97 | 0 98 | 0 99 | I11 100 | 101 | true 102 | true 103 | false 104 | 1 105 | false 106 | false 107 | 0 108 | phot_pimplant.drawing 109 | 440/0@1 110 | 111 | 112 | #0000ff 113 | #0000ff 114 | 0 115 | 0 116 | I7 117 | 118 | true 119 | true 120 | false 121 | 1 122 | false 123 | false 124 | 0 125 | phot_nimplant.drawing 126 | 450/0@1 127 | 128 | 129 | Put this block between the last properties block but befor the end of the name block. 130 | 131 | Import of example Vias 132 | ---------------------- 133 | 134 | Importing a .LEF will create the layerproperties. The layerproperties are the layer-purpose-pairs of KLayout. When using the lef import script built into 135 | KLayout, it will automatically load example vias into a new layout. Unfortunately, the layers are not the correct layers from the technology files. 136 | The layers can be edited by selecting a layer in the layers sub-window and then editing the layer via :menuselection:`Edit --> Layer --> Edit Layer Specification`. 137 | Recommended place is in the `~/.klayout/tech/libraries` or if using a package: `~/.klayout/salt//tech/libraries`. These will automatically be loaded and are available as static cells for insert or in PCells. 138 | 139 | Layermap 140 | -------- 141 | 142 | The .layermap file is usually supplied by the foundry. This file can be used in the pcell_lib_ext to use layernames instead of layer numbers in the PCell Library. 143 | It contains layername | layernumber | layerdatatype on each line for each layer. They have to be separated by white spaces. Afterwards, they can by used by the `self.add_layer(str varname, str layername)` 144 | function during the `__init__` of a new class of a PCell. Later the layer is accessible as `self.varname`. 145 | 146 | Recommended place is again in the tech folder. 147 | -------------------------------------------------------------------------------- /python/kppc/photonics/dataprep.py: -------------------------------------------------------------------------------- 1 | # This file is part of KLayoutPhotonicPCells, an extension for Photonic Layouts in KLayout. 2 | # Copyright (c) 2018, Sebastian Goeldi 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | 17 | import pya 18 | import kppc 19 | 20 | 21 | def file_len(fname: str): 22 | """Returns the number of lines in the file fname""" 23 | with open(fname) as f: 24 | for i, l in enumerate(f): 25 | pass 26 | return i + 1 27 | 28 | 29 | def add(layout, cell, slayers, dlayers, ex_amount, layers, out_cell=None): 30 | """Combines all slayers' shapes into a region and merges this region with each of dlayers' regions. 31 | 32 | :param layout: the layout on which the cells are located 33 | :param cell: the cell from which to copy the layers (source shapes) 34 | :param slayers: the layers to copy 35 | :param dlayers: the layers where to copy to 36 | :param ex_amount: the amount added around the source shapes 37 | :param layers: the layermapping 38 | :param out_cell: the cell where to put the shapes. If not specified, the input cell will be used. 39 | """ 40 | # adjust amount from microns to database units 41 | am = ex_amount / layout.dbu 42 | 43 | if out_cell: 44 | o_cell = out_cell 45 | else: 46 | o_cell = cell 47 | 48 | srclayers = [slayers, ] if isinstance(slayers, str) else slayers 49 | dstlayers = [dlayers, ] if isinstance(dlayers, str) else dlayers 50 | 51 | in_layers = [layout.layer(layers[m][0], layers[m][1]) for m in srclayers] 52 | region = pya.Region() 53 | for layer in in_layers: 54 | if layer != -1: 55 | shapeit = cell.begin_shapes_rec(layer) 56 | region.insert(shapeit) 57 | region.merge() 58 | if ex_amount > 0: 59 | # increase the size of the region 60 | region.size(am) 61 | region.merge() 62 | for layer in dstlayers: 63 | layer_n, layer_d = layers[layer] 64 | l = layout.layer(layer_n, layer_d) 65 | shapeit = o_cell.begin_shapes_rec(l) 66 | add_region = pya.Region() 67 | add_region.insert(shapeit) 68 | add_region.merge() 69 | o_cell.shapes(l).clear() 70 | o_cell.shapes(l).insert(add_region + region) 71 | 72 | 73 | def sub(layout, cell, slayers, dlayers, ex_amount, layers, out_cell=None): 74 | """Analogous to :func:`~kppc.photonics.dataprep.add` 75 | 76 | Instead of perfoming a combination with the destination layers, this function will substract the input region. 77 | """ 78 | if out_cell: 79 | o_cell = out_cell 80 | else: 81 | o_cell = cell 82 | 83 | am = ex_amount / layout.dbu 84 | 85 | srclayers = [slayers, ] if isinstance(slayers, str) else slayers 86 | dstlayers = [dlayers, ] if isinstance(dlayers, str) else dlayers 87 | 88 | in_layers = [layout.layer(layers[m][0], layers[m][1]) for m in srclayers] 89 | region = pya.Region() 90 | for layer in in_layers: 91 | if layer != -1: 92 | shapeit = layout.begin_shapes(cell, layer) 93 | region.insert(shapeit) 94 | region.merge() 95 | if ex_amount != 0: 96 | region.size(am) 97 | region.merge() 98 | for layer in dstlayers: 99 | sub_region = pya.Region() 100 | layer_n, layer_d = layers[layer] 101 | l = layout.layer(layer_n, layer_d) 102 | shapeit = o_cell.begin_shapes_rec(l) 103 | sub_region.insert(shapeit) 104 | sub_region.merge() 105 | o_cell.shapes(l).clear() 106 | o_cell.shapes(l).insert(sub_region - region) 107 | 108 | 109 | def dataprep(in_cell, layout, out_cell=None, config=None, layers_org=None): 110 | """Dataprep that creates excludes layers etc. with boolean operation on input layers that will be added/substracted to outputlayers. 111 | 112 | :param in_cell: the cell from which to take shapes 113 | :param layout: the layout on which we perform the operations (most likely self.layout) 114 | :param out_cell: the output cell. if not specified take the input cell 115 | :param config: the config file. This file specifies the boolean operations (self.dataprepconfig) 116 | :param layers_org: the original layermap we use (most likely self.layermap) 117 | """ 118 | # without config or layermap we can't work 119 | if config is None: 120 | return 121 | if layers_org is None: 122 | return 123 | layers = {} 124 | 125 | if kppc.settings.General.Progressbar: 126 | l = file_len(config) 127 | progress = pya.RelativeProgress('Layermapping from abstract to Foundry Layers', l) 128 | 129 | # create one dimensional dictionary of the layermap (maybe remove in the future as this is not necessary anymore 130 | for key in layers_org: 131 | for k in layers_org[key]: 132 | layers[key + '.' + k] = [int(i) for i in layers_org[key][k]] 133 | 134 | # define conveniance functions 135 | def _add(slayers, dlayers, amount=0, layers=layers): 136 | add(layout, in_cell, slayers, dlayers, amount, layers, out_cell) 137 | 138 | def _sub(slayers, dlayers, amount=0, layers=layers): 139 | sub(layout, in_cell, slayers, dlayers, amount, layers, out_cell) 140 | 141 | count = 0 142 | 143 | # process the config file 144 | with open(config, 'r') as df: 145 | for line in df: 146 | strings = line.split() 147 | 148 | if strings[0] == 'add': 149 | if len(strings) == 4: 150 | amount = float(strings[3]) 151 | else: 152 | amount = 0 153 | progress.format = 'Adding Layer(s) {} to Layer {}'.format(strings[1].split(','), 154 | strings[2].split(',')) 155 | _add(strings[1].split(','), strings[2].split(','), amount) 156 | progress.inc() 157 | elif strings[0] == 'sub': 158 | if len(strings) == 4: 159 | amount = float(strings[3]) 160 | else: 161 | amount = 0 162 | progress.format = 'Subtracting Layer(s) {} from Layer {}'.format(strings[1].split(','), 163 | strings[2].split(',')) 164 | _sub(strings[1].split(','), strings[2].split(','), amount) 165 | progress.inc() 166 | else: 167 | progress.inc() 168 | progress._destroy() 169 | -------------------------------------------------------------------------------- /docs/introduction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Introduction — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 72 | 73 |
74 |
75 |
76 |
77 | 78 |
79 |

Introduction

80 |

The KLayoutPhotonicPCells`kppc` module is an extension for KLayout PCells to facilitate photonic PCells. 81 | Photonics often works with the concept of ports. 82 | Ports are defined by a coordinate and a direction. In the case of this module ports will be stored in PCell parameters in the background. 83 | They are serialized KLayout Trans objects. For an introduction on how to build your own PCell Library, have a look at 84 | how to create Example Library.

85 |

When building PCell Libraries it is recommended to build it with three packages as shown in Fig. 1

86 |
87 | The intended use for this library extension is to work with 3 packages per PCell-Library. First this one, second a technology specific package which contains techfile and import from techfile and finally the PCell Library. 88 |

Fig. 1 The recommend structure for working with the photonic PCell extension: 89 | * Photonic Library Extension: New functionalities for KLayout PCells

90 |
91 |
92 |
    93 |
  • Ports, DR-Cleaning, DataPrep

  • 94 |
95 |
96 |
    97 |
  • Technology: Contains manufacturer specific data

    98 |
    99 |
      100 |
    • Design rules

    • 101 |
    • Layermapping from abstract to manufacturer layers

    • 102 |
    103 |
    104 |
  • 105 |
  • PCell-Library:

    106 |
    107 |
      108 |
    • Definitions of PCells

    • 109 |
    • Library specific modules if required

    • 110 |
    111 |
    112 |
  • 113 |
114 |
115 |
116 |
117 | 118 | 119 |
120 |
121 |
122 |
123 |
124 | 142 | 146 | 147 | -------------------------------------------------------------------------------- /docsrc/_source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Configuration file for the Sphinx documentation builder. 4 | # 5 | # This file does only contain a selection of the most common options. For a 6 | # full list see the documentation: 7 | # http://www.sphinx-doc.org/en/stable/config 8 | 9 | # -- Path setup -------------------------------------------------------------- 10 | 11 | # If extensions (or modules to document with autodoc) are in another directory, 12 | # add these directories to sys.path here. If the directory is relative to the 13 | # documentation root, use os.path.abspath to make it absolute, like shown here. 14 | # 15 | import os 16 | import sys 17 | from sphinx_markdown_parser.parser import MarkdownParser 18 | sys.path.insert(0, os.path.abspath('../../python')) 19 | sys.path.insert(0, os.path.expanduser("~/.local/bin")) 20 | 21 | numfig = True 22 | 23 | #from unittest.mock import MagicMock 24 | #class Mock(MagicMock): 25 | # @classmethod 26 | # def __getattr__(cls, name): 27 | # return MagicMock() 28 | # 29 | #MOCK_MODULES = ['pya'] 30 | #sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) 31 | 32 | 33 | # -- Project information ----------------------------------------------------- 34 | 35 | project = 'KLayout Photonic PCells' 36 | copyright = '2019, Sebastian Goeldi' 37 | author = 'Sebastian Goeldi' 38 | 39 | # The short X.Y version 40 | version = '1.1' 41 | # The full version, including alpha/beta/rc tags 42 | release = '1.1.0' 43 | 44 | 45 | # -- General configuration --------------------------------------------------- 46 | 47 | # If your documentation needs a minimal Sphinx version, state it here. 48 | # 49 | # needs_sphinx = '1.0' 50 | 51 | # Add any Sphinx extension module names here, as strings. They can be 52 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 53 | # ones. 54 | extensions = [ 55 | 'sphinx.ext.autodoc', 56 | 'sphinx.ext.doctest', 57 | 'sphinx.ext.napoleon', 58 | 'sphinx.ext.intersphinx', 59 | 'sphinx.ext.todo', 60 | 'sphinx.ext.coverage', 61 | 'sphinx.ext.mathjax', 62 | 'sphinx.ext.ifconfig', 63 | 'sphinx.ext.viewcode', 64 | 'sphinx.ext.githubpages', 65 | 'sphinx.ext.imgconverter', 66 | 'sphinx_autodoc_typehints', 67 | ] 68 | # 'sphinx_autodoc_typehints', 69 | # Add any paths that contain templates here, relative to this directory. 70 | templates_path = ['_templates'] 71 | 72 | # The suffix(es) of source filenames. 73 | # You can specify multiple suffix as a list of string: 74 | # 75 | # source_suffix = ['.rst', '.md'] 76 | source_suffix = '.rst' 77 | 78 | # The master toctree document. 79 | master_doc = 'index' 80 | 81 | # The language for content autogenerated by Sphinx. Refer to documentation 82 | # for a list of supported languages. 83 | # 84 | # This is also used if you do content translation via gettext catalogs. 85 | # Usually you set "language" from the command line for these cases. 86 | language = None 87 | 88 | # List of patterns, relative to source directory, that match files and 89 | # directories to ignore when looking for source files. 90 | # This pattern also affects html_static_path and html_extra_path . 91 | exclude_patterns = ['build/*'] 92 | 93 | # The name of the Pygments (syntax highlighting) style to use. 94 | pygments_style = 'sphinx' 95 | 96 | 97 | # -- Options for HTML output ------------------------------------------------- 98 | 99 | # The theme to use for HTML and HTML Help pages. See the documentation for 100 | # a list of builtin themes. 101 | # 102 | # html_theme = 'alabaster' 103 | html_theme = 'bizstyle' 104 | 105 | # Theme options are theme-specific and customize the look and feel of a theme 106 | # further. For a list of options available for each theme, see the 107 | # documentation. 108 | # 109 | html_theme_options = {'body_max_width': 'none'} 110 | 111 | # Add any paths that contain custom static files (such as style sheets) here, 112 | # relative to this directory. They are copied after the builtin static files, 113 | # so a file named "default.css" will overwrite the builtin "default.css". 114 | html_static_path = ['_static'] 115 | 116 | # Custom sidebar templates, must be a dictionary that maps document names 117 | # to template names. 118 | # 119 | # The default sidebars (for documents that don't match any pattern) are 120 | # defined by theme itself. Builtin themes are using these templates by 121 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', 122 | # 'searchbox.html']``. 123 | # 124 | # html_sidebars = {} 125 | 126 | 127 | # -- Options for HTMLHelp output --------------------------------------------- 128 | 129 | # Output file base name for HTML help builder. 130 | htmlhelp_basename = 'KLayoutPhotonicPCellsdoc' 131 | 132 | 133 | # -- Options for LaTeX output ------------------------------------------------ 134 | 135 | latex_elements = { 136 | # The paper size ('letterpaper' or 'a4paper'). 137 | # 138 | 'papersize': 'a4paper', 139 | 140 | # The font size ('10pt', '11pt' or '12pt'). 141 | # 142 | 'pointsize': '10pt', 143 | 144 | # Additional stuff for the LaTeX preamble. 145 | # 146 | # 'preamble': '', 147 | 148 | # Latex figure (float) alignment 149 | # 150 | 'figure_align': 'htbp', 151 | 152 | 'preamble': r''' 153 | \usepackage{charter} 154 | \usepackage[defaultsans]{lato} 155 | \usepackage{inconsolata} 156 | ''', 157 | 158 | 159 | } 160 | 161 | latex_show_urls = 'footnote' 162 | 163 | # Grouping the document tree into LaTeX files. List of tuples 164 | # (source start file, target name, title, 165 | # author, documentclass [howto, manual, or own class]). 166 | latex_documents = [ 167 | (master_doc, 'KLayoutPhotonicPCells.tex', 'KLayout Photonic PCells Documentation', 168 | 'Sebastian Goeldi', 'manual'), 169 | ] 170 | 171 | 172 | # -- Options for manual page output ------------------------------------------ 173 | 174 | # One entry per manual page. List of tuples 175 | # (source start file, name, description, authors, manual section). 176 | man_pages = [ 177 | (master_doc, 'klayoutphotonicpcells', 'KLayout Photonic PCells Documentation', 178 | [author], 1) 179 | ] 180 | 181 | 182 | # -- Options for Texinfo output ---------------------------------------------- 183 | 184 | # Grouping the document tree into Texinfo files. List of tuples 185 | # (source start file, target name, title, author, 186 | # dir menu entry, description, category) 187 | texinfo_documents = [ 188 | (master_doc, 'KLayoutPhotonicPCells', 'KLayout Photonic PCells Documentation', 189 | author, 'KLayoutPhotonicPCells', 'One line description of project.', 190 | 'Miscellaneous'), 191 | ] 192 | 193 | 194 | # -- Extension configuration ------------------------------------------------- 195 | 196 | autodoc_mock_imports = ['pya'] 197 | 198 | #class Mock(MagicMock): 199 | # @classmethod 200 | # def __getattr__(cls, name): 201 | # return MagicMock() 202 | # 203 | #MOCK_MODULES = ['pya'] 204 | #sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) 205 | 206 | #autodoc_mock_imports = ["pya"] 207 | 208 | # -- Options for intersphinx extension --------------------------------------- 209 | 210 | # Example configuration for intersphinx: refer to the Python standard library. 211 | intersphinx_mapping = {'python': ('https://docs.python.org/3', None), 212 | 'cython': ('https://cython.readthedocs.io/en/latest',None), 213 | 'setuptools': ('https://setuptools.readthedocs.io/en/latest/',None) 214 | } 215 | 216 | # -- Options for todo extension ---------------------------------------------- 217 | 218 | # If true, `todo` and `todoList` produce output, else they produce nothing. 219 | todo_include_todos = True 220 | 221 | source_suffix = { 222 | '.rst': 'restructuredtext', 223 | '.md': 'markdown' 224 | } 225 | 226 | def setup(app): 227 | app.add_source_suffix('.md', 'markdown') 228 | app.add_source_parser(MarkdownParser) 229 | -------------------------------------------------------------------------------- /docs/photonics/first_steps.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | First Steps — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 45 | 81 | 82 |
83 |
84 |
85 |
86 | 87 |
88 |

First Steps

89 |
90 |

Prerequisites

91 |

To use the library extension, make sure you have installed Cython. Part of the cleaning process relies on a C++ module that needs to be compiled first. To compile it we use pythons Setuptools and Cython. Make sure you have these packages before starting. It is sufficient to install Cython, as setuptools is either built-in of python or installed along Cython.

92 |
93 |
94 |

Installation

95 |

This installation procedure is solely written for Linux. For this installation Cython is required. So get Cython either from the package manager of your distribution or through pip. The package is tested on Python 3.5+. No special python3 modules are used, therefore it should work with python 2.7, too. The Python version used should be the same KLayout uses. By default, this is the system interpreter for Python3. 96 | If you installed the package manually, move the unpackaged package into ~/.klayout/salt or into the KLayout folder if you used a custom directory. This tutorial assumes default pathes. 97 | After unpacking and moving you should have a ~/.klayout/salt/KLayouPhotonicPCells/core folder. If you installed the FreePDK45_Cells & FreePDK45_tech, then you should have the folders ~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_ExampleCells and ~/.klayout/salt/KLayouPhotonicPCells/FreePDK45_tech, too. The library extension package needs manual setup before being usable.

98 |

Use a console and execute the following commands. If you are familiar with setuptools you can skip these instructions. For further information consult the drc documentation.

99 |
cd ~/.klayout/salt/KLayouPhotonicPCells/cor/python/kppc/drc/
100 | sh compile.sh
101 | 
102 |
103 |
104 | Compile the C++Python module with Cython 105 |

Fig. 2 Change directory to the drc folder and execute the setup script.

106 |
107 |
108 |
109 | 110 | 111 |
112 |
113 |
114 |
115 |
116 | 134 | 138 | 139 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Photonic PCell Library Extension Documentation — KLayout Photonic PCells 1.1.0 documentation 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 41 | 65 | 66 |
67 |
68 |
69 |
70 | 71 |
72 |

Photonic PCell Library Extension Documentation

73 |

KLayout Photonic PCells introduces the concept of ports to KLayout. Ports in contrast to pins also track directions. Additionally, PCells can be built hierarchically from other PCells and new shapes. The sub-cells can be connected to each other through ports.

74 |

The source code can be found on Github

75 |
76 |

Contents:

77 | 121 |
122 |

Glossary:

123 | 128 |
129 | 130 | 131 |
132 |
133 |
134 |
135 |
136 | 151 | 155 | 156 | --------------------------------------------------------------------------------