bank/description/AutoCSR: add autocsr_exclude
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 8 May 2013 18:58:57 +0000 (20:58 +0200)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Wed, 8 May 2013 18:58:57 +0000 (20:58 +0200)
migen/bank/description.py

index 2369579c53d3de2c025820a2bf0558083ebc2125..92dcdcd26386f253a6e25374bd4a7470c55d45c9 100644 (file)
@@ -96,23 +96,33 @@ def memprefix(prefix, memories):
 
 class AutoCSR:
        def get_memories(self):
+               try:
+                       exclude = self.autocsr_exclude
+               except AttributeError:
+                       exclude = {}
                r = []
                for k, v in self.__dict__.items():
-                       if isinstance(v, Memory):
-                               r.append(v)
-                       elif hasattr(v, "get_memories") and callable(v.get_memories):
-                               memories = v.get_memories()
-                               memprefix(k + "_", memories)
-                               r += memories
+                       if k not in exclude:
+                               if isinstance(v, Memory):
+                                       r.append(v)
+                               elif hasattr(v, "get_memories") and callable(v.get_memories):
+                                       memories = v.get_memories()
+                                       memprefix(k + "_", memories)
+                                       r += memories
                return sorted(r, key=lambda x: x.huid)
 
        def get_csrs(self):
+               try:
+                       exclude = self.autocsr_exclude
+               except AttributeError:
+                       exclude = {}
                r = []
                for k, v in self.__dict__.items():
-                       if isinstance(v, _CSRBase):
-                               r.append(v)
-                       elif hasattr(v, "get_csrs") and callable(v.get_csrs):
-                               csrs = v.get_csrs()
-                               csrprefix(k + "_", csrs)
-                               r += csrs
+                       if k not in exclude:
+                               if isinstance(v, _CSRBase):
+                                       r.append(v)
+                               elif hasattr(v, "get_csrs") and callable(v.get_csrs):
+                                       csrs = v.get_csrs()
+                                       csrprefix(k + "_", csrs)
+                                       r += csrs
                return sorted(r, key=lambda x: x.huid)