Fixes
diff --git a/gds_to_lef_gds_mag.py b/gds_to_lef_gds_mag.py
index b3ec636..72247e3 100755
--- a/gds_to_lef_gds_mag.py
+++ b/gds_to_lef_gds_mag.py
@@ -811,58 +811,60 @@
assert not os.path.exists(out_spice_file), ("Existing spice:", out_spice_file)
out_mag_file = os.path.join(temp_dir, new_cellname+'.mag')
+ out_clean_mag_file = os.path.join(temp_dir, new_cellname+'-temp.mag')
assert not os.path.exists(out_mag_file), ("Existing mag:", out_mag_file)
+ assert not os.path.exists(out_clean_mag_file), ("Existing mag:", out_clean_mag_file)
magic_generate_output(techfile, gds_file, in_lef_file, in_cdl_file, new_cellname)
+ # .magic.lef file -> output
assert os.path.exists(out_lef_file), ("Missing new LEF:", out_lef_file)
- rewrite_out_lef(out_lef_file)
-
out_mlef_file = os.path.join(temp_dir, new_cellname+'.magic.lef')
assert not os.path.exists(out_mlef_file), ("Existing .magic.lef:", out_mlef_file)
- os.rename(out_lef_file, out_mlef_file)
+ rewrite_out_lef(out_lef_file, out_mlef_file)
+ copy_file_to_output(out_mlef_file, final_dir, lib, ver, new_cellname)
+ # spice file -> output
assert os.path.exists(out_spice_file), ("Missing new spice:", out_spice_file)
rewrite_out_spice(out_spice_file)
- # spice file -> output
copy_file_to_output(out_spice_file, final_dir, lib, ver, new_cellname)
# mag file -> output
assert os.path.exists(out_mag_file), ("Missing new mag:", out_mag_file)
- rewrite_out_mag(out_mag_file)
- # mag file -> output
- copy_file_to_output(out_mag_file, final_dir, lib, ver, new_cellname)
+ rewrite_out_mag(out_mag_file, out_clean_mag_file)
+ copy_file_to_output(out_clean_mag_file, final_dir, lib, ver, new_cellname)
# GDS file -> output
copy_file_to_output(gds_file, final_dir, lib, ver, new_cellname)
copy_file_to_output(gds_opin_file, final_dir, lib, ver, new_cellname)
- # .magic.lef file -> output
- copy_file_to_output(out_mlef_file, final_dir, lib, ver, new_cellname)
return new_cellname
-def rewrite_out_lef(lef_file):
- with open(lef_file, 'r') as f:
+def rewrite_out_lef(lef_in_file, lef_out_file=None):
+ if lef_out_file is None:
+ lef_out_file = lef_in_file
+
+ with open(lef_in_file, 'r') as f:
contents = f.read()
contents = canonicalize_lef(contents)
- with open(lef_file, 'w') as f:
+ with open(lef_out_file, 'w') as f:
f.write(contents)
prepend_copyright(lef_file)
-def rewrite_out_mag(mag_file):
- with open(mag_file, 'r') as f:
+def rewrite_out_mag(mag_in_file, mag_out_file):
+ with open(mag_in_file, 'r') as f:
contents = f.read()
contents = re.sub('timestamp [0-9]+', 'timestamp 0', contents)
contents = re.sub('string GDS_FILE .*', 'string GDS_FILE '+mag_file.replace('.mag', '.gds'), contents)
- with open(mag_file, 'w') as f:
+ with open(mag_out_file, 'w') as f:
f.write(contents)
diff --git a/mag_rewrite.py b/mag_rewrite.py
new file mode 100755
index 0000000..f58f0d0
--- /dev/null
+++ b/mag_rewrite.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+
+import sys
+
+from gds_to_lef_gds_mag import rewrite_out_mag
+
+sys.exit(rewrite_out_mag(sys.argv[1]))