Use constants for CSR addresses
authorJean THOMAS <git0@pub.jeanthomas.me>
Thu, 25 Jun 2020 10:32:36 +0000 (12:32 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Thu, 25 Jun 2020 10:32:36 +0000 (12:32 +0200)
gram/test/test_dfii.py

index f143867524f618a3eb80c0ae52a1de778ef2a3d4..339ad7c5144c914b1a4d1158e9f5099edb6cce96 100644 (file)
@@ -7,6 +7,14 @@ from gram.dfii import *
 from gram.phy.dfi import Interface
 from utils import *
 
+# Phase injector CSR addresses
+PI_COMMAND_ADDR = 0x00
+PI_COMMAND_ISSUE_ADDR = 0x04
+PI_ADDRESS_ADDR = 0x08
+PI_BADDRESS_ADDR = 0x0C
+PI_WRDATA_ADDR = 0x10
+PI_RDDATA_ADDR = 0x14
+
 class CSRHost(Peripheral, Elaboratable):
     def __init__(self, name="csrhost"):
         super().__init__(name=name)
@@ -48,7 +56,7 @@ class PhaseInjectorTestCase(FHDLTestCase):
         m, dfi, csrhost = self.generate_phaseinjector()
 
         def process():
-            yield from wb_write(csrhost.bus, 0x8 >> 2, 0xCDC, sel=0xF)
+            yield from wb_write(csrhost.bus, PI_ADDRESS_ADDR >> 2, 0xCDC, sel=0xF)
             self.assertEqual((yield dfi.phases[0].address), 0xCDC)
 
         runSimulation(m, process, "test_phaseinjector.vcd")
@@ -57,7 +65,7 @@ class PhaseInjectorTestCase(FHDLTestCase):
         m, dfi, csrhost = self.generate_phaseinjector()
 
         def process():
-            yield from wb_write(csrhost.bus, 0xC >> 2, 0xA8, sel=0xF)
+            yield from wb_write(csrhost.bus, PI_BADDRESS_ADDR >> 2, 0xA8, sel=0xF)
             self.assertEqual((yield dfi.phases[0].bank), 0xA8)
 
         runSimulation(m, process, "test_phaseinjector.vcd")