From a730fd0f10768171e165125f2b884a89c7fcee2a Mon Sep 17 00:00:00 2001 From: mrg Date: Wed, 14 Apr 2021 10:01:43 -0700 Subject: [PATCH] Use magic for LEF abstract. Fix supply perimter pin. --- compiler/base/hierarchy_layout.py | 4 +++ compiler/base/lef.py | 51 +++++++++++++++++++++++++++++-- compiler/router/router.py | 3 +- compiler/sram/sram_base.py | 18 +++++++---- 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/compiler/base/hierarchy_layout.py b/compiler/base/hierarchy_layout.py index f10280aa..36a54937 100644 --- a/compiler/base/hierarchy_layout.py +++ b/compiler/base/hierarchy_layout.py @@ -124,6 +124,8 @@ class layout(): if len(self.pin_map) > 0: for pin_set in self.pin_map.values(): + if len(pin_set) == 0: + continue lowestx = min(min(pin.lx() for pin in pin_set), lowestx) lowesty = min(min(pin.by() for pin in pin_set), lowesty) @@ -146,6 +148,8 @@ class layout(): if len(self.pin_map) > 0: for pin_set in self.pin_map.values(): + if len(pin_set) == 0: + continue highestx = max(max(pin.rx() for pin in pin_set), highestx) highesty = max(max(pin.uy() for pin in pin_set), highesty) diff --git a/compiler/base/lef.py b/compiler/base/lef.py index 942a8ac2..8ca4918b 100644 --- a/compiler/base/lef.py +++ b/compiler/base/lef.py @@ -7,6 +7,9 @@ # import debug from tech import layer_names +import os +import shutil +from globals import OPTS class lef: @@ -23,9 +26,53 @@ class lef: # Round to ensure float values are divisible by 0.0025 (the manufacturing grid) self.round_grid = 4 + def magic_lef_write(self, lef_name): + """ Use a magic script to perform LEF creation. """ + debug.info(3, "Writing abstracted LEF to {0}".format(lef_name)) + + # Copy .magicrc file into the output directory + magic_file = OPTS.openram_tech + "tech/.magicrc" + if os.path.exists(magic_file): + shutil.copy(magic_file, OPTS.openram_temp) + else: + debug.warning("Could not locate .magicrc file: {}".format(magic_file)) + + gds_name = OPTS.openram_temp + "{}.gds".format(self.name) + self.gds_write(gds_name) + + run_file = OPTS.openram_temp + "run_lef.sh" + f = open(run_file, "w") + f.write("#!/bin/sh\n") + f.write('export OPENRAM_TECH="{}"\n'.format(os.environ['OPENRAM_TECH'])) + f.write('echo "$(date): Starting GDS to MAG using Magic {}"\n'.format(OPTS.drc_exe[1])) + f.write('\n') + f.write("{} -dnull -noconsole << EOF\n".format(OPTS.drc_exe[1])) + f.write("drc off\n") + f.write("gds polygon subcell true\n") + f.write("gds warning default\n") + f.write("gds flatten true\n") + f.write("gds ordering true\n") + f.write("gds readonly true\n") + f.write("gds read {}\n".format(gds_name)) + f.write('puts "Finished reading gds {}"\n'.format(gds_name)) + f.write("load {}\n".format(self.name)) + f.write('puts "Finished loading cell {}"\n'.format(self.name)) + f.write("cellname delete \\(UNNAMED\\)\n") + f.write("lef write {} -hide\n".format(lef_name)) + f.write('puts "Finished writing LEF cell {}"\n'.format(self.name)) + f.close() + os.system("chmod u+x {}".format(run_file)) + from run_script import run_script + (outfile, errfile, resultsfile) = run_script(self.name, "lef") + def lef_write(self, lef_name): - """Write the entire lef of the object to the file.""" - debug.info(3, "Writing to {0}".format(lef_name)) + """ Write the entire lef of the object to the file. """ + + if OPTS.drc_exe[0] == "magic": + self.magic_lef_write(lef_name) + return + + debug.info(3, "Writing detailed LEF to {0}".format(lef_name)) self.indent = "" # To maintain the indent level easily diff --git a/compiler/router/router.py b/compiler/router/router.py index aa01c71f..5213af4a 100644 --- a/compiler/router/router.py +++ b/compiler/router/router.py @@ -1215,8 +1215,9 @@ class router(router_tech): return None - def get_pin(self, pin_name): + def get_ll_pin(self, pin_name): """ Return the lowest, leftest pin group """ + keep_pin = None for index,pg in enumerate(self.pin_groups[pin_name]): for pin in pg.enclosures: diff --git a/compiler/sram/sram_base.py b/compiler/sram/sram_base.py index 753200b8..6dacdd90 100644 --- a/compiler/sram/sram_base.py +++ b/compiler/sram/sram_base.py @@ -248,21 +248,27 @@ class sram_base(design, verilog, lef): # Find the lowest leftest pin for vdd and gnd for pin_name in ["vdd", "gnd"]: - # Copy the pin shape to rectangles + # Copy the pin shape(s) to rectangles for pin in self.get_pins(pin_name): self.add_rect(pin.layer, pin.ll(), pin.width(), pin.height()) - # Remove the pins + + # Remove the pin shape(s) self.remove_layout_pin(pin_name) - pin = rtr.get_pin(pin_name) - + # Get the lowest, leftest pin + pin = rtr.get_ll_pin(pin_name) + + # Add it as an IO pin to the perimeter + lowest_coord = self.find_lowest_coords() + pin_width = pin.rx() - lowest_coord.x + pin_offset = vector(lowest_coord.x, pin.by()) self.add_layout_pin(pin_name, pin.layer, - pin.ll(), - pin.width(), + pin_offset, + pin_width, pin.height()) def route_escape_pins(self):