From e62ac1d3a1a2855ed241ac9f29d9103afdc0d2a0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 11 Feb 2012 11:52:15 +0100 Subject: [PATCH] corelogic/misc: contiguous split --- migen/corelogic/misc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migen/corelogic/misc.py b/migen/corelogic/misc.py index 3b48bad4..dfe44d4a 100644 --- a/migen/corelogic/misc.py +++ b/migen/corelogic/misc.py @@ -31,3 +31,11 @@ def optree(op, operands, lb=None, ub=None, default=None): return _Operator(op, [optree(op, operands, lb, s, default), optree(op, operands, s, ub, default)]) + +def split(v, *counts): + r = [] + offset = 0 + for n in counts: + r.append(v[offset:offset+n]) + offset += n + return tuple(r) -- 2.30.2