Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 1 | #!/bin/env python3 |
| 2 | #------------------------------------------------------------------------- |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 3 | # run_drc.py --- A script to run magic in batch mode and apply full DRC |
| 4 | # checks on a layout. This inclues full DRC, antenna rule checks, and |
| 5 | # density checks. |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 6 | # |
| 7 | # Usage: |
| 8 | # |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 9 | # run_drc.py <layout_name> |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 10 | # |
| 11 | # Results: |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 12 | # |
| 13 | # generates a file "<layout_name>_drc.txt" containing a human-readable |
| 14 | # list of the DRC errors. |
| 15 | # |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 16 | #------------------------------------------------------------------------- |
| 17 | |
| 18 | import subprocess |
| 19 | import shutil |
| 20 | import sys |
| 21 | import os |
| 22 | import re |
| 23 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 24 | # Work in progress |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 25 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 26 | def run_full_drc(layout_name, output_file): |
| 27 | with open('run_magic_drc.tcl', 'w') as ofile: |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 28 | |
| 29 | # Create the GDS of the seal ring |
| 30 | |
| 31 | mproc = subprocess.run(['magic', '-dnull', '-noconsole', |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 32 | 'run_magic_drc.tcl'], |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 33 | stdin = subprocess.DEVNULL, stdout = subprocess.PIPE, |
| 34 | stderr = subprocess.PIPE, universal_newlines = True) |
| 35 | if mproc.stdout: |
| 36 | for line in mproc.stdout.splitlines(): |
| 37 | print(line) |
| 38 | if mproc.stderr: |
| 39 | print('Error message output from magic:') |
| 40 | for line in mproc.stderr.splitlines(): |
| 41 | print(line) |
| 42 | if mproc.returncode != 0: |
| 43 | print('ERROR: Magic exited with status ' + str(mproc.returncode)) |
| 44 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 45 | # If called as main, run all DRC tests |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 46 | |
| 47 | if __name__ == '__main__': |
| 48 | |
| 49 | # Divide up command line into options and arguments |
| 50 | options = [] |
| 51 | arguments = [] |
| 52 | for item in sys.argv[1:]: |
| 53 | if item.find('-', 0) == 0: |
| 54 | options.append(item) |
| 55 | else: |
| 56 | arguments.append(item) |
| 57 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 58 | # Need one argument: path to layout |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 59 | # If two arguments, then 2nd argument is the output file. |
| 60 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 61 | if len(arguments) < 3: |
| 62 | layout_root = arguments[1] |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 63 | |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 64 | if len(arguments == 1): |
| 65 | out_fileroot = layout_root + "_drc.txt" |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 66 | else: |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 67 | out_fileroot = arguments[2] |
| 68 | |
| 69 | if len(arguments) < 3: |
| 70 | run_full_drc(layout_root, out_filename) |
| 71 | else: |
| 72 | print("Usage: run_drc.py <layout_name> [<output_file>] [options]") |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 73 | print("Options:") |
Tim Edwards | a443116 | 2020-10-28 17:16:09 -0400 | [diff] [blame] | 74 | print(" (none)") |
Tim Edwards | 55f4d0e | 2020-07-05 15:41:02 -0400 | [diff] [blame] | 75 | |
| 76 | |