From c2da46e377fbf04488622dbf33aa240988b1dd9e Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Mon, 4 May 2020 13:07:07 -0400 Subject: [PATCH] Flatten the output of RecordObject.ports() If a record contains records, calling ports on it will give a result that cannot be passed to the nmigen simulation backend. This flattens it, so that ports() will just return signals --- src/nmutil/iocontrol.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nmutil/iocontrol.py b/src/nmutil/iocontrol.py index 853a1d0..e403da7 100644 --- a/src/nmutil/iocontrol.py +++ b/src/nmutil/iocontrol.py @@ -103,7 +103,15 @@ class RecordObject(Record): yield x def ports(self): # would be better being called "keys" - return list(self) + results = [] + # If the record itself contains records, flatten them + for item in list(self): + ports_fun = getattr(item, "ports", None) + if callable(ports_fun): + results.extend(ports_fun()) + else: + results.append(item) + return results class PrevControl(Elaboratable): -- 2.30.2