blob: 02cec3173ca263fec4dc94fc88a5a66277e95a33 [file] [log] [blame] [edit]
#!/usr/bin/env python3
# Copyright 2020 The Skywater PDK Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import os
import pprint
import re
from collections import defaultdict
import common
from spice import RE_SPICE_INC
"""
* RF MOS PARAMETERS
.inc "nshort_rf_base_b_tt_leak.cor"
.inc "nlowvt_rf_base_b_tt_leak.cor"
.inc "nhv_rf_base_b_tt_leak.cor"
.inc "pshort_rf_base_b_tt_leak.cor"
.inc "nshort_rf_mm.cor"
.inc "nlowvt_rf_mm.cor"
.inc "nhv_rf_mm.cor"
.inc "pshort_rf_mm.cor"
.inc "pmedlvt_rf_ttleak_discrete.cor"
.inc "pmedlvt_rf_mm.cor"
"""
includes = {}
include_files = defaultdict(set)
for pn in common.files('spice'):
_, ext = os.path.splitext(pn)
cmts = [('*', '//'), [('/*','*/')]]
includes[pn] = set()
basedir = os.path.split(pn)[0]
print("--", "Reading -->", pn)
for line in common.read_without_cmts(pn, cmts):
m = RE_SPICE_INC.match(line)
if not m:
continue
print(line)
else:
fullname = os.path.realpath(os.path.join(basedir, m.group("inc")))
_, ext = os.path.splitext(fullname)
if os.path.exists(fullname):
print(ext, " Found", fullname)
else:
print(ext, "*Not* Found", fullname)
includes[pn].add(fullname)
# Save the include graph
for inculder in includes:
includes[inculder] = tuple(sorted(includes[inculder]))
json.dump(includes, open(".files.includes.spice.json", "w"), sort_keys=True, indent=2)
# Work out any missing includes
missing = set()
for inculder in includes:
for includee in includes[inculder]:
if includee not in includes:
missing.add(includee)
with open(".files.includes.spice.missing", "w") as f:
for pn in sorted(missing):
f.write(pn)
f.write("\n")
# Build a reverse include (dependency) map
rincludes = defaultdict(set)
for includer in includes:
rincludes[includer].add(None)
for includee in includes[includer]:
rincludes[includee].add(includer)
for includee in rincludes:
rincludes[includee] = tuple(sorted(x for x in rincludes[includee] if x is not None))
json.dump(rincludes, open(".files.rincludes.spice.json", "w"), sort_keys=True, indent=2)
print()
if missing:
print("Missing?")
print("-"*75)
for pn in sorted(missing):
if not os.path.exists(pn):
print(" ", end="")
else:
print(">", end="")
print(pn)
print("-"*75)
else:
print("No missing includes!")