From: Michael Nolan Date: Mon, 4 May 2020 17:07:07 +0000 (-0400) Subject: Flatten the output of RecordObject.ports() X-Git-Tag: 24jan2021_ls180~63 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c2da46e377fbf04488622dbf33aa240988b1dd9e;p=nmutil.git 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 --- 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):