From: Luke Kenneth Casson Leighton Date: Mon, 9 Apr 2018 13:24:55 +0000 (+0100) Subject: record bus/ganged type in tsv spec files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15673f9e7fb1e605df83c6d7f47674a6811d8516;p=pinmux.git record bus/ganged type in tsv spec files --- diff --git a/src/spec/gen.py b/src/spec/gen.py index 41d9834..2c1335f 100644 --- a/src/spec/gen.py +++ b/src/spec/gen.py @@ -5,11 +5,27 @@ from spec.interfaces import Pinouts 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: @@ -17,6 +33,7 @@ def specgen(of, pth, pinouts, bankspec, pinbanks, fixedpins): 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 @@ -29,7 +46,10 @@ def specgen(of, pth, pinouts, bankspec, pinbanks, fixedpins): 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()) diff --git a/src/spec/interfaces.py b/src/spec/interfaces.py index c57a076..03d7a2a 100644 --- a/src/spec/interfaces.py +++ b/src/spec/interfaces.py @@ -73,7 +73,8 @@ class PinGen(object): 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 @@ -83,6 +84,7 @@ class Pinouts(object): self.bankspec = bankspec self.pins = {} self.fnspec = {} + self.ganged = {} for fname, pinfn in pinspec: if isinstance(pinfn, tuple): name, pinfn = pinfn @@ -90,6 +92,9 @@ class Pinouts(object): 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 @@ -164,6 +169,8 @@ class Pinouts(object): for (pinidx, v) in fn.pins.items(): self.update(pinidx, v) + return fname + class Pins(object):