From: Luke Kenneth Casson Leighton Date: Tue, 20 Jul 2021 20:58:35 +0000 (+0100) Subject: cleanup X-Git-Tag: xlen-bcd~241 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44f880c34f7ec774a84ad4160a092001074b8ec1;p=openpower-isa.git cleanup --- diff --git a/src/openpower/decoder/isa/fastdctlee.py b/src/openpower/decoder/isa/fastdctlee.py index 898cee43..abfd8d9b 100644 --- a/src/openpower/decoder/isa/fastdctlee.py +++ b/src/openpower/decoder/isa/fastdctlee.py @@ -69,6 +69,45 @@ def reverse_bits(val, width): return result +# reverse top half of a list, recursively. the recursion can be +# applied *after* or *before* the reversal of the top half. these +# are inverses of each other. +# this function is unused except to test the iterative version (halfrev2) +def halfrev(l, pre_rev=True): + n = len(l) + if n == 1: + return l + ll, lh = l[:n//2], l[n//2:] + if pre_rev: + ll, lh = halfrev(ll, pre_rev), halfrev(lh, pre_rev) + lh.reverse() + if not pre_rev: + ll, lh = halfrev(ll, pre_rev), halfrev(lh, pre_rev) + return ll + lh + + +# iterative version of [recursively-applied] half-rev. +# relies on the list lengths being power-of-two and the fact +# that bit-inversion of a list of binary numbers is the same +# as reversing the order of the list +# this version is dead easy to implement in hardware. +# a big surprise is that the half-reversal can be done with +# such a simple XOR. the inverse operation is slightly trickier +def halfrev2(vec, pre_rev=True): + res = [] + for i in range(len(vec)): + if pre_rev: + res.append(i ^ (i>>1)) + else: + ri = i + bl = i.bit_length() + for ji in range(1, bl): + if (1<>1)) - else: - ri = i - bl = i.bit_length() - for ji in range(1, bl): - if (1<