296cbb84c5ef18b1cb637b82cedb3c2bae862860
1 from liteeth
.common
import *
2 from liteeth
.mac
.common
import *
3 from liteeth
.test
.common
import *
6 print_with_prefix(s
, "[PHY]")
9 class PHYSource(PacketStreamer
):
10 def __init__(self
, dw
):
11 PacketStreamer
.__init
__(self
, eth_phy_description(dw
))
13 class PHYSink(PacketLogger
):
14 def __init__(self
, dw
):
15 PacketLogger
.__init
__(self
, eth_phy_description(dw
))
18 def __init__(self
, dw
, debug
=False):
22 self
.submodules
.phy_source
= PHYSource(dw
)
23 self
.submodules
.phy_sink
= PHYSink(dw
)
25 self
.source
= self
.phy_source
.source
26 self
.sink
= self
.phy_sink
.sink
28 self
.mac_callback
= None
30 def set_mac_callback(self
, callback
):
31 self
.mac_callback
= callback
33 def send(self
, datas
):
34 packet
= Packet(datas
)
37 r
+= "length " + str(len(datas
)) + "\n"
41 yield from self
.phy_source
.send(packet
)
44 yield from self
.phy_sink
.receive()
47 r
+= "length " + str(len(self
.phy_sink
.packet
)) + "\n"
48 for d
in self
.phy_sink
.packet
:
51 self
.packet
= self
.phy_sink
.packet