blob: 4a310c1f26bf78abc09fd362c2e929e2ee044ce9 [file] [log] [blame]
#!/usr/bin/env python3
import sys
import pathlib
import os
import common
from spice import header, change_names
_, src_dir, dst_dir = sys.argv
for a in pathlib.Path(src_dir).rglob("*.spice"):
a = str(a)[len(src_dir):]
src = a
dst = a
s = os.path.join(src_dir, src)
with open(s, "r") as f:
data = f.read()
sdir, sfile = src.split('/', 1)
sbase, sext = sfile.split('.', 1)
ddir, dfile = dst.split('/', 1)
dbase, dext = dfile.split('.', 1)
dbase = common.convert_cell_fullname(dbase)
assert '__' in dbase, (dbase, src)
ddir = dbase.split('__')[-1]
data = data.replace(sbase, dbase)
data = change_names("sky130_fd_bd_sram", data)
d = os.path.join(dst_dir, ddir, f"{dbase}.{dext}")
with open(d, "w") as f:
if not data.startswith(header):
f.write(header)
f.write(data)
print("Created", s, "from", d)
# "libraries/sky130_fd_bd_sram/v0.0.0/cells"