From f73eb5fe71f61bbd5ce9501b4612caaa87d3bce2 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 19 Apr 2017 09:55:19 +0200 Subject: [PATCH] gen/genlib/misc: add BitSlip --- litex/gen/genlib/misc.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litex/gen/genlib/misc.py b/litex/gen/genlib/misc.py index 42ad878c..a28e30d9 100644 --- a/litex/gen/genlib/misc.py +++ b/litex/gen/genlib/misc.py @@ -86,3 +86,19 @@ class WaitTimer(Module): If(self.wait, If(~self.done, count.eq(count - 1)) ).Else(count.eq(count.reset)) + + +class BitSlip(Module): + def __init__(self, dw): + self.i = Signal(dw) + self.o = Signal(dw) + self.value = Signal(max=dw) + + # # # + + r = Signal(2*dw) + self.sync += r.eq(Cat(r[dw:], self.i)) + cases = {} + for i in range(dw): + cases[i] = self.o.eq(r[i:dw+i]) + self.sync += Case(self.value, cases) -- 2.30.2