Skip to content

Commit

Permalink
test_lib_cdc: test platform dependency injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Wren6991 committed Mar 4, 2019
1 parent 8b9f855 commit 26442d3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nmigen/test/test_lib_cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def test_paramcheck(self):
m = MultiReg(i, o, n=1)
m = MultiReg(i, o, reset=-1)

def test_platform(self):
platform = lambda: None
platform.get_multi_reg = lambda m: "foobar{}".format(len(m._regs))
i = Signal()
o = Signal()
m = MultiReg(i, o, n=5)
self.assertEqual(m.elaborate(platform), "foobar5")

def test_basic(self):
i = Signal()
o = Signal()
Expand Down Expand Up @@ -67,6 +75,13 @@ def test_paramcheck(self):
r = ResetSynchronizer(arst, n="a")
r = ResetSynchronizer(arst)

def test_platform(self):
platform = lambda: None
platform.get_reset_sync = lambda m: "foobar{}".format(len(m._regs))
arst = Signal()
rs = ResetSynchronizer(arst, n=6)
self.assertEqual(rs.elaborate(platform), "foobar6")

def test_basic(self):
arst = Signal()
m = Module()
Expand Down

0 comments on commit 26442d3

Please sign in to comment.