2015-01-28 03:14:01 -05:00
|
|
|
from liteeth.common import *
|
|
|
|
from liteeth.mac.core import LiteEthMACCore
|
|
|
|
from liteeth.mac.frontend import wishbone
|
|
|
|
|
|
|
|
class LiteEthMAC(Module, AutoCSR):
|
2015-01-28 05:45:19 -05:00
|
|
|
def __init__(self, phy, dw, interface="wishbone", 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-27 17:59:06 -05:00
|
|
|
if interface == "wishbone":
|
2015-01-28 05:45:19 -05:00
|
|
|
self.interface = wishbone.LiteEthMACWishboneInterface(dw, 2, 2)
|
|
|
|
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
|
2015-01-28 03:14:01 -05:00
|
|
|
elif interface == "core":
|
2015-01-28 05:45:19 -05:00
|
|
|
self.sink, self.source = self.core.sink, self.core.source
|
2015-01-27 17:59:06 -05:00
|
|
|
else:
|
2015-01-28 03:14:01 -05:00
|
|
|
raise ValueError("EthMAC only supports Wishbone, DMA or core interfaces")
|
2015-01-28 05:45:19 -05:00
|
|
|
|
|
|
|
def get_csrs(self):
|
|
|
|
return self.csrs
|