2015-01-28 03:14:01 -05:00
|
|
|
from liteeth.common import *
|
|
|
|
from liteeth.mac.core import LiteEthMACCore
|
|
|
|
from liteeth.mac.frontend import wishbone
|
2015-01-28 18:25:55 -05:00
|
|
|
from liteeth.generic.depacketizer import LiteEthDepacketizer
|
|
|
|
from liteeth.generic.packetizer import LiteEthPacketizer
|
|
|
|
|
|
|
|
class LiteEthMACDepacketizer(LiteEthDepacketizer):
|
|
|
|
def __init__(self):
|
|
|
|
LiteEthDepacketizer.__init__(self,
|
|
|
|
eth_phy_description(8),
|
|
|
|
eth_mac_description(8),
|
|
|
|
mac_header,
|
|
|
|
mac_header_length)
|
|
|
|
|
|
|
|
class LiteEthMACPacketizer(LiteEthDepacketizer):
|
|
|
|
def __init__(self):
|
|
|
|
LiteEthDepacketizer.__init__(self,
|
|
|
|
eth_mac_description(8),
|
|
|
|
eth_phy_description(8),
|
|
|
|
mac_header,
|
|
|
|
mac_header_length)
|
2015-01-28 03:14:01 -05:00
|
|
|
|
|
|
|
class LiteEthMAC(Module, AutoCSR):
|
2015-01-28 14:55:18 -05:00
|
|
|
def __init__(self, phy, dw, interface="core", endianness="be",
|
2015-01-28 03:14:01 -05:00
|
|
|
with_hw_preamble_crc=True):
|
2015-01-28 05:45:19 -05:00
|
|
|
self.submodules.core = LiteEthMACCore(phy, dw, endianness, with_hw_preamble_crc)
|
|
|
|
self.csrs = None
|
2015-01-28 14:55:18 -05:00
|
|
|
if interface == "core":
|
|
|
|
self.sink, self.source = self.core.sink, self.core.source
|
|
|
|
elif interface == "wishbone":
|
2015-01-28 15:54:09 -05:00
|
|
|
self.submodules.interface = wishbone.LiteEthMACWishboneInterface(dw, 2, 2)
|
|
|
|
self.comb += [
|
|
|
|
Record.connect(self.interface.source, self.core.sink),
|
|
|
|
Record.connect(self.core.source, self.interface.sink)
|
|
|
|
]
|
2015-01-28 05:45:19 -05:00
|
|
|
self.ev, self.bus = self.interface.sram.ev, self.interface.bus
|
|
|
|
self.csrs = self.interface.get_csrs()
|
2015-01-28 03:14:01 -05:00
|
|
|
elif interface == "dma":
|
2015-01-27 17:59:06 -05:00
|
|
|
raise NotImplementedError
|
|
|
|
else:
|
2015-01-28 14:55:18 -05:00
|
|
|
raise ValueError(inteface + " not supported by LiteEthMac!")
|
2015-01-28 05:45:19 -05:00
|
|
|
|
|
|
|
def get_csrs(self):
|
|
|
|
return self.csrs
|