From: Luke Kenneth Casson Leighton Date: Mon, 13 Jul 2020 14:13:21 +0000 (+0100) Subject: reduce rotl module to one line (use bit_select) X-Git-Tag: div_pipeline~59 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8a45a6610a8c4c457b1658db2e49607b284fe391;p=soc.git reduce rotl module to one line (use bit_select) --- 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