convert to class style for peripheral gen
[pinmux.git] / src / spec / base.py
index 1f241b0dae870a41b375fcc867fc1e8334d71f56..9993f19e47263a00f59683ba2a976bf45d1cdd26 100644 (file)
@@ -5,16 +5,22 @@ from spec.ifaceprint import display_fixed
 
 
 class PinSpec(Pinouts):
-    def __init__(self, pinbanks, fixedpins, function_names):
-        self.pinbanks = pinbanks
+    def __init__(self, pinbanks, fixedpins, function_names, fast=None):
+        self.fastbus = fast or {}
+        self.pinbanks = {}
+        self.muxwidths = {}
+        for bank, (sz, muxwidth) in pinbanks.items():
+            self.pinbanks[bank] = sz
+            self.muxwidths[bank] = muxwidth
         self.fixedpins = fixedpins
         self.function_names = function_names
         bankspec = {}
         self.offs = 0
-        pkeys = sorted(pinbanks.keys())
+        pkeys = sorted(self.pinbanks.keys())
+        print self.pinbanks
         for kn in pkeys:
             bankspec[kn] = self.offs
-            self.offs += pinbanks[kn]
+            self.offs += self.pinbanks[kn]
 
         self.scenarios = []
 
@@ -31,18 +37,23 @@ class PinSpec(Pinouts):
         self.scenarios.append((name, needed, eint, pwm, descriptions))
 
     def write(self, of):
-        of.write ("""# Pinouts (PinMux)
+        of.write("""# Pinouts (PinMux)
 auto-generated by [[pinouts.py]]
 
 [[!toc  ]]
 
 """)
-        display(of, self)
-
-        of.write ("\n# Pinouts (Fixed function)\n\n")
+        bk = sorted(self.pinbanks.keys())
+        for bank in bk:
+            of.write(
+                "\n## Bank %s (%d pins, width %d)\n\n" %
+                (bank, self.pinbanks[bank], self.muxwidths[bank]))
+            display(of, self, bank, muxwidth=self.muxwidths[bank])
+
+        of.write("\n# Pinouts (Fixed function)\n\n")
         fixedpins = display_fixed(of, self.fixedpins, len(self))
 
-        of.write ("""# Functions (PinMux)
+        of.write("""# Functions (PinMux)
 
 auto-generated by [[pinouts.py]]
 
@@ -57,8 +68,7 @@ auto-generated by [[pinouts.py]]
                                           needed, eint, pwm,
                                           descriptions)
 
-
-        of.write ("""# Reference Datasheets
+        of.write("""# Reference Datasheets
 
 datasheets and pinout links
 * <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
@@ -74,4 +84,3 @@ datasheets and pinout links
 """)
 
         return self, self.bankspec, self.pinbanks, fixedpins
-