flow/actor: add packetized parameter for Sink and Source
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Wed, 17 Sep 2014 15:23:27 +0000 (17:23 +0200)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Mon, 22 Sep 2014 15:45:28 +0000 (23:45 +0800)
migen/flow/actor.py

index a8388e20d11b66810e3e23e3a91267c5d57cb716..8968b5337274ccbf4d277ecd03cf394303114eaf 100644 (file)
@@ -13,13 +13,18 @@ def _make_m2s(layout):
        return r
 
 class _Endpoint(Record):
-       def __init__(self, layout):
-               full_layout = [
+       def __init__(self, layout, packetized=False):
+               endpoint_layout = [
                        ("payload", _make_m2s(layout)),
                        ("stb", 1, DIR_M_TO_S),
                        ("ack", 1, DIR_S_TO_M)
                ]
-               Record.__init__(self, full_layout)
+               if packetized:
+                       endpoint_layout += [
+                               ("sop", 1, DIR_M_TO_S),
+                               ("eop", 1, DIR_S_TO_M)
+                       ]
+               Record.__init__(self, endpoint_layout)
 
 class Source(_Endpoint):
        def connect(self, sink):
@@ -72,7 +77,7 @@ class SequentialActor(BinaryActor):
                        ).Elif(~ready,
                                timer.eq(timer - 1)
                        )
-               
+
                mask = Signal()
                self.comb += [
                        stb_o.eq(ready & mask),