From cce1305da37eba227fd124150efbe94b219050f4 Mon Sep 17 00:00:00 2001 From: mrg Date: Mon, 12 Jul 2021 11:01:51 -0700 Subject: [PATCH] Add technology parameter for library prefix during uniquification of GDS --- .../example_configs/sky130_sram_common.py | 1 + compiler/gdsMill/gdsMill/vlsiLayout.py | 19 +++++++++++++------ compiler/prefixGDS.py | 19 ------------------- compiler/sram/sram.py | 7 ++++++- compiler/uniquifyGDS.py | 12 ++++++------ 5 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 compiler/prefixGDS.py diff --git a/compiler/example_configs/sky130_sram_common.py b/compiler/example_configs/sky130_sram_common.py index a827b5a9..445c88cc 100644 --- a/compiler/example_configs/sky130_sram_common.py +++ b/compiler/example_configs/sky130_sram_common.py @@ -12,6 +12,7 @@ nominal_corner_only = True route_supplies = "ring" #route_supplies = "left" check_lvsdrc = True +uniquify = True #perimeter_pins = False #netlist_only = True #analytical_delay = False diff --git a/compiler/gdsMill/gdsMill/vlsiLayout.py b/compiler/gdsMill/gdsMill/vlsiLayout.py index dbc0248b..466f4be6 100644 --- a/compiler/gdsMill/gdsMill/vlsiLayout.py +++ b/compiler/gdsMill/gdsMill/vlsiLayout.py @@ -81,7 +81,7 @@ class VlsiLayout: coordinatesRotate.extend((newX,newY)) return coordinatesRotate - def uniquify(self): + def uniquify(self, prefix_name=None): new_structures = {} if self.rootStructureName[-1] == "\x00": prefix = self.rootStructureName[0:-1] + "_" @@ -92,7 +92,10 @@ class VlsiLayout: base_name = name[0:-1] else: base_name = name - if name != self.rootStructureName: + # Don't do library cells + if prefix_name and base_name.startswith(prefix_name): + new_name = name + elif name != self.rootStructureName: new_name = self.padText(prefix + base_name) else: new_name = name @@ -105,7 +108,11 @@ class VlsiLayout: base_sref_name = sref.sName[0:-1] else: base_sref_name = sref.sName - new_sref_name = self.padText(prefix + base_sref_name) + # Don't do library cells + if prefix_name and base_sref_name.startswith(prefix_name): + new_sref_name = sref.sName + else: + new_sref_name = self.padText(prefix + base_sref_name) sref.sName = new_sref_name #print("SREF: {0} -> {1}".format(base_sref_name, new_sref_name)) self.structures = new_structures @@ -774,9 +781,9 @@ class VlsiLayout: shapes = self.getAllShapes(lpp) else: lpp = layer_override[label_text] - - - + + + except: pass for boundary in shapes: diff --git a/compiler/prefixGDS.py b/compiler/prefixGDS.py deleted file mode 100644 index 942bb7a0..00000000 --- a/compiler/prefixGDS.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 - -import sys -from gdsMill import gdsMill - -if len(sys.argv) < 3: - print("Script to prefix every instance and structure with the root cell name to provide unique namespace.") - print("Usage: {0} in.gds out.gds".format(sys.argv[0])) - sys.exit(1) - -gds_file = sys.argv[1] -gds = gdsMill.VlsiLayout() -reader = gdsMill.Gds2reader(gds) -reader.loadFromFile(gds_file) - -gds.uniquify() - -writer = gdsMill.Gds2writer(gds) -writer.writeToFile(sys.argv[2]) diff --git a/compiler/sram/sram.py b/compiler/sram/sram.py index a7d825a8..90855d8e 100644 --- a/compiler/sram/sram.py +++ b/compiler/sram/sram.py @@ -69,7 +69,12 @@ class sram(): reader = gdsMill.Gds2reader(gds) reader.loadFromFile(name) - gds.uniquify() + # Uniquify but skip the library cells since they are hard coded + try: + from tech import library_prefix_name + except ImportError: + library_prefix_name = None + gds.uniquify(library_prefix_name) writer = gdsMill.Gds2writer(gds) unique_name = name.replace(".gds", "_unique.gds") diff --git a/compiler/uniquifyGDS.py b/compiler/uniquifyGDS.py index 942bb7a0..8eddce3d 100755 --- a/compiler/uniquifyGDS.py +++ b/compiler/uniquifyGDS.py @@ -3,17 +3,17 @@ import sys from gdsMill import gdsMill -if len(sys.argv) < 3: - print("Script to prefix every instance and structure with the root cell name to provide unique namespace.") - print("Usage: {0} in.gds out.gds".format(sys.argv[0])) +if len(sys.argv) < 4: + print("Script to prefix every instance and structure with the root cell name to provide unique namespace, but skip cells that begin with the library prefix.") + print("Usage: {0} in.gds out.gds".format(sys.argv[0])) sys.exit(1) -gds_file = sys.argv[1] +gds_file = sys.argv[2] gds = gdsMill.VlsiLayout() reader = gdsMill.Gds2reader(gds) reader.loadFromFile(gds_file) -gds.uniquify() +gds.uniquify(prefix_name=sys.argv[1]) writer = gdsMill.Gds2writer(gds) -writer.writeToFile(sys.argv[2]) +writer.writeToFile(sys.argv[3])