Skip to content

Commit 16437b5

Browse files
committed
test/test_etherbone: Update/Cleanup test.
1 parent 793575b commit 16437b5

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

test/test_etherbone.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,29 @@
1919

2020
from litex.gen.sim import *
2121

22-
ip_address = 0x12345678
22+
# Constants ----------------------------------------------------------------------------------------
23+
24+
ip_address = 0x12345678
2325
mac_address = 0x12345678abcd
2426

27+
# DUT ----------------------------------------------------------------------------------------------
2528

26-
class DUT(Module):
29+
class DUT(LiteXModule):
2730
def __init__(self):
28-
self.submodules.phy_model = phy.PHY(8, debug=False)
29-
self.submodules.mac_model = mac.MAC(self.phy_model, debug=False, loopback=False)
30-
self.submodules.arp_model = arp.ARP(self.mac_model, mac_address, ip_address, debug=False)
31-
self.submodules.ip_model = ip.IP(self.mac_model, mac_address, ip_address, debug=False, loopback=False)
32-
self.submodules.udp_model = udp.UDP(self.ip_model, ip_address, debug=False, loopback=False)
33-
self.submodules.etherbone_model = etherbone.Etherbone(self.udp_model, debug=False)
31+
self.phy_model = phy.PHY(8, debug=False)
32+
self.mac_model = mac.MAC(self.phy_model, debug=False, loopback=False)
33+
self.arp_model = arp.ARP(self.mac_model, mac_address, ip_address, debug=False)
34+
self.ip_model = ip.IP(self.mac_model, mac_address, ip_address, debug=False, loopback=False)
35+
self.udp_model = udp.UDP(self.ip_model, ip_address, debug=False, loopback=False)
36+
self.etherbone_model = etherbone.Etherbone(self.udp_model, debug=False)
3437

35-
self.submodules.core = LiteEthUDPIPCore(self.phy_model, mac_address, ip_address, 100000)
36-
self.submodules.etherbone = LiteEthEtherbone(self.core.udp, 0x1234)
38+
self.core = LiteEthUDPIPCore(self.phy_model, mac_address, ip_address, 100000)
39+
self.etherbone = LiteEthEtherbone(self.core.udp, 0x1234)
3740

38-
self.submodules.sram = wishbone.SRAM(1024)
39-
self.submodules.interconnect = wishbone.InterconnectPointToPoint(self.etherbone.wishbone.bus, self.sram.bus)
41+
self.sram = wishbone.SRAM(1024)
42+
self.interconnect = wishbone.InterconnectPointToPoint(self.etherbone.wishbone.bus, self.sram.bus)
4043

44+
# Genrator -----------------------------------------------------------------------------------------
4145

4246
def main_generator(dut):
4347
test_probe = True
@@ -104,17 +108,19 @@ def main_generator(dut):
104108
s, l, e = check(writes_datas, loopback_writes_datas)
105109
print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e))
106110

111+
# Test Etherbone -----------------------------------------------------------------------------------
107112

108113
class TestEtherbone(unittest.TestCase):
109114
def test_etherbone(self):
110115
dut = DUT()
111116
generators = {
112-
"sys" : [main_generator(dut)],
113-
"eth_tx": [dut.phy_model.phy_sink.generator(),
114-
dut.phy_model.generator()],
115-
"eth_rx": dut.phy_model.phy_source.generator()
117+
"sys" : [main_generator(dut)],
118+
"eth_tx" : [dut.phy_model.phy_sink.generator(), dut.phy_model.generator()],
119+
"eth_rx" : [dut.phy_model.phy_source.generator()]
120+
}
121+
clocks = {
122+
"sys": 10,
123+
"eth_rx": 10,
124+
"eth_tx": 10,
116125
}
117-
clocks = {"sys": 10,
118-
"eth_rx": 10,
119-
"eth_tx": 10}
120126
#run_simulation(dut, generators, clocks, vcd_name="sim.vcd") # FIXME: hanging

0 commit comments

Comments
 (0)