From 37930d70acd64d2a646cc5fc84c716fdec213416 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 20 Aug 2013 16:52:48 +0200 Subject: [PATCH] genlib/misc: improve genericity of split/displacer/chooser --- migen/genlib/misc.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- 2.30.2