X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Ffu%2Fshift_rot%2Frotl.py;h=8a62460dda533fb3b1fe581e53383a4e1e425580;hb=8a45a6610a8c4c457b1658db2e49607b284fe391;hp=d2ebfcf71a622c4935686a37ed33acb121086b9b;hpb=afb3fa284ae21fccb6ee649ae6b7ef7ab41e3e68;p=soc.git diff --git a/src/soc/fu/shift_rot/rotl.py b/src/soc/fu/shift_rot/rotl.py index d2ebfcf7..8a62460d 100644 --- a/src/soc/fu/shift_rot/rotl.py +++ b/src/soc/fu/shift_rot/rotl.py @@ -1,4 +1,4 @@ -from nmigen import (Elaboratable, Signal, Module) +from nmigen import (Elaboratable, Signal, Module, Cat) import math class ROTL(Elaboratable): @@ -13,12 +13,8 @@ class ROTL(Elaboratable): def elaborate(self, platform): m = Module() comb = m.d.comb - - shl = Signal.like(self.a) - shr = Signal.like(self.a) - - comb += shl.eq(self.a << self.b) - comb += shr.eq(self.a >> (self.width - self.b)) - - comb += self.o.eq(shl | shr) + # trick to do double-concatenation of a then left shift. + # synth tools know to turn this pattern into a barrel-shifter + comb += self.o.eq(Cat(self.a, self.a).bit_select(self.width - self.b, + len(self.a))) return m