2015-02-28 03:02:28 -05:00
|
|
|
from misoclib.com.liteeth.common import *
|
|
|
|
from misoclib.com.liteeth.generic import *
|
|
|
|
from misoclib.com.liteeth.generic.depacketizer import LiteEthDepacketizer
|
|
|
|
from misoclib.com.liteeth.generic.packetizer import LiteEthPacketizer
|
|
|
|
from misoclib.com.liteeth.generic.crossbar import LiteEthCrossbar
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACDepacketizer(LiteEthDepacketizer):
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self):
|
|
|
|
LiteEthDepacketizer.__init__(self,
|
|
|
|
eth_phy_description(8),
|
|
|
|
eth_mac_description(8),
|
|
|
|
mac_header,
|
|
|
|
mac_header_len)
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACPacketizer(LiteEthPacketizer):
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self):
|
|
|
|
LiteEthPacketizer.__init__(self,
|
|
|
|
eth_mac_description(8),
|
|
|
|
eth_phy_description(8),
|
|
|
|
mac_header,
|
|
|
|
mac_header_len)
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACMasterPort:
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self, dw):
|
|
|
|
self.source = Source(eth_mac_description(dw))
|
|
|
|
self.sink = Sink(eth_mac_description(dw))
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACSlavePort:
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self, dw):
|
|
|
|
self.sink = Sink(eth_mac_description(dw))
|
|
|
|
self.source = Source(eth_mac_description(dw))
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACUserPort(LiteEthMACSlavePort):
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self, dw):
|
|
|
|
LiteEthMACSlavePort.__init__(self, dw)
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-02-10 09:22:06 -05:00
|
|
|
class LiteEthMACCrossbar(LiteEthCrossbar):
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self):
|
|
|
|
LiteEthCrossbar.__init__(self, LiteEthMACMasterPort, "ethernet_type")
|
2015-02-10 09:22:06 -05:00
|
|
|
|
2015-04-13 03:53:43 -04:00
|
|
|
def get_port(self, ethernet_type):
|
|
|
|
port = LiteEthMACUserPort(8)
|
|
|
|
if ethernet_type in self.users.keys():
|
|
|
|
raise ValueError("Ethernet type {0:#x} already assigned".format(ethernet_type))
|
|
|
|
self.users[ethernet_type] = port
|
|
|
|
return port
|