blob: d3723d74f390c5162aca7f543b89d81766258a72 [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 re
import common
# library (s8iom0s8_top_xres_2_ss_1.60v_1.65v_-40C) {
RE_LIB = re.compile('library\s*\(\s*"?([^) /"]+)"?\s*\)')
def process_library(l):
if 'library' not in l:
return
m = RE_LIB.search(l)
if not m:
if 'library,' in l or '_library' in l or 'library_' in l:
return
print(" Error:", m, repr(l))
return
mod = m.group(1)
assert mod, (l, m.groups())
libname, corner = common.corners_extract_from_filename(mod+'.lib')
return corner.mod
# cell (s8iom0s8_top_xres_2) {
RE_CELL = re.compile('cell\s*\(\s*"?([^) /"]+)"?\s*\)')
def process_cell(l):
# cell (s8iom0s8_top_xres_2) {
if 'cell' not in l:
return
m = RE_CELL.search(l)
if not m:
if "_cell" in l or "cell_" in l:
return
print(" Error:", m, repr(l))
return
mod = m.group(1)
assert mod, (l, m.groups())
return mod
broken = []
for pn in common.files(['.lib']):
if pn.endswith("cds.lib"):
continue
print("lib file", pn)
found = False
for l in common.read_without_cmts(pn, 'c'):
l = l.strip().lower()
mod = process_library(l)
if mod:
common.add_file_for_module(mod, pn)
found = True
continue
mod = process_cell(l)
if mod:
common.add_file_for_module(mod, pn)
found = True
continue
if pn.endswith('models/s8.lib'):
found = True
if not found:
broken.append(pn)
print(" !!!! No cells found in", pn)
common.write_mod_json('lib', common.modules, broken)