File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 3
3
from amaranth import *
4
4
5
5
from . import stream
6
+ from ..cores .time .timer import *
6
7
7
8
8
9
__all__ = [
@@ -288,9 +289,10 @@ class Arbiter(Elaboratable):
288
289
289
290
sinks: a list of streams to arbiter.
290
291
"""
291
- def __init__ (self , sinks , source ):
292
+ def __init__ (self , sinks , source , timeout = 2 ** 16 ):
292
293
self .sinks = sinks
293
294
self .source = source
295
+ self .timeout = timeout
294
296
295
297
def elaborate (self , platform ):
296
298
source = self .source
@@ -311,10 +313,15 @@ def elaborate(self, platform):
311
313
with m .If (source .valid & source .ready ):
312
314
m .d .sync += ongoing .eq (~ source .last )
313
315
316
+ # Prevent a stall if the selected sink stream is no longer valid
317
+ # for some time but did not give a `last` signal.
318
+ m .submodules .stall = stall = WaitTimer (self .timeout )
319
+ m .d .comb += stall .wait .eq (ongoing & ~ source .valid & ~ run )
320
+
314
321
# Run the round robin when:
315
322
# the current transaction has completed,
316
323
# or nothing is currently ongoing or pending.
317
- m .d .comb += run .eq (~ (ongoing | pending ) | complete )
324
+ m .d .comb += run .eq (~ (ongoing | pending ) | complete | stall . done )
318
325
319
326
with m .Switch (rr .grant ):
320
327
for i , sink in enumerate (self .sinks ):
You can’t perform that action at this time.
0 commit comments