-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tt_um_kmakise_sram): workaround for SRAM macro DRC errors
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Authors: Uri Shaked | ||
|
||
import klayout.db as pya | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Extracts a given macro from a user project into a separate file, removing the original macro content from the user's project." | ||
) | ||
|
||
parser.add_argument("--design-name", "-n", required=True) | ||
parser.add_argument("--project-gds", "-p", required=True) | ||
parser.add_argument("--macro-name", "-m", required=True) | ||
parser.add_argument("--extracted-gds", "-x", required=True) | ||
|
||
|
||
args = parser.parse_args() | ||
|
||
design_name = args.design_name | ||
project_gds = args.project_gds | ||
macro_name = args.macro_name | ||
extracted_gds = args.extracted_gds | ||
|
||
user_layout = pya.Layout() | ||
user_layout.read(project_gds) | ||
|
||
macro_to_extract = user_layout.cell(macro_name) | ||
if macro_to_extract.is_empty(): | ||
raise ValueError(f"Cell {macro_name} is empty.") | ||
|
||
extracted_layout = pya.Layout() | ||
extracted_layout.dbu = user_layout.dbu | ||
extracted_cell = extracted_layout.create_cell(macro_to_extract) | ||
extracted_cell.name = macro_name | ||
extracted_cell.copy_tree(macro_to_extract) | ||
|
||
macro_to_extract.clear() | ||
# Create a single shape in the original cell to avoid opelane error about empty cells during the Stream Out (KLayout) step. | ||
macro_to_extract.shapes(0).insert(pya.Box(0, 0, 0, 0)) | ||
|
||
has_orphan_cells = True | ||
while has_orphan_cells: | ||
has_orphan_cells = False | ||
for cell in user_layout.top_cells(): | ||
if cell.name != design_name: | ||
cell.delete() | ||
has_orphan_cells = True | ||
|
||
print(f"Extracted {macro_name} from {project_gds} to {extracted_gds}.") | ||
user_layout.write(project_gds) | ||
extracted_layout.write(extracted_gds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Authors: Uri Shaked | ||
|
||
import klayout.db as pya | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description="Injects the macro into a user's project.") | ||
|
||
parser.add_argument("--input-gds", "-i", required=True) | ||
parser.add_argument("--output-gds", "-o", required=True) | ||
parser.add_argument("--project-name", "-p", required=True) | ||
parser.add_argument("--macro-name", "-m", required=True) | ||
parser.add_argument("--inject-gds", required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
input_gds = args.input_gds | ||
output_gds = args.output_gds | ||
macro_name = args.macro_name | ||
project_name = args.project_name | ||
inject_gds = args.inject_gds | ||
|
||
tt_layout = pya.Layout() | ||
tt_layout.read(input_gds) | ||
|
||
user_project_cell = tt_layout.cell(project_name) | ||
prefix = None | ||
for inst in user_project_cell.each_inst(): | ||
assert inst | ||
prefix = inst.cell.name[:3] | ||
assert prefix[2] == "_" | ||
|
||
assert prefix | ||
|
||
macro_layout = pya.Layout() | ||
macro_layout.read(inject_gds) | ||
|
||
target_cell = tt_layout.cell(prefix + macro_name) | ||
target_cell.clear() | ||
target_cell.copy_tree(macro_layout.cell(macro_name)) | ||
|
||
print(f"Injected {macro_name} and wrote the result into {output_gds}.") | ||
tt_layout.write(output_gds) |