interconnect/axi/axi_stream: Simplify by always adding id/dest/user to endpoints and add layout/name parameters for more flexibility.
This commit is contained in:
parent
3cd4a3830c
commit
bc385c7358
|
@ -17,7 +17,7 @@ from litex.soc.interconnect.axi.axi_common import *
|
|||
# AXI-Stream Definition ----------------------------------------------------------------------------
|
||||
|
||||
class AXIStreamInterface(stream.Endpoint):
|
||||
def __init__(self, data_width=32, keep_width=0, id_width=0, dest_width=0, user_width=0):
|
||||
def __init__(self, data_width=0, keep_width=0, id_width=0, dest_width=0, user_width=0, layout=None, name=None):
|
||||
self.data_width = data_width
|
||||
self.keep_width = keep_width
|
||||
self.id_width = id_width
|
||||
|
@ -25,21 +25,20 @@ class AXIStreamInterface(stream.Endpoint):
|
|||
self.user_width = user_width
|
||||
|
||||
# Define Payload Layout.
|
||||
payload_layout = [("data", data_width)]
|
||||
if self.keep_width:
|
||||
payload_layout += [("keep", keep_width)]
|
||||
if layout is not None:
|
||||
payload_layout = layout
|
||||
else:
|
||||
payload_layout = [("data", max(1, data_width))]
|
||||
payload_layout += [("keep", max(1, keep_width))]
|
||||
|
||||
# Define Param Layout.
|
||||
param_layout = []
|
||||
if self.id_width:
|
||||
param_layout += [("id", id_width)]
|
||||
if self.dest_width:
|
||||
param_layout += [("dest", dest_width)]
|
||||
if self.user_width:
|
||||
param_layout += [("user", user_width)]
|
||||
param_layout = []
|
||||
param_layout += [("id", max(1, id_width))]
|
||||
param_layout += [("dest", max(1, dest_width))]
|
||||
param_layout += [("user", max(1, user_width))]
|
||||
|
||||
# Create Endpoint.
|
||||
stream.Endpoint.__init__(self, stream.EndpointDescription(payload_layout, param_layout))
|
||||
stream.Endpoint.__init__(self, stream.EndpointDescription(payload_layout, param_layout), name=name)
|
||||
|
||||
def get_ios(self, bus_name="axi"):
|
||||
# Control Signals.
|
||||
|
@ -50,17 +49,13 @@ class AXIStreamInterface(stream.Endpoint):
|
|||
]
|
||||
|
||||
# Payload Signals.
|
||||
subsignals += [Subsignal("tdata", Pins(self.data_width))]
|
||||
if self.keep_width:
|
||||
subsignals += [Subsignal("tkeep", Pins(self.keep_width))]
|
||||
subsignals += [Subsignal("tdata", Pins(self.data_width))]
|
||||
subsignals += [Subsignal("tkeep", Pins(self.keep_width))]
|
||||
|
||||
# Param Signals.
|
||||
if self.id_width:
|
||||
subsignals += [Subsignal("tid", Pins(self.id_width))]
|
||||
if self.dest_width:
|
||||
subsignals += [Subsignal("tdest", Pins(self.dest_width))]
|
||||
if self.user_width:
|
||||
subsignals += [Subsignal("tuser", Pins(self.user_width))]
|
||||
subsignals += [Subsignal("tid", Pins(self.id_width))]
|
||||
subsignals += [Subsignal("tdest", Pins(self.dest_width))]
|
||||
subsignals += [Subsignal("tuser", Pins(self.user_width))]
|
||||
ios = [(bus_name , 0) + tuple(subsignals)]
|
||||
return ios
|
||||
|
||||
|
@ -74,15 +69,11 @@ class AXIStreamInterface(stream.Endpoint):
|
|||
r.append(pads.tlast.eq(self.last))
|
||||
# Payload Signals.
|
||||
r.append(pads.tdata.eq(self.data))
|
||||
if self.keep_width:
|
||||
r.append(pads.tkeep.eq(self.keep))
|
||||
r.append(pads.tkeep.eq(self.keep))
|
||||
# Param Signals.
|
||||
if self.id_width:
|
||||
r.append(pads.tid.eq(self.id))
|
||||
if self.dest_width:
|
||||
r.append(pads.tdest.eq(self.dest))
|
||||
if self.user_width:
|
||||
r.append(pads.tuser.eq(self.user))
|
||||
r.append(pads.tid.eq(self.id))
|
||||
r.append(pads.tdest.eq(self.dest))
|
||||
r.append(pads.tuser.eq(self.user))
|
||||
if mode == "slave":
|
||||
# Control Signals.
|
||||
r.append(self.valid.eq(pads.tvalid))
|
||||
|
@ -90,13 +81,9 @@ class AXIStreamInterface(stream.Endpoint):
|
|||
r.append(self.last.eq(pads.tlast))
|
||||
# Payload Signals.
|
||||
r.append(self.data.eq(pads.tdata))
|
||||
if self.keep_width:
|
||||
r.append(self.keep.eq(pads.tkeep))
|
||||
r.append(self.keep.eq(pads.tkeep))
|
||||
# Param Signals.
|
||||
if self.id_width:
|
||||
r.append(self.id.eq(pads.tid))
|
||||
if self.dest_width:
|
||||
r.append(self.dest.eq(pads.tdest))
|
||||
if self.user_width:
|
||||
r.append(self.user.eq(pads.tuser))
|
||||
r.append(self.id.eq(pads.tid))
|
||||
r.append(self.dest.eq(pads.tdest))
|
||||
r.append(self.user.eq(pads.tuser))
|
||||
return r
|
||||
|
|
Loading…
Reference in New Issue