gen/genlib/misc: add BitSlip

This commit is contained in:
Florent Kermarrec 2017-04-19 09:55:19 +02:00
parent b708b9cfba
commit f73eb5fe71
1 changed files with 16 additions and 0 deletions

View File

@ -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)