blob: 324093975e45cbb145f7109cb4973bf3043f530d [file] [log] [blame]
#!/usr/bin/env python3
#
# fix_vddio_pad_gds.py ---
#
# Special-purpose script that does the work of what ought to be a simple
# binary diff and patch. Except that no such thing exists as a standard
# offering on most Linux systems, so instead of adding another OS
# package requirement, I'm just writing a binary search-and-replace in
# python.
#
# The purpose of the patch is to add metal3 resistor ID markers to the
# sky130_fd_io__hvc_clampv2 cell. Also add label for PADISOL|R
# in the isolated metal3 region formed by the resistors, in the
# sky130_fd_io__top_power_hvc_wpadv2 cell.
#
import sys
if len(sys.argv) != 2:
print('Usage: fix_vddio_pad_gds.py <filename>')
sys.exit(1)
else:
file_name = sys.argv[1]
# Metal 3 resistor at (0.505um 63.12um 24.385um 63.56um)
add_data_1 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\x01\xf9\x00\x00\xf6\x90\x00\x00\x5f\x41\x00\x00\xf6\x90\x00\x00\x5f\x41\x00\x00\xf8\x48\x00\x00\x01\xf9\x00\x00\xf8\x48\x00\x00\x01\xf9\x00\x00\xf6\x90\x00\x04\x11\x00'
# Metal 3 resistor at (50.40um 63.12um 74.28um 63.56um)
add_data_2 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\xc4\xe0\x00\x00\xf6\x90\x00\x01\x22\x28\x00\x00\xf6\x90\x00\x01\x22\x28\x00\x00\xf8\x48\x00\x00\xc4\xe0\x00\x00\xf8\x48\x00\x00\xc4\xe0\x00\x00\xf6\x90\x00\x04\x11\x00'
# Metal 3 resistor at (24.375um 63.56um 24.385um 69.07um)
add_data_3 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\x5f\x37\x00\x00\xf8\x48\x00\x00\x5f\x41\x00\x00\xf8\x48\x00\x00\x5f\x41\x00\x01\x0d\xce\x00\x00\x5f\x37\x00\x01\x0d\xce\x00\x00\x5f\x37\x00\x00\xf8\x48\x00\x04\x11\x00'
# Metal 3 resistor at (0.505um 63.56um 0.515um 69.07um)
add_data_4 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\x01\xf9\x00\x00\xf8\x48\x00\x00\x02\x03\x00\x00\xf8\x48\x00\x00\x02\x03\x00\x01\x0d\xce\x00\x00\x01\xf9\x00\x01\x0d\xce\x00\x00\x01\xf9\x00\x00\xf8\x48\x00\x04\x11\x00'
# Metal 3 resistor at (0.505um 69.07um 24.385um 69.51um)
add_data_5 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\x01\xf9\x00\x01\x0d\xce\x00\x00\x5f\x41\x00\x01\x0d\xce\x00\x00\x5f\x41\x00\x01\x0f\x86\x00\x00\x01\xf9\x00\x01\x0f\x86\x00\x00\x01\xf9\x00\x01\x0d\xce\x00\x04\x11\x00'
# Metal 3 resistor at (50.40um 69.07um 74.28um 69.51um)
add_data_6 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\xc4\xe0\x00\x01\x0d\xce\x00\x01\x22\x28\x00\x01\x0d\xce\x00\x01\x22\x28\x00\x01\x0f\x86\x00\x00\xc4\xe0\x00\x01\x0f\x86\x00\x00\xc4\xe0\x00\x01\x0d\xce\x00\x04\x11\x00'
# Metal 3 resistor at (50.40um 63.56um 50.41um 69.07um)
add_data_7 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x00\xc4\xe0\x00\x00\xf8\x48\x00\x00\xc4\xea\x00\x00\xf8\x48\x00\x00\xc4\xea\x00\x01\x0d\xce\x00\x00\xc4\xe0\x00\x01\x0d\xce\x00\x00\xc4\xe0\x00\x00\xf8\x48\x00\x04\x11\x00'
# Metal 3 resistor at (74.27um 63.56um 74.28um 69.07um)
add_data_8 = b'\x00\x04\x08\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x0e\x02\x00\x0d\x00\x2c\x10\x03\x00\x01\x22\x1e\x00\x00\xf8\x48\x00\x01\x22\x28\x00\x00\xf8\x48\x00\x01\x22\x28\x00\x01\x0d\xce\x00\x01\x22\x1e\x00\x01\x0d\xce\x00\x01\x22\x1e\x00\x00\xf8\x48\x00\x04\x11\x00'
# PADISOR label at (67.45um 66.22um) size 0.3um on MET3PIN
add_data_9 = b'\x00\x04\x0c\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x16\x02\x00\x10\x00\x06\x17\x01\x00\x05\x00\x06\x1a\x01\x00\x00\x00\x0c\x1b\x05\x40\x4c\x66\x66\x66\x66\x66\x66\x00\x0c\x10\x03\x00\x01\x07\x7a\x00\x01\x02\xac\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x52\x00\x00\x04\x11\x00'
# PADISOL label at (5.05um 66.22um) size 0.3um on MET3PIN
add_data_10 = b'\x00\x04\x0c\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x16\x02\x00\x10\x00\x06\x17\x01\x00\x05\x00\x06\x1a\x01\x00\x00\x00\x0c\x1b\x05\x40\x4c\x66\x66\x66\x66\x66\x66\x00\x0c\x10\x03\x00\x00\x13\xba\x00\x01\x02\xac\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x4c\x00\x00\x04\x11\x00'
# Append metal resistors after this data (between 70:44 and 69:44)
orig_data_1 = b'\x00\x02\x9d\x33\x00\x00\x2b\x1b\x00\x02\x9d\xfb\x00\x00\x2a\x53\x00\x02\x9d\xfb\x00\x00\x2a\x53\x00\x02\x9d\x33\x00\x04\x11\x00'
# Append port label after this data (after "P_CORE" label)
orig_data_2 = b'\x00\x0c\x10\x03\x00\x00\x2d\x1e\x00\x00\x05\x23\x00\x0a\x19\x06\x50\x5f\x43\x4f\x52\x45\x00\x04\x11\x00'
# This is not efficient, but only needs to be done once.
with open(file_name, 'rb') as ifile:
data = ifile.read()
data = data.replace(orig_data_1, orig_data_1 + add_data_1 + add_data_2 + add_data_3 + add_data_4 + add_data_5 + add_data_6 + add_data_7 + add_data_8)
data = data.replace(orig_data_2, orig_data_2 + add_data_9 + add_data_10)
# Write back into the same file
with open(file_name, 'wb') as ofile:
ofile.write(data)
print("Done!")