From 2bd819fcbe633ac341ba4dc3ff2996cbdf939d01 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 18 Apr 2019 11:58:51 +0800 Subject: [PATCH] roundrobin: use nmigen zero-width signals --- heavycomps/heavycomps/roundrobin.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/heavycomps/heavycomps/roundrobin.py b/heavycomps/heavycomps/roundrobin.py index f0e6e71..5747884 100644 --- a/heavycomps/heavycomps/roundrobin.py +++ b/heavycomps/heavycomps/roundrobin.py @@ -9,16 +9,12 @@ class RoundRobin: def elaborate(self, platform): m = Module() - n = self.n - if n > 1: - with m.Switch(self.grant): - for i in range(n): - with m.Case(i): - with m.If(~self.request[i]): - for j in reversed(range(i+1, i+n)): - t = j % n - with m.If(self.request[t]): - m.d.sync += self.grant.eq(t) - else: - m.d.comb += self.grant.eq(0) + with m.Switch(self.grant): + for i in range(self.n): + with m.Case(i): + with m.If(~self.request[i]): + for j in reversed(range(i+1, i+self.n)): + t = j % self.n + with m.If(self.request[t]): + m.d.sync += self.grant.eq(t) return m