pep8 cleanup
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 04:03:53 +0000 (05:03 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 04:03:53 +0000 (05:03 +0100)
15 files changed:
src/bsv/interface_decl.py
src/bsv/peripheral_gen/base.py
src/bsv/peripheral_gen/eint.py
src/bsv/peripheral_gen/gpio.py
src/bsv/peripheral_gen/jtag.py
src/bsv/peripheral_gen/pwm.py
src/bsv/peripheral_gen/qspi.py
src/bsv/peripheral_gen/quart.py
src/bsv/peripheral_gen/rgbttl.py
src/bsv/peripheral_gen/rs232.py
src/bsv/peripheral_gen/sdmmc.py
src/bsv/peripheral_gen/spi.py
src/bsv/peripheral_gen/twi.py
src/bsv/peripheral_gen/uart.py
src/bsv/pinmux_generator.py

index e535db1509a8c30322592cdb77d3ce515ebd3b0a..f697fdaa63a73c5b3e85d2d5510aeab624fe0b47 100644 (file)
@@ -20,7 +20,7 @@ class Pin(object):
     """
 
     def __init__(self, name,
-                 name_ = None,
+                 name_=None,
                  idx=None,
                  ready=True,
                  enabled=True,
@@ -121,7 +121,7 @@ class Pin(object):
     def ifacedef2(self, fmtoutfn, fmtinfn, fmtdecfn):
         if self.action:
             fmtname = fmtinfn(self.name)
-            res =  "            interface %s = interface Put\n" % self.name_
+            res = "            interface %s = interface Put\n" % self.name_
             res += '              method '
             res += "Action put"
             #res += fmtdecfn(self.name)
@@ -131,7 +131,7 @@ class Pin(object):
             res += '            endinterface;'
         else:
             fmtname = fmtoutfn(self.name)
-            res =  "            interface %s = interface Get\n" % self.name_
+            res = "            interface %s = interface Get\n" % self.name_
             res += '              method ActionValue#'
             res += '(%s) get;\n' % self.bitspec
             res += "                return %s;\n" % (fmtname)
@@ -153,6 +153,7 @@ class Pin(object):
             name = 'tget'
         return (name, res)
 
+
 class Interface(PeripheralIface):
     """ create an interface from a list of pinspecs.
         each pinspec is a dictionary, see Pin class arguments
@@ -195,7 +196,7 @@ class Interface(PeripheralIface):
                     # NOTice - outen key is removed
             else:
                 name = p['name']
-                if name.isdigit(): # HACK!  deals with EINT case
+                if name.isdigit():  # HACK!  deals with EINT case
                     name = self.pname(name)
                 _p['name_'] = name
                 _p['idx'] = idx
@@ -334,7 +335,7 @@ class Interface(PeripheralIface):
             decfn = self.ifacefmtdecfn3
             outfn = self.ifacefmtoutenfn
         return pin.ifacedef2(outfn, self.ifacefmtinfn,
-                            decfn)
+                             decfn)
 
     def ifacedef(self, *args):
         res = '\n'.join(map(self.ifacefmtpin, self.pins))
@@ -368,6 +369,7 @@ class IOInterface(Interface):
     def wirefmt(self, *args):
         return generic_io.format(*args)
 
+
 class InterfaceGPIO(Interface):
 
     def ifacepfmt(self, *args):
@@ -421,7 +423,7 @@ class InterfaceGPIO(Interface):
             decfn = self.ifacefmtdecfn3
             outfn = self.ifacefmtoutenfn
         return pin.ifacedef3(outfn, self.ifacefmtinfn,
-                            decfn)
+                             decfn)
 
 
 class Interfaces(InterfacesBase, PeripheralInterfaces):
@@ -430,7 +432,7 @@ class Interfaces(InterfacesBase, PeripheralInterfaces):
 
     def __init__(self, pth=None):
         InterfacesBase.__init__(self, Interface, pth,
-                                            {'gpio': InterfaceGPIO })
+                                {'gpio': InterfaceGPIO})
         PeripheralInterfaces.__init__(self)
 
     def ifacedef(self, f, *args):
index f40e4dee55e5bd73eebc16b3f6c4e94dc652c5c7..90aae7d40e9bf1d20642a155865c941c70fb2725 100644 (file)
@@ -1,5 +1,6 @@
 import types
 
+
 class PBase(object):
     def __init__(self, name):
         self.name = name
@@ -85,8 +86,8 @@ class PBase(object):
                         ps_ = ps + '_out'
                     else:
                         ps_ = ps
