From: Florent Kermarrec Date: Mon, 20 Oct 2014 06:47:48 +0000 (+0200) Subject: _Endpoint: allow direct access of payload elements X-Git-Tag: 24jan2021_ls180~2099^2~284 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff688fb2f91c4c4f8c0ef9603330450bad922b8f;p=litex.git _Endpoint: allow direct access of payload elements --- diff --git a/migen/flow/actor.py b/migen/flow/actor.py index d8093724..00837fd3 100644 --- a/migen/flow/actor.py +++ b/migen/flow/actor.py @@ -12,8 +12,17 @@ def _make_m2s(layout): r.append((f[0], _make_m2s(f[1]))) return r +def _check_layout(layout, packetized): + reserveds = ["stb", "ack", "payload"] + if packetized: + reserveds += ["sop", "eop"] + for f in layout: + if f[0] in reserveds: + raise ValueError(f[0] + " cannot be used in Sink/Source layout") + class _Endpoint(Record): def __init__(self, layout, packetized=False): + _check_layout(layout, packetized) endpoint_layout = [ ("payload", _make_m2s(layout)), ("stb", 1, DIR_M_TO_S), @@ -26,6 +35,12 @@ class _Endpoint(Record): ] Record.__init__(self, endpoint_layout) + def __del__(self): + pass + + def __getattr__(self, name): + return getattr(self.payload, name) + class Source(_Endpoint): def connect(self, sink): return Record.connect(self, sink)