add master connection
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 30 Jul 2018 10:23:48 +0000 (11:23 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 30 Jul 2018 10:23:48 +0000 (11:23 +0100)
src/bsv/bsv_lib/soc_template.bsv
src/bsv/peripheral_gen/base.py
src/bsv/peripheral_gen/rgbttl.py
src/bsv/pinmux_generator.py

index 0e0886ecf9ff83e416f1096212eacfce055c5fd3..d35faf2f012f977041a5b199b63e5fac207ebb2d 100644 (file)
@@ -175,6 +175,7 @@ package socgen;
          mkConnection (dma.mmu, fabric.v_from_masters
                               [fromInteger(valueOf(DMA_master_num))]);
         `endif
+{13}
 
 
         // Connect fabric to memory slaves
index 1892fc1ce94a6567a4143f47de1246f4575a2fc9..018015c06b0ac55784f2fd444f2addb039be26a1 100644 (file)
@@ -333,23 +333,30 @@ Ifc_sync#({0}) {1}_sync <-mksyncconnection(
             return ''
         return txt.format(con, aname, fabricname)
 
-    def __mk_master_connection(self, con, aname):
-        txt = "mkConnection (slow_fabric.v_to_slaves\n" + \
-              "            [fromInteger(valueOf({1}))],\n" + \
-              "            {0});"
+    def __mk_master_connection(self, con, aname, fabricname):
+        txt = "mkConnection ({0}, {2}.v_from_masters\n" + \
+              "            [fromInteger(valueOf({1}))]);\n" 
 
-        print "PBase __mk_connection", self.name, aname
+        print "PBase __mk_master_connection", self.name, aname
         if not con:
             return ''
-        return txt.format(con, aname)
+        return txt.format(con, aname, fabricname)
+
+    def mk_master_connection(self, count, fabricname, typ, name=None):
+        if not self.has_axi_master():
+            return ''
+        if name is None:
+            name = self.name
+        print "PBase mk_master_conn", self.name, count
+        aname = self.axi_master_name(name, count, typ)
+        con = self._mk_connection(name, count, True).format(count, aname)
+        return self.__mk_master_connection(con, aname, fabricname)
 
     def mk_connection(self, count, fabricname, typ, name=None):
         if name is None:
             name = self.name
         print "PBase mk_conn", self.name, count
         aname = self.axi_slave_name(name, count, typ)
-        #dname = self.mksuffix(name, count)
-        #dname = "{0}{1}".format(name, dname)
         con = self._mk_connection(name, count).format(count, aname)
         return self.__mk_connection(con, aname, fabricname)
 
@@ -505,7 +512,8 @@ class PeripheralIface(object):
                       'mkfast_peripheral',
                       'mk_plic', 'mk_ext_ifacedef',
                       '_mk_clk_con', 'mk_ext_ifacedef',
-                      'mk_connection', 'mk_cellconn', '_mk_pincon']:
+                      'mk_connection', 'mk_master_connection',
+                      'mk_cellconn', '_mk_pincon']:
             fn = CallFn(self, fname)
             setattr(self, fname, types.MethodType(fn, self))
 
@@ -715,31 +723,29 @@ class PeripheralInterfaces(object):
                 ret.append(x.format(suffix))
         return '\n'.join(li(list(filter(None, ret)), 8))
 
-    def mk_fast_connection(self, *args):
+    def _mk_connection(self, fabric, typ, indent, master, *args):
         ret = []
         for (name, count) in self.ifacecount:
             for i in range(count):
                 if self.is_on_fastbus(name, i):
                     continue
-                txt = self.data[name].mk_connection(i, "fabric", "fast")
+                if master:
+                    txt = self.data[name].mk_master_connection(i, fabric, typ)
+                else:
+                    txt = self.data[name].mk_connection(i, fabric, typ)
                 if name == 'gpioa':
                     print "txt", txt
-                    print self.data[name].mk_connection
                 ret.append(txt)
-        return '\n'.join(li(list(filter(None, ret)), 12))
+        return '\n'.join(li(list(filter(None, ret)), indent))
+
+    def mk_master_connection(self, *args):
+        return self._mk_connection("fabric", "fast", 8, True, *args)
+
+    def mk_fast_connection(self, *args):
+        return self._mk_connection("fabric", "fast", 12, False, *args)
 
     def mk_connection(self, *args):
-        ret = []
-        for (name, count) in self.ifacecount:
-            for i in range(count):
-                if self.is_on_fastbus(name, i):
-                    continue
-                txt = self.data[name].mk_connection(i, "slow_fabric", "")
-                if name == 'gpioa':
-                    print "txt", txt
-                    print self.data[name].mk_connection
-                ret.append(txt)
-        return '\n'.join(li(list(filter(None, ret)), 8))
+        return self._mk_connection("slow_fabric", "", 8, False, *args)
 
     def mk_cellconn(self):
         ret = []
index 9c917e775aec9de4145c415be6861d43542ec88b..ca2fbad38d2f0b23a690c1aa20c8aebb16c04f69 100644 (file)
@@ -16,7 +16,9 @@ class rgbttl(PBase):
         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):
+    def _mk_connection(self, name=None, count=0, master=False):
+        if master:
+            return "lcd{0}.master"
         return "lcd{0}.slave"
 
     def pinname_out(self, pname):
index 87326a7fd2b2bbd819c65bf303b2e865bd021bba..b348cf47465aa49c8574fe2745d2d8f9941f0ce5 100644 (file)
@@ -152,6 +152,7 @@ def write_soc(soc, soct, fastmf, fastmt, p, ifaces, iocells):
     fnaddrmap = ifaces.axi_fastaddr_map()
     mkfast = ifaces.mkfast_peripheral()
     mkcon = ifaces.mk_fast_connection()
+    mkmstcon = ifaces.mk_master_connection()
     mkcellcon = ifaces.mk_cellconn()
     pincon = ifaces.mk_fast_pincon()
     inst = ifaces.extfastifinstance()
@@ -169,7 +170,7 @@ def write_soc(soc, soct, fastmf, fastmt, p, ifaces, iocells):
                                    slavedecl, mastdecl, mkcon,
                                    inst, dma, num_dmachannels,
                                    pincon, regdef, fnaddrmap,
-                                   clockcon,
+                                   clockcon, mkmstcon,
                                    ))
 
     with open(fastmf, "w") as bsv_file: