8a62460dda533fb3b1fe581e53383a4e1e425580
1 from nmigen
import (Elaboratable
, Signal
, Module
, Cat
)
4 class ROTL(Elaboratable
):
5 def __init__(self
, width
):
7 self
.shiftwidth
= math
.ceil(math
.log2(width
))
8 self
.a
= Signal(width
, reset_less
=True)
9 self
.b
= Signal(self
.shiftwidth
, reset_less
=True)
11 self
.o
= Signal(width
, reset_less
=True)
13 def elaborate(self
, platform
):
16 # trick to do double-concatenation of a then left shift.
17 # synth tools know to turn this pattern into a barrel-shifter
18 comb
+= self
.o
.eq(Cat(self
.a
, self
.a
).bit_select(self
.width
- self
.b
,