Add test for _AntiStarvation timer duration
[gram.git] / gram / test / test_core_multiplexer.py
1 from nmigen import *
2
3 from gram.core.multiplexer import _AntiStarvation
4 from utils import *
5
6 class AntiStarvationTestCase(FHDLTestCase):
7 def test_duration(self):
8 def generic_test(timeout):
9 m = Module()
10 m.submodules = dut = _AntiStarvation(timeout)
11
12 def process():
13 yield dut.en.eq(1)
14 yield
15 yield dut.en.eq(0)
16 yield
17
18 for i in range(timeout):
19 self.assertFalse((yield dut.max_time))
20 yield
21
22 self.assertTrue((yield dut.max_time))
23
24 runSimulation(m, process, "test_core_multiplexer_antistarvation.vcd")
25
26 def test_formal(self):
27 def generic_test(timeout):
28 dut = _AntiStarvation(timeout)
29 self.assertFormal(dut, mode="bmc", depth=4)
30
31 generic_test(0)
32 #generic_test(1)
33 generic_test(5)
34 generic_test(10)
35 generic_test(0x20)