| #!/usr/bin/env python3 |
| # |
| # fix_vssio_lvc_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_lvc_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_lvc_gds.py <filename>') |
| sys.exit(1) |
| else: |
| file_name = sys.argv[1] |
| |
| # Metal 3 resistor at (0.505um 61.12um 24.385um 61.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\xee\xc0\x00\x00\x5f\x41\x00\x00\xee\xc0\x00\x00\x5f\x41\x00\x00\xf0\x78\x00\x00\x01\xf9\x00\x00\xf0\x78\x00\x00\x01\xf9\x00\x00\xee\xc0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (50.76um 61.12um 74.64um 61.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\xc6\x48\x00\x00\xee\xc0\x00\x01\x23\x90\x00\x00\xee\xc0\x00\x01\x23\x90\x00\x00\xf0\x78\x00\x00\xc6\x48\x00\x00\xf0\x78\x00\x00\xc6\x48\x00\x00\xee\xc0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (24.375um 55.760um 24.385um 61.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\xd9\xd0\x00\x00\x5f\x41\x00\x00\xd9\xd0\x00\x00\x5f\x41\x00\x00\xee\xc0\x00\x00\x5f\x37\x00\x00\xee\xc0\x00\x00\x5f\x37\x00\x00\xd9\xd0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (0.505um 55.760um 0.515um 61.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\xd9\xd0\x00\x00\x02\x03\x00\x00\xd9\xd0\x00\x00\x02\x03\x00\x00\xee\xc0\x00\x00\x01\xf9\x00\x00\xee\xc0\x00\x00\x01\xf9\x00\x00\xd9\xd0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (0.505um 55.32um 24.385um 55.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\xd8\x18\x00\x00\x5f\x41\x00\x00\xd8\x18\x00\x00\x5f\x41\x00\x00\xd9\xd0\x00\x00\x01\xf9\x00\x00\xd9\xd0\x00\x00\x01\xf9\x00\x00\xd8\x18\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (50.76um 55.32um 74.64um 55.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\xc6\x48\x00\x00\xd8\x18\x00\x01\x23\x90\x00\x00\xd8\x18\x00\x01\x23\x90\x00\x00\xd9\xd0\x00\x00\xc6\x48\x00\x00\xd9\xd0\x00\x00\xc6\x48\x00\x00\xd8\x18\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (50.76um 55.760um 50.77um 61.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\xc6\x48\x00\x00\xd9\xd0\x00\x00\xc6\x52\x00\x00\xd9\xd0\x00\x00\xc6\x52\x00\x00\xee\xc0\x00\x00\xc6\x48\x00\x00\xee\xc0\x00\x00\xc6\x48\x00\x00\xd9\xd0\x00\x04\x11\x00' |
| |
| # Metal 3 resistor at (74.63um 55.760um 74.64um 61.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\x23\x86\x00\x00\xd9\xd0\x00\x01\x23\x90\x00\x00\xd9\xd0\x00\x01\x23\x90\x00\x00\xee\xc0\x00\x01\x23\x86\x00\x00\xee\xc0\x00\x01\x23\x86\x00\x00\xd9\xd0\x00\x04\x11\x00' |
| |
| # PADISOR label at (67.45um 58.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\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\x00\xe3\xe4\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x52\x00\x00\x04\x11\x00' |
| |
| # PADISOL label at (5.05um 58.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\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\x00\xe3\xe4\x00\x0c\x19\x06\x50\x41\x44\x49\x53\x4f\x4c\x00\x00\x04\x11\x00' |
| |
| # Append after this data |
| orig_data = b'\x00\x00\x61\x8f\x00\x01\x12\xc4\x00\x03\x05\x70\x00\x01\x0b\xda\x00\x03\x05\x70\x00\x01\x0b\xda\x00\x00\x61\x8f\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!") |