def specgen(of, pth, pinouts, bankspec, pinbanks, fixedpins):
""" generates a specification of pinouts (tsv files)
- for reading in by pinmux
+ for reading in by pinmux.
+
+ files generated:
+ * interfaces.txt - contains name and number of interfaces
+ * {interfacename}.txt - contains name of pin, type, and bus
+
+ type may be in, out or inout.
+ if type is "inout" then a THIRD optional parameter of type
+ "bus" indicates whether the bus is ganged together. in
+ future this may be "bus1", "bus2" and so on if an interface
+ contains more than one ganged group.
+
+ basically if the function needs to control whether a group
+ of pins shall be switched from input to output (as opposed
+ to the *pinmux* via user control deciding that), bus is
+ the way to indicate it.
"""
pth = pth or ''
#print bankspec.keys()
#print fixedpins.keys()
+ #print pinouts.ganged.items()
if not os.path.exists(pth):
os.makedirs(pth)
with open(os.path.join(pth, 'interfaces.txt'), 'w') as f:
s = pinouts.fnspec[k]
f.write("%s\t%d\n" % (k.lower(), len(s)))
s0 = s[list(s.keys())[0]] # hack, take first
+ gangedgroup = pinouts.ganged[k]
with open(os.path.join(pth, '%s.txt' % k.lower()), 'w') as g:
if len(s0.pingroup) == 1: # only one function, grouped higher
for ks in s.keys(): # grouped by interface
for pinname in s0.pingroup:
fntype = s0.fntype.get(pinname, 'inout')
pn = pinname.lower()
- g.write("%s\t%s\n" % (pn, fntype))
+ g.write("%s\t%s" % (pn, fntype))
+ if fntype == 'inout' and pinname in gangedgroup:
+ g.write("\tbus")
+ g.write("\n")
pks = sorted(pinouts.keys())
pins = Pins(prefix, pingroup, self.bankspec,
suffix, offs, bank, mux,
spec, origsuffix=suffix, gangedgrp=gangedgroup)
- self.pinouts.pinmerge(pins)
+ fname = self.pinouts.pinmerge(pins)
+ self.pinouts.setganged(fname, gangedgroup)
# pinouts class
self.bankspec = bankspec
self.pins = {}
self.fnspec = {}
+ self.ganged = {}
for fname, pinfn in pinspec:
if isinstance(pinfn, tuple):
name, pinfn = pinfn
name = pinfn.__name__
setattr(self, name, PinGen(self, fname, pinfn, self.bankspec))
+ def setganged(self, fname, grp):
+ self.ganged[fname] = map(lambda x: x[:-1], grp)
+
def __contains__(self, k):
return k in self.pins
for (pinidx, v) in fn.pins.items():
self.update(pinidx, v)
+ return fname
+
class Pins(object):