From 90c5353cacbe96ab816adf70ab114d5ef598d3a2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 21 Apr 2020 14:32:58 +0000 Subject: [PATCH] logic/if tidyup --- experiments7/doAlu16.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/experiments7/doAlu16.py b/experiments7/doAlu16.py index 0eda61c..d6fa746 100755 --- a/experiments7/doAlu16.py +++ b/experiments7/doAlu16.py @@ -80,21 +80,22 @@ class ALU16(Module): :param plug_name: name of the plug to use to guess the bit index, :return: boolean, True if the instance has been matched. """ - matched = False + if not inst.getMasterCell().getName().startswith(op): + return False re_net_index = re.compile(r'[^(]+\((?P[\d]+)\)$') - if inst.getMasterCell().getName().startswith(op): - for plug in inst.getPlugs(): - if plug.getMasterNet().getName() == plug_name: - m = re_net_index.match(plug.getNet().getName()) - if m: - bit_slice = datapath_insts[int(m.group('index'))] - for column in bit_slice: - if column[0] == op: - column[1] = inst - matched = True - break - break - return matched + 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 + return True + break + return False def place_datapath(self, datapath_insts, x_orig, y_orig, fold): channel_sff1 = self.to_dbu(0) @@ -125,9 +126,10 @@ class ALU16(Module): datapath_insts.append([['nmx2', None], ['no2', None], ['sff1', None]]) for inst in self.cell.getInstances(): - if ALU16.match_instance(datapath_insts, 'nmx2', 'i0', inst): continue - if ALU16.match_instance(datapath_insts, 'no2', 'nq', inst): continue - if ALU16.match_instance(datapath_insts, 'sff1', 'i', inst): continue + 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)): + continue # place to right of add add, sub = self.submodules -- 2.30.2