Skip to content

Commit ff688fb

Browse files
enjoy-digitalsbourdeauducq
authored andcommittedOct 20, 2014
_Endpoint: allow direct access of payload elements
1 parent dbaeaf7 commit ff688fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎migen/flow/actor.py

+15
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ def _make_m2s(layout):
1212
r.append((f[0], _make_m2s(f[1])))
1313
return r
1414

15+
def _check_layout(layout, packetized):
16+
reserveds = ["stb", "ack", "payload"]
17+
if packetized:
18+
reserveds += ["sop", "eop"]
19+
for f in layout:
20+
if f[0] in reserveds:
21+
raise ValueError(f[0] + " cannot be used in Sink/Source layout")
22+
1523
class _Endpoint(Record):
1624
def __init__(self, layout, packetized=False):
25+
_check_layout(layout, packetized)
1726
endpoint_layout = [
1827
("payload", _make_m2s(layout)),
1928
("stb", 1, DIR_M_TO_S),
@@ -26,6 +35,12 @@ def __init__(self, layout, packetized=False):
2635
]
2736
Record.__init__(self, endpoint_layout)
2837

38+
def __del__(self):
39+
pass
40+
41+
def __getattr__(self, name):
42+
return getattr(self.payload, name)
43+
2944
class Source(_Endpoint):
3045
def connect(self, sink):
3146
return Record.connect(self, sink)

0 commit comments

Comments
 (0)
Please sign in to comment.