create new get/put interface pinmux declaration
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 23 Jul 2018 05:47:32 +0000 (06:47 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 23 Jul 2018 05:47:32 +0000 (06:47 +0100)
src/bsv/interface_decl.py
src/bsv/pinmux_generator.py
src/test_bsv/pinmux_experiment.bsv

index 4e16fa1349600730e4efbda7b11a8843803fbf1c..f87bdd979552a51bbdb44401983a473980fc1727 100644 (file)
@@ -186,7 +186,7 @@ class Interface(PeripheralIface):
                 return 'input'
         return None
 
-    def pname(self, name):
+    def iname(self):
         """ generates the interface spec e.g. flexbus_ale
             if there is only one flexbus interface, or
             sd{0}_cmd if there are several.  string format
@@ -194,8 +194,17 @@ class Interface(PeripheralIface):
             appropriate.  single mode stops the numerical extension.
         """
         if self.single:
-            return '%s_%s' % (self.ifacename, name)
-        return '%s{0}_%s' % (self.ifacename, name)
+            return self.ifacename
+        return '%s{0}' % self.ifacename
+
+    def pname(self, name):
+        """ generates the interface spec e.g. flexbus_ale
+            if there is only one flexbus interface, or
+            sd{0}_cmd if there are several.  string format
+            function turns this into sd0_cmd, sd1_cmd as
+            appropriate.  single mode stops the numerical extension.
+        """
+        return "%s_%s" % (self.iname(), name)
 
     def busfmt(self, *args):
         """ this function creates a bus "ganging" system based
@@ -343,6 +352,14 @@ class Interfaces(InterfacesBase, PeripheralInterfaces):
                 f.write(c.format(i))
                 f.write(self.data[name].ifacefmt(i))
 
+    def ifacefmt2(self, f, *args):
+        comment = '''
+            interface PeripheralSide{0} {1};'''
+        for (name, count) in self.ifacecount:
+            for i in range(count):
+                iname = self.data[name].iname().format(i)
+                f.write(comment.format(name.upper(), iname))
+
     def wirefmt(self, f, *args):
         comment = '\n      // following wires capture signals ' \
                   'to IO CELL if %s-{0} is\n' \
index a74eee16a555a211415da314323a7f4571d6f1fa..69a19c565468759fd0cc016bcb162a71c82cb244 100644 (file)
@@ -176,7 +176,7 @@ def write_pmp(pmp, p, ifaces, iocells):
         # ==============================================================
 
         # == create method definitions for all peripheral interfaces ==#
-        ifaces.ifacefmt(bsv_file)
+        ifaces.ifacefmt2(bsv_file)
         bsv_file.write("\n      endinterface\n")
 
         # ===== finish interface definition and start module definition=======
@@ -205,6 +205,7 @@ def write_pmp(pmp, p, ifaces, iocells):
       // the I/O from the IOcell actually goes.
       interface IOCellSide iocell_side;
    endinterface
+
    (*synthesize*)
    module mkpinmux(Ifc_pinmux);
 ''')
@@ -245,16 +246,18 @@ def write_pmp(pmp, p, ifaces, iocells):
         bsv_file.write("\n    endinterface;")
 
         bsv_file.write('''
+
     interface iocell_side = interface IOCellSide
 ''')
         iocells.ifacedef(bsv_file)
         bsv_file.write("\n     endinterface;")
 
         bsv_file.write('''
-    interface peripheral_side = interface PeripheralSide
+
+     interface peripheral_side = interface PeripheralSide
 ''')
         ifaces.ifacedef(bsv_file)
-        bsv_file.write("\n     endinterface;")
+        bsv_file.write("\n      endinterface;")
 
         bsv_file.write(footer)
         print("BSV file successfully generated: bsv_src/pinmux.bsv")
index 49bee6f6cf358376da5504da18ae02f3a173ca9b..94c880f35dd088992aeaca78f29ce1249a136ced 100644 (file)
@@ -85,7 +85,6 @@ import GetPut::*;
       // peripheral and an output field will be an input to the peripheral.
       // Bi-directional functions also have an output-enable (which
       // again comes *in* from the peripheral)
-          // interface declaration between UART-0 and pinmux
             interface PeripheralSideUART uart;
             interface PeripheralSideGPIOA gpioa;
             interface PeripheralSideTWI twi;
@@ -115,8 +114,8 @@ import GetPut::*;
       // the I/O from the IOcell actually goes.
       interface IOCellSide iocell_side;
    endinterface
-   (*synthesize*)
 
+   (*synthesize*)
    module mkpinmux(Ifc_pinmux);
 
       // the followins wires capture the pin-mux selection
@@ -289,7 +288,8 @@ import GetPut::*;
       endmethod
 
      endinterface;
-      interface peripheral_side= interface PeripheralSide
+
+     interface peripheral_side = interface PeripheralSide
         interface uart = interface PeripheralSideUART
             // interface declaration between UART and pinmux
             interface tx = interface Put