4 __all__
= ["RoundRobin"]
7 class RoundRobin(Elaboratable
):
8 """A round-robin scheduler.
13 Maximum number of requests to handle.
18 Signal where a '1' on the i-th bit represents an incoming request from the i-th device.
19 grant : Signal(range(n))
20 Signal that equals to the index of the device which is currently granted access.
22 def __init__(self
, n
):
24 self
.request
= Signal(n
)
25 self
.grant
= Signal(range(n
))
27 def elaborate(self
, platform
):
30 with m
.Switch(self
.grant
):
31 for i
in range(self
.n
):
33 with m
.If(~self
.request
[i
]):
34 for j
in reversed(range(i
+1, i
+self
.n
)):
36 with m
.If(self
.request
[t
]):
37 m
.d
.sync
+= self
.grant
.eq(t
)