interconnect:axi/axi_lite/interconnect: Cosmetic cleanups.

This commit is contained in:
Florent Kermarrec 2022-06-20 19:07:27 +02:00
parent bb1702e6d5
commit 573479b395
1 changed files with 28 additions and 17 deletions

View File

@ -568,7 +568,7 @@ class AXILiteTimeout(Module):
) )
]) ])
# AXI-Lite Interconnect ---------------------------------------------------------------------------- # AXI-Lite Interconnect Components -----------------------------------------------------------------
class _AXILiteRequestCounter(Module): class _AXILiteRequestCounter(Module):
def __init__(self, request, response, max_requests=256): def __init__(self, request, response, max_requests=256):
@ -594,10 +594,6 @@ class _AXILiteRequestCounter(Module):
), ),
] ]
class AXILiteInterconnectPointToPoint(Module):
def __init__(self, master, slave):
self.comb += master.connect(slave)
class AXILiteArbiter(Module): class AXILiteArbiter(Module):
"""AXI Lite arbiter """AXI Lite arbiter
@ -633,9 +629,13 @@ class AXILiteArbiter(Module):
# Allow to change rr.grant only after all requests from a master have been responded to. # Allow to change rr.grant only after all requests from a master have been responded to.
self.submodules.wr_lock = wr_lock = _AXILiteRequestCounter( self.submodules.wr_lock = wr_lock = _AXILiteRequestCounter(
request=target.aw.valid & target.aw.ready, response=target.b.valid & target.b.ready) request = target.aw.valid & target.aw.ready,
response = target.b.valid & target.b.ready
)
self.submodules.rd_lock = rd_lock = _AXILiteRequestCounter( self.submodules.rd_lock = rd_lock = _AXILiteRequestCounter(
request=target.ar.valid & target.ar.ready, response=target.r.valid & target.r.ready) request = target.ar.valid & target.ar.ready,
response = target.r.valid & target.r.ready
)
# Switch to next request only if there are no responses pending. # Switch to next request only if there are no responses pending.
self.comb += [ self.comb += [
@ -681,11 +681,13 @@ class AXILiteDecoder(Module):
# TODO: we could reuse arbiter counters # TODO: we could reuse arbiter counters
locks = { locks = {
"write": _AXILiteRequestCounter( "write": _AXILiteRequestCounter(
request=master.aw.valid & master.aw.ready, request = master.aw.valid & master.aw.ready,
response=master.b.valid & master.b.ready), response = master.b.valid & master.b.ready,
),
"read": _AXILiteRequestCounter( "read": _AXILiteRequestCounter(
request=master.ar.valid & master.ar.ready, request = master.ar.valid & master.ar.ready,
response=master.r.valid & master.r.ready), response = master.r.valid & master.r.ready
),
} }
self.submodules += locks.values() self.submodules += locks.values()
@ -701,16 +703,18 @@ class AXILiteDecoder(Module):
slave_sel_dec["read"][i].eq(decoder(master.ar.addr[addr_shift:])), slave_sel_dec["read"][i].eq(decoder(master.ar.addr[addr_shift:])),
] ]
# Dhange the current selection only when we've got all responses. # Change the current selection only when we've got all responses.
for channel in locks.keys(): for channel in locks.keys():
self.sync += If(locks[channel].ready, slave_sel_reg[channel].eq(slave_sel_dec[channel])) self.sync += If(locks[channel].ready, slave_sel_reg[channel].eq(slave_sel_dec[channel]))
# We have to cut the delaying select. # We have to cut the delaying select.
for ch, final in slave_sel.items(): for ch, final in slave_sel.items():
self.comb += If(locks[ch].ready, self.comb += [
final.eq(slave_sel_dec[ch]) If(locks[ch].ready,
).Else( final.eq(slave_sel_dec[ch])
final.eq(slave_sel_reg[ch]) ).Else(
) final.eq(slave_sel_reg[ch])
)
]
# Connect master->slaves signals except valid/ready. # Connect master->slaves signals except valid/ready.
for i, (_, slave) in enumerate(slaves): for i, (_, slave) in enumerate(slaves):
@ -735,6 +739,13 @@ class AXILiteDecoder(Module):
masked.append(src & mask) masked.append(src & mask)
self.comb += dst.eq(reduce(or_, masked)) self.comb += dst.eq(reduce(or_, masked))
# AXI-Lite Interconnect ----------------------------------------------------------------------------
class AXILiteInterconnectPointToPoint(Module):
"""AXI Lite point to point interconnect"""
def __init__(self, master, slave):
self.comb += master.connect(slave)
class AXILiteInterconnectShared(Module): class AXILiteInterconnectShared(Module):
"""AXI Lite shared interconnect""" """AXI Lite shared interconnect"""
def __init__(self, masters, slaves, register=False, timeout_cycles=1e6): def __init__(self, masters, slaves, register=False, timeout_cycles=1e6):