From: Robert Jordens Date: Tue, 3 Dec 2013 00:23:56 +0000 (-0700) Subject: migen.fhdl.structure: have Cat() flat_iteration-ize its arguments X-Git-Tag: 24jan2021_ls180~2099^2~404 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c71eb5778f9d7ad8e782a68389b87349e35fb7df;p=litex.git migen.fhdl.structure: have Cat() flat_iteration-ize its arguments --- diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index a94c198b..aba747b3 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -4,6 +4,7 @@ import builtins from collections import defaultdict from migen.fhdl import tracer +from migen.util.misc import flat_iteration class HUID: __next_uid = 0 @@ -87,7 +88,7 @@ class Value(HUID): elif isinstance(key, slice): start, stop, step = key.indices(flen(self)) if step != 1: - return Cat(*(self[i] for i in range(start, stop, step))) + return Cat(self[i] for i in range(start, stop, step)) return _Slice(self, start, stop) else: raise KeyError @@ -155,11 +156,11 @@ class Cat(Value): meeting these properties. The bit length of the return value is the sum of the bit lengths of the arguments:: - flen(Cat(*args)) == sum(flen(arg) for arg in args) + flen(Cat(args)) == sum(flen(arg) for arg in args) Parameters ---------- - *args : Value, inout + *args : Values or iterables of Values, inout `Value` s to be concatenated. Returns @@ -169,7 +170,7 @@ class Cat(Value): """ def __init__(self, *args): Value.__init__(self) - self.l = args + self.l = list(flat_iteration(args)) class Replicate(Value): """Replicate a value