From: Florent Kermarrec Date: Fri, 3 Jul 2020 12:39:31 +0000 (+0200) Subject: interconnect/stream: add ClockDomainCrossing wrapper around AsyncFIFO. X-Git-Tag: 24jan2021_ls180~115 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c53f9b2ff9135f8fa7afc959337feecbab3fb80;p=litex.git interconnect/stream: add ClockDomainCrossing wrapper around AsyncFIFO. --- diff --git a/litex/soc/interconnect/stream.py b/litex/soc/interconnect/stream.py index f70393aa..8fb3213a 100644 --- a/litex/soc/interconnect/stream.py +++ b/litex/soc/interconnect/stream.py @@ -235,6 +235,23 @@ class AsyncFIFO(_FIFOWrapper): layout = layout, depth = depth) +# ClockDomainCrossing ------------------------------------------------------------------------------ + +class ClockDomainCrossing(Module): + def __init__(self, layout, cd_from="sys", cd_to="sys"): + self.sink = Endpoint(layout) + self.source = Endpoint(layout) + # # # + + if cd_from == cd_to: + self.comb += self.sink.connect(self.source) + else: + cdc = AsyncFIFO(layout) + cdc = ClockDomainsRenamer({"write": cd_from, "read": cd_to})(cdc) + self.submodules += cdc + self.comb += self.sink.connect(cdc.sink) + self.comb += cdc.source.connect(self.source) + # Mux/Demux ---------------------------------------------------------------------------------------- class Multiplexer(Module):