add external interfaces v2
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 26 Jul 2018 05:54:05 +0000 (06:54 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 26 Jul 2018 05:54:05 +0000 (06:54 +0100)
src/bsv/bsv_lib/slow_peripherals_template.bsv
src/bsv/peripheral_gen/base.py
src/bsv/peripheral_gen/gpio.py
src/bsv/pinmux_generator.py

index f03e6187a296ba6bd9022e4ac2ebb9c556400b61..1ed48f824f3e0d75e87d1b3049db7b16b6695a54 100644 (file)
@@ -218,8 +218,8 @@ package slow_peripherals;
        */
                endinterface
         interface iocell_side=pinmux.iocell_side;
-        interface pad_config0= gpioa.pad_config;
 {9}
+{13}
                /*===================================*/
        endmodule
 endpackage
index cb4eadb8aebb2c493b4e023f2fa9daf6123d6b83..3e6fbde0209d888a7eb1db0aca14bd92a656151e 100644 (file)
@@ -273,6 +273,9 @@ class PBase(object):
         template = "        interface {0}{3} = {2}{1};"
         return template.format(pname, sname, prefix, suffix)
 
+    def extifinstance2(self, name, count):
+        return ''
+
     def extifinstance(self, name, count):
         return self._extifinstance(name, count, "",
                                             "pinmux.peripheral_side.")
@@ -362,7 +365,8 @@ class PeripheralIface(object):
             self.slow = slow(ifacename)
             self.slow.peripheral = self
         for fname in ['slowimport',
-                      'extfastifinstance', 'extifinstance', 'extifdecl',
+                      'extfastifinstance',
+                      'extifinstance2', 'extifinstance', 'extifdecl',
                       'slowifdecl', 'slowifdeclmux',
                       'fastifdecl',
                       'mkslow_peripheral',
@@ -424,6 +428,14 @@ class PeripheralInterfaces(object):
                 ret.append(self.data[name].extfastifinstance(name, i))
         return '\n'.join(list(filter(None, ret)))
 
+    def extifinstance2(self, *args):
+        ret = []
+        for (name, count) in self.ifacecount:
+            for i in range(count):
+                iname = self.data[name].iname().format(i)
+                ret.append(self.data[name].extifinstance2(name, i))
+        return '\n'.join(list(filter(None, ret)))
+
     def extifinstance(self, *args):
         ret = []
         for (name, count) in self.ifacecount:
index 2e6f859c3871deea702f3664ee5c56ac973e47bd..6ed41b676e33b640205c4fdc563893ff3db9f14f 100644 (file)
@@ -8,10 +8,16 @@ class gpio(PBase):
                "    import mux::*;\n" + \
                "    import gpio::*;\n"
 
+    def extifinstance2(self, name, count):
+        template = "interface pad_config{0} = {1}.pad_config;"
+        dname = self.mksuffix(self.name, count)
+        return template.format(dname, name)
+
     def slowifdeclmux(self, name, count):
         size = len(self.peripheral.pinspecs)
-        return "        interface GPIO_config#(%d) pad_config%d;" % \
-            (size, count)
+        dname = self.mksuffix(self.name, count)
+        return "interface GPIO_config#(%d) pad_config%s;" % \
+            (size, dname)
 
     def num_axi_regs32(self):
         return 2
index 3a9a4a02d97e4cd8f8c2bd05ce1d6d657ebb1e56..8b23f0e43339998972a5b5f5542e605404890481 100644 (file)
@@ -114,6 +114,7 @@ def write_slow(slow, slowt, p, ifaces, iocells):
     mkcellcon = ifaces.mk_cellconn()
     pincon = ifaces.mk_pincon()
     inst = ifaces.extifinstance()
+    inst2 = ifaces.extifinstance2()
     mkplic = ifaces.mk_plic()
     numsloirqs = ifaces.mk_sloirqsdef()
     ifacedef = ifaces.mk_ext_ifacedef()
@@ -122,7 +123,8 @@ def write_slow(slow, slowt, p, ifaces, iocells):
         bsv_file.write(slowt.format(imports, ifdecl, regdef, slavedecl,
                                     fnaddrmap, mkslow, mkcon, mkcellcon,
                                     pincon, inst, mkplic,
-                                    numsloirqs, ifacedef))
+                                    numsloirqs, ifacedef,
+                                    inst2))
 
 def write_soc(soc, soct, p, ifaces, iocells):
     """ write out the soc.bsv file.