sort out mkConnection for gpio vectorised
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 23 Jul 2018 12:28:13 +0000 (13:28 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 23 Jul 2018 12:28:13 +0000 (13:28 +0100)
src/bsv/interface_decl.py
src/bsv/peripheral_gen/gpio.py

index 281c6c3a90dd228037fe3e3a162eb16c4816c54c..e535db1509a8c30322592cdb77d3ce515ebd3b0a 100644 (file)
@@ -373,7 +373,7 @@ class InterfaceGPIO(Interface):
     def ifacepfmt(self, *args):
         return """
           interface Put#(Vector#({0}, Bit#(1))) out;
-          interface Put#(Vector#({0}, Bit#(1))) outen;
+          interface Put#(Vector#({0}, Bit#(1))) out_en;
           interface Get#(Vector#({0}, Bit#(1))) in;
 """.format(len(self.pinspecs))
 
@@ -398,7 +398,7 @@ class InterfaceGPIO(Interface):
 {1}
                  endmethod
                endinterface;
-               interface outen = interface Put#({0})
+               interface out_en = interface Put#({0})
                  method Action put(Vector#({0},Bit#(1)) in);
 {2}
                  endmethod
index 93dcd3bf4b3fbed6a1debebd149f68bb99910640..222f14456edd25ae3ab3584ac055da3da15ac93b 100644 (file)
@@ -68,19 +68,13 @@ class gpio(PBase):
         return "func.gpio_out_en[{0}]".format(pname[1:])
 
     def mk_pincon(self, name, count):
-        ret = [PBase.mk_pincon(self, name, count)]
+        #ret = [PBase.mk_pincon(self, name, count)]
         # special-case for gpio in, store in a temporary vector
+        ret = []
         plen = len(self.peripheral.pinspecs)
-        ret.append("    rule con_%s%d_in;" % (name, count))
-        ret.append("       Vector#({0},Bit#(1)) temp;".format(plen))
-        for p in self.peripheral.pinspecs:
-            typ = p['type']
-            pname = p['name']
-            idx = pname[1:]
-            n = name
-            sname = self.peripheral.pname(pname).format(count)
-            ps = "pinmux.peripheral_side.%s_in" % sname
-            ret.append("        temp[{0}]={1};".format(idx, ps))
-        ret.append("        {0}.func.gpio_in(temp);".format(name))
-        ret.append("    endrule")
+        template = "      mkConnection({0}_{1},\n\t\t\t{2}_{1});"
+        ps = "pinmux.peripheral_side.%s" % name
+        n = "{0}.func.gpio".format(name)
+        for ptype in ['out', 'out_en', 'in']:
+            ret.append(template.format(ps, ptype, n))
         return '\n'.join(ret)