From a4294762d0d81757a2d57ad80636e66feb4e151c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 16 Mar 2012 16:54:47 +0100 Subject: [PATCH] corelogic/roundrobin: CE switching --- migen/corelogic/roundrobin.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/migen/corelogic/roundrobin.py b/migen/corelogic/roundrobin.py index 1f0e5527..6b0ca531 100644 --- a/migen/corelogic/roundrobin.py +++ b/migen/corelogic/roundrobin.py @@ -1,11 +1,16 @@ from migen.fhdl.structure import * +(SP_WITHDRAW, SP_CE) = range(2) + class RoundRobin: - def __init__(self, n): + def __init__(self, n, switch_policy=SP_WITHDRAW): self.n = n self.bn = bits_for(self.n-1) self.request = Signal(BV(self.n)) self.grant = Signal(BV(self.bn)) + self.switch_policy = switch_policy + if self.switch_policy == SP_CE: + self.ce = Signal() def get_fragment(self): cases = [] @@ -20,7 +25,12 @@ class RoundRobin: *switch ) ] - case = If(~self.request[i], *switch) - cases.append([Constant(i, BV(self.bn)), case]) + if self.switch_policy == SP_WITHDRAW: + case = [If(~self.request[i], *switch)] + else: + case = switch + cases.append([Constant(i, BV(self.bn))] + case) statement = Case(self.grant, *cases) + if self.switch_policy == SP_CE: + statement = If(self.ce, statement) return Fragment(sync=[statement]) -- 2.30.2