add pin class for auto-generating interface lines
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 20 Mar 2018 15:55:30 +0000 (15:55 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 20 Mar 2018 15:55:30 +0000 (15:55 +0000)
src/interface_decl.py

index df54caf6834862ddfcd544a01dd10ec6a011f345..3297f7c71947f5e381a9fcf93084485c7e6b9b03 100644 (file)
@@ -69,3 +69,30 @@ pwminterface_decl = '''
       (*always_ready,always_enabled*) method Action pwm{0}(Bit#(1) in);
 '''
 # ======================================= #
+
+class Pin(object):
+
+    def __init__(self, name, ready, enabled, action, inout):
+        self.name = name
+        self.ready = ready
+        self.enabled = enabled
+        self.action = action
+        self.inout = inout
+
+    def __str__(self):
+        res = '    (*'
+        status = []
+        if self.ready:
+            status.append('always_ready')
+        if self.enabled:
+            status.append('always_enabled')
+        res += ','.join(status)
+        res += "*) method "
+        if self.action:
+            res += " Action "
+        res += self.name
+        if inout:
+            res += ' (Bit#(1) in)'
+        res += ";"
+        return res
+