2015-01-28 03:14:01 -05:00
|
|
|
from liteeth.common import *
|
2015-02-10 09:22:06 -05:00
|
|
|
from liteeth.mac.common import *
|
2015-01-30 10:27:56 -05:00
|
|
|
from liteeth.mac.core import LiteEthMACCore
|
|
|
|
from liteeth.mac.frontend.wishbone import LiteEthMACWishboneInterface
|
2015-01-28 18:25:55 -05:00
|
|
|
|
2015-01-28 03:14:01 -05:00
|
|
|
class LiteEthMAC(Module, AutoCSR):
|
2015-02-09 06:57:05 -05:00
|
|
|
def __init__(self, phy, dw, interface="crossbar", endianness="big",
|
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)
|
2015-02-05 05:02:46 -05:00
|
|
|
self.csrs = []
|
2015-01-30 10:27:56 -05:00
|
|
|
if interface == "crossbar":
|
|
|
|
self.submodules.crossbar = LiteEthMACCrossbar()
|
|
|
|
self.submodules.packetizer = LiteEthMACPacketizer()
|
|
|
|
self.submodules.depacketizer = LiteEthMACDepacketizer()
|
2015-01-28 19:03:47 -05:00
|
|
|
self.comb += [
|
2015-01-30 10:27:56 -05:00
|
|
|
Record.connect(self.crossbar.master.source, self.packetizer.sink),
|
|
|
|
Record.connect(self.packetizer.source, self.core.sink),
|
|
|
|
Record.connect(self.core.source, self.depacketizer.sink),
|
|
|
|
Record.connect(self.depacketizer.source, self.crossbar.master.sink)
|
2015-01-28 19:03:47 -05:00
|
|
|
]
|
2015-01-28 14:55:18 -05:00
|
|
|
elif interface == "wishbone":
|
2015-01-30 13:34:13 -05:00
|
|
|
self.submodules.interface = LiteEthMACWishboneInterface(dw, 2, 2)
|
2015-02-10 09:37:29 -05:00
|
|
|
self.comb += Port.connect(self.interface, self.core)
|
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-30 11:44:44 -05:00
|
|
|
raise ValueError(interface + " not supported by LiteEthMac!")
|
2015-01-28 05:45:19 -05:00
|
|
|
|
|
|
|
def get_csrs(self):
|
|
|
|
return self.csrs
|