add qspi get/put mkConnection
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 05:33:50 +0000 (06:33 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 05:33:50 +0000 (06:33 +0100)
src/bsv/peripheral_gen/qspi.py

index 462b57bfbba26980d0596bb5b511017ac96642cf..c4a6764920c5c704ac5b7ca81563ffe4f6165dde 100644 (file)
@@ -22,43 +22,24 @@ class qspi(PBase):
     def pinname_out(self, pname):
         return {'ck': 'out.clk_o',
                 'nss': 'out.ncs_o',
-                'io0': 'out.io_o[0]',
-                'io1': 'out.io_o[1]',
-                'io2': 'out.io_o[2]',
-                'io3': 'out.io_o[3]',
                 }.get(pname, '')
 
     def pinname_outen(self, pname):
         return {'ck': 1,
                 'nss': 1,
-                'io0': 'out.io_enable[0]',
-                'io1': 'out.io_enable[1]',
-                'io2': 'out.io_enable[2]',
-                'io3': 'out.io_enable[3]',
                 }.get(pname, '')
 
     def mk_pincon(self, name, count):
         ret = [PBase.mk_pincon(self, name, count)]
         # special-case for gpio in, store in a temporary vector
+        ret = []
         plen = len(self.peripheral.pinspecs)
-        ret.append("    // XXX NSS and CLK are hard-coded master")
-        ret.append("    // TODO: must add qspi slave-mode")
-        ret.append("    // all ins done in one rule from 4-bitfield")
-        ret.append("    rule con_%s%d_io_in;" % (name, count))
-        ret.append("       {0}{1}.out.io_i({{".format(name, count))
-        for i, p in enumerate(self.peripheral.pinspecs):
-            typ = p['type']
-            pname = p['name']
-            if not pname.startswith('io'):
-                continue
-            idx = pname[1:]
-            n = name
-            sname = self.peripheral.pname(pname).format(count)
-            ps = "pinmux.peripheral_side.%s_in" % sname
-            comma = '' if i == 5 else ','
-            ret.append("            {0}{1}".format(ps, comma))
-        ret.append("        });")
-        ret.append("    endrule")
+        template = "      mkConnection({0}.{1},\n\t\t\t{2}.{1});"
+        ps = "pinmux.peripheral_side.%s" % name
+        name = self.get_iname(count)
+        n = "{0}.out".format(name)
+        for ptype in ['io_out', 'io_out_en', 'io_in']:
+            ret.append(template.format(ps, ptype, n))
         return '\n'.join(ret)
 
     def num_irqs(self):