From 68a1419a80e68d70531be6db1b9e0c2eed8266bd Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 13 Apr 2020 18:21:01 +0100 Subject: [PATCH] detect if data_o or data_i is iterable in NextControl and PrevControl --- src/nmutil/iocontrol.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nmutil/iocontrol.py b/src/nmutil/iocontrol.py index efe0c38..853a1d0 100644 --- a/src/nmutil/iocontrol.py +++ b/src/nmutil/iocontrol.py @@ -94,7 +94,10 @@ class RecordObject(Record): def __iter__(self): for x in self.fields.values(): # remember: fields is an OrderedDict - if isinstance(x, Iterable): + if isinstance(x, Record): + for f in x.fields.values(): + yield f + elif isinstance(x, Iterable): yield from x # a bit like flatten (nmigen.tools) else: yield x @@ -189,7 +192,8 @@ class PrevControl(Elaboratable): yield self.stop_i if hasattr(self.data_i, "ports"): yield from self.data_i.ports() - elif isinstance(self.data_i, Sequence): + elif (isinstance(self.data_i, Sequence) or + isinstance(self.data_i, Iterable)): yield from self.data_i else: yield self.data_i @@ -272,7 +276,8 @@ class NextControl(Elaboratable): yield self.stop_o if hasattr(self.data_o, "ports"): yield from self.data_o.ports() - elif isinstance(self.data_o, Sequence): + elif (isinstance(self.data_o, Sequence) or + isinstance(self.data_o, Iterable)): yield from self.data_o else: yield self.data_o -- 2.30.2