From f5aea1f69da69776cbbc189695569b3afc6b42fd Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 21 Apr 2020 15:07:11 +0000 Subject: [PATCH] move match_instance to Module --- experiments7/doAlu16.py | 38 +++----------------------------------- experiments7/utils.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index d9c2a97..490f9b8 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from __future__ import print_function import sys -import re import CRL import Cfg @@ -68,37 +67,6 @@ class AddSub(Module): class ALU16(Module): - @staticmethod - def match_instance(datapath_insts, op, plug_name, inst): - """ - Guess the position of an instance from its nets connections, - and put it at the right place in the datapath vector. - - :param datapath_insts: vector of bit slices, - :param op: operator name, - :param inst: instance to classify, - :param plug_name: name of the plug to use to guess the bit index, - :return: boolean, True if the instance has been matched. - """ - if not inst.getMasterCell().getName().startswith(op): - return False - re_net_index = re.compile(r'[^(]+\((?P[\d]+)\)$') - for plug in inst.getPlugs(): - if plug.getMasterNet().getName() != plug_name: - continue - m = re_net_index.match(plug.getNet().getName()) - if not m: - continue - bit_slice = datapath_insts[int(m.group('index'))] - for column in bit_slice: - if column[0] == op: - column[1] = inst - print ("match", plug_name, int(m.group('index')), - column, inst) - return True - break - return False - def place_datapath(self, datapath_insts, x_orig, y_orig, fold): channel_sff1 = self.to_dbu(0) with SessionManager(): @@ -130,9 +98,9 @@ class ALU16(Module): ['sff1', None]]) for inst in self.cell.getInstances(): - if (ALU16.match_instance(datapath_insts, 'nmx2', 'i0', inst) or - ALU16.match_instance(datapath_insts, 'no2', 'nq', inst) or - ALU16.match_instance(datapath_insts, 'sff1', 'i', inst)): + if (Module.match_instance(datapath_insts, 'nmx2', 'i0', inst) or + Module.match_instance(datapath_insts, 'no2', 'nq', inst) or + Module.match_instance(datapath_insts, 'sff1', 'i', inst)): continue # place to right of add diff --git a/experiments7/utils.py b/experiments7/utils.py index 47d29e7..cfaf56e 100644 --- a/experiments7/utils.py +++ b/experiments7/utils.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import print_function +import re import Anabatic import CRL @@ -164,6 +165,37 @@ class Module(object): def ab_height(self): return self.from_dbu(self.ab.getXHeight()) + @staticmethod + def match_instance(datapath_insts, op, plug_name, inst): + """ + Guess the position of an instance from its nets connections, + and put it at the right place in the datapath vector. + + :param datapath_insts: vector of bit slices, + :param op: operator name, + :param inst: instance to classify, + :param plug_name: name of the plug to use to guess the bit index, + :return: boolean, True if the instance has been matched. + """ + if not inst.getMasterCell().getName().startswith(op): + return False + re_net_index = re.compile(r'[^(]+\((?P[\d]+)\)$') + for plug in inst.getPlugs(): + if plug.getMasterNet().getName() != plug_name: + continue + m = re_net_index.match(plug.getNet().getName()) + if not m: + continue + bit_slice = datapath_insts[int(m.group('index'))] + for column in bit_slice: + if column[0] == op: + column[1] = inst + print ("match", plug_name, int(m.group('index')), + column, inst) + return True + break + return False + def compute_ab(self): """ Compute default abutment box without placement. """ etesian = Etesian.EtesianEngine.create(self.cell) -- 2.30.2