ad9fa0e819eb4d06428157ab75cf1820ad54c41f
3 from spec
.interfaces
import Pinouts
6 def specgen(pth
, pinouts
, bankspec
, fixedpins
):
7 """ generates a specification of pinouts (tsv files)
8 for reading in by pinmux
11 #print bankspec.keys()
12 #print fixedpins.keys()
13 if not os
.path
.exists(pth
):
15 with
open(os
.path
.join(pth
, 'interfaces.txt'), 'w') as f
:
16 for k
in pinouts
.fnspec
.keys():
18 f
.write("%s\t%d\n" % (k
.lower(), len(s
)))
19 s0
= s
[s
.keys()[0]] # hack, take first
20 with
open(os
.path
.join(pth
, '%s.txt' % k
.lower()), 'w') as g
:
21 if len(s0
.pingroup
) == 1: # only one function, grouped higher
22 for ks
in s
.keys(): # grouped by interface
23 assert False, "TODO, single-function"
24 fntype
= 'inout' # XXX TODO
27 g
.write("%s\t%s\n" % (k_
, fntype
))
29 for pinname
in s0
.pingroup
:
30 fntype
= s0
.fntype
.get(pinname
, 'inout')
32 g
.write("%s\t%s\n" % (pn
, fntype
))
37 # truly dreadful way to work out the max mux size...
40 for m
in pinouts
[k
].keys():
41 muxsz
= max(muxsz
, m
+ 1)
43 # write out the mux...
44 with
open(os
.path
.join(pth
, 'pinmap.txt'), 'w') as g
:
48 for midx
in range(muxsz
):
49 if pinouts
[k
].has_key(midx
):
50 fname
= pinouts
[k
][midx
][0]
53 res
.append(fname
.lower())
54 g
.write('\t'.join(res
) + '\n')
56 # ... and the dedicated pins
57 with
open(os
.path
.join(pth
, 'fixedpins.txt'), 'w') as g
:
61 g
.write('\t'.join(p
) + '\n')