roundrobin: use nmigen zero-width signals

This commit is contained in:
Sebastien Bourdeauducq 2019-04-18 11:58:51 +08:00
parent e14031fba6
commit 2bd819fcbe

View File

@ -9,16 +9,12 @@ class RoundRobin:
def elaborate(self, platform): def elaborate(self, platform):
m = Module() m = Module()
n = self.n with m.Switch(self.grant):
if n > 1: for i in range(self.n):
with m.Switch(self.grant): with m.Case(i):
for i in range(n): with m.If(~self.request[i]):
with m.Case(i): for j in reversed(range(i+1, i+self.n)):
with m.If(~self.request[i]): t = j % self.n
for j in reversed(range(i+1, i+n)): with m.If(self.request[t]):
t = j % n m.d.sync += self.grant.eq(t)
with m.If(self.request[t]):
m.d.sync += self.grant.eq(t)
else:
m.d.comb += self.grant.eq(0)
return m return m