diff --git a/litex/soc/interconnect/stream.py b/litex/soc/interconnect/stream.py index e425cb347..559c38e9d 100644 --- a/litex/soc/interconnect/stream.py +++ b/litex/soc/interconnect/stream.py @@ -844,25 +844,22 @@ class Pipeline(Module): def __init__(self, *modules): n = len(modules) m = modules[0] - # expose sink of first module - # if available + # Expose sink of first module if available. if hasattr(m, "sink"): self.sink = m.sink + # Iterate on Modules/Endpoints. for i in range(1, n): m_n = modules[i] - if isinstance(m, Endpoint): - source = m - else: - source = m.source - if isinstance(m_n, Endpoint): - sink = m_n - else: - sink = m_n.sink + # If m is an Endpoint, use it as Source, else use Module.source. + source = m if isinstance(m, Endpoint) else m.source + # If m_n is an Endpoint, use it as Sink, else use Module.sink. + sink = m_n if isinstance(m_n, Endpoint) else m_n.sink + # Connect Source to Sink (when m is not m_n). if m is not m_n: self.comb += source.connect(sink) + # Update m. m = m_n - # expose source of last module - # if available + # Expose source of last module if available. if hasattr(m, "source"): self.source = m.source