fhdl/tools: bitreverse
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 14 Dec 2012 22:56:16 +0000 (23:56 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 14 Dec 2012 22:56:16 +0000 (23:56 +0100)
migen/fhdl/tools.py

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