blob: 629b4c172c67cc57914a42695c41e1b4ec0797bf [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 os
import re
import common
from pathlib import Path
re_subckt = re.compile('^\s*(?:inline)?\s*\.?(?:subckt|model)\s+([^\s]*)\s*')
broken = []
unassigned = []
for pn in common.files('spice'):
print("spice file", pn)
found = False
if Path(pn).suffix in ['.cor', '.scs', '.all']:
unassigned.append(pn)
continue
if Path(pn).suffix in ['.hed', '.txt']:
continue
with open(pn) as f:
f = iter(f)
try:
while True:
l = next(f)
l = l.strip().lower()
if l.startswith('*'):
continue
if l.startswith('//'):
continue
if 'subckt' not in l and '.model' not in l and 'model' not in l:
continue
nl = next(f)
nl = nl.strip().lower()
if 'ends' in nl:
common.add_file_for_module(mod, pn, include=True)
continue
m = re_subckt.search(l)
if not m:
print(" Error:", l)
continue
mod = m.group(1)
if mod == 'par_polyres_sub(r0':
mod = 'par_polyres_sub'
common.add_file_for_module(mod, pn)
found = True
except StopIteration:
pass
# Hack for empty file
if 's8rf_pshort_W1p65_L0p15_M4_b' in pn:
found = True
if not found:
broken.append(pn)
print(" !!!! No subckt found in", pn)
common.write_mod_json('spice', common.modules, broken)
if unassigned:
with open('.files.mod2files.spice.unassigned', 'w') as f:
for fname in unassigned:
f.write(f'{fname}\n')