blob: 0513066e2ca58249f439eb081b55698e5ef44e4f [file] [log] [blame]
Tim Edwards55f4d0e2020-07-05 15:41:02 -04001#!/bin/env python3
2#-------------------------------------------------------------------------
Tim Edwardsa4431162020-10-28 17:16:09 -04003# 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 Edwards55f4d0e2020-07-05 15:41:02 -04006#
7# Usage:
8#
Tim Edwardsa4431162020-10-28 17:16:09 -04009# run_drc.py <layout_name>
Tim Edwards55f4d0e2020-07-05 15:41:02 -040010#
11# Results:
Tim Edwardsa4431162020-10-28 17:16:09 -040012#
13# generates a file "<layout_name>_drc.txt" containing a human-readable
14# list of the DRC errors.
15#
Tim Edwards55f4d0e2020-07-05 15:41:02 -040016#-------------------------------------------------------------------------
17
18import subprocess
19import shutil
20import sys
21import os
22import re
23
Tim Edwardsa4431162020-10-28 17:16:09 -040024# Work in progress
Tim Edwards55f4d0e2020-07-05 15:41:02 -040025
Tim Edwardsa4431162020-10-28 17:16:09 -040026def run_full_drc(layout_name, output_file):
27 with open('run_magic_drc.tcl', 'w') as ofile:
Tim Edwards55f4d0e2020-07-05 15:41:02 -040028
29 # Create the GDS of the seal ring
30
31 mproc = subprocess.run(['magic', '-dnull', '-noconsole',
Tim Edwardsa4431162020-10-28 17:16:09 -040032 'run_magic_drc.tcl'],
Tim Edwards55f4d0e2020-07-05 15:41:02 -040033 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 Edwardsa4431162020-10-28 17:16:09 -040045# If called as main, run all DRC tests
Tim Edwards55f4d0e2020-07-05 15:41:02 -040046
47if __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 Edwardsa4431162020-10-28 17:16:09 -040058 # Need one argument: path to layout
Tim Edwards55f4d0e2020-07-05 15:41:02 -040059 # If two arguments, then 2nd argument is the output file.
60
Tim Edwardsa4431162020-10-28 17:16:09 -040061 if len(arguments) < 3:
62 layout_root = arguments[1]
Tim Edwards55f4d0e2020-07-05 15:41:02 -040063
Tim Edwardsa4431162020-10-28 17:16:09 -040064 if len(arguments == 1):
65 out_fileroot = layout_root + "_drc.txt"
Tim Edwards55f4d0e2020-07-05 15:41:02 -040066 else:
Tim Edwardsa4431162020-10-28 17:16:09 -040067 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 Edwards55f4d0e2020-07-05 15:41:02 -040073 print("Options:")
Tim Edwardsa4431162020-10-28 17:16:09 -040074 print(" (none)")
Tim Edwards55f4d0e2020-07-05 15:41:02 -040075
76