litex/misoclib/com/liteeth/core/mac/common.py

48 lines
1.3 KiB
Python
Raw Normal View History

from misoclib.com.liteeth.common import *
from misoclib.com.liteeth.crossbar import LiteEthCrossbar
2015-02-10 09:22:06 -05:00
2015-04-13 04:20:02 -04:00
class LiteEthMACDepacketizer(Depacketizer):
def __init__(self):
Depacketizer.__init__(self,
eth_phy_description(8),
eth_mac_description(8),
mac_header)
2015-02-10 09:22:06 -05:00
2015-04-13 04:20:02 -04:00
class LiteEthMACPacketizer(Packetizer):
def __init__(self):
Packetizer.__init__(self,
eth_mac_description(8),
eth_phy_description(8),
mac_header)
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:
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:
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):
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):
def __init__(self):
LiteEthCrossbar.__init__(self, LiteEthMACMasterPort, "ethernet_type")
2015-02-10 09:22:06 -05: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