Add tests in DFI Injector for odt and reset signals
authorJean THOMAS <git0@pub.jeanthomas.me>
Fri, 3 Jul 2020 12:55:20 +0000 (14:55 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Fri, 3 Jul 2020 12:55:20 +0000 (14:55 +0200)
gram/test/test_dfii.py

index 27543f7308bf0f945950cfdac88922fd70a58fa0..475e980f4057fc16d51b473f75a86f0a8902a959 100644 (file)
@@ -120,7 +120,7 @@ class PhaseInjectorTestCase(FHDLTestCase):
 class DFIInjectorTestCase(FHDLTestCase):
     def generate_dfiinjector(self):
         csrhost = CSRHost()
-        dut = DFIInjector(csrhost.bank, 14, 3, 1, 16, nphases=1)
+        dut = DFIInjector(csrhost.bank, addressbits=14, bankbits=3, nranks=1, databits=16, nphases=1)
         csrhost.init_bridge()
         m = Module()
         m.submodules += csrhost
@@ -141,3 +141,31 @@ class DFIInjectorTestCase(FHDLTestCase):
             self.assertFalse((yield dut.master.phases[0].cke[0]))
 
         runSimulation(m, process, "test_dfiinjector.vcd")
+
+    def test_odt(self):
+        m, dut, csrhost = self.generate_dfiinjector()
+
+        def process():
+            yield from wb_write(csrhost.bus, DFII_CONTROL_ADDR >> 2, (1 << 2), sel=0xF)
+            yield
+            self.assertTrue((yield dut.master.phases[0].odt[0]))
+
+            yield from wb_write(csrhost.bus, DFII_CONTROL_ADDR >> 2, 0, sel=0xF)
+            yield
+            self.assertFalse((yield dut.master.phases[0].odt[0]))
+
+        runSimulation(m, process, "test_dfiinjector.vcd")
+
+    def test_reset(self):
+        m, dut, csrhost = self.generate_dfiinjector()
+
+        def process():
+            yield from wb_write(csrhost.bus, DFII_CONTROL_ADDR >> 2, (1 << 3), sel=0xF)
+            yield
+            self.assertTrue((yield dut.master.phases[0].reset_n))
+
+            yield from wb_write(csrhost.bus, DFII_CONTROL_ADDR >> 2, 0, sel=0xF)
+            yield
+            self.assertFalse((yield dut.master.phases[0].reset_n))
+
+        runSimulation(m, process, "test_dfiinjector.vcd")