add += operator to fragment
authorNina Engelhardt <nina.engelhardt@omnium-gatherum.de>
Sun, 11 Aug 2013 21:11:30 +0000 (23:11 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 12 Aug 2013 11:15:05 +0000 (13:15 +0200)
migen/fhdl/structure.py

index 2be1a6403c358ceeebe288841cdec5c50750f0d5..9ef2cb324f14f07ffc0717cee1239d89bce1ecea 100644 (file)
@@ -275,3 +275,16 @@ class _Fragment:
                        self.specials | other.specials,
                        self.clock_domains + other.clock_domains,
                        self.sim + other.sim)
+
+       def __iadd__(self, other):
+               newsync = defaultdict(list)
+               for k, v in self.sync.items():
+                       newsync[k] = v[:]
+               for k, v in other.sync.items():
+                       newsync[k].extend(v)
+               self.comb += other.comb
+               self.sync = newsync
+               self.specials |= other.specials
+               self.clock_domains += other.clock_domains
+               self.sim += other.sim
+               return self