etherbone: add etherbone_tb, able to probe etherbone endpoint
[litex.git] / liteeth / core / etherbone / __init__.py
1 from liteeth.common import *
2 from liteeth.core.etherbone import common
3 from liteeth.core.etherbone.packet import *
4
5 class LiteEthEtherbone(Module):
6 def __init__(self, udp, udp_port):
7 self.submodules.packet = packet = LiteEthEtherbonePacket(udp, udp_port)
8
9 self.submodules.fsm = fsm = FSM(reset_state="IDLE")
10 fsm.act("IDLE",
11 packet.source.ack.eq(1),
12 If(packet.source.stb & packet.source.sop,
13 If(packet.source.pf,
14 packet.source.ack.eq(0),
15 NextState("SEND_PROBE_RESPONSE")
16 )
17 )
18 )
19 fsm.act("SEND_PROBE_RESPONSE",
20 packet.sink.stb.eq(1),
21 packet.sink.sop.eq(1),
22 packet.sink.eop.eq(1),
23 packet.sink.pr.eq(1),
24 packet.sink.ip_address.eq(packet.source.ip_address),
25 packet.sink.length.eq(0),
26 If(packet.sink.ack,
27 packet.source.ack.eq(1),
28 NextState("IDLE")
29 )
30 )