-                    ret.append("      mkConnection({0},\n\t\t\t{1}.{2});" \
-                                .format(ps_, n_, fname))
+                    ret.append("      mkConnection({0},\n\t\t\t{1}.{2});"
+                               .format(ps_, n_, fname))
                 fname = None
                 if p.get('outen'):
                     fname = self.pinname_outen(pname)
@@ -94,8 +95,8 @@ class PBase(object):
                     if isinstance(fname, str):
                         fname = "{0}.{1}".format(n_, fname)
                     fname = self.pinname_tweak(pname, 'outen', fname)
-                    ret.append("      mkConnection({0}_outen,\n\t\t\t{1});"\
-                                .format(ps, fname))
+                    ret.append("      mkConnection({0}_outen,\n\t\t\t{1});"
+                               .format(ps, fname))
             if typ == 'in' or typ == 'inout':
                 fname = self.pinname_in(pname)
                 if fname:
@@ -172,7 +173,7 @@ class PBase(object):
             print "plic_obj", name, idx, plic_obj
             plic = mkplic_rule.format(name, plic_obj, irq_offs)
             res.append(plic)
-            irq_offs += 1 # increment to next irq
+            irq_offs += 1  # increment to next irq
         return ('\n'.join(res), irq_offs)
 
     def mk_ext_ifacedef(self, iname, inum):
@@ -228,7 +229,7 @@ class PeripheralIface(object):
         if slow:
             self.slow = slow(ifacename)
             self.slow.peripheral = self
-        for fname in ['slowimport', 
+        for fname in ['slowimport',
                       'slowifinstance', 'slowifdecl', 'slowifdeclmux',
                       'mkslow_peripheral', 'mk_plic', 'mk_ext_ifacedef',
                       'mk_connection', 'mk_cellconn', 'mk_pincon']:
@@ -375,10 +376,9 @@ class PeripheralInterfaces(object):
                 ret.append(txt)
         return '\n'.join(list(filter(None, ret)))
 
-
     def mk_plic(self):
         ret = []
-        irq_offs = 8 # XXX: DMA scovers 0-7?
+        irq_offs = 8  # XXX: DMA scovers 0-7?
         for (name, count) in self.ifacecount:
             for i in range(count):
                 res = self.data[name].mk_plic(i, irq_offs)
@@ -426,6 +426,7 @@ class PFactory(object):
                 return v
         return None
 
+
 slowfactory = PFactory()
 
 if __name__ == '__main__':
index cd3be2c24bf3958a92c3068e3833b477fdcef79a..f5a6e86f84e6882e6bc540670b7e21438489f8e8 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class eint(PBase):
 
     def slowimport(self):
index 8678b4878e0202397f9676c8810edf7ab9bdde9b..9419f1c5bab85955ac5dd7c3c637c94863f04579 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class gpio(PBase):
 
     def slowimport(self):
index 09c049de54b50e93a23537fe25d60a43ab6e324b..0592b382aa008ca756f4e89c71a708e608cddf40 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class jtag(PBase):
 
     def axi_slave_name(self, name, ifacenum):
@@ -18,7 +19,8 @@ class jtag(PBase):
                "        method  Action jtag_ck (Bit#(1) in);"
 
     def slowifinstance(self):
-        return jtag_method_template # bit of a lazy hack this...
+        return jtag_method_template  # bit of a lazy hack this...
+
 
 jtag_method_template = """\
         method  Action jtag_ms (Bit#(1) in);
index 1a43c1320fded3f9a798d067b0a780e0633cdc33..b5354f6ca036d195b8b01f8bd1747c9bf8864d2c 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class pwm(PBase):
 
     def slowimport(self):
index 0ed26b3358e73cd4790819adddde6f3da464fbf1..462b57bfbba26980d0596bb5b511017ac96642cf 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class qspi(PBase):
 
     def slowimport(self):
index 5850b8e7e29091958d49b0354ce0d9aa0577e539..36ddaba23bc639b32a408ea6fd8908d8322c04cc 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class quart(PBase):
 
     def slowimport(self):
@@ -21,14 +22,14 @@ class quart(PBase):
         return "quart{0}.slave_axi_uart"
 
     def pinname_out(self, pname):
-        return {'tx' : 'coe_rs232.stx_out',
+        return {'tx': 'coe_rs232.stx_out',
                 'rts': 'coe_rs232.rts_out',
-               }.get(pname, '')
+                }.get(pname, '')
 
     def pinname_in(self, pname):
-        return {'rx': 'coe_rs232.srx_in', 
+        return {'rx': 'coe_rs232.srx_in',
                 'cts': 'coe_rs232.cts_in'
-               }.get(pname, '')
+                }.get(pname, '')
 
     def __disabled_mk_pincon(self, name, count):
         ret = [PBase.mk_pincon(self, name, count)]
@@ -64,6 +65,7 @@ class quart(PBase):
     def slowifdeclmux(self):
         return "        method Bit#(1) {1}{0}_intr;"
 
+
 uart_plic_template = """\
      // PLIC {0} synchronisation with irq {1}
      SyncBitIfc#(Bit#(1)) {0}_interrupt <-
@@ -72,4 +74,3 @@ uart_plic_template = """\
          {0}_interrupt.send({0}.irq);
      endrule
 """
-
index 874c625b42c0ef969a7cde7e11edbc1bdc074491..e350e65e447b6ac592edf617e5d3f4cbb6fbe108 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class rgbttl(PBase):
 
     def slowimport(self):
@@ -9,7 +10,7 @@ class rgbttl(PBase):
         return 10
 
     def mkslow_peripheral(self):
-        sz = len(self.peripheral.pinspecs) - 4 # subtract CK, DE, HS, VS
+        sz = len(self.peripheral.pinspecs) - 4  # subtract CK, DE, HS, VS
         return "        Ifc_rgbttl_dummy lcd{0} <-  mkrgbttl_dummy();"
 
     def _mk_connection(self, name=None, count=0):
index 597ad3eee308f6b6d12a47a6699cc68d77a6edf4..2882c255c356738515a257d7dce29ede423dc47f 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class rs232(PBase):
 
     def slowimport(self):
index 00407ec391d26a0163f816471219d62fc6c9ca4b..74db274a69b8e6525c194bc4b7a9f82de43cc011 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class sdmmc(PBase):
 
     def slowimport(self):
index be51297af198e4e37dcae17fd46b0275f9cafa7e..1725d00a004aeda7d34b1836ebb6b1a6aaf781a2 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class spi(PBase):
 
     def slowimport(self):
@@ -56,5 +57,3 @@ class spi(PBase):
 
     def slowifdeclmux(self):
         return "        method Bit#(1) {1}{0}_isint;"
-
-
index 2fcd6fed5c6d3cf2735212d37c837c9dc8ca94ac..e20ea4cbec77e8e3f085355d4abc3c3f3f395ca8 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class twi(PBase):
 
     def slowimport(self):
@@ -37,7 +38,7 @@ class twi(PBase):
         return ["{0}.isint()",
                 "{0}.timerint()",
                 "{0}.isber()"
-               ][idx].format(pname)
+                ][idx].format(pname)
 
     def mk_ext_ifacedef(self, iname, inum):
         name = self.get_iname(inum)
