X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fspec%2Fgen.py;h=8a54e9353505b5473ceb76fd9d2d316bba7f9087;hb=8c41066184b2196a45421619d98ba0be890a1c05;hp=cb7957f525b454bdeb12247b41c0589fbed4e5b2;hpb=c32ca0071d9ef044b487f59ce92d781160af5728;p=pinmux.git diff --git a/src/spec/gen.py b/src/spec/gen.py index cb7957f..8a54e93 100644 --- a/src/spec/gen.py +++ b/src/spec/gen.py @@ -3,20 +3,45 @@ import os.path from spec.interfaces import Pinouts -def specgen(pth, pinouts, bankspec, pinbanks, fixedpins): +def specgen(of, pth, pinouts, bankspec, pinbanks, fixedpins, fastbus): """ 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, 'bankwidths.txt'), 'w') as f: + for k, v in pinouts.muxwidths.items(): + f.write("%s\t%d\n" % (k, v)) with open(os.path.join(pth, 'interfaces.txt'), 'w') as f: for k in pinouts.fnspec.keys(): s = pinouts.fnspec[k] - f.write("%s\t%d\n" % (k.lower(), len(s))) - s0 = s[s.keys()[0]] # hack, take first + line = [k.lower(), str(len(s))] + for b in fastbus: + if b.startswith(k.lower()): + line.append(b) + line = '\t'.join(line) + f.write("%s\n" % line) + 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 +54,10 @@ def specgen(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()) @@ -60,8 +88,10 @@ def specgen(pth, pinouts, bankspec, pinbanks, fixedpins): g.write('\t'.join(p) + '\n') # lists bankspec, shows where the pin-numbers *start* - print ("# Pin Bank starting points and lengths\n") + of.write("# Pin Bank starting points and lengths\n\n") with open(os.path.join(pth, 'pinspec.txt'), 'w') as g: - for bank, pinstart in bankspec.items(): - print ("* %s %d %d" % (bank, pinstart, pinbanks[bank])) + keys = sorted(bankspec.keys()) + for bank in keys: + pinstart = bankspec[bank] + of.write("* %s %d %d\n" % (bank, pinstart, pinbanks[bank])) g.write("%s\t%d\t%d\n" % (bank, pinstart, pinbanks[bank]))