sim/generic/multiread: do not return spurious items
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 23 Nov 2012 22:07:25 +0000 (23:07 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 23 Nov 2012 22:07:25 +0000 (23:07 +0100)
migen/sim/generic.py

index b4bd0ab0ddd535425f3769e28a6eab3b54b593a2..373740eeea86a69da600db1b25438e6d970e0869 100644 (file)
@@ -146,9 +146,19 @@ class Simulator:
                if isinstance(obj, Signal):
                        return self.rd(obj)
                elif isinstance(obj, list):
-                       return [self.multiread(item) for item in obj]
+                       r = []
+                       for item in obj:
+                               rd = self.multiread(item)
+                               if isinstance(item, Signal) or rd:
+                                       r.append(rd)
+                       return r
                elif hasattr(obj, "__dict__"):
-                       return dict([(k, self.multiread(v)) for k, v in obj.__dict__.items()])
+                       r = {}
+                       for k, v in obj.__dict__.items():
+                               rd = self.multiread(v)
+                               if isinstance(v, Signal) or rd:
+                                       r[k] = rd
+                       return r
        
        def multiwrite(self, obj, value):
                if isinstance(obj, Signal):