use new Migen feature: payload_layout/param_layout
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 10 Feb 2015 09:30:39 +0000 (10:30 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 10 Feb 2015 09:30:39 +0000 (10:30 +0100)
liteeth/common.py
liteeth/core/ip/common.py
liteeth/core/udp/common.py

index e3ba7547f2a1fe221da14e116f874e1559c5e8e9..ce7e0d6334f62f9c73a4b20257cd9405ea262a76 100644 (file)
@@ -123,27 +123,28 @@ def _layout_from_header(header):
        return _layout
 
 def eth_phy_description(dw):
-       layout = [
+       payload_layout = [
                ("data", dw),
                ("last_be", dw//8),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       return EndpointDescription(payload_layout, packetized=True)
 
 def eth_mac_description(dw):
-       layout = _layout_from_header(mac_header) + [
+       payload_layout = _layout_from_header(mac_header) + [
                ("data", dw),
                ("last_be", dw//8),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       return EndpointDescription(payload_layout, packetized=True)
 
 def eth_arp_description(dw):
-       layout = _layout_from_header(arp_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(arp_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 arp_table_request_layout = [
        ("ip_address", 32)
@@ -155,21 +156,24 @@ arp_table_response_layout = [
 ]
 
 def eth_ipv4_description(dw):
-       layout = _layout_from_header(ipv4_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(ipv4_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_ipv4_user_description(dw):
-       layout = [
-               ("length", 16),
-               ("protocol", 8),
-               ("ip_address", 32),
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = [
+               ("length", 16),
+               ("protocol", 8),
+               ("ip_address", 32)
+       ]
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def convert_ip(s):
        ip = 0
@@ -179,63 +183,73 @@ def convert_ip(s):
        return ip
 
 def eth_icmp_description(dw):
-       layout = _layout_from_header(icmp_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(icmp_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_icmp_user_description(dw):
-       layout = _layout_from_header(icmp_header) + [
-               ("ip_address", 32),
-               ("length", 16),
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(icmp_header) + [
+               ("ip_address", 32),
+               ("length", 16)
+       ]
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_udp_description(dw):
-       layout = _layout_from_header(udp_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(udp_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_udp_user_description(dw):
-       layout = [
+       payload_layout = [
+               ("data", dw),
+               ("error", dw//8)
+       ]
+       param_layout = [
                ("src_port", 16),
                ("dst_port", 16),
                ("ip_address", 32),
-               ("length", 16),
-               ("data", dw),
-               ("error", dw//8)
+               ("length", 16)
        ]
-       return EndpointDescription(layout, packetized=True)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_etherbone_description(dw):
-       layout = _layout_from_header(etherbone_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(etherbone_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_etherbone_description(dw):
-       layout = _layout_from_header(etherbone_header) + [
+       payload_layout = [
                ("data", dw),
                ("error", dw//8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       param_layout = _layout_from_header(etherbone_header)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 def eth_etherbone_user_description(dw):
-       layout = [
+       payload_layout = [
+               ("data", dw),
+               ("error", dw//8)
+       ]
+       param_layout = [
                ("length", 16),
                ("ip_address", 32),
                ("wcount", 8),
-               ("rcount", 8),
-               ("data", dw),
-               ("error", dw//8)
+               ("rcount", 8)
        ]
-       return EndpointDescription(layout, packetized=True)
+       return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 
 # Generic modules
index fef6d2d4d893cf71ef993de0f080f3fc23858d55..b61c27c950dbeb6b57ace4c3ece8e0fc0a7c4488 100644 (file)
@@ -2,6 +2,7 @@ from liteeth.common import *
 
 class LiteEthIPV4MasterPort:
        def __init__(self, dw):
+               self.dw = dw
                self.source = Source(eth_ipv4_user_description(dw))
                self.sink = Sink(eth_ipv4_user_description(dw))
 
@@ -13,6 +14,7 @@ class LiteEthIPV4MasterPort:
 
 class LiteEthIPV4SlavePort:
        def __init__(self, dw):
+               self.dw = dw
                self.sink = Sink(eth_ipv4_user_description(dw))
                self.source = Source(eth_ipv4_user_description(dw))
 
index feb55bf864bc92980d1a632488d41cd27e9c65cc..eed6f1d248748e1e19fa33da9baf8a7cdeb6430a 100644 (file)
@@ -2,6 +2,7 @@ from liteeth.common import *
 
 class LiteEthUDPMasterPort:
        def __init__(self, dw):
+               self.dw = dw
                self.source = Source(eth_udp_user_description(dw))
                self.sink = Sink(eth_udp_user_description(dw))
 
@@ -13,6 +14,7 @@ class LiteEthUDPMasterPort:
 
 class LiteEthUDPSlavePort:
        def __init__(self, dw):
+               self.dw =dw
                self.sink = Sink(eth_udp_user_description(dw))
                self.source = Source(eth_udp_user_description(dw))