Add test for _AntiStarvation timer duration
authorJean THOMAS <git0@pub.jeanthomas.me>
Fri, 17 Jul 2020 15:22:27 +0000 (17:22 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Fri, 17 Jul 2020 15:22:27 +0000 (17:22 +0200)
gram/test/test_core_multiplexer.py

index 1076bb91fcfb0566e80e9a705ce05337c8ef32a0..4cbfe50d3403990a960e1670b45293db5e21097a 100644 (file)
@@ -4,6 +4,25 @@ from gram.core.multiplexer import _AntiStarvation
 from utils import *
 
 class AntiStarvationTestCase(FHDLTestCase):
+    def test_duration(self):
+        def generic_test(timeout):
+            m = Module()
+            m.submodules = dut = _AntiStarvation(timeout)
+
+            def process():
+                yield dut.en.eq(1)
+                yield
+                yield dut.en.eq(0)
+                yield
+
+                for i in range(timeout):
+                    self.assertFalse((yield dut.max_time))
+                    yield
+
+                self.assertTrue((yield dut.max_time))
+
+            runSimulation(m, process, "test_core_multiplexer_antistarvation.vcd")
+
     def test_formal(self):
         def generic_test(timeout):
             dut = _AntiStarvation(timeout)
@@ -13,3 +32,4 @@ class AntiStarvationTestCase(FHDLTestCase):
         #generic_test(1)
         generic_test(5)
         generic_test(10)
+        generic_test(0x20)