@@ -45,5 +46,3 @@ class twi(PBase):
 
     def slowifdeclmux(self):
         return "        method Bit#(1) {1}{0}_isint;"
-
-
index 1533d7f86c696b63ba804aa7ae153609c56e2c2d..a5eaacd50fb1178fbceb49d1d75573479b41668e 100644 (file)
@@ -1,5 +1,6 @@
 from bsv.peripheral_gen.base import PBase
 
+
 class uart(PBase):
 
     def slowimport(self):
index 881f99b2b56e8fe3ccc9aa26b33d24b70e8f371d..bf4bfa6576eb539a6037799329542ee7a3e57ead 100644 (file)
@@ -75,7 +75,7 @@ def pinmuxgen(pth=None, verify=True):
     shutil.copyfile(os.path.join(cwd, 'Makefile.template'),
                     os.path.join(bp, 'Makefile'))
     cwd = os.path.join(cwd, 'bsv_lib')
-    for fname in [ ]:
+    for fname in []:
         shutil.copyfile(os.path.join(cwd, fname),
                         os.path.join(bl, fname))
 
@@ -117,9 +117,9 @@ def write_slow(slow, slowt, p, ifaces, iocells):
     ifacedef = ifaces.mk_ext_ifacedef()
     with open(slow, "w") as bsv_file:
         bsv_file.write(slowt.format(imports, ifdecl, regdef, slavedecl,
-                                       fnaddrmap, mkslow, mkcon, mkcellcon,
-                                       pincon, inst, mkplic,
-                                       numsloirqs, ifacedef))
+                                    fnaddrmap, mkslow, mkcon, mkcellcon,
+                                    pincon, inst, mkplic,
+                                    numsloirqs, ifacedef))
 
 
 def write_bus(bus, p, ifaces):