decorators: fix class/instance logic
authorRobert Jordens <jordens@gmail.com>
Fri, 3 Apr 2015 20:55:20 +0000 (14:55 -0600)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Sat, 4 Apr 2015 11:16:58 +0000 (19:16 +0800)
migen/fhdl/decorators.py

index 815d7fcd1c05be855da659173e35c24de03cdd6b..b6e906cd0e665098bb02b25a6a2b58fd2e08f32b 100644 (file)
@@ -1,6 +1,7 @@
 import warnings
 
 from migen.fhdl.structure import *
+from migen.fhdl.module import Module
 from migen.fhdl.tools import insert_reset, rename_clock_domain
 
 class ModuleTransformer:
@@ -40,10 +41,10 @@ class ModuleTransformer:
                return victim
 
        def __call__(self, victim):
-               try:
-                       return self.wrap_class(victim)
-               except TypeError:
+               if isinstance(victim, Module):
                        return self.wrap_instance(victim)
+               else:
+                       return self.wrap_class(victim)
 
        @classmethod
        def adhoc(cls, i, *args, **kwargs):