mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
corelogic/roundrobin: handle correctly special case with 1 request source
This commit is contained in:
parent
94b02aa8ed
commit
0dfc215fe8
1 changed files with 24 additions and 21 deletions
|
@ -13,24 +13,27 @@ class RoundRobin:
|
||||||
self.ce = Signal()
|
self.ce = Signal()
|
||||||
|
|
||||||
def get_fragment(self):
|
def get_fragment(self):
|
||||||
cases = []
|
if self.n > 1:
|
||||||
for i in range(self.n):
|
cases = []
|
||||||
switch = []
|
for i in range(self.n):
|
||||||
for j in reversed(range(i+1,i+self.n)):
|
switch = []
|
||||||
t = j % self.n
|
for j in reversed(range(i+1,i+self.n)):
|
||||||
switch = [
|
t = j % self.n
|
||||||
If(self.request[t],
|
switch = [
|
||||||
self.grant.eq(Constant(t, BV(self.bn)))
|
If(self.request[t],
|
||||||
).Else(
|
self.grant.eq(Constant(t, BV(self.bn)))
|
||||||
*switch
|
).Else(
|
||||||
)
|
*switch
|
||||||
]
|
)
|
||||||
if self.switch_policy == SP_WITHDRAW:
|
]
|
||||||
case = [If(~self.request[i], *switch)]
|
if self.switch_policy == SP_WITHDRAW:
|
||||||
else:
|
case = [If(~self.request[i], *switch)]
|
||||||
case = switch
|
else:
|
||||||
cases.append([Constant(i, BV(self.bn))] + case)
|
case = switch
|
||||||
statement = Case(self.grant, *cases)
|
cases.append([Constant(i, BV(self.bn))] + case)
|
||||||
if self.switch_policy == SP_CE:
|
statement = Case(self.grant, *cases)
|
||||||
statement = If(self.ce, statement)
|
if self.switch_policy == SP_CE:
|
||||||
return Fragment(sync=[statement])
|
statement = If(self.ce, statement)
|
||||||
|
return Fragment(sync=[statement])
|
||||||
|
else:
|
||||||
|
return Fragment([self.grant.eq(0)])
|
||||||
|
|
Loading…
Reference in a new issue