+def bond_int_to_ext(pin, bank):
+ """ note that internal numbering is 0-31 whereas the DISPLAY internal
+ numbering is 1-32. this uses the INTERNAL numbering.
+
+ side: N S E W
+
+ outer ring numbers: the python list order of the outer pads
+ middle numbers: the package number wires (plus side they are on)
+ inner numbers: the IO pad *python internal (0-31)* numbers plus side
+
+ 0 1 2 3 N 34 35 36 37
+ N102 N101 N100 99 N 68 N67 N66 N65
+ W29 W30 W31 N0 N N31 E29 E30 E31
+
+ 25 103 W28 E28 64 25
+ W W W E E E
+ 0 128 W3 E3 39 0
+
+ W2 W1 W0 S0 S S31 E0 E1 E2
+ S1 S2 S3 4 S 35 S36 S37 S38
+ 0 1 2 3 S 34 35 36 37
+
+ """
+ # returns side, order-on-the-side, pin number
+ if bank == 'N':
+ return 'N', pin+3, 99-pin
+ if bank == 'S':
+ return 'S', pin+3, 4+pin
+ if bank == 'W':
+ if pin >= 29: # 29, 30, 31
+ return 'N', pin-29, 100+(31-pin)
+ if pin <= 2:
+ return 'S', 2-pin, 3-pin
+ return 'W', pin-3, 103+(28-pin)
+ if bank == 'E':
+ if pin >= 29:
+ return 'N', pin+6, 67-(pin-29)
+ if pin <= 2:
+ return 'S', pin+35, 36+pin
+ return 'E', pin-3, 39+(pin-3)
+