From b06fbdedd6bbc3e2fe7db86964bc84a6f10aa811 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 14 Dec 2012 23:56:16 +0100 Subject: [PATCH] fhdl/tools: bitreverse --- migen/fhdl/tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/migen/fhdl/tools.py b/migen/fhdl/tools.py index 186dd8e4a..c4af475a5 100644 --- a/migen/fhdl/tools.py +++ b/migen/fhdl/tools.py @@ -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)