From: Luke Kenneth Casson Leighton Date: Tue, 27 Mar 2018 14:53:51 +0000 (+0100) Subject: first effort at generating pinmap.txt X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36deafd1d0ee3a399ba2bdb825ee6440e5718545;p=pinmux.git first effort at generating pinmap.txt --- diff --git a/src/spec/gen.py b/src/spec/gen.py index 2f859eb..7fb4186 100644 --- a/src/spec/gen.py +++ b/src/spec/gen.py @@ -8,7 +8,6 @@ def specgen(pth, pinouts, bankspec, fixedpins): """ pth = pth or '' #print bankspec.keys() - #print pinouts.keys() #print fixedpins.keys() if not os.path.exists(pth): os.makedirs(pth) @@ -29,3 +28,25 @@ def specgen(pth, pinouts, bankspec, fixedpins): k_ = k.lower() pn = pinname.lower() g.write("%s_%s\t%s\n" % (k_, pn, fntype)) + + pks = pinouts.keys() + pks.sort() + + # truly dreadful way to work out the max mux size... + muxsz = 0 + for k in pks: + for m in pinouts[k].keys(): + muxsz = max(muxsz, m + 1) + + with open(os.path.join(pth, 'pinmap.txt'), 'w') as g: + for k in pks: + res = [str(k)] + # append pin mux + for midx in range(muxsz): + if pinouts[k].has_key(midx): + fname = pinouts[k][midx][0] + else: + fname = '' + print k, midx, fname + res.append(fname.lower()) + g.write('\t'.join(res) + '\n') diff --git a/src/spec/interfaces.py b/src/spec/interfaces.py index 864821a..b917e8f 100644 --- a/src/spec/interfaces.py +++ b/src/spec/interfaces.py @@ -32,6 +32,9 @@ class Pinouts(object): def __delitem__(self, k): del self.pins[k] + def __getitem__(self, k): + return self.pins[k] + class Pins(object):