blob: 3b3c332d1d2816a288a293427eda3c050021afa2 [file] [log] [blame]
#!/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 common
spice = [
'.all',
'.cor',
'.hed',
'.mod',
'.pm3',
'.scs',
'.sp',
'.spi',
'.spice',
'.txt',
]
txt_ignore = [
'README.txt',
]
o = open('.files.spice', 'w')
for pname in common.files(spice):
pname = pname.strip()
fname = os.path.split(pname)[-1]
_, ext = os.path.splitext(pname)
if ext not in spice:
continue
contents = open(pname).read()
found = []
if not contents.strip():
found.append('empty')
# Forms of subckt
# ------------------------
# Normal `.subckt` form
if '.subckt' in contents:
found.append('.subckt')
elif '.SUBCKT' in contents:
found.append('.SUBCKT')
# `inline subckt` form found in SPECTRE/*/*.pm3 files
elif 'inline subckt' in contents:
assert ext in (".pm3", '.mod'), pname
found.append('inline subckt')
# Bare `subckt` form found in XXX/spectre/spice.sp files
elif 'subckt ' in contents:
assert fname == "spice.sp", pname
found.append('bare subckt')
# Special file indicators
# ------------------------
if "SPICE3 file" in contents:
assert ext == ".spice", pname
found.append('SPICE3')
if "SPICE3 file" in contents:
assert ext == ".spice", pname
found.append('SPICE3')
if "NGSPICE file" in contents:
assert ext.startswith(".sp"), pname
found.append('NGSPICE')
# Includes
# ------------------------
if ".inc " in contents:
found.append(".inc(lude)")
if ".include " in contents:
found.append(".include")
elif "include " in contents:
found.append("(.)include")
# Other . objects
# ------------------------
if ".param" in contents:
found.append('.param')
if '.model' in contents:
found.append('.model')
if "simulator lang=spectre" in contents:
found.append('lang=spectre')
if "simulator lang=spice" in contents:
found.append('lang=spectre')
if "* model.hed" in contents:
found.append("hed")
if "save " in contents:
found.append("save")
if not found:
if fname == 'icm_pmlog.txt':
continue
if 'Calibre' in pname:
assert ext == '.mod', pname
continue
print("--", pname, 'not spice model?')
else:
print(pname, found)
o.write(pname)
o.write('\n')
o.close()