Coverage for klayout_pex/magic/magic_ext_data_structures.py: 99%
79 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-03-31 19:36 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-03-31 19:36 +0000
1#! /usr/bin/env python3
2#
3# --------------------------------------------------------------------------------
4# SPDX-FileCopyrightText: 2024 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/martinjankoehler/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"
75@dataclass
76class Device:
77 device_type: DeviceType
78 model: str
79 x_bot: int
80 y_bot: int
81 x_top: int
82 y_top: int
85@dataclass
86class ExtData:
87 path: Path
88 ports: List[Port]
89 nodes: List[Node]
90 devices: List[Device]
93@dataclass
94class ResNode:
95 name: str
96 int_r: int
97 fin_c: int
98 x_bot: int
99 y_bot: int
102@dataclass
103class Resistor:
104 node1: str
105 node2: str
106 value_ohm: float
109@dataclass
110class ResExtData:
111 path: Path
112 rnodes: List[ResNode]
113 resistors: List[Resistor]
115 def rnodes_by_name(self, name: str) -> List[ResNode]:
116 return [n for n in self.rnodes if n.name == name]
119@dataclass
120class CellExtData:
121 ext_data: ExtData
122 res_ext_data: Optional[ResExtData]
125@dataclass
126class MagicPEXRun:
127 run_dir: Path
128 cells: Dict[CellName, CellExtData]