| #!/usr/bin/env python3 |
| # |
| # fix_vssio_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__top_ground_hvc_wpad cell. Also add label for PAD_ISO |
| # in the isolated metal3 regions formed by the resistors. |
| # |
| |
| import sys |
| |
| if len(sys.argv) != 2: |
| print('Usage: fix_vssio_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 57.760um 24.385um 63.120um) |
| 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\xe1\xa0\x00\x00\x5f\x41\x00\x00\xe1\xa0\x00\x00\x5f\x41\x00\x00\xf6\x90\x00\x00\x5f\x37\x00\x00\xf6\x90\x00\x00\x5f\x37\x00\x00\xe1\xa0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (0.505um 57.760um 0.515um 63.120um) |
| 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\xe1\xa0\x00\x00\x02\x03\x00\x00\xe1\xa0\x00\x00\x02\x03\x00\x00\xf6\x90\x00\x00\x01\xf9\x00\x00\xf6\x90\x00\x00\x01\xf9\x00\x00\xe1\xa0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (0.505um 57.32um 24.385um 57.76um) |
| 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\x00\xdf\xe8\x00\x00\x5f\x41\x00\x00\xdf\xe8\x00\x00\x5f\x41\x00\x00\xe1\xa0\x00\x00\x01\xf9\x00\x00\xe1\xa0\x00\x00\x01\xf9\x00\x00\xdf\xe8\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (50.40um 57.32um 74.28um 57.76um) |
| 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\x00\xdf\xe8\x00\x01\x22\x28\x00\x00\xdf\xe8\x00\x01\x22\x28\x00\x00\xe1\xa0\x00\x00\xc4\xe0\x00\x00\xe1\xa0\x00\x00\xc4\xe0\x00\x00\xdf\xe8\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (50.40um 57.760um 50.41um 63.120um) |
| 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\xe1\xa0\x00\x00\xc4\xea\x00\x00\xe1\xa0\x00\x00\xc4\xea\x00\x00\xf6\x90\x00\x00\xc4\xe0\x00\x00\xf6\x90\x00\x00\xc4\xe0\x00\x00\xe1\xa0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (74.27um 57.760um 74.28um 63.120um) |
| 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\xe1\xa0\x00\x01\x22\x28\x00\x00\xe1\xa0\x00\x01\x22\x28\x00\x00\xf6\x90\x00\x01\x22\x1e\x00\x00\xf6\x90\x00\x01\x22\x1e\x00\x00\xe1\xa0\x00\x04\x11\x00' |
| |
| # PADISOR label at (67.45um 60.34um) size 0.3um on MET3PIN |
| add_data_9 = b'\x00\x04\x0c\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x16\x02\x00\x05\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\x00\xeb\xb4\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x52\x00\x00\x04\x11\x00' |
| |
| # PADISOL label at (5.05um 60.34um) size 0.3um on MET3PIN |
| add_data_10 = b'\x00\x04\x0c\x00\x00\x06\x0d\x02\x00\x46\x00\x06\x16\x02\x00\x05\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\x00\xeb\xb4\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x4c\x00\x00\x04\x11\x00' |
| |
| # Append after this data |
| orig_data = b'\x00\x02\x7d\xd0\x00\x01\x11\xb1\x00\x02\x7e\x98\x00\x01\x10\xe9\x00\x02\x7e\x98\x00\x01\x10\xe9\x00\x02\x7d\xd0\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, orig_data + add_data_1 + add_data_2 + add_data_3 + add_data_4 + add_data_5 + add_data_6 + add_data_7 + add_data_8 + add_data_9 + add_data_10) |
| |
| # Write back into the same file |
| with open(file_name, 'wb') as ofile: |
| ofile.write(data) |
| |
| print("Done!") |