move more things to common files
[litex.git] / liteeth / mac / __init__.py
1 from liteeth.common import *
2 from liteeth.mac.common import *
3 from liteeth.mac.core import LiteEthMACCore
4 from liteeth.mac.frontend.wishbone import LiteEthMACWishboneInterface
5
6 class LiteEthMAC(Module, AutoCSR):
7 def __init__(self, phy, dw, interface="crossbar", endianness="big",
8 with_hw_preamble_crc=True):
9 self.submodules.core = LiteEthMACCore(phy, dw, endianness, with_hw_preamble_crc)
10 self.csrs = []
11 if interface == "crossbar":
12 self.submodules.crossbar = LiteEthMACCrossbar()
13 self.submodules.packetizer = LiteEthMACPacketizer()
14 self.submodules.depacketizer = LiteEthMACDepacketizer()
15 self.comb += [
16 Record.connect(self.crossbar.master.source, self.packetizer.sink),
17 Record.connect(self.packetizer.source, self.core.sink),
18 Record.connect(self.core.source, self.depacketizer.sink),
19 Record.connect(self.depacketizer.source, self.crossbar.master.sink)
20 ]
21 elif interface == "wishbone":
22 self.submodules.interface = LiteEthMACWishboneInterface(dw, 2, 2)
23 self.comb += [
24 Record.connect(self.interface.source, self.core.sink),
25 Record.connect(self.core.source, self.interface.sink)
26 ]
27 self.ev, self.bus = self.interface.sram.ev, self.interface.bus
28 self.csrs = self.interface.get_csrs()
29 elif interface == "dma":
30 raise NotImplementedError
31 else:
32 raise ValueError(interface + " not supported by LiteEthMac!")
33
34 def get_csrs(self):
35 return self.csrs