klayout-pex 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. klayout_pex/__init__.py +23 -0
  2. klayout_pex/__main__.py +33 -0
  3. klayout_pex/common/__init__.py +23 -0
  4. klayout_pex/common/capacitance_matrix.py +85 -0
  5. klayout_pex/fastcap/__init__.py +23 -0
  6. klayout_pex/fastcap/fastcap_runner.py +143 -0
  7. klayout_pex/fastercap/__init__.py +23 -0
  8. klayout_pex/fastercap/fastercap_input_builder.py +340 -0
  9. klayout_pex/fastercap/fastercap_model_generator.py +1044 -0
  10. klayout_pex/fastercap/fastercap_runner.py +129 -0
  11. klayout_pex/klayout/__init__.py +27 -0
  12. klayout_pex/klayout/lvs_runner.py +97 -0
  13. klayout_pex/klayout/lvsdb_extractor.py +272 -0
  14. klayout_pex/klayout/netlist_csv.py +59 -0
  15. klayout_pex/klayout/netlist_expander.py +148 -0
  16. klayout_pex/klayout/netlist_reducer.py +63 -0
  17. klayout_pex/klayout/repair_rdb.py +137 -0
  18. klayout_pex/kpex_cli.py +824 -0
  19. klayout_pex/log/__init__.py +44 -0
  20. klayout_pex/log/logger.py +183 -0
  21. klayout_pex/magic/__init__.py +23 -0
  22. klayout_pex/magic/magic_runner.py +154 -0
  23. klayout_pex/pdk/__init__.py +23 -0
  24. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/bjt_connections.lvs +69 -0
  25. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/bjt_derivations.lvs +125 -0
  26. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/bjt_extraction.lvs +81 -0
  27. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/cap_connections.lvs +39 -0
  28. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/cap_derivations.lvs +64 -0
  29. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/cap_extraction.lvs +55 -0
  30. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_classes.lvs +55 -0
  31. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_combiner.lvs +199 -0
  32. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_devices.lvs +225 -0
  33. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_extractor.lvs +405 -0
  34. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_mim_extractor.lvs +245 -0
  35. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_reader.lvs +346 -0
  36. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/custom_writer.lvs +66 -0
  37. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/devices_connections.lvs +84 -0
  38. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/diode_connections.lvs +39 -0
  39. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/diode_derivations.lvs +64 -0
  40. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/diode_extraction.lvs +41 -0
  41. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/esd_connections.lvs +108 -0
  42. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/esd_derivations.lvs +147 -0
  43. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/esd_extraction.lvs +116 -0
  44. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/general_connections.lvs +64 -0
  45. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/general_derivations.lvs +104 -0
  46. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/globals.lvs +68 -0
  47. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/ind_connections.lvs +37 -0
  48. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/ind_derivations.lvs +66 -0
  49. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/ind_extraction.lvs +44 -0
  50. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/layers_definitions.lvs +1856 -0
  51. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/mos_connections.lvs +24 -0
  52. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/mos_derivations.lvs +83 -0
  53. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/mos_extraction.lvs +77 -0
  54. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/res_connections.lvs +36 -0
  55. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/res_derivations.lvs +75 -0
  56. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/res_extraction.lvs +89 -0
  57. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/rfmos_connections.lvs +24 -0
  58. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/rfmos_derivations.lvs +47 -0
  59. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/rfmos_extraction.lvs +80 -0
  60. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/tap_connections.lvs +32 -0
  61. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/tap_derivations.lvs +42 -0
  62. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/rule_decks/tap_extraction.lvs +32 -0
  63. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/sg13g2.lvs +486 -0
  64. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/sg13g2.lyp +7282 -0
  65. klayout_pex/pdk/ihp_sg13g2/libs.tech/kpex/sg13g2.lyt +198 -0
  66. klayout_pex/pdk/sky130A/libs.tech/kpex/debug_sky130.lvs.lylvs +35 -0
  67. klayout_pex/pdk/sky130A/libs.tech/kpex/sky130.lvs +2536 -0
  68. klayout_pex/pdk/sky130A/libs.tech/kpex/sky130A.lyp +8563 -0
  69. klayout_pex/pdk/sky130A/libs.tech/kpex/sky130A.lyt +169 -0
  70. klayout_pex/pdk_config.py +32 -0
  71. klayout_pex/rcx25/__init__.py +23 -0
  72. klayout_pex/rcx25/extraction_results.py +164 -0
  73. klayout_pex/rcx25/extractor.py +743 -0
  74. klayout_pex/tech_info.py +285 -0
  75. klayout_pex/util/__init__.py +23 -0
  76. klayout_pex/util/argparse_helpers.py +52 -0
  77. klayout_pex/util/multiple_choice.py +69 -0
  78. klayout_pex/version.py +24 -0
  79. klayout_pex-0.1.4.dist-info/LICENSE +674 -0
  80. klayout_pex-0.1.4.dist-info/METADATA +75 -0
  81. klayout_pex-0.1.4.dist-info/RECORD +89 -0
  82. klayout_pex-0.1.4.dist-info/WHEEL +4 -0
  83. klayout_pex-0.1.4.dist-info/entry_points.txt +3 -0
  84. klayout_pex_protobuf/__init__.py +34 -0
  85. klayout_pex_protobuf/ihp_sg13g2_tech.pb.json +644 -0
  86. klayout_pex_protobuf/process_parasitics_pb2.py +54 -0
  87. klayout_pex_protobuf/process_stack_pb2.py +58 -0
  88. klayout_pex_protobuf/sky130A_tech.pb.json +1482 -0
  89. klayout_pex_protobuf/tech_pb2.py +44 -0
@@ -0,0 +1,23 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
@@ -0,0 +1,33 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
24
+ from .kpex_cli import KpexCLI
25
+ import sys
26
+
27
+ def main():
28
+ cli = KpexCLI()
29
+ cli.main(sys.argv)
30
+
31
+ if __name__ == '__main__':
32
+ main()
33
+
@@ -0,0 +1,23 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
@@ -0,0 +1,85 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
24
+ from __future__ import annotations
25
+
26
+ import copy
27
+ from dataclasses import dataclass
28
+ from typing import *
29
+
30
+
31
+ @dataclass
32
+ class CapacitanceMatrix:
33
+ conductor_names: List[str] # NOTE FasterCap generates [g_1, g_2, ...]
34
+ rows: List[List[float]] # NOTE: in µm
35
+
36
+ def __getitem__(self, key):
37
+ return self.rows.__getitem__(key)
38
+
39
+ def __setitem__(self, key, value):
40
+ self.rows.__setitem__(key, value)
41
+
42
+ @property
43
+ def dimension(self):
44
+ return len(self.conductor_names)
45
+
46
+ @classmethod
47
+ def parse_csv(cls, path: str, separator: str = ';'):
48
+ with open(path, 'r') as f:
49
+ lines = f.readlines()
50
+ if len(lines) < 2:
51
+ raise Exception(f"Capacitance Matrix CSV must at least have 2 lines: "
52
+ f"{path}")
53
+ conductor_names = [cell.strip() for cell in lines[0].split(sep=separator)]
54
+ rows = []
55
+ for line in lines[1:]:
56
+ row = [float(cell.strip()) for cell in line.split(sep=separator)]
57
+ rows.append(row)
58
+ return CapacitanceMatrix(conductor_names=conductor_names,
59
+ rows=rows)
60
+
61
+ def write_csv(self, output_path: str, separator: str = ';'):
62
+ with open(output_path, 'w') as f:
63
+ header_line = separator.join(self.conductor_names)
64
+ f.write(header_line)
65
+ f.write('\n')
66
+
67
+ for row in self.rows:
68
+ cells = ['%.12g' % cell for cell in row]
69
+ row_line = separator.join(cells)
70
+ f.write(row_line)
71
+ f.write('\n')
72
+
73
+ def averaged_off_diagonals(self) -> CapacitanceMatrix:
74
+ c = copy.deepcopy(self)
75
+ for i in range(len(self.rows)):
76
+ for j in range(len(self.conductor_names)):
77
+ if j <= i:
78
+ continue
79
+ v1 = self[i][j]
80
+ v2 = self[j][i]
81
+ avg = (v1 + v2) / 2
82
+ # print(f"i={i} j={j}, avg({v1}, {v2}) == {avg}")
83
+ c[i][j] = avg
84
+ c[j][i] = avg
85
+ return c
@@ -0,0 +1,23 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
@@ -0,0 +1,143 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #
24
+ import re
25
+ import time
26
+ from typing import *
27
+
28
+ import os
29
+ import subprocess
30
+
31
+ from ..log import (
32
+ debug,
33
+ info,
34
+ warning,
35
+ error,
36
+ rule,
37
+ subproc,
38
+ )
39
+ from ..common.capacitance_matrix import CapacitanceMatrix
40
+
41
+
42
+ def run_fastcap(exe_path: str,
43
+ lst_file_path: str,
44
+ log_path: str,
45
+ expansion_order: float = 2,
46
+ partitioning_depth: str = 'auto',
47
+ permittivity_factor: float = 1.0,
48
+ iterative_tolerance: float = 0.01):
49
+ work_dir = os.path.dirname(lst_file_path)
50
+
51
+ # we have to chdir into the directory containing the lst file,
52
+ # so make all paths absolute, and the lst_file relative
53
+ log_path = os.path.abspath(log_path)
54
+ lst_file_path = os.path.basename(lst_file_path)
55
+
56
+ info(f"Chdir to {work_dir}")
57
+ os.chdir(work_dir)
58
+ args = [
59
+ exe_path,
60
+ f"-o{expansion_order}",
61
+ ]
62
+
63
+ if partitioning_depth != 'auto':
64
+ args += [
65
+ f"-d{partitioning_depth}",
66
+ ]
67
+
68
+ args += [
69
+ f"-p{permittivity_factor}",
70
+ f"-t{iterative_tolerance}",
71
+ f"-l{lst_file_path}",
72
+ ]
73
+
74
+ info(f"Calling FastCap2")
75
+ subproc(f"{' '.join(args)}, output file: {log_path}")
76
+
77
+ rule('FastCap Output')
78
+ start = time.time()
79
+
80
+ proc = subprocess.Popen(args,
81
+ stdin=subprocess.DEVNULL,
82
+ stdout=subprocess.PIPE,
83
+ stderr=subprocess.STDOUT,
84
+ universal_newlines=True,
85
+ text=True)
86
+ with open(log_path, 'w') as f:
87
+ while True:
88
+ line = proc.stdout.readline()
89
+ if not line:
90
+ break
91
+ subproc(line[:-1]) # remove newline
92
+ f.writelines([line])
93
+ proc.wait()
94
+
95
+ duration = time.time() - start
96
+
97
+ rule()
98
+
99
+ if proc.returncode == 0:
100
+ info(f"FastCap2 succeeded after {'%.4g' % duration}s")
101
+ else:
102
+ raise Exception(f"FastCap2 failed with status code {proc.returncode} after {'%.4g' % duration}s, "
103
+ f"see log file: {log_path}")
104
+
105
+
106
+ # CAPACITANCE MATRIX, picofarads
107
+ # 1 2 3 4
108
+ # $1%GROUP2 1 7850 -7277 -2115 54.97
109
+ # $1%GROUP2 2 -7277 3.778e+05 130.9 -3.682e+05
110
+ # $2%GROUP3 3 -2115 130.9 6792 -5388
111
+ # $2%GROUP3 4 54.97 -3.682e+05 -5388 3.753e+05
112
+ def fastcap_parse_capacitance_matrix(log_path: str) -> CapacitanceMatrix:
113
+ with open(log_path, 'r') as f:
114
+ rlines = f.readlines()
115
+ rlines.reverse()
116
+
117
+ # multiple iterations possible, find the last matrix
118
+ for idx, line in enumerate(rlines):
119
+ if line.startswith('CAPACITANCE MATRIX, '):
120
+ section_m = re.match(r'CAPACITANCE MATRIX, (\w+)', line)
121
+ if not section_m:
122
+ raise Exception(f"Could not parse capacitor unit")
123
+ unit_str = section_m.group(1)
124
+
125
+ dimension_line = rlines[idx-1].strip()
126
+ dimensions = dimension_line.split() # remove whitespace
127
+ dim = len(dimensions)
128
+ conductor_names: List[str] = []
129
+ rows: List[List[float]] = []
130
+ for i in reversed(range(idx-1-dim, idx-1)):
131
+ line = rlines[i].strip()
132
+ cells = [cell.strip() for cell in line.split(' ')]
133
+ if cells[1] != str(i):
134
+ warning(f"Expected capacitor matrix row to have index {i}, but obtained {cells[1]}")
135
+ cells.pop(1)
136
+ cells = list(filter(lambda c: len(c) >= 1, cells))
137
+ conductor_names.append(cells[0])
138
+ row = [float(cell)/1e6 for cell in cells[1:]]
139
+ rows.append(row)
140
+ cm = CapacitanceMatrix(conductor_names=conductor_names, rows=rows)
141
+ return cm
142
+
143
+ raise Exception(f"Could not extract capacitance matrix from FasterCap log file {log_path}")
@@ -0,0 +1,23 @@
1
+ #
2
+ # --------------------------------------------------------------------------------
3
+ # SPDX-FileCopyrightText: 2024 Martin Jan Köhler and Harald Pretl
4
+ # Johannes Kepler University, Institute for Integrated Circuits.
5
+ #
6
+ # This file is part of KPEX
7
+ # (see https://github.com/martinjankoehler/klayout-pex).
8
+ #
9
+ # This program is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # This program is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License
20
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ # SPDX-License-Identifier: GPL-3.0-or-later
22
+ # --------------------------------------------------------------------------------
23
+ #