New module: 'pex'

This commit is contained in:
Matthias Koefferlein 2025-04-18 13:12:45 +02:00
parent c6a4b6aba0
commit 16604e5a92
22 changed files with 489 additions and 5 deletions

View File

@ -592,6 +592,25 @@ _db = Library(
) )
config.add_extension(_db) config.add_extension(_db)
# ------------------------------------------------------------------
# _pex dependency library
_pex_path = os.path.join("src", "pex", "pex")
_pex_sources = set(glob.glob(os.path.join(_pex_path, "*.cc")))
_pex = Library(
config.root + "._pex",
define_macros=config.macros() + [("MAKE_PEX_LIBRARY", 1)],
include_dirs=[_tl_path, _gsi_path, _db_path, _pex_path],
extra_objects=[config.path_of("_tl", _tl_path), config.path_of("_gsi", _gsi_path), config.path_of("_db", _db_path)],
language="c++",
libraries=config.libraries('_pex'),
extra_link_args=config.link_args("_pex"),
extra_compile_args=config.compile_args("_pex"),
sources=list(_pex_sources),
)
config.add_extension(_pex)
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# _lib dependency library # _lib dependency library
@ -869,6 +888,28 @@ db = Extension(
sources=list(db_sources), sources=list(db_sources),
) )
# ------------------------------------------------------------------
# pex extension library
pex_path = os.path.join("src", "pymod", "pex")
pex_sources = set(glob.glob(os.path.join(pex_path, "*.cc")))
pex = Extension(
config.root + ".pexcore",
define_macros=config.macros(),
include_dirs=[_db_path, _tl_path, _gsi_path, _pya_path, _pex_path],
extra_objects=[
config.path_of("_db", _db_path),
config.path_of("_pex", _pex_path),
config.path_of("_tl", _tl_path),
config.path_of("_gsi", _gsi_path),
config.path_of("_pya", _pya_path),
],
extra_link_args=config.link_args("pexcore"),
extra_compile_args=config.compile_args("pexcore"),
sources=list(pex_sources),
)
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# lib extension library # lib extension library
@ -1011,8 +1052,8 @@ if __name__ == "__main__":
package_data={config.root: ["src/pymod/distutils_src/klayout/*.pyi"]}, package_data={config.root: ["src/pymod/distutils_src/klayout/*.pyi"]},
data_files=[(config.root, ["src/pymod/distutils_src/klayout/py.typed"])], data_files=[(config.root, ["src/pymod/distutils_src/klayout/py.typed"])],
include_package_data=True, include_package_data=True,
ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _laybasic, _layview, _ant, _edt, _img] ext_modules=[_tl, _gsi, _pya, _rba, _db, _pex, _lib, _rdb, _lym, _laybasic, _layview, _ant, _edt, _img]
+ db_plugins + db_plugins
+ [tl, db, lib, rdb, lay, pya], + [tl, db, pex, lib, rdb, lay, pya],
cmdclass={'build_ext': klayout_build_ext} cmdclass={'build_ext': klayout_build_ext}
) )

View File

@ -1,6 +1,7 @@
TL_INC = $$PWD/tl/tl TL_INC = $$PWD/tl/tl
DB_INC = $$PWD/db/db DB_INC = $$PWD/db/db
PEX_INC = $$PWD/pex/pex
DRC_INC = $$PWD/drc/drc DRC_INC = $$PWD/drc/drc
LVS_INC = $$PWD/lvs/lvs LVS_INC = $$PWD/lvs/lvs
EDT_INC = $$PWD/edt/edt EDT_INC = $$PWD/edt/edt

View File

