Skip to content

Commit

Permalink
compat.fhdl.module: CompatModule should be elaboratable.
Browse files Browse the repository at this point in the history
Fixes #83.
  • Loading branch information
whitequark committed Jun 4, 2019
1 parent 4310254 commit 39ca0e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nmigen/compat/fhdl/module.py
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -94,14 +94,17 @@ def __iadd__(self, other):
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
self.get_fragment_called = True
self.finalize()
return self._module

def elaborate(self, platform):
return self.get_fragment()

def __getattr__(self, name):
if name == "comb":
return _CompatModuleComb(self)
Expand Down
9 changes: 9 additions & 0 deletions nmigen/test/test_compat.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 39ca0e6

Please sign in to comment.