|
20 | 20 | for i in main_layout.each_cell(): |
21 | 21 | print("[INFO] '{0}'".format(i.name)) |
22 | 22 |
|
23 | | -print("[INFO] Reading DEF ...") |
24 | 23 | main_layout.read(in_def, layoutOptions) |
25 | 24 |
|
26 | 25 | # Clear cells |
27 | 26 | top_cell_index = main_layout.cell(design_name).cell_index() |
28 | 27 |
|
29 | 28 | # remove orphan cell BUT preserve cell with VIA_ |
30 | 29 | # - KLayout is prepending VIA_ when reading DEF that instantiates LEF's via |
31 | | -print("[INFO] Clearing cells...") |
32 | 30 | for i in main_layout.each_cell(): |
33 | 31 | if i.cell_index() != top_cell_index: |
34 | 32 | if not i.name.startswith("VIA_") and not i.name.endswith("_DEF_FILL"): |
35 | 33 | i.clear() |
36 | 34 |
|
37 | 35 | # Load in the gds to merge |
38 | | -print("[INFO] Merging GDS/OAS files...") |
39 | 36 | for fil in in_files.split(): |
40 | 37 | print("\t{0}".format(fil)) |
41 | 38 | main_layout.read(fil) |
42 | 39 |
|
43 | 40 | # Copy the top level only to a new layout |
44 | | -print("[INFO] Copying toplevel cell '{0}'".format(design_name)) |
45 | 41 | top_only_layout = pya.Layout() |
46 | 42 | top_only_layout.dbu = main_layout.dbu |
47 | 43 | top = top_only_layout.create_cell(design_name) |
48 | 44 | top.copy_tree(main_layout.cell(design_name)) |
49 | 45 |
|
50 | | -print("[INFO] Checking for missing cell from GDS/OAS...") |
51 | 46 | missing_cell = False |
52 | | -regex = None |
53 | | -if "GDS_ALLOW_EMPTY" in os.environ: |
54 | | - print("[INFO] Found GDS_ALLOW_EMPTY variable.") |
55 | | - regex = os.getenv("GDS_ALLOW_EMPTY") |
| 47 | +allow_empty = os.environ.get("GDS_ALLOW_EMPTY", "") |
| 48 | +regex = re.compile(allow_empty) if allow_empty else None |
| 49 | + |
| 50 | +if allow_empty: |
| 51 | + print(f"[INFO] GDS_ALLOW_EMPTY={allow_empty}") |
| 52 | + |
56 | 53 | for i in top_only_layout.each_cell(): |
57 | 54 | if i.is_empty(): |
58 | 55 | missing_cell = True |
59 | | - if regex is not None and re.match(regex, i.name): |
| 56 | + if regex is not None and regex.match(i.name): |
60 | 57 | print( |
61 | 58 | "[WARNING] LEF Cell '{0}' ignored. Matches GDS_ALLOW_EMPTY.".format( |
62 | 59 | i.name |
|
72 | 69 | if not missing_cell: |
73 | 70 | print("[INFO] All LEF cells have matching GDS/OAS cells") |
74 | 71 |
|
75 | | -print("[INFO] Checking for orphan cell in the final layout...") |
76 | 72 | orphan_cell = False |
77 | 73 | for i in top_only_layout.each_cell(): |
78 | 74 | if i.name != design_name and i.parent_cells() == 0: |
|
81 | 77 | errors += 1 |
82 | 78 |
|
83 | 79 | if not orphan_cell: |
84 | | - print("[INFO] No orphan cells") |
| 80 | + print("[INFO] No orphan cells in the final layout") |
85 | 81 |
|
86 | 82 |
|
87 | 83 | if seal_file: |
88 | 84 | top_cell = top_only_layout.top_cell() |
89 | 85 |
|
90 | | - print("[INFO] Reading seal GDS/OAS file...") |
91 | | - print("\t{0}".format(seal_file)) |
92 | 86 | top_only_layout.read(seal_file) |
93 | 87 |
|
94 | 88 | for cell in top_only_layout.top_cells(): |
|
101 | 95 | top.insert(pya.CellInstArray(cell.cell_index(), pya.Trans())) |
102 | 96 |
|
103 | 97 | # Write out the GDS |
104 | | -print("[INFO] Writing out GDS/OAS '{0}'".format(out_file)) |
105 | 98 | top_only_layout.write(out_file) |
106 | 99 |
|
107 | 100 | sys.exit(errors) |
0 commit comments