import getopt
import os.path
import sys
+import json
from spec import modules, specgen, dummytest
with open(fname, "w") as of:
with open(pyname, "w") as pyf:
ps = module.pinspec()
+ pm, chip = module.pinparse(ps, pinspec)
+ litexmap = ps.pywrite(pyf, pm)
pinout, bankspec, pin_spec, fixedpins = ps.write(of)
+ chip['litex.map'] = litexmap
+ chip = json.dumps(chip)
+ with open("%s/litex_pinpads.json" % pinspec, "w") as f:
+ f.write(chip)
+
if testing:
dummytest(ps, output_dir, output_type)
else:
specgen(of, output_dir, pinout,
bankspec, ps.muxwidths, pin_spec, fixedpins,
ps.fastbus)
- pm = module.pinparse(ps, pinspec)
- ps.pywrite(pyf, pm)
else:
if output_type == 'bsv':
from bsv.pinmux_generator import pinmuxgen as gentypes
#!/usr/bin/env python
from copy import deepcopy
-
+from collections import OrderedDict
def display(of, pins, banksel=None, muxwidth=4):
of.write("""\
def python_pindict(of, pinmap, pins, function_names, dname, remap):
+ res = OrderedDict()
of.write("\n%s = OrderedDict()\n" % dname)
for k, pingroup in pins.byspec.items():
a = "%s%s" % (a, n)
fblower = a.lower()
of.write("%s['%s'] = [ " % (dname, fblower))
+ res[fblower] = []
count = 0
for i, p in enumerate(pingroup):
- of.write("'%s', " % map_name(pinmap, k[0], fblower, p, remap))
+ name = map_name(pinmap, k[0], fblower, p, remap)
+ res[fblower].append(name)
+ of.write("'%s', " % name)
count += 1
if count == 4 and i != len(pingroup)-1:
of.write("\n ")
of.write("]\n")
print " dict %s" % dname, a, n, pingroup
of.write("\n\n")
+ return res
def python_dict_fns(of, pinmap, pins, function_names):
of.write("# auto-generated by Libre-SOC pinmux program: do not edit\n")
print "by spec", pins.byspec
print pinmap
- python_pindict(of, {}, pins, function_names, 'pindict', False)
- python_pindict(of, pinmap, pins, function_names, 'litexdict', True)
+ pd = python_pindict(of, {}, pins, function_names, 'pindict', False)
+ ld = python_pindict(of, pinmap, pins, function_names, 'litexdict', True)
+
+ print "pd", pd
+ print "ld", ld
+ # process results and create name map
+ litexmap = OrderedDict()
+ for k in pd.keys():
+ pl = pd[k]
+ ll = ld[k]
+ for pname, lname in zip(pl, ll):
+ pname = "%s_%s" % (k, pname[:-1]) # strip direction +/-/*
+ lname = lname[:-1] # strip direction +/-/*
+ if k in ['eint', 'pwm', 'gpio', 'vdd', 'vss']: # sigh
+ lname = "%s_%s" % (k, lname)
+ litexmap[pname] = lname
+ print "litexmap", litexmap
+ of.write("litexmap = {\n")
+ for k, v in litexmap.items():
+ of.write("\t'%s': '%s',\n" % (k, v))
+ of.write("}\n")
+ return litexmap
def display_fns(of, bankspec, pins, function_names):