fix pinmerge issue, merge pingroup
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 28 Mar 2018 15:12:35 +0000 (16:12 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 28 Mar 2018 15:12:35 +0000 (16:12 +0100)
src/spec/gen.py
src/spec/interfaces.py

index d398384480775ccd99af039e5edc9e02655caaa6..eff692e2657fd1623f9419acea10a9fc1389fc72 100644 (file)
@@ -21,7 +21,7 @@ def specgen(pth, pinouts, bankspec, fixedpins):
                 if len(s0.pingroup) == 1:  # only one function, grouped higher
                     for ks in s.keys():  # grouped by interface
                         fntype = 'inout' # XXX TODO
-                        k = "%s_%s" % (s[ks].fname, s[ks].suffix)
+                        k = s[ks].suffix
                         k_ = k.lower()
                         g.write("%s\t%s\n" % (k_, fntype))
                 else:
@@ -48,6 +48,5 @@ def specgen(pth, pinouts, bankspec, fixedpins):
                     fname = pinouts[k][midx][0]
                 else:
                     fname = ''
-                print k, midx, fname
                 res.append(fname.lower())
             g.write('\t'.join(res) + '\n')
index 891a12311f5d66da6932c5368b8b040d6b150fa5..64cd229709935be3766bf88b99ac1097dd8d4c3c 100644 (file)
@@ -1,5 +1,8 @@
 #!/usr/bin/env python
 
+from copy import deepcopy
+
+
 class Pinouts(object):
     def __init__(self):
         self.pins = {}
@@ -301,8 +304,19 @@ def pinmerge(pins, fn):
         specname = fname + suffix
     else:
         specname = fname + bank
-    pins.fnspec[fname][specname] = fn
-
+    if pins.fnspec[fname].has_key(specname):
+        # ok so some declarations may bring in different
+        # names at different stages (EINT, PWM, flexbus1/2)
+        # so we have to merge the names in.  main thing is
+        # the pingroup
+        tomerge = pins.fnspec[fname][specname]
+        for p in fn.pingroup:
+            if p not in tomerge.pingroup:
+                tomerge.pingroup.append(p)
+        tomerge.pins.update(fn.pins)
+        tomerge.fntype.update(fn.fntype)
+    else:
+        pins.fnspec[fname][specname] = deepcopy(fn)
 
     # merge actual pins
     for (pinidx, v) in fn.pins.items():