Fix AntiStarvation
authorJean THOMAS <git0@pub.jeanthomas.me>
Fri, 24 Jul 2020 12:36:32 +0000 (14:36 +0200)
committerJean THOMAS <git0@pub.jeanthomas.me>
Fri, 24 Jul 2020 12:36:32 +0000 (14:36 +0200)
gram/core/multiplexer.py

index 62bc7b229e606d84b850fe7fe8d984c80ceb1dc4..789a07b9d1413b2ca33ed38a09d86a7ef22d979b 100644 (file)
@@ -220,16 +220,18 @@ class _AntiStarvation(Elaboratable):
         if self._timeout > 0:
             time = Signal(range(self._timeout))
             with m.If(~self.en):
-                m.d.sync += time.eq(self._timeout-1)
+                m.d.sync += [
+                    time.eq(self._timeout-1),
+                    self.max_time.eq(0),
+                ]
+            with m.Elif(time != 0):
+                m.d.sync += [
+                    time.eq(time-1)
+                ]
                 with m.If(time == 1):
                     m.d.sync += self.max_time.eq(1)
                 with m.Else():
                     m.d.sync += self.max_time.eq(0)
-            with m.Elif(time != 0):
-                m.d.sync += [
-                    time.eq(time-1),
-                    self.max_time.eq(0),
-                ]
         else:
             m.d.comb += self.max_time.eq(0)