litepcie/frontend/dma: add loop counter (useful to detect missed interrupts)
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 22 Jul 2015 20:55:11 +0000 (22:55 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 22 Jul 2015 20:55:11 +0000 (22:55 +0200)
misoclib/com/litepcie/frontend/dma/common.py

index 8db28463a657ae980049b2d4e60162f737f3f62d..e54846cd5bf49c50b0b8cb011f7b29d6e157f2fb 100644 (file)
@@ -30,6 +30,7 @@ class DMARequestTable(Module, AutoCSR):
         self._loop_prog_n = CSRStorage()
         self._index = CSRStatus(log2_int(depth))
         self._level = CSRStatus(log2_int(depth))
+        self._loop = CSRStatus(16)
         self._flush = CSR()
 
         self.irq = Signal()
@@ -41,6 +42,7 @@ class DMARequestTable(Module, AutoCSR):
         we = self._we.r & self._we.re
         loop_prog_n = self._loop_prog_n.storage
         index = self._index.status
+        loop = self._loop.status
         level = self._level.status
         flush = self._flush.r & self._flush.re
 
@@ -86,10 +88,12 @@ class DMARequestTable(Module, AutoCSR):
         # "loop" mode
         self.sync += \
             If(flush,
-                index.eq(0)
+                index.eq(0),
+                loop.eq(0),
             ).Elif(source.stb & source.ack,
                 If(fifo.dout.start,
-                    index.eq(0)
+                    index.eq(0),
+                    loop.eq(loop+1)
                 ).Else(
                     index.eq(index+1)
                 )