add peripheral interfaces
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 12:31:39 +0000 (13:31 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 24 Jul 2018 12:31:39 +0000 (13:31 +0100)
src/bsv/peripheral_gen/base.py
src/bsv/peripheral_gen/gpio.py
src/bsv/peripheral_gen/jtag.py
src/bsv/peripheral_gen/nspi.py
src/bsv/peripheral_gen/quart.py
src/bsv/peripheral_gen/rgbttl.py
src/bsv/peripheral_gen/twi.py

index 90aae7d40e9bf1d20642a155865c941c70fb2725..324fbf3e1ac8417cffc7920ad7485109bbc254d9 100644 (file)
@@ -5,10 +5,10 @@ class PBase(object):
     def __init__(self, name):
         self.name = name
 
-    def slowifdeclmux(self):
+    def slowifdeclmux(self, name, count):
         return ''
 
-    def slowifinstance(self):
+    def slowifinstance(self, name, count):
         return ''
 
     def slowimport(self):
@@ -274,15 +274,15 @@ class PeripheralInterfaces(object):
     def slowifinstance(self, *args):
         ret = []
         for (name, count) in self.ifacecount:
-            #print "slowimport", name, self.data[name].slowimport
-            ret.append(self.data[name].slowifinstance())
+            for i in range(count):
+                ret.append(self.data[name].slowifinstance(name, i))
         return '\n'.join(list(filter(None, ret)))
 
     def slowifdeclmux(self, *args):
         ret = []
         for (name, count) in self.ifacecount:
             for i in range(count):
-                ret.append(self.data[name].slowifdeclmux().format(i, name))
+                ret.append(self.data[name].slowifdeclmux(name, i))
         return '\n'.join(list(filter(None, ret)))
 
     def slowifdecl(self, *args):
index 9419f1c5bab85955ac5dd7c3c637c94863f04579..4b6ab4c9c300275c6e02f366e89dc00ca7cd8ca9 100644 (file)
@@ -8,9 +8,10 @@ class gpio(PBase):
                "    import mux::*;\n" + \
                "    import gpio::*;\n"
 
-    def slowifdeclmux(self):
+    def slowifdeclmux(self, name, count):
         size = len(self.peripheral.pinspecs)
-        return "        interface GPIO_config#(%d) pad_config{0};" % size
+        return "        interface GPIO_config#(%d) pad_config%d;" % \
+                            (size, count)
 
     def num_axi_regs32(self):
         return 2
index 0592b382aa008ca756f4e89c71a708e608cddf40..e4c9e529e4dd1eb355e9eebc28ea70f13c8c2459 100644 (file)
@@ -12,25 +12,13 @@ class jtag(PBase):
     def axi_addr_map(self, name, ifacenum):
         return ''
 
-    def slowifdeclmux(self):
-        return "        method  Action jtag_ms (Bit#(1) in);\n" +  \
-               "        method  Bit#(1) jtag_di;\n" + \
-               "        method  Action jtag_do (Bit#(1) in);\n" + \
-               "        method  Action jtag_ck (Bit#(1) in);"
-
-    def slowifinstance(self):
-        return jtag_method_template  # bit of a lazy hack this...
-
-
-jtag_method_template = """\
-        method  Action jtag_ms (Bit#(1) in);
-          pinmux.peripheral_side.jtag_ms(in);
-        endmethod
-        method  Bit#(1) jtag_di=pinmux.peripheral_side.jtag_di;
-        method  Action jtag_do (Bit#(1) in);
-          pinmux.peripheral_side.jtag_do(in);
-        endmethod
-        method  Action jtag_ck (Bit#(1) in);
-          pinmux.peripheral_side.jtag_ck(in);
-        endmethod
-"""
+    def slowifdeclmux(self, name, count):
+        sname = self.get_iname(count)
+        return "        interface PeripheralSideJTAG %s;" % sname
+
+    def slowifinstance(self, name, count):
+        sname = self.peripheral.iname().format(count)
+        pname = self.get_iname(count)
+        template = "        interface {0} = pinmux.peripheral_side.{1};"
+        return template.format(pname, sname)
+
index 46ff961b878bc3d74e2e55511dd3127fb0340e2a..0f97013011dc16311cd9ef400f7e35e0f87dee90 100644 (file)
@@ -56,5 +56,6 @@ class nspi(PBase):
         name = self.get_iname(inum)
         return "        method {0}_isint = {0}.interrupts[5];".format(name)
 
-    def slowifdeclmux(self):
-        return "        method Bit#(1) {1}{0}_isint;"
+    def slowifdeclmux(self, name, count):
+        sname = self.peripheral.iname().format(count)
+        return "        method Bit#(1) %s_isint;" % sname
index 36ddaba23bc639b32a408ea6fd8908d8322c04cc..a6646db1899ff0ad2bd498b027ec8fa38c3b9823 100644 (file)
@@ -62,8 +62,9 @@ class quart(PBase):
         name = self.get_iname(inum)
         return "        method {0}_intr = {0}.irq;".format(name)
 
-    def slowifdeclmux(self):
-        return "        method Bit#(1) {1}{0}_intr;"
+    def slowifdeclmux(self, name, count):
+        sname = self.peripheral.iname().format(count)
+        return "        method Bit#(1) %s_intr;" % sname
 
 
 uart_plic_template = """\
index e9a83255aa45f2d2d10295bed8a240baaf2c26cf..ca065bb08b5db0842d928b58e422b9c53cf16848 100644 (file)
@@ -34,4 +34,13 @@ class rgbttl(PBase):
             ret.append(template.format(ps, ptype, n))
         return '\n'.join(ret)
 
+    def slowifdeclmux(self, name, count):
+        sname = self.get_iname(count)
+        return "        interface PeripheralSideLCD %s;" % sname
+
+    def slowifinstance(self, name, count):
+        sname = self.peripheral.iname().format(count)
+        pname = self.get_iname(count)
+        template = "        interface {0} = pinmux.peripheral_side.{1};"
+        return template.format(pname, sname)
 
index e20ea4cbec77e8e3f085355d4abc3c3f3f395ca8..b77724f932556cf19f7fa2eb25e7426b07a4fba0 100644 (file)
@@ -44,5 +44,6 @@ class twi(PBase):
         name = self.get_iname(inum)
         return "        method {0}_isint = {0}.isint;".format(name)
 
-    def slowifdeclmux(self):
-        return "        method Bit#(1) {1}{0}_isint;"
+    def slowifdeclmux(self, name, inum):
+        sname = self.get_iname(inum)
+        return "        method Bit#(1) %s_isint;" % sname