Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rotator(Elaboratable):
- def __init__(self, datain, dataout, rotation=0, comb=True):
- assert len(datain) == len(dataout)
- self.datain = datain
- self.dataout = dataout
- self.rotation = rotation
- self.comb = comb
- self.ports = [
- self.datain,
- self.dataout,
- self.rotation,
- ]
- def elaborate(self, platform):
- m = Module()
- length = len(self.datain)
- with m.Switch(self.rotation):
- for i in range(length):
- with m.Case(i):
- if self.comb:
- m.d.comb += self.dataout.eq(Cat(self.datain[i:length], self.datain[0:i]))
- else:
- m.d.sync += self.dataout.eq(Cat(self.datain[i:length], self.datain[0:i]))
- return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement