From ff2a9c2176c1d8ed0e3bcd24f635af7627bf12d3 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 31 May 2017 12:10:06 +0200 Subject: [PATCH] gen/genlib/cdc/gearbox: add more margin on pointers (for cases where clocks are not perfectly aligned) --- litex/gen/genlib/cdc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/litex/gen/genlib/cdc.py b/litex/gen/genlib/cdc.py index e7e09add..2ece028a 100644 --- a/litex/gen/genlib/cdc.py +++ b/litex/gen/genlib/cdc.py @@ -224,11 +224,12 @@ class Gearbox(Module): ] self.clock_domains += cd_write, cd_read - storage = Signal(lcm(iwidth, owidth)) + # TODO: optimize storage/resets for lowest ressource usage / lowest latency + storage = Signal(2*lcm(iwidth, owidth)) wrchunks = len(storage)//iwidth rdchunks = len(storage)//owidth - wrpointer = Signal(max=wrchunks, reset=0 if iwidth > owidth else wrchunks-1) - rdpointer = Signal(max=rdchunks, reset=rdchunks-1 if iwidth > owidth else 0) + wrpointer = Signal(max=wrchunks, reset=0 if iwidth > owidth else wrchunks//2) + rdpointer = Signal(max=rdchunks, reset=rdchunks//2 if iwidth > owidth else 0) self.sync.write += \ If(wrpointer == wrchunks-1, -- 2.30.2