# Pastebin faTkYMwb # AXILite CDC -------------------------------------------------------------------------------------- class AXILiteClockDomainCrossing(Module): """AXILite Clock Domain Crossing""" def __init__(self, master, slave, cd_from="sys", cd_to="sys"): self.master = master self.slave = slave # # # # Same Clock Domain, direct connection. if cd_from == cd_to: self.comb += [ # Write. master.aw.connect(slave.aw), master.w.connect(slave.w), slave.b.connect(master.b), # Read. master.ar.connect(slave.ar), slave.r.connect(master.r), ] # Clock Domain Crossing. else: # Write. aw_cdc = stream.ClockDomainCrossing(master.aw.layout, cd_from, cd_to) w_cdc = stream.ClockDomainCrossing(master.w.layout, cd_from, cd_to) b_cdc = stream.ClockDomainCrossing(master.b.layout, cd_to, cd_from) self.submodules += aw_cdc, w_cdc, b_cdc self.comb += [ master.aw.connect(aw_cdc.sink), aw_cdc.source.connect(slave.aw), master.w.connect(w_cdc.sink), w_cdc.source.connect(slave.w), slave.b.connect(b_cdc.sink), b_cdc.source.connect(master.b), ] # Read. ar_cdc = stream.ClockDomainCrossing(master.ar.layout, cd_from, cd_to) r_cdc = stream.ClockDomainCrossing(master.r.layout, cd_to, cd_from) self.submodules += ar_cdc, r_cdc self.comb += [ master.ar.connect(ar_cdc.sink), ar_cdc.source.connect(slave.ar), slave.r.connect(r_cdc.sink), r_cdc.source.connect(master.r), ]