1 from liteeth
.common
import *
2 from liteeth
.generic
.arbiter
import Arbiter
3 from liteeth
.generic
.dispatcher
import Dispatcher
4 from liteeth
.mac
import LiteEthMAC
6 class LiteEthIPStack(Module
, AutoCSR
):
7 def __init__(self
, phy
,
8 mac_address
= 0x12345678abcd,
9 ip_address
="192.168.0.10"):
11 self
.submodules
.mac
= mac
= LiteEthMAC(phy
, 8, interface
="mac", with_hw_preamble_crc
=True)
12 self
.submodules
.arp
= arp
= LiteEthARP(mac_address
, ip_address
)
13 self
.submodules
.ip
= ip
= LiteEthMACIP()
16 self
.submodules
.mac_dispatcher
= mac_dispatcher
= Dispatcher(mac
.source
, [arp
.sink
, ip
.sink
], one_hot
=True)
18 Case(mac
.source
.eth_type
, {
19 ethernet_type_arp
: [mac_dispatcher
.sel
.eq(1)],
20 ethernet_type_ip
: [mac_dispatcher
.sel
.eq(2)],
21 "default" : [mac_dispatcher
.sel
.eq(0)],
24 self
.submodules
.mac_arbiter
= mac_arbiter
= Arbiter([arp
.source
, ip
.source
], mac
.sink
)