Skip to content

Commit

Permalink
lasmibus: fix master locking
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Jul 15, 2013
1 parent 7083764 commit b016a60
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions migen/bus/lasmibus.py
Expand Up @@ -66,13 +66,23 @@ def __init__(self, controllers, nmasters, cba_shift):
controller_selected = [1]*nmasters
master_req_acks = [0]*nmasters
master_dat_acks = [0]*nmasters
for nb in range(nbanks):
rrs = [roundrobin.RoundRobin(nmasters, roundrobin.SP_CE) for n in range(nbanks)]
self.submodules += rrs
for nb, rr in enumerate(rrs):
bank = getattr(controller, "bank"+str(nb))

# for each master, determine if another bank locks it
master_locked = []
for nm, master in enumerate(self.masters):
locked = 0
for other_nb, other_rr in enumerate(rrs):
if other_nb != nb:
other_bank = getattr(controller, "bank"+str(other_nb))
locked = locked | (other_bank.lock & (other_rr.grant == nm))
master_locked.append(locked)

# arbitrate
rr = roundrobin.RoundRobin(nmasters, roundrobin.SP_CE)
self.submodules += rr
bank_selected = [cs & (ba == nb) for cs, ba in zip(controller_selected, m_ba)]
bank_selected = [cs & (ba == nb) & ~locked for cs, ba, locked in zip(controller_selected, m_ba, master_locked)]
bank_requested = [bs & master.stb for bs, master in zip(bank_selected, self.masters)]
self.comb += [
rr.request.eq(Cat(*bank_requested)),
Expand Down

0 comments on commit b016a60

Please sign in to comment.