use OrderedDict in pinmap so that JTAG boundary scan is ordered
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 1 Apr 2021 15:50:31 +0000 (16:50 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 1 Apr 2021 15:50:31 +0000 (16:50 +0100)
src/spec/ifaceprint.py

index dba37e651a426fea980a2d4783d293fe3682d7f5..3d3cfb4b27662b58e348dacc8202eb8e2184c0bc 100644 (file)
@@ -89,14 +89,14 @@ def map_name(pinmap, fn, fblower, pin, rename):
 
 def python_pindict(of, pinmap, pins, function_names, dname, remap):
 
-    of.write("%s = {\n" % dname)
+    of.write("\n%s = OrderedDict()\n" % dname)
 
     for k, pingroup in pins.byspec.items():
         (a, n) = k.split(":")
         if n.isdigit():
             a = "%s%s" % (a, n)
         fblower = a.lower()
-        of.write("    '%s': [ " % fblower)
+        of.write("%s['%s'] = [ " % (dname, fblower))
         count = 0
         for i, p in enumerate(pingroup):
             of.write("'%s', " % map_name(pinmap, k[0], fblower, p, remap))
@@ -104,13 +104,15 @@ def python_pindict(of, pinmap, pins, function_names, dname, remap):
             if count == 4 and i != len(pingroup)-1:
                 of.write("\n                ")
                 count = 0
-        of.write("],\n")
+        of.write("]\n")
         print "    dict %s" % dname, a, n, pingroup
-    of.write("}\n\n")
+    of.write("\n\n")
 
 def python_dict_fns(of, pinmap, pins, function_names):
     of.write("# auto-generated by Libre-SOC pinmux program: do not edit\n")
     of.write("# python src/pinmux_generator.py -v -s {spec} -o {output}\n")
+    of.write("# use OrderedDict to fix stable order for JTAG Boundary Scan\n")
+    of.write("from collections import OrderedDict\n")
 
     fn_names = function_names.keys()
     fns = {}