fhdl/tools: bitreverse

This commit is contained in:
Sebastien Bourdeauducq 2012-12-14 23:56:16 +01:00
parent 1f350adf14
commit b06fbdedd6
1 changed files with 5 additions and 0 deletions

View File

@ -205,3 +205,8 @@ def lower_arrays(f):
f2 = al.visit(f) f2 = al.visit(f)
f2.comb += al.comb f2.comb += al.comb
return f2 return f2
def bitreverse(s):
length, signed = value_bits_sign(s)
l = [s[i] for i in reversed(range(length))]
return Cat(*l)