forked from SiEPIC/openEBL-2024-07-Si-Heaters
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_DRC.py
101 lines (85 loc) · 2.87 KB
/
run_DRC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pya
import os
import sys
"""
Load a layout file passed through the commmand line
Run DRC verification.
Lukas Chrostowski 2024/07/12
"""
num_errors = 0
# gds file to run verification on
if len(sys.argv)>1:
gds_file = sys.argv[1]
else:
# debugging:
import os
gds_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'submissions/EBeam_heaters_BraggGratingwithHeater.gds')
if "framework/EBL_Framework_1cm_PCM_static" in gds_file:
exit()
# load into layout
try:
# load into layout
layout = pya.Layout()
layout.read(gds_file)
except:
print('Error loading layout')
num_errors = 1
# get top cell from layout
try:
# get top cell from layout
if len(layout.top_cells()) != 1:
print('Error: the layout needs to have only 1 top cell. It has %s.' % len(layout.top_cells()))
num_errors += 1
top_cell = layout.top_cell()
except:
print('Unknown error occurred')
num_errors = 1
'''
# run verification
# Presently not possible via Python pya module
# https://www.klayout.de/forum/discussion/2108/build-qt-ui-in-python-module-to-run-drc
drc_interpreter = pya.Interpreter.ruby_interpreter()
drc_interpreter.define_variable("input", layout)
drc_script = os.path.join(layout.technology().base_path(), "drc/SiEPIC_EBeam.drc")
m = pya.Macro.new(drc_script)
m.interpreter=pya.Macro.Ruby
m.run()
'''
# run verification
rule_table_space_width = [
['Silicon 1/0', 1,0,70,60],
['Silicon Nitride 1/5', 1,5,120,120],
['M1 Heater 11/0', 11,0,3000,3000],
['M2 Routing metal', 12,0,5000,8000],
['Metal Pad open', 13,0,10000,10000],
]
def check_space_width (cell, rule_table_space_width, tolerance=1):
'''
KLayout DRC checking using pya.Region.
Input:
cell: pya.Cell
rule_table_space_width: [
['name', layer_number, data_type, min_space, min_size]
]
min_space, min_size: Int, in database units
tolerance: int, subtract from the rule
'''
errors = 'Manufacturing Design Rule Check (DRC)\n'
num_errors = 0
for rule in rule_table_space_width:
r = pya.Region(cell.begin_shapes_rec(cell.layout().layer(rule[1], rule[2])))
e = r.space_check(rule[3]-tolerance, ignore_angle=80, metrics=pya.Region.Euclidian)
if e:
errors += ' - Layer %s, Space %s nm minimum, %s error(s).\n' % (rule[0], rule[3], len(e))
num_errors += len(e)
e = r.width_check(rule[4]-tolerance, ignore_angle=80, metrics=pya.Region.Euclidian)
if e:
errors += ' - Layer %s, Width %s nm minimum, %s error(s).\n' % (rule[0], rule[4], len(e))
num_errors += len(e)
if num_errors == 0:
errors += ' - No Space/Width errors detected.'
return num_errors, errors
num_errors, errors = check_space_width (layout.top_cell(), rule_table_space_width)
print(errors)
# Print the result value to standard output
print(num_errors)