litex/liteeth/__init__.py

27 lines
945 B
Python
Raw Normal View History

2015-01-28 19:03:47 -05:00
from liteeth.common import *
from liteeth.generic.arbiter import Arbiter
from liteeth.generic.dispatcher import Dispatcher
from liteeth.mac import LiteEthMAC
class LiteEthIPStack(Module, AutoCSR):
2015-01-29 15:07:02 -05:00
def __init__(self, phy,
mac_address= 0x12345678abcd,
ip_address="192.168.0.10"):
2015-01-28 19:03:47 -05:00
self.phy = phy
self.submodules.mac = mac = LiteEthMAC(phy, 8, interface="mac", with_hw_preamble_crc=True)
2015-01-29 15:07:02 -05:00
self.submodules.arp = arp = LiteEthARP(mac_address, ip_address)
2015-01-28 19:03:47 -05:00
self.submodules.ip = ip = LiteEthMACIP()
# MAC dispatch
self.submodules.mac_dispatcher = mac_dispatcher = Dispatcher(mac.source, [arp.sink, ip.sink], one_hot=True)
2015-01-29 15:07:02 -05:00
self.comb += \
Case(mac.source.eth_type, {
ethernet_type_arp : [mac_dispatcher.sel.eq(1)],
ethernet_type_ip : [mac_dispatcher.sel.eq(2)],
"default" : [mac_dispatcher.sel.eq(0)],
})
2015-01-28 19:03:47 -05:00
# MAC arbitrate
self.submodules.mac_arbiter = mac_arbiter = Arbiter([arp.source, ip.source], mac.sink)