first effort at generating pinmap.txt
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 27 Mar 2018 14:53:51 +0000 (15:53 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 27 Mar 2018 14:53:51 +0000 (15:53 +0100)
src/spec/gen.py
src/spec/interfaces.py

index 2f859eb278ef7a07977056c3ab3d6199e1e5f034..7fb4186bc8d1bae4c023796ced6c5368aaf67f02 100644 (file)
@@ -8,7 +8,6 @@ def specgen(pth, pinouts, bankspec, fixedpins):
     """
     pth = pth or ''
     #print bankspec.keys()
-    #print pinouts.keys()
     #print fixedpins.keys()
     if not os.path.exists(pth):
         os.makedirs(pth)
@@ -29,3 +28,25 @@ def specgen(pth, pinouts, bankspec, fixedpins):
                         k_ = k.lower()
                         pn = pinname.lower()
                         g.write("%s_%s\t%s\n" % (k_, pn, fntype))
+
+    pks = pinouts.keys()
+    pks.sort()
+
+    # truly dreadful way to work out the max mux size...
+    muxsz = 0
+    for k in pks:
+        for m in pinouts[k].keys():
+            muxsz = max(muxsz, m + 1)
+
+    with open(os.path.join(pth, 'pinmap.txt'), 'w') as g:
+        for k in pks:
+            res = [str(k)]
+            # append pin mux 
+            for midx in range(muxsz):
+                if pinouts[k].has_key(midx):
+                    fname = pinouts[k][midx][0]
+                else:
+                    fname = ''
+                print k, midx, fname
+                res.append(fname.lower())
+            g.write('\t'.join(res) + '\n')
index 864821acd6e823eced948d2be2a3c211a20c7b50..b917e8f72d6704782611c1091e9ddba5cb9c70ef 100644 (file)
@@ -32,6 +32,9 @@ class Pinouts(object):
     def __delitem__(self, k):
         del self.pins[k]
 
+    def __getitem__(self, k):
+        return self.pins[k]
+
 
 class Pins(object):