blob: b47b42e3832878a41ad317a9987eded79d3659bf [file] [log] [blame] [edit]
#!/usr/bin/env python3
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)