fhdl/autofragment: from_attributes
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 11 Feb 2013 17:34:01 +0000 (18:34 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 11 Feb 2013 17:34:01 +0000 (18:34 +0100)
migen/fhdl/autofragment.py

index 554db1a8d85c095e3fa92f59a02091a3c962c10d..50e7bc379202edaa68dd09bbc13f34c39d4d0c6f 100644 (file)
@@ -11,3 +11,10 @@ def from_local():
                if hasattr(obj, "get_fragment"):
                        f += obj.get_fragment()
        return f
+
+def from_attributes(obj):
+       f = Fragment()
+       for x in obj.__dict__.values():
+               if hasattr(x, "get_fragment"):
+                       f += x.get_fragment()
+       return f