From 33c3a927c26252bc713588c14ce84e364142d9d3 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 31 Oct 2014 13:09:24 +0100 Subject: [PATCH] actorlib/structuring: add Pipeline Pipeline enables easy cascading of dataflow modules. DataFlowGraph can eventually use it to implement the add_pipeline method to avoid duplicating things. --- migen/actorlib/structuring.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/migen/actorlib/structuring.py b/migen/actorlib/structuring.py index 70a60e5d3..24199aca5 100644 --- a/migen/actorlib/structuring.py +++ b/migen/actorlib/structuring.py @@ -197,3 +197,31 @@ 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 + # use of busy is encouraged + # but not mandatory + if hasattr(m, "busy"): + busy = m.busy + else: + busy = 0 + for i in range(1, n): + m_n = modules[i] + if hasattr(m_n, "busy"): + busy_n = m_n.busy + else: + busy_n = 0 + self.comb += m.source.connect(m_n.sink) + m = m_n + busy = busy | busy_n + # expose source of last module + # if available + if hasattr(m, "source"): + self.source = m.source + self.busy = busy