From: Florent Kermarrec Date: Tue, 20 Aug 2013 14:52:48 +0000 (+0200) Subject: genlib/misc: improve genericity of split/displacer/chooser X-Git-Tag: 24jan2021_ls180~2099^2~473 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=37930d70acd64d2a646cc5fc84c716fdec213416;p=litex.git genlib/misc: improve genericity of split/displacer/chooser --- diff --git a/migen/genlib/misc.py b/migen/genlib/misc.py index 97d0be0e..38d24d19 100644 --- a/migen/genlib/misc.py +++ b/migen/genlib/misc.py @@ -24,11 +24,16 @@ def split(v, *counts): r = [] offset = 0 for n in counts: - r.append(v[offset:offset+n]) + if n != 0: + r.append(v[offset:offset+n]) + else: + r.append(None) offset += n return tuple(r) def displacer(signal, shift, output, n=None, reverse=False): + if shift is None: + return output.eq(signal) if n is None: n = 2**flen(shift) w = flen(signal) @@ -40,6 +45,8 @@ def displacer(signal, shift, output, n=None, reverse=False): return output.eq(Cat(*l)) def chooser(signal, shift, output, n=None, reverse=False): + if shift is None: + return output.eq(signal) if n is None: n = 2**flen(shift) w = flen(output)