put jtag interface straight out, not with bscan etc
[pinmux.git] / src / bsv / peripheral_gen / base.py
index ef8f881cc42b08c5db3b3e086489a3fce83def1b..23adfb687cc295e2e9cd677a7e633a2aeb7a38cd 100644 (file)
@@ -12,6 +12,9 @@ class PBase(object):
     def has_axi_master(self):
         return False
 
+    def fastifdecl(self, name, count):
+        return ''
+
     def slowifdeclmux(self, name, count):
         return ''
 
@@ -134,7 +137,17 @@ class PBase(object):
     def mksuffix(self, name, i):
         return i
 
-    def __mk_connection(self, con, aname):
+    def __mk_connection(self, con, aname, fabricname):
+        txt = "        mkConnection ({2}.v_to_slaves\n" + \
+            "                    [fromInteger(valueOf({1}))],\n" + \
+            "                    {0});"
+
+        print "PBase __mk_connection", self.name, aname
+        if not con:
+            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});"
@@ -144,15 +157,15 @@ class PBase(object):
             return ''
         return txt.format(con, aname)
 
-    def mk_connection(self, count, name=None):
+    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)
+        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)
+        return self.__mk_connection(con, aname, fabricname)
 
     def _mk_connection(self, name=None, count=0):
         return ''
@@ -194,11 +207,21 @@ class PBase(object):
     def mk_ext_ifacedef(self, iname, inum):
         return ''
 
-    def extifinstance(self, name, count):
-        sname = self.peripheral.iname().format(count)
+    def extfastifinstance(self, name, count):
+        return ''
+
+    def _extifinstance(self, name, count, suffix, prefix, samename=False):
         pname = self.get_iname(count)
-        template = "        interface {0} = pinmux.peripheral_side.{1};"
-        return template.format(pname, sname)
+        if samename:
+            sname = pname
+        else:
+            sname = self.peripheral.iname().format(count)
+        template = "        interface {0}{3} = {2}{1};"
+        return template.format(pname, sname, prefix, suffix)
+
+    def extifinstance(self, name, count):
+        return self._extifinstance(name, count, "",
+                                            "pinmux.peripheral_side.")
 
 
 mkplic_rule = """\
@@ -274,8 +297,9 @@ class PeripheralIface(object):
             self.slow = slow(ifacename)
             self.slow.peripheral = self
         for fname in ['slowimport',
-                      'extifinstance', 'extifdecl',
+                      'extfastifinstance', 'extifinstance', 'extifdecl',
                       'slowifdecl', 'slowifdeclmux',
+                      'fastifdecl',
                       'mkslow_peripheral', 
                       'mkfast_peripheral',
                       'mk_plic', 'mk_ext_ifacedef',
@@ -323,6 +347,17 @@ class PeripheralInterfaces(object):
             ret.append(self.data[name].slowimport())
         return '\n'.join(list(filter(None, ret)))
 
+    def extfastifinstance(self, *args):
+        ret = []
+        for (name, count) in self.ifacecount:
+            for i in range(count):
+                iname = self.data[name].iname().format(i)
+                print "extfast", iname, self.is_on_fastbus(name, i)
+                if self.is_on_fastbus(name, i):
+                    continue
+                ret.append(self.data[name].extfastifinstance(name, i))
+        return '\n'.join(list(filter(None, ret)))
+
     def extifinstance(self, *args):
         ret = []
         for (name, count) in self.ifacecount:
@@ -349,6 +384,16 @@ class PeripheralInterfaces(object):
                 ret.append(self.data[name].slowifdeclmux(name, i))
         return '\n'.join(list(filter(None, ret)))
 
+    def fastifdecl(self, *args):
+        ret = []
+        for (name, count) in self.ifacecount:
+            for i in range(count):
+                print "fastifdecl", name, i, self.is_on_fastbus(name, i)
+                if self.is_on_fastbus(name, i):
+                    continue
+                ret.append(self.data[name].fastifdecl(name, i))
+        return '\n'.join(list(filter(None, ret)))
+
     def slowifdecl(self, *args):
         ret = []
         for (name, count) in self.ifacecount:
@@ -441,13 +486,26 @@ class PeripheralInterfaces(object):
                 ret.append(x.format(suffix))
         return '\n'.join(list(filter(None, ret)))
 
+    def mk_fast_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, "fabric", "fast")
+                if name == 'gpioa':
+                    print "txt", txt
+                    print self.data[name].mk_connection
+                ret.append(txt)
+        return '\n'.join(list(filter(None, ret)))
+
     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)
+                txt = self.data[name].mk_connection(i, "slow_fabric", "")
                 if name == 'gpioa':
                     print "txt", txt
                     print self.data[name].mk_connection