From ce2db44d9846adf13b5477a3cfa714b6eb17d3d1 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Thu, 25 Feb 2010 20:10:10 +0100 Subject: Better error messages for impossible layouts Signed-off-by: Michael Buesch --- libtoprammer/top2049/gnd_layouts.py | 10 ++++++---- libtoprammer/top2049/shiftreg_layout.py | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libtoprammer/top2049/gnd_layouts.py b/libtoprammer/top2049/gnd_layouts.py index 6afd48d..5a3d6b5 100644 --- a/libtoprammer/top2049/gnd_layouts.py +++ b/libtoprammer/top2049/gnd_layouts.py @@ -20,6 +20,9 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ +from libtoprammer.util import * + + class GNDLayout: # A list of valid ZIF GND pins (0=none) validPins = (0, 5, 14, 15, 16, 17, 18, 19, 20, 24, 26, 27, @@ -50,16 +53,15 @@ class GNDLayout: for zifPin in zifPinsList: assert(zifPin >= 1) zifMask |= (1 << (zifPin - 1)) - return self.setLayoutMask(zifMask) + self.setLayoutMask(zifMask) def setLayoutMask(self, zifMask): "Load a ZIF mask." for (layoutId, layoutMask) in self.layouts: if layoutMask == zifMask: self.setLayoutID(layoutId) - return True - raise Exception() - #return False + return + raise TOPException("GND layout mask impossible due to hardware constraints") def setLayoutID(self, id): "Load a specific layout ID." diff --git a/libtoprammer/top2049/shiftreg_layout.py b/libtoprammer/top2049/shiftreg_layout.py index d5a06de..edf839c 100644 --- a/libtoprammer/top2049/shiftreg_layout.py +++ b/libtoprammer/top2049/shiftreg_layout.py @@ -20,6 +20,9 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ +from libtoprammer.util import * + + class ShiftregLayout: def __init__(self, nrShiftRegs): assert(nrShiftRegs <= 4) @@ -81,16 +84,15 @@ class ShiftregLayout: for zifPin in zifPinsList: assert(zifPin >= 1) zifMask |= (1 << (zifPin - 1)) - return self.setLayoutMask(zifMask) + self.setLayoutMask(zifMask) def setLayoutMask(self, zifMask): "Load a ZIF mask." for (layoutId, layoutMask) in self.layouts: if layoutMask == zifMask: self.setLayoutID(layoutId) - return True - raise Exception() - #return False + return + raise TOPException("Layout mask impossible due to hardware constraints") def setLayoutID(self, id): "Load a specific layout ID." -- cgit v1.2.3