gen/genlib/cdc/gearbox: add more margin on pointers (for cases where clocks are not...
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 31 May 2017 10:10:06 +0000 (12:10 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 31 May 2017 11:23:31 +0000 (13:23 +0200)
litex/gen/genlib/cdc.py

index e7e09addbc58dad23491d089eed7ce38470eb784..2ece028ad66c9ba4d65f875c50f8ff1b3f06008e 100644 (file)
@@ -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,