From fea65a4a164e96ed7454627e3aa6fdae4d6c750f Mon Sep 17 00:00:00 2001 From: Jean THOMAS Date: Wed, 24 Jun 2020 10:56:21 +0200 Subject: [PATCH] Simply arbiter when there is only 1 request to arbitrate --- gram/compat.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/gram/compat.py b/gram/compat.py index e049dcd..49ae710 100644 --- a/gram/compat.py +++ b/gram/compat.py @@ -52,16 +52,19 @@ class RoundRobin(Elaboratable): def elaborate(self, platform): m = Module() - with m.If(self.stb): - with m.Switch(self.grant): - for i in range(self.n): - with m.Case(i): - for j in reversed(range(i+1, i+self.n)): - # If i+1 <= j < n, then t == j; (after i) - # If n <= j < i+n, then t == j - n (before i) - t = j % self.n - with m.If(self.request[t]): - m.d.sync += self.grant.eq(t) + if self.n == 1: + m.d.comb += self.grant.eq(0) + else: + with m.If(self.stb): + with m.Switch(self.grant): + for i in range(self.n): + with m.Case(i): + for j in reversed(range(i+1, i+self.n)): + # If i+1 <= j < n, then t == j; (after i) + # If n <= j < i+n, then t == j - n (before i) + t = j % self.n + with m.If(self.request[t]): + m.d.sync += self.grant.eq(t) return m -- 2.30.2