From 2e533747c8b94303887d84544d58b2fa3622c06e Mon Sep 17 00:00:00 2001 From: Jock Tanner Date: Mon, 6 Apr 2020 14:11:17 +0000 Subject: [PATCH] Attempt to auto-place ALU16. --- experiments7/doAlu16.py | 34 ++++++++++++++++++++++++++-------- experiments7/utils.py | 16 ++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index 9af989a..435c619 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -71,18 +71,33 @@ class ALU16(Module): def build(self): + h_margin = 25.0 + v_margin = 75.0 + if not self.build_submodules(): return False # at this point we have the (auto-calculated) submodules' dimensions # in their `ab` properties. + add, sub = self.submodules + with SessionManager(): - self.init_ab() - self.place_submodules() + self.compute_ab() + + width = self.from_dbu( + self.ab.getWidth() + add.ab.getWidth() + sub.ab.getWidth() + ) + 4*h_margin + height = self.from_dbu(max([ + self.ab.getHeight(), add.ab.getHeight(), sub.ab.getHeight() + ])) + 2*v_margin + self.ab = Box(0, 0, self.to_dbu(width), self.to_dbu(height)) + + self.place_submodule(add, h_margin, v_margin) + self.place_submodule(sub, width-sub.ab_width-h_margin, v_margin) # TODO: replace with some form of lazy evaluation? - y_north = self.from_dbu(self.cell.getAbutmentBox().getYMax()) + y_north = self.from_dbu(self.ab.getYMax()) for pin_conf in self.north_pins: pin_conf['y'] = y_north @@ -95,14 +110,18 @@ class ALU16(Module): # this puts all the remaining cells (little ones) # into this (small) space so that they do not go # "all over the place" around the add and sub - self.ab = Box(self.to_dbu(400.0), self.to_dbu(50.0), - self.to_dbu(700.0), self.to_dbu(500.0)) + self.ab = Box( + self.to_dbu((width-self.ab_width)/2 - h_margin), + self.to_dbu(v_margin), + self.to_dbu((width+self.ab_width)/2 + h_margin), + self.to_dbu(height - v_margin) + ) self.place() # then route (globally) # this connects up not just in the remaining (little) cells, # it connects *to add and sub and the outside world as well* - self.init_ab() + self.ab = Box(0, 0, self.to_dbu(width), self.to_dbu(height)) result = self.place_and_route() self.save() @@ -144,8 +163,7 @@ def ScriptMain(editor=None, **kwargs): ) alu16 = ALU16( - 'alu16', editor, width=1100.0, height=570.0, - submodules=[(add, 25.0, 75.0), (sub, 725.0, 75.0)], + 'alu16', editor, submodules=[add, sub], north_pins=[ {'net': 'o({})', 'x': 50.0, 'delta': 60.0, 'repeat': BIT_WIDTH}, {'net': 'op'}, diff --git a/experiments7/utils.py b/experiments7/utils.py index 62ba528..5e5738f 100644 --- a/experiments7/utils.py +++ b/experiments7/utils.py @@ -143,6 +143,22 @@ class Module(object): """ return DbU.toLambda(dbu) + @property + def ab_x(self): + return self.from_dbu(self.ab.getXMin()) + + @property + def ab_y(self): + return self.from_dbu(self.ab.getYMin()) + + @property + def ab_width(self): + return self.from_dbu(self.ab.getWidth()) + + @property + def ab_height(self): + return self.from_dbu(self.ab.getXHeight()) + def compute_ab(self): """ Compute default abutment box without placement. """ etesian = Etesian.EtesianEngine.create(self.cell) -- 2.30.2