@ -7,6 +7,7 @@ SUBDIRS = \
tl \ tl \
gsi \ gsi \
db \ db \
pex \
rdb \ rdb \
lib \ lib \
plugins \ plugins \
@ -62,6 +63,7 @@ equals(HAVE_PYTHON, "1") {
gsi.depends += tl gsi.depends += tl
db.depends += gsi db.depends += gsi
pex.depends += db
rdb.depends += db rdb.depends += db
lib.depends += db lib.depends += db

6
src/pex/pex.pro Normal file
View File

@ -0,0 +1,6 @@
TEMPLATE = subdirs
SUBDIRS = pex unit_tests
unit_tests.depends += pex

View File

@ -0,0 +1,44 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "gsiDecl.h"
#include "pexRExtractor.h"
namespace gsi
{
// @@@
static pex::RExtractor *new_sqc_rextractor ()
{
return new pex::RExtractor ();
}
Class<pex::RExtractor> decl_RExtractor ("pex", "RExtractor",
gsi::constructor ("square_counting", &new_sqc_rextractor,
"@brief Creates a square counting R extractor\n"
),
"@brief A base class for the R extractor\n"
);
}

23
src/pex/pex/pex.pro Normal file
View File

@ -0,0 +1,23 @@
DESTDIR = $$OUT_PWD/../..
TARGET = klayout_pex
include($$PWD/../../lib.pri)
DEFINES += MAKE_PEX_LIBRARY
SOURCES = \
pexForceLink.cc \
pexRExtractor.cc \
gsiDeclRExtractor.cc \
HEADERS = \
pexForceLink.h \
pexRExtractor.h \
RESOURCES = \
INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC
DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db

51
src/pex/pex/pexCommon.h Normal file
View File

@ -0,0 +1,51 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(HDR_pexCommon_h)
# define HDR_pexCommon_h
# if defined _WIN32 || defined __CYGWIN__
# ifdef MAKE_PEX_LIBRARY
# define PEX_PUBLIC __declspec(dllexport)
# else
# define PEX_PUBLIC __declspec(dllimport)
# endif
# define PEX_LOCAL
# define PEX_PUBLIC_TEMPLATE
# else
# if __GNUC__ >= 4 || defined(__clang__)
# define PEX_PUBLIC __attribute__ ((visibility ("default")))
# define PEX_PUBLIC_TEMPLATE __attribute__ ((visibility ("default")))
# define PEX_LOCAL __attribute__ ((visibility ("hidden")))
# else
# define PEX_PUBLIC
# define PEX_PUBLIC_TEMPLATE
# define PEX_LOCAL
# endif
# endif
#endif

View File

@ -0,0 +1,32 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pexForceLink.h"
namespace pex
{
int _force_link_f ()
{
return 0;
}
}

View File

@ -0,0 +1,40 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_pexForceLink
#define HDR_pexForceLink
#include "pexCommon.h"
/**
* @file Include this function to force linking of the pex module
*/
namespace pex
{
PEX_PUBLIC int _force_link_f ();
static int _force_link_target = _force_link_f ();
}
#endif

View File

@ -0,0 +1,36 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pexRExtractor.h"
namespace pex
{
RExtractor::RExtractor ()
{
// .. nothing yet ..
}
}

View File

@ -0,0 +1,49 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_pexRExtractor
#define HDR_pexRExtractor
#include "pexCommon.h"
#include <string>
namespace pex
{
/**
* @brief A base class for an resistance extractor
*
* The R extractor takes a polyon, a technology definition
* and port definitions and extracts a resistor network.
*
* Ports are points or polygons that define the connection
* points to the network.
*/
struct PEX_PUBLIC RExtractor
{
RExtractor ();
};
}
#endif

View File

@ -0,0 +1,31 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pexRExtractor.h"
#include "tlUnitTest.h"
TEST(1)
{
// @@@
}

View File

@ -0,0 +1,16 @@
DESTDIR_UT = $$OUT_PWD/../..
DESTDIR = $$OUT_PWD/..
TARGET = pex_tests
include($$PWD/../../lib_ut.pri)
SOURCES = \
pexRExtractorTests.cc \
INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$PEX_INC
DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$PEX_INC
LIBS += -L$$DESTDIR_UT -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_pex

View File

@ -0,0 +1,4 @@
import sys
from ..pexcore import __all__
from ..pexcore import *

14
src/pymod/pex/pex.pro Normal file
View File

@ -0,0 +1,14 @@
TARGET = pexcore
REALMODULE = pex
PYI = pexcore.pyi
include($$PWD/../pymod.pri)
SOURCES = \
pexMain.cc \
HEADERS += \
LIBS += -lklayout_pex

31
src/pymod/pex/pexMain.cc Normal file
View File

@ -0,0 +1,31 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../pymodHelper.h"
#include "pexMain.h"
static PyObject *pex_module_init (const char *pymod_name, const char *mod_name, const char *mod_description)
{
return module_init (pymod_name, mod_name, mod_description);
}
DEFINE_PYMOD_WITH_INIT(pexcore, "pex", "KLayout core module 'pex'", pex_module_init)

24
src/pymod/pex/pexMain.h Normal file
View File

@ -0,0 +1,24 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2025 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// to force linking of the pex module
#include "../../pex/pex/pexForceLink.h"

View File

@ -4,6 +4,7 @@ include($$PWD/../klayout.pri)
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = \ SUBDIRS = \
db \ db \
pex \
tl \ tl \
rdb \ rdb \
lib \ lib \

View File

@ -84,6 +84,7 @@ PYMODTEST (bridge, "bridge.py")
PYMODTEST (import_tl, "import_tl.py") PYMODTEST (import_tl, "import_tl.py")
PYMODTEST (import_db, "import_db.py") PYMODTEST (import_db, "import_db.py")
PYMODTEST (import_pex, "import_pex.py")
PYMODTEST (klayout_db_tests, "klayout_db_tests.py") PYMODTEST (klayout_db_tests, "klayout_db_tests.py")
PYMODTEST (import_rdb, "import_rdb.py") PYMODTEST (import_rdb, "import_rdb.py")
PYMODTEST (import_lay, "import_lay.py") PYMODTEST (import_lay, "import_lay.py")

View File

@ -1,8 +1,8 @@
INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$PEX_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC
DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$PEX_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC
LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_ant -lklayout_img -lklayout_edt -lklayout_lib LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_pex -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_ant -lklayout_img -lklayout_edt -lklayout_lib
!equals(HAVE_QT, "0") { !equals(HAVE_QT, "0") {

37
testdata/pymod/import_pex.py vendored Executable file
View File

@ -0,0 +1,37 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2025 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.pex as pex
import unittest
import sys
import os
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("RExtractor" in pex.__all__, True)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)