compat.fhdl.module: CompatModule should be elaboratable.
authorwhitequark <cz@m-labs.hk>
Tue, 4 Jun 2019 11:10:46 +0000 (11:10 +0000)
committerwhitequark <cz@m-labs.hk>
Tue, 4 Jun 2019 11:11:31 +0000 (11:11 +0000)
Fixes #83.

nmigen/compat/fhdl/module.py
nmigen/test/test_compat.py [new file with mode: 0644]

index e81f2b6b8ae034d0e2585c812b4af1ba138e7d7e..26feb16debf33031f67796a832da27365161be7f 100644 (file)
@@ -1,7 +1,7 @@
 from collections.abc import Iterable
 
 from ...tools import flatten, deprecated
-from ...hdl import dsl
+from ...hdl import dsl, ir
 
 
 __all__ = ["Module", "FinalizeError"]
@@ -94,7 +94,7 @@ class _CompatModuleClockDomains(_CompatModuleProxy):
         return self
 
 
-class CompatModule:
+class CompatModule(ir.Elaboratable):
     # Actually returns nmigen.fhdl.Module, not a Fragment.
     def get_fragment(self):
         assert not self.get_fragment_called
@@ -102,6 +102,9 @@ class CompatModule:
         self.finalize()
         return self._module
 
+    def elaborate(self, platform):
+        return self.get_fragment()
+
     def __getattr__(self, name):
         if name == "comb":
             return _CompatModuleComb(self)
diff --git a/nmigen/test/test_compat.py b/nmigen/test/test_compat.py
new file mode 100644 (file)
index 0000000..d42812c
--- /dev/null
@@ -0,0 +1,9 @@
+from ..hdl.ir import Fragment
+from ..compat import *
+from .tools import *
+
+
+class CompatTestCase(FHDLTestCase):
+    def test_fragment_get(self):
+        m = Module()
+        f = Fragment.get(m, platform=None)