Coverage for klayout_pex / magic / magic_ext_data_structures.py: 99%
80 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-02 17:12 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-02 17:12 +0000
1#! /usr/bin/env python3
2#
3# --------------------------------------------------------------------------------
4# SPDX-FileCopyrightText: 2024-2025 Martin Jan Köhler and Harald Pretl
5# Johannes Kepler University, Institute for Integrated Circuits.
6#
7# This file is part of KPEX
8# (see https://github.com/iic-jku/klayout-pex).
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22# SPDX-License-Identifier: GPL-3.0-or-later
23# --------------------------------------------------------------------------------
24#
26from __future__ import annotations
28from enum import StrEnum
29from dataclasses import dataclass
30from pathlib import Path
31from typing import *
34CellName = str
37@dataclass
38class Port:
39 net: str
40 x_bot: int
41 y_bot: int
42 x_top: int
43 y_top: int
44 layer: str
47@dataclass
48class Node:
49 net: str
50 int_r: int
51 fin_c: int
52 x_bot: int
53 y_bot: int
54 layer: str
57class DeviceType(StrEnum):
58 FET = "fet"
59 MOSFET = "mosfet"
60 ASSYMETRIC = "asymmetric"
61 BJT = "bjt"
62 DEVRES = "devres"
63 DEVCAP = "devcap"
64 DEVCAPREV = "devcaprev"
65 VSOURCE = "vsource"
66 DIODE = "diode"
67 PDIODE = "pdiode"
68 NDIODE = "ndiode"
69 SUBCKT = "subckt"
70 RSUBCKT = "rsubckt"
71 MSUBCKT = "msubckt"
72 CSUBCKT = "csubckt"
73 DSUBCKT = "dsubckt"
76@dataclass
77class Device:
78 device_type: DeviceType
79 model: str
80 x_bot: int
81 y_bot: int
82 x_top: int
83 y_top: int
86@dataclass
87class ExtData:
88 path: Path
89 ports: List[Port]
90 nodes: List[Node]
91 devices: List[Device]
94@dataclass
95class ResNode:
96 name: str
97 int_r: int
98 fin_c: int
99 x_bot: int
100 y_bot: int
103@dataclass
104class Resistor:
105 node1: str
106 node2: str
107 value_ohm: float
110@dataclass
111class ResExtData:
112 path: Path
113 rnodes: List[ResNode]
114 resistors: List[Resistor]
116 def rnodes_by_name(self, name: str) -> List[ResNode]:
117 return [n for n in self.rnodes if n.name == name]
120@dataclass
121class CellExtData:
122 ext_data: ExtData
123 res_ext_data: Optional[ResExtData]
126@dataclass
127class MagicPEXRun:
128 run_dir: Path
129 cells: Dict[CellName, CellExtData]