From 89b189ce4aa8c17581ad755e740feff89c577574 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 12 Nov 2015 00:51:32 +0100 Subject: [PATCH] soc/interconnect/stream: reintroduce PipelinedActor/Buffer --- litex/soc/interconnect/stream.py | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/litex/soc/interconnect/stream.py b/litex/soc/interconnect/stream.py index 0c708420..56ac1769 100644 --- a/litex/soc/interconnect/stream.py +++ b/litex/soc/interconnect/stream.py @@ -200,6 +200,56 @@ class CombinatorialActor(BinaryActor): ] +class PipelinedActor(BinaryActor): + def __init__(self, latency): + self.pipe_ce = Signal() + BinaryActor.__init__(self, latency) + + def build_binary_control(self, sink, source, latency): + busy = 0 + valid = sink.stb + for i in range(latency): + valid_n = Signal() + self.sync += If(self.pipe_ce, valid_n.eq(valid)) + valid = valid_n + busy = busy | valid + + self.comb += [ + self.pipe_ce.eq(source.ack | ~valid), + sink.ack.eq(self.pipe_ce), + source.stb.eq(valid), + self.busy.eq(busy) + ] + if sink.description.packetized: + sop = sink.stb & sink.sop + eop = sink.stb & sink.eop + for i in range(latency): + sop_n = Signal() + eop_n = Signal() + self.sync += \ + If(self.pipe_ce, + sop_n.eq(sop), + eop_n.eq(eop) + ) + sop = sop_n + eop = eop_n + + self.comb += [ + source.eop.eq(eop), + source.sop.eq(sop) + ] + + +class Buffer(PipelinedActor): + def __init__(self, layout): + self.d = Sink(layout) + self.q = Source(layout) + PipelinedActor.__init__(self, 1) + self.sync += \ + If(self.pipe_ce, + self.q.payload.eq(self.d.payload) + ) + class Unpack(Module): def __init__(self, n, layout_to, reverse=False): self.source = source = Source(layout_to) -- 2.30.2