From dfa3c5fe7109ba7d5d4c7e80298e486b81457563 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 21 Feb 2010 19:31:16 +0100 Subject: Add setup.py Signed-off-by: Michael Buesch --- libtoprammer/top2049/__init__.py | 1 + libtoprammer/top2049/gnd_layouts.py | 66 +++++++++++++ libtoprammer/top2049/shiftreg_layout.py | 98 ++++++++++++++++++++ libtoprammer/top2049/vccx_layouts.py | 150 ++++++++++++++++++++++++++++++ libtoprammer/top2049/vpp_layouts.py | 159 ++++++++++++++++++++++++++++++++ 5 files changed, 474 insertions(+) create mode 100644 libtoprammer/top2049/__init__.py create mode 100644 libtoprammer/top2049/gnd_layouts.py create mode 100644 libtoprammer/top2049/shiftreg_layout.py create mode 100644 libtoprammer/top2049/vccx_layouts.py create mode 100644 libtoprammer/top2049/vpp_layouts.py (limited to 'libtoprammer/top2049') diff --git a/libtoprammer/top2049/__init__.py b/libtoprammer/top2049/__init__.py new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/libtoprammer/top2049/__init__.py @@ -0,0 +1 @@ + diff --git a/libtoprammer/top2049/gnd_layouts.py b/libtoprammer/top2049/gnd_layouts.py new file mode 100644 index 0000000..4e48688 --- /dev/null +++ b/libtoprammer/top2049/gnd_layouts.py @@ -0,0 +1,66 @@ +""" +# TOP2049 Open Source programming suite +# +# TOP2049 GND layout definitions +# +# Copyright (c) 2010 Michael Buesch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +class GNDLayout: + # A list of valid ZIF GND pins (0=none) + validPins = (0, 5, 14, 15, 16, 17, 18, 19, 20, 24, 26, 27, + 28, 29, 33, 34, 35) + + def __init__(self, top): + self.top = top + self.layouts = [] + for pin in self.validPins: + id = pin + if id != 0: + id -= 4 + mask = 0 + if pin != 0: + mask |= (1 << (pin - 1)) + self.layouts.append( (id, mask) ) + + def supportedLayouts(self): + """Returns a list of supported layouts. + Each entry is a tuple of (id, bitmask), where bitmask is + the ZIF layout. bit0 is ZIF-pin-1. A bit set means a hot pin.""" + return self.layouts + + def setLayoutPins(self, zifPinsList): + """Load a layout. zifPinsList is a list of hot ZIF pins. + The first ZIF pin is 1.""" + zifMask = 0 + for zifPin in zifPinsList: + assert(zifPin >= 1) + zifMask |= (1 << (zifPin - 1)) + return 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 + + def setLayoutID(self, id): + "Load a specific layout ID." + self.top.cmdLoadGNDLayout(id) diff --git a/libtoprammer/top2049/shiftreg_layout.py b/libtoprammer/top2049/shiftreg_layout.py new file mode 100644 index 0000000..d5a06de --- /dev/null +++ b/libtoprammer/top2049/shiftreg_layout.py @@ -0,0 +1,98 @@ +""" +# TOP2049 Open Source programming suite +# +# TOP2049 Shiftregister based layout definitions +# +# Copyright (c) 2010 Michael Buesch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +class ShiftregLayout: + def __init__(self, nrShiftRegs): + assert(nrShiftRegs <= 4) + self.nrShiftRegs = nrShiftRegs + self.layouts = [] + for id in range(0, len(self.shiftreg_masks)): + shreg_mask = self.shiftreg_masks[id] + zif_mask = 0 + for bit in range(0, self.nrShiftRegs * 8): + if (shreg_mask & (1 << bit)) == 0: + continue + regId = self.__bitnr2shregId(bit) + zifPin = self.shreg2zif_map[regId] + zif_mask |= (1 << (zifPin - 1)) + if id == 0 or zif_mask != 0: + self.layouts.append( (id, zif_mask) ) + + def __bitnr2shregId(self, bitNr): + if bitNr >= 24: + register = 3 + pin = bitNr - 24 + elif bitNr >= 16: + register = 2 + pin = bitNr - 16 + elif bitNr >= 8: + register = 1 + pin = bitNr - 8 + else: + register = 0 + pin = bitNr + return "%d.%d" % (register, pin) + + def __repr__(self): + res = "" + for (id, zif_mask) in self.supportedLayouts(): + res += "Layout %d:\n" % id + res += " o---------o\n" + for pin in range(1, 25): + left = " " + right = "" + if (1 << (pin - 1)) & zif_mask: + left = "HOT >" + if (1 << (49 - pin - 1)) & zif_mask: + right = "< HOT" + res += "%s | %2d | %2d | %s\n" % (left, pin, 49 - pin, right) + res += " o---------o\n\n" + return res + + def supportedLayouts(self): + """Returns a list of supported layouts. + Each entry is a tuple of (id, bitmask), where bitmask is + the ZIF layout. bit0 is ZIF-pin-1. A bit set means a hot pin.""" + return self.layouts + + def setLayoutPins(self, zifPinsList): + """Load a layout. zifPinsList is a list of hot ZIF pins. + The first ZIF pin is 1.""" + zifMask = 0 + for zifPin in zifPinsList: + assert(zifPin >= 1) + zifMask |= (1 << (zifPin - 1)) + return 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 + + def setLayoutID(self, id): + "Load a specific layout ID." + # Reimplement me in the subclass + raise Exception() diff --git a/libtoprammer/top2049/vccx_layouts.py b/libtoprammer/top2049/vccx_layouts.py new file mode 100644 index 0000000..b1df094 --- /dev/null +++ b/libtoprammer/top2049/vccx_layouts.py @@ -0,0 +1,150 @@ +""" +# TOP2049 Open Source programming suite +# +# TOP2049 VCCX layout definitions +# +# Copyright (c) 2010 Michael Buesch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +from shiftreg_layout import * + +class VCCXLayout(ShiftregLayout): + # "shiftreg_masks" is a dump of the VCCX shiftregister states. The array index + # is the layout ID and the array entries are the inverted shift + # register outputs. The least significant byte is the first + # shift register in the chain. + shiftreg_masks = ( + 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + 0x000000, 0x000000, 0x000001, 0x000000, 0x000000, 0x002000, + 0x000000, 0x000002, 0x000000, 0x000000, 0x080000, 0x000004, + 0x000000, 0x000000, 0x010000, 0x004000, 0x000000, 0x000000, + 0x000008, 0x000010, 0x000020, 0x000040, 0x000080, 0x000000, + 0x000100, 0x000000, 0x000200, 0x000000, 0x000400, 0x000000, + 0x000800, 0x000000, 0x008000, 0x000000, 0x001000, 0x000000, + 0x020000, 0x000000, 0x040000, #0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x012000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, + #0x000000, 0x000000, 0x000000, 0x000000, + ) + # "shreg2zif_map" is a mapping of the shift register outputs + # to the ZIF socket pins + shreg2zif_map = { + # SHREG.PIN : ZIF_PIN + + # left side + # 1 + # 2 + # 3 + # 4 + # 5 + # 6 + # 7 + # 8 + # 9 + # 10 + # 11 + "0.0" : 12, # Q8C + # 13 + # 14 + "1.5" : 15, # Q11C + # 16 + "0.1" : 17, # Q13C + # 18 + # 19 + "2.3" : 20, # Q16C + "0.2" : 21, # Q17C + # 22 + # 23 + "2.0" : 24, # Q20C + + # right side + "2.2" : 48, # Q44C + # 47 + "2.1" : 46, # Q42C + # 45 + "1.4" : 44, # Q40C + # 43 + "1.7" : 42, # Q38C + # 41 + "1.3" : 40, # Q36C + # 39 + "1.2" : 38, # Q34C + # 37 + "1.1" : 36, # Q32C + # 35 + "1.0" : 34, # Q30C + # 33 + "0.7" : 32, # Q28C + "0.6" : 31, # Q27C + "0.5" : 30, # Q26C + "0.4" : 29, # Q25C + "0.3" : 28, # Q24C + # 27 + # 26 + "1.6" : 25, # Q21C + } + + def __init__(self, top): + ShiftregLayout.__init__(self, 3) + self.top = top + + def minVoltage(self): + "Get the min supported voltage" + return 3 + + def maxVoltage(self): + "Get the max supported voltage" + return 5 + + def setLayoutID(self, id): + self.top.cmdLoadVCCXLayout(id) + +if __name__ == "__main__": + print "ZIF socket VCCX layouts" + print VCCXLayout(None) diff --git a/libtoprammer/top2049/vpp_layouts.py b/libtoprammer/top2049/vpp_layouts.py new file mode 100644 index 0000000..07d5845 --- /dev/null +++ b/libtoprammer/top2049/vpp_layouts.py @@ -0,0 +1,159 @@ +""" +# TOP2049 Open Source programming suite +# +# TOP2049 VPP layout definitions +# +# Copyright (c) 2010 Michael Buesch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +from shiftreg_layout import * + +class VPPLayout(ShiftregLayout): + # "shiftreg_masks" is a dump of the VPP shiftregister states. The array index + # is the layout ID and the array entries are the inverted shift + # register outputs. The least significant byte is the first + # shift register in the chain. + shiftreg_masks = ( + 0x00000000, 0x02000000, 0x03000000, 0x03000008, 0x03000008, + 0x03100008, 0x03100008, 0x03120008, 0x03130008, 0x03134008, + 0x03136008, 0x03137008, 0x03137208, 0x03137208, 0x03137308, + 0x03137328, 0x03137328, 0x03137328, 0x03137328, 0x03137328, + 0x03137329, 0x03137329, 0x0313732B, 0x0313732B, 0x0313732B, + 0x0313732B, 0x0313732F, 0x0313733F, 0x0313737F, 0x031373FF, + 0x031377FF, 0x03137FFF, 0x03137FFF, 0x0313FFFF, 0x0317FFFF, + 0x031FFFFF, 0x031FFFFF, 0x033FFFFF, 0x033FFFFF, 0x037FFFFF, + 0x03FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x8FFFFFFF, + 0xCFFFFFFF, 0xEFFFFFFF, 0xFFFFFFFF, #0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #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 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + #0xFFFFFFFF, + ) + # "shreg2zif_map" is a mapping of the shift register outputs + # to the ZIF socket pins + shreg2zif_map = { + # SHREG.PIN : ZIF_PIN + + # left side + "3.6" : 1, # QP31 + "3.5" : 2, # QP30 + "3.4" : 3, # QP29 + # 4 + "3.1" : 5, # QP26 + "3.0" : 6, # QP25 + "0.3" : 7, # QP4 + # 8 + "2.4" : 9, # QP21 + # 10 + "2.1" : 11, # QP18 + "2.0" : 12, # QP17 + "1.6" : 13, # QP15 + "1.5" : 14, # QP14 + "1.4" : 15, # QP13 + "1.1" : 16, # QP10 + # 17 + "1.0" : 18, # QP9 + "0.5" : 19, # QP6 + # 20 + # 21 + # 22 + # 23 + "0.0" : 24, # QP1 + + # right side + "3.7" : 48, # QP32 + "3.3" : 47, # QP28 + "3.2" : 46, # QP27 + # 45 + "2.7" : 44, # QP24 + "2.6" : 43, # QP23 + # 42 + "2.5" : 41, # QP22 + # 40 + "2.3" : 39, # QP20 + "2.2" : 38, # QP19 + "1.7" : 37, # QP16 + # 36 + "1.3" : 35, # QP12 + "1.2" : 34, # QP11 + "0.7" : 33, # QP8 + "0.6" : 32, # QP7 + "0.4" : 31, # QP5 + "0.2" : 30, # QP3 + # 29 + # 28 + # 27 + "0.1" : 26, # QP2 + # 25 + } + + def __init__(self, top): + ShiftregLayout.__init__(self, 4) + self.top = top + + def minVoltage(self): + "Get the min supported voltage" + return 5 + + def maxVoltage(self): + "Get the max supported voltage" + return 21 + + def setLayoutID(self, id): + self.top.cmdLoadVPPLayout(id) + +if __name__ == "__main__": + print "ZIF socket VPP layouts" + print VPPLayout(None) -- cgit v1.2.3