From 36deafd1d0ee3a399ba2bdb825ee6440e5718545 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 27 Mar 2018 15:53:51 +0100 Subject: [PATCH] first effort at generating pinmap.txt --- src/spec/gen.py | 23 ++++++++++++++++++++++- src/spec/interfaces.py | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) 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): -- 2.30.2