import os.path
-from UserDict import UserDict
+try:
+ from UserDict import UserDict
+except ImportError:
+ from collections import UserDict
-from wire_def import generic_io # special case
-from wire_def import muxwire # special case
+from bsv.wire_def import generic_io # special case
+from bsv.wire_def import muxwire # special case
class Pin(object):
l1 = l1.split("\n")
l2 = l2.split("\n")
for p1, p2 in zip(l1, l2):
- print repr(p1)
- print repr(p2)
- print
+ print (repr(p1))
+ print (repr(p2))
+ print ()
assert p1 == p2
ifaces = Interfaces()
ifaceuart = ifaces['uart']
- print ifaceuart.ifacedef(0)
- print uartinterface_decl.ifacedef(0)
+ print (ifaceuart.ifacedef(0))
+ print (uartinterface_decl.ifacedef(0))
assert ifaceuart.ifacedef(0) == uartinterface_decl.ifacedef(0)
ifacetwi = ifaces['twi']
- print ifacetwi.ifacedef(0)
- print twiinterface_decl.ifacedef(0)
+ print (ifacetwi.ifacedef(0))
+ print (twiinterface_decl.ifacedef(0))
assert ifacetwi.ifacedef(0) == twiinterface_decl.ifacedef(0)
#!/usr/bin/env python
-from interfaces import Pinouts
-from ifaceprint import display, display_fns, check_functions
-from ifaceprint import display_fixed
+from spec.ifaceprint import display, display_fns, check_functions
+from spec.ifaceprint import display_fixed
-def pinspec():
+def pinspec(of):
pinouts = {}
pinbanks = {'A': 16,
pinmerge(pinouts, rgmii(bankspec, "", ('G', 0), "G", 1))
- print "# Pinouts (PinMux)"
- print
- print "auto-generated by [[pinouts.py]]"
- print
- print "[[!toc ]]"
- print
- display(pinouts)
- print
+ of.write("""# Pinouts (PinMux)
- print "# Pinouts (Fixed function)"
- print
+auto-generated by [[pinouts.py]]
+
+[[!toc ]]
+""")
+
+ display(of, pinouts)
+
+ of.write("\n# Pinouts (Fixed function)\n\n")
fixedpins = {
'CTRL_SYS': [
display_fixed(fixedpins, len(pinouts))
- print "# Functions (PinMux)"
- print
- print "auto-generated by [[pinouts.py]]"
- print
+ of.write("""# Functions (PinMux)
+
+auto-generated by [[pinouts.py]]
+
+""")
function_names = {'EINT': 'External Interrupt',
'FB': 'MC68k FlexBus',
}
fns = display_fns(bankspec, pinouts, function_names)
- print
+ of.write('\n')
# Scenarios below can be spec'd out as either "find first interface"
# by name/number e.g. SPI1, or as "find in bank/mux" which must be
unused_pins = check_functions("Robotics", bankspec, fns, pinouts,
robotics, robotics_eint, robotics_pwm)
- print "# Reference Datasheets"
- print
- print "datasheets and pinout links"
- print
- print "* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>"
- print "* <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>"
- print "* <http://pinouts.ru/Memory/sdcard_pinout.shtml>"
- print "* p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>"
- print "* <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>"
- print "* <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>"
- print "* <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>"
- print "* ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>"
- print "* ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>"
-
- return pinouts, bankspec, fixedpins
+ of.write ("""# Reference Datasheets
+
+datasheets and pinout links
+* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
+* <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>
+* <http://pinouts.ru/Memory/sdcard_pinout.shtml>
+* p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>
+* <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>
+* <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>
+* <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
+* ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
+* ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
+
+""")
+
+ return pinouts, bankspec, pinbanks, fixedpins
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
+ s0 = s[list(s.keys())[0]] # hack, take first
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
# lists bankspec, shows where the pin-numbers *start*
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():
+ keys = list(bankspec.keys())
+ keys.sort()
+ 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]))