soc/interconnect/stream: add Pipeline
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 12 Nov 2015 00:41:23 +0000 (01:41 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Thu, 12 Nov 2015 00:41:23 +0000 (01:41 +0100)
litex/soc/interconnect/stream.py

index c420f3af6a9dfc0142be94789ec82f7de644c99c..f6b1bb0213b4f398376afeb0b8d0b8f569a0edaf 100644 (file)
@@ -440,4 +440,23 @@ class Converter(Module):
         else:
             self.comb += Record.connect(self.sink, self.source)
 
+
+class Pipeline(Module):
+    def __init__(self, *modules):
+        n = len(modules)
+        m = modules[0]
+        # expose sink of first module
+        # if available
+        if hasattr(m, "sink"):
+            self.sink = m.sink
+        for i in range(1, n):
+            m_n = modules[i]
+            self.comb += m.source.connect(m_n.sink)
+            m = m_n
+        # expose source of last module
+        # if available
+        if hasattr(m, "source"):
+            self.source = m.source
+
+
 # XXX