Coverage for klayout_pex/klayout/lvs_runner.py: 96%
26 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-17 17:24 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-17 17:24 +0000
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#
24from __future__ import annotations
26import os
27import subprocess
28import time
30from ..log import (
31 debug,
32 info,
33 warning,
34 error,
35 subproc,
36 rule
37)
40class LVSRunner:
41 @staticmethod
42 def run_klayout_lvs(exe_path: str,
43 lvs_script: str,
44 gds_path: str,
45 schematic_path: str,
46 log_path: str,
47 lvsdb_path: str):
48 args = [
49 exe_path,
50 '-b',
51 '-r', lvs_script,
52 '-rd', f"input={os.path.abspath(gds_path)}",
53 '-rd', f"report={os.path.abspath(lvsdb_path)}",
54 '-rd', f"schematic={os.path.abspath(schematic_path)}",
55 '-rd', 'thr=22',
56 '-rd', 'run_mode=deep',
57 '-rd', 'spice_net_names=true',
58 '-rd', 'spice_comments=false',
59 '-rd', 'scale=false',
60 '-rd', 'verbose=true',
61 '-rd', 'schematic_simplify=false',
62 '-rd', 'net_only=false',
63 '-rd', 'top_lvl_pins=true',
64 '-rd', 'combine=false',
65 '-rd', 'combine_devices=false', # IHP
66 '-rd', 'purge=false',
67 '-rd', 'purge_nets=false',
68 '-rd', 'no_simplify=true', # IHP
69 ]
70 info(f"Calling {' '.join(args)}, output file: {log_path}")
71 rule()
72 start = time.time()
74 proc = subprocess.Popen(args,
75 stdin=subprocess.DEVNULL,
76 stdout=subprocess.PIPE,
77 stderr=subprocess.STDOUT,
78 universal_newlines=True,
79 text=True)
80 with open(log_path, 'w') as f:
81 while True:
82 line = proc.stdout.readline()
83 if not line:
84 break
85 subproc(line[:-1]) # remove newline
86 f.writelines([line])
87 proc.wait()
89 duration = time.time() - start
91 rule()
93 if proc.returncode == 0:
94 info(f"klayout LVS succeeded after {'%.4g' % duration}s")
95 else:
96 warning(f"klayout LVS failed with status code {proc.returncode} after {'%.4g' % duration}s, "
97 f"see log file: {log_